IDE for RTEMS application

Hi everyone, I’m wondering which IDE do you use to develop RTEMS applications? I have settled on VS Code for now, but there is some problem with header files and intellisense. I’m considering eclipse or something similar as a more stable alternative.

Hello AlMao,

I usually use vim or neovim for nearly everything. But that has historic reasons and nowadays I most likely would pick VS Code (or Codium) too.

I just recently set up a project with VS Codium. I would suggest to use clangd LSP (llvm-vs-code-extensions.vscode-clangd). You have to set up some extra CompilerFlags and use something like bear to generate the compile_commands.json. But if you do that, it seems to work quite well.

Best regards

Christian

1 Like

If your application uses waf you can have waf generate the compile_commands.json

1 Like

Thanks, I’ll try this extension today!

Thank you, could you please share how it is done in WAF?

I checked what I had set up:

I created a .clangd in the project folder with the following content:

CompileFlags:
  Add: # from `echo | /opt/rtems/7/bin/arm-rtems7-gcc -E -Wp,-v -`
    - "-isystem/opt/rtems/7/lib/gcc/arm-rtems7/13.3.0/include"
    - "-isystem/opt/rtems/7/lib/gcc/arm-rtems7/13.3.0/include-fixed"
    - "-isystem/opt/rtems/7/lib/gcc/arm-rtems7/13.3.0/../../../../arm-rtems7/include"

That helps clang to find all include paths. Note that you might have to adapt to your install location / compiler version / … Just use the command in the comment to find the right paths.

Beneath that, I have created the following task (via a .vscode/tasks.json in the project):

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build embedded application",
            "type": "shell",
            "command": "mkdir build; bear --output ${workspaceFolder}/build/compile_commands.json -- make clean all",
            "problemMatcher": [],
        },
    ]
}

That assumes a Makefile project. And I’m sure it could be optimized to use a problemMatcher, a better command and so on. It was only as a starting point for a project.

From your answer to bosconovic, I assume you use a waf based project. So that most likely will look a bit different. I didn’t check how to do that with waf yet. I only know that it is some kind of extension. The module used for that is here waflib/extras/clang_compilation_database.py · master · ita1024 / waf · GitLab

1 Like

Thank you, it’s useful for me. You mention the makefile project. Does the new version of RTEMS also support makefile? I am interested in this question.

waf is only the build system that is used for the RTEMS core itself. You can use any build system for your application like waf, make or cmake. Usually you only have to make sure, that you get all linker flags right.

Also not all examples are maintained, the examples project should contain quite some demo projects. And the portable_hello looks up to date and has both options: hello · main · RTEMS / RTOS / Examples · GitLab

I usually use a Makefile with more manual parts like the one here: demo · master · Christian Mauderer / rtems-simulation-environment · GitLab

1 Like

@AndreiC uses the old RTEMS Eclipse plugin as well hopefully he can explain how he gets that working we should really find a place on our GitLab to place it to give it some attention.

1 Like

Yes, I use Eclipse (with CDT). I’m old. At one time I used Microsoft Visual Studio exclusively (2000s) and one day Eclipse came out, I gave it a try, and (actually) immediately deleted Visual Studio. More recently Microsoft released Visual Studio Code and I just can’t, they should have changed the name maybe, but I can’t. It’s nice to know that if I can’t run Eclipse anymore, VSC is there, but the stank of Microsoft editors … it’s like durian.

Anyway, Eclipse with CDT, add in the RTEMS plugin (It looks like I got it at https://ftp.rtems.org/pub/rtems/eclipse/updates) using <Help><Install New Software...><Add> , give it a name and put in the address, select All, hit Next. From there it’s reasonably straight forward but I don’t remember the details.

Now, in the properties for your Eclipse project, in C/C++ Build, you now have an RTEMS tab. In this tab you put in paths for your RTEMS tools as well as the BSP that you are using.

When compiling your project, Eclipse will now pick up the appropriate version of gcc (say arm-rtems5-gcc) and have all of the libraries and headers as spec-ed in the BSP.

For me it’s pretty close to magic since it’s been working in the various iterations of Eclipse for about a decade.

Yes, I’ve used vi/vim/emacs/uemacs, been there, done that, got the t-shirt. Am I saying that you should use Eclipse? HAH! That’s like saying that you should use tabs that are three spaces wide.

2 Likes

@c-mauderer bear works with waf too. I’ve had success generating compile_commands.json for RTEMS using bear -- ./waf build

It usually needs cleaning up to remove unsupported compiler flags and add toolchain include paths, though. I wrote a script to automate this process here.

1 Like

@JJL77: Thanks for the note about the script. I use clangd with nvim so I had to solve that problem at some point too. It depends a bit on the architecture whether you have to remove flags or not. For ARM targets, it usually works quite well out of the box. For PowerPC I had some problems too. I mentioned using .clangd to add the include paths. You can use it to remove flags too. For a PowerPC target, I used:

CompileFlags:
  Add:
    - -Wno-unknown-warning-option
      /* some more options */
  Remove: [-m*, -f*]

@AndreiC: I think development environments are largely a matter of personal preference. I never liked any development environment that tries to hide the ugly parts from me (and that includes Eclipse). Usually at some point I have to change something in these ugly parts and then it’s difficult to find the right location in an IDE to change it. But like I said: Personal preference.

2 Likes

Assuming that you would want to use Eclipse with CDT as an IDE and have added in the RTEMS plugin (see above), to create a new project:

<File><New><Project...><C project><Others><RTEMS Executable>

Give it a project name and fill in the location for your project to live.

<right click><New><Source File><Source file:>init.c<Finish>

Here’s some code that you will eventually recognize, put it into init.c:

#include <bsp.h>
#include <stdio.h>
rtems_task Init(rtems_task_argument ignored) {
	printf("Hello, World!\r\n");
}

/* NOTICE: the clock driver is explicitly disabled */
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER

#define CONFIGURE_MAXIMUM_TASKS            1

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE

#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT

#define CONFIGURE_INIT
#include <rtems/confdefs.h>

Next, you have to fill in the RTEMS path information:

<File><Properties><C/C++ Build><RTEMS>

The “Base path” is the directory that you specified with --prefix= when you built RTEMS.

The BSP path is a couple of directories down from the Base path.

How do I explain this?? With an example. I’m using RTEMS 5 on an STM32F767.
I use a Base path of:
/Users/me/RTEMS5/rtems/5
and my BSP path is:
/Users/me/RTEMS5/rtems/5/arm-rtems5/stm32f767

Your version of RTEMS, architecture, and BSP will vary, so it could be under 6/powerpc-rtems6/ss555 or what your particular install requires.

Compile, fix your/my mistakes, feel smug.

I mostly put this here so future me can refer to it, but it might help someone someday.

1 Like

Okay, today I learned that with the RTEMS plugin for Eclipse you can set the default base path and BSP path through:
<Eclipse><Settings...><C/C++><RTEMS>
Set the base and BSP paths here, and the next time you create a project, it will be filled in for you.