Build your embedded code as a Windows .EXE app

Posted by Magnus Unemyr on Jan 30, 2015 11:13:00 AM


Embedded developers typically run their embedded code on the target platform, such as a Cortex-M based microcontroller like STM32, Kinetis, LPC or EFM32. This is all and well, but sometimes it is really hard to debug and test the code in an embedded board. There are certain use-cases when it would be much easier to debug and test the embedded code on a Windows PC instead.

Control algorithms processing live sensor data comes to mind, as live sensor data is difficult to reproduce when testing modifications to the algorithm. Wouldn’t it be much easier to test the algorithm implementation on a PC, using well-known predefined data from a data file, rather than from the live sensor in real-time?


This is in fact very much possible, if you have a Windows PC C/C++ compiler in parallel to your embedded C/C++ compiler. In the case of our Atollic TrueSTUDIO C/C++ IDE for ARM development, it is even easier. As it uses the GNU compiler (GCC) for ARM development, we integrated GCC for x86 in the product too. Developers can thus easily develop both Windows-based applications (command line .EXE applications) and ARM target applications using the same tool.

Since ARM (embedded) and x86 (Windows PC) applications can share the same source code files, it is very easy to quickly knock-up a Windows PC application that uses the same control algorithm you normally run in the embedded target board.

Just change the data reading from the live embedded sensor to reading from a data file on the PC’s hard-drive, and you can easily modify the algorithm and see how it behaves differently for the same data. And not to mention the value in regression testing, where you much more easily can test that a change to the control algorithm did not change the behavior for certain sets of input data.

In addition to debugging and testing parts of your embedded logic on a PC, the integrated PC tools can be used to develop PC-only code as well, such as various utilities like uploading data logs from the embedded board, or downloading configuration changes to the target system.

You may for example write a PC utility that communicates with the embedded board using a proprietary communications protocol. The same protocol implementation files can then be compiled into both the embedded application and the PC application, reducing duplication of development and test efforts. But because Atollic TrueSTUDIO not only contains the ARM and PC compilers, but the corresponding GNU GDB debuggers too, you can in fact debug both sides of the communication protocol, at the same time, in the same debugger GUI instance!

You can for example single step the PC application until it sends a communication package to the embedded board. On the embedded side, you have a breakpoint that stops the CPU once the packet is received. You can then continue to single-step on the embedded side. This capability to debug both sides of a communication protocol forwards and backwards is really powerful and can help tremendously in certain debug scenarios.

By integrating both an ARM and a PC compiler and debugger, Atollic TrueSTUDIO effectively provides you with two development tools in one. This feature, described as “super useful” by several customers, gives considerable flexibility and convenience to developers who can use the built-in PC compiler to develop Windows PC command line tools and utilities that are used in conjunction with embedded applications development.

If you are an Atollic TrueSTUDIO user and have not learnt about this capability before, you may want to check this out for future use!

More information on our Eclipse-based C/C++ IDE for ARM Cortex development is available in this whitepaper:

Read our ARM development whitepaper!

Topics: ARM Cortex, GNU tools (GCC/GDB), Debugging, Atollic TrueSTUDIO