RAMSES: Generate Code from an Example

Install components to read generated code

RAMSES can generate code for different architectures:

  • POSIX-Linux
  • nxtOSEK
  • POK

For the last two architectures, you need to install programs to launch them.


Go to the following nxtOSEK website: http://lejos-osek.sourceforge.net/.

Download and install nxtOSEK following the instructions in the “Installation” page.

For Linux users: the script “build_arm_toolchain.sh” is not up-to-date for recent versions of GCC. Open it with an editor, and change the “GCC_BINARY_VERSION” to your version of GCC. Example for Ubuntu 16.04 users:


Then change the line where CC variable is exported to dodge compilation problems like following:

export CC="$GCC_BINARY_VERSION -fgnu89-inline"

The option “-fgnu89-inline” is required since the default option of GCC changed in recent versions. Before launching the script, you need also to install a new version of texinfo. The version 4.13 is correct. Extract the archive and then install it with these commands:

sudo make install

Once you have correctly installed nxtOSEK, you need to change the file “ecrobot/ecrobot.mak”. Open it and go to the line 304. You should have the following line:

WINECONSOLE := wineconsole

Add a new line below with the following:

WINE := wine

Then go to the line 330 in the “else ifeq ($(TOPPERS_KERNEL), OSEK_COM) … else …” clause. Change this clause with the following:

    @echo "Generating OSEK kernel config files from $(TOPPERS_OSEK_OIL_SOURCE), $(WINE)"
-os=ECC2 -I${TOPPERS_OSEK_ROOT_SG}/sg/impl_oil \

This is done not to use Cygwin program, which is useless since we are already on a Linux environment.

For all users: To use RAMSES with nxtOSEK, you need to add a line in the “ecrobot/ecrobot.mak” file. Add to the variable “TOPPERS_INC_PATH” (line 84) the value:


You will need also to copy the “sg.exe” file, available on the download page of nxtOSEK (detailed informations are on this page).

To install programs on your brick, you need the following deployment tools, and you need to change the firmware of the Lego brick as follows

Step 1: To set the brick into firmware update mode: press the reset button (at the back of the NXT, upper left corner beneath the USB connector) for more than 5 seconds while the NXT is turned on. The NXT will audibly tick when it is in firmware update mode.

Step 2: Connect PC and the NXT by USB cable.

Step 3: Type the following command 
$ <deployment_tools_path>/NeXTTool /COM=usb -firmware=<deployment_tools_path>/lms_arm_nbcnxc_107.rfw
Program upload may take around half minutes and then, NXT LCD is turned to display some chunk from blank. 

Step 4: Remove the battery from the NXT and insert it again, and then press orange rectangle button on the NXT to turn on the Enhanced NXT firmware. The Enhanced NXT firmware has same GUI as the LEGO standard firmware.


Install POK from the following git repository: https://github.com/pok-kernel/pok. You need the following programs on your machine to make POK works:

  • GCC
  • binutils
  • perl
  • libxml-xpath-perl (the XML::XPath::XMLParser)
  • libxml-libxml-perl (the XML::LibXML Perl module)
  • mtools (optional)
  • qemu
  • make

Then, in the root of the repository, run this command:


Depending on your architecture, one configuration will be created. If not, install the missing programs.

Import one of our Examples

The RAMSES archive also contains examples you can use to get familiar with RAMSES. To import them, follow these instructions:

  • in the AADL navigator, right click and select New… -> Example… (or in the File menu select New… -> Example…)
  • select RAMSES examples, like on the following picture:

  • name the project you are creating and select the example to import in your workspace:


  • click on Next and select Plugin_Resources as a referenced project:

Generate the code of the example

With this example, you can generate code for three architectures:

  • POSIX-Linux
  • nxtOSEK
  • POK

We will first generate code for POSIX-Linux.


Open an AADL model. In the outline view, right-click on the system implementation “main.posix” you want to generate code for and click on Launch RAMSES.


A configuration page pops up. Select POSIX-Linux target:


The generation can take some time. At the end, you obtain a directory called “generated-code”. Inside, you have your program “the_cpu/the_proc/the_proc”. Execute it by running the following command:

$ sudo ./the_cpu/the_proc/the_proc

You need to be root to execute some threads functions. You should obtain something like following in your terminal:



In the project tab, select the root of the project, right-click and select “Properties”. Choose “RAMSES Configuration” on the left. Then, select the target “OSEK/NXT-nxtOSEK”. Below, click on the button “Choose the target platform path” and select the path where you installed nxtOSEK:


Then you can go in “Outline” tab, right-click on “main.osek” and “Launch RAMSES” like previously for POSIX-Linux. You should obtain in your “generated-code” directory the following file : “the_cpu/the_proc/the_proc_OSEK.rxe”.

You can install and launch it on your nxt brick with this command using the deployment tool (see above):

sudo <PATH_TO_DEPLOYMENT_TOOLS>/NeXTTool /COM=usb -download=<PATH_TO_EXAMPLE>/the_cpu/the_proc/the_proc_OSEK.rxe

Launch the program on the brick. You should see variables which send and receive incrementing values.


Like previously, open the properties of the project and go in the RAMSE Configuration. Select the POK target, configure the path to your POK install directory. The POK install directory should contain a “misc/mk/config.mk” file, produced during the installation of POK. You can now execute the code generation by right-click on the “main.pok” system, and select “Launch RAMSES”.

After code generation, the generated code is compiled. If you need to re-compile it, open a terminal, go to the “generated-code” directory, and execute:

$ make

To execute the generated code, go to the generated-code directory and execute:

$ make run

You should obtain something similar to this in a new window: