COMASSO BSW generation and validation

The COMASSO initiative provides a community-sourced AUTOSAR 4.x basic software stack and tooling to work with that. One of the tools is the BSWDT, which uses the Eclipse projects Xpand and Xtend for model checking and code generation. It provides not only the BSW in readable form, but also the code generators and validators are there for you to inspect, learn from and modify. This blog article shows how to find your way around those files.

First of all, we need to create a simple Eclipse project (File->New Project…) and then make it a BSW configuration project by invoking the context menu on the project and setting the project configuration:


After that, we import the BSW and BSW code generators into the project:

2013-11-04_15h52_46You will notice that there is a directory for each of the BSW modules. You will find the Xpand/Xtend files under each modules sub-path scripts/templates/

2013-11-04_15h54_09The relevant file types are:

  • .chk: These contain model validations and checks
  • .xpt: The actual code generators
  • .ext: Model-to-Model transformations and utility functions
  • .oaw: Workflow files (not discussed here)
  • .bamf: Build action manifests.

All files except the .bamf come from the Eclipse Project xpand/mwe. The .bamf files are an implementation of the AUTOSAR build action manifest. In short, the bamf files invoke the oaw-files which in turn invoke .chk, and .ext. The details will not be discussed here.


However, we will have a look at the .chk files. A .chk files consists of a number of context statements. A context statement of a specific type will be invoked for all occurances of that type in your model. This is a very simple check for the ComMChannel. No need to loop through the model yourself, everything is done by the framework:

2013-11-04_15h58_00More complex checks can be factored into dedicated subroutines:

2013-11-04_15h59_58Depending on the .bamf-Configuration a failed check can result in a stop of the build process.


Code generation is done with Xpand. Xpand is a template based language that allows you to easily specifiy the generators. The big advantage is the flexible type system, that derives the available types from the param-defs in your workspace. So if you have vendor-specific param defs, all the types will be immediately available in the language as first-class types.

2013-11-04_16h02_24Note that everything highlighted blue in the example above will be printed 1:1 in the output and the statements between ‘<<‘ and ‘>>’ will be evaluated on the model. Note in line 124 that complex queries are possible. Of course, Xpand provides a comfortable set of additional statements for outputing code.


The files under “generateid” are used for automatically setting information prior to generation – e.g. by generating ids. An example from LIN could be:

2013-11-04_16h08_26Note that Xtend/Xpand offer full content assist – no need to refer to the AUTOSAR spec to find out which elements are supported.


The system comes with a profiling component that supports analysis of the time spent in checks and generation. Profiling will be introduced in another blog post.