C Programming – Compiling and Deploying to an MCU with RTOS

armccpuoperating systemsreal time

Please note: Even though I'm specifically talking about an RTOS called Embox here, and even though I'm talking about AVR/ARm, I think this question can be answered by anybody whose ever done a fair amount of C-based MCU programming.

Say I have an MCU running Embox on it. Now, I'd like to write 2 executables, and 1 static library (used by both programs) in C and deploy all three artifacts to the MCU/RTOS. I have a few very-similarly-related questions/concerns (hence my choice to make this one question instead of 4):

  • What formats of executables and libraries does Embox require, and how can I tell? EXE/SO?
  • How does one compile a C program into an executable/library format (again, perhaps EXE/SO) that is compatible with Embox? For instance, I'm on a Windows machine with GCC provided by MinGW. I don't think I'd be able to write a program for Linux and then deploy it to a Linux machine. I'd need a Linux machine for that. But if the machine I'm deploying to is a simple RTOS/MCU, how do I develop on one platform/architecture (Windows) and make binaries that are compatible on another?
  • How does one deploy the executables to the MCU such that the RTOS can run the 2 apps at startup?
  • How does a user interact with the RTOS? Shell/SSH/console?

Best Answer

What formats of executables and libraries does Embox require, and how can I tell?

Embox is a configurable OS and one can create separate kernel image and user application. But since MCU has rather small memory size, most embedded RTOSes including Embox link all software (kernel, apps etc.) to a single image by default.

How does one compile a C program into an executable/library format (again, perhaps EXE/SO) that is compatible with Embox?

You should setup make and a cross-compiler. Then you have to configure Embox (choose a desired template) with make confload-xxx. And finally build the image with a command make. After that you can find the image in a file ./build/base/bin/embox. Here is a short [getting started][1] page.

How does one deploy the executables to the MCU such that the RTOS can run the 2 apps at startup?

Although Embox creates a single image you can have several apps in it. Unlike most RTOSes in Embox you can have several main routines. This feature is enabled by using a special build system. Embox consists of set of modules and each module is described using a DSL language. There is an 'application' type of module. If a module is marked as an 'application' the build system strips main symbol away and replaces it with <package-name>_<module-name>_main. Also the build system adds the new symbol and the application name to a special applications registry, so that you can run your application from the Embox shell or in some other way.

How does a user interact with the RTOS? Shell/SSH/console?

Embox has a built-in shell and you can access it through UART (COM port), for example. Embox also has telnet and httpd apps which you can interact through. Also Embox has a port of sshd (with dropbear project), but I think it's not the easiest way to communicate with MCU.