Fixing “REENT malloc succeeded” Assertion

One little nasty assertion in the GNU standard library appeared a few days ago, kind out of nowhere, reporting “REENT malloc succeeded”:

Obviously it was caused by the call to srand() which sets the ‘seed’ for the standard library (pseudo) random number generator. The assertion happens as well later for calling the rand() function.

Continue reading

Choosing GNU Compiler Optimizations

Tool chains like the GNU compiler collection (gcc) have a plethora of options. The probably most important ones are the ones which tell the compiler how to optimize the code. Running out of code space, or the application is not performing well? Then have a look at the compiler optimization levels!

However, which one to select can be a difficult choice. And the result might very well depend on the application and coding style too. So I’ll give you some hints and guidance with an autonomous robot application we use at the Lucerne University for research and education.

INTRO Sumo Robot
INTRO Sumo Robot
Continue reading

Tutorial: Creating and using ROM Libraries with GNU Build Tools

You might never heard about ROM Libraries, and you are probably not alone. Some might thing that this refers to the boot ROM modern MCUs have built in, which is kinda close. But the thing here is about to build your own (possibly constant) ROM library, program it to your device of choice, and then use it from the application running on the device.

So the concept is to have a (fixed, stable) part with code and data on your device, which can be used by a (possibly changing) application: Think about a stable LoRaWAN network stack in the ROM, with a changing application using it: Would that not be cool?

ROM Library Concept

This not only adds flexibility, but as well allows smaller updates, as only a part of the program has to be changed or updated.

The question is: how to create and use such a ROM Library with the normal GNU build tools?

Continue reading

Include .bin Binary Files in a GNU Linker File

Sometimes it is needed or desired just to add or link a piece of data or BLOB (Binary Large OBject) to the application. For example I have created a .bin file of my code and constant data, and I need to add it to an application using the linker file. How to do this?

added BLOB to application
Continue reading

Tutorial: GNU gcov Coverage with the NXP i.MX RT1064

This tutorial shows how to use and collect coverage data using the GNU gcov tool. As board and hardaware I’m using the NXP i.MX RT1064 EVK:

MIMXRT1064-EVK running ThreadX
MIMXRT1064-EVK

While this tutorial uses this specific board, things are pretty generic and should be applicable for any other board or MCU.

Continue reading

Placing Code in Sections with managed GNU Linker Scripts

Managed linker scripts are great on one side: the simplify the otherwise complex GNU linker script handling. On the other side it requires knowledge how to tweak them in case ‘non-standard’ behavior is needed.

Continue reading

Tutorial: GNU Coverage with MCUXpresso IDE

If you are developing Linux or desktop applications with GNU tools, you  very likely are familiar with gcov: the GNU coverage tool. It collects data what parts of the code gets executed and represents that in different formats, great to check what is really used in the application code or what has been covered during multiple test runs.

Coverage Information with gcov

Coverage Information with gcov

line never executed

line never executed

GNU coverage is possible for resource constraint embedded systems too: it still needs some extra RAM and code space, but very well spent for gathering metrics and improves the firmware quality. As I wrote in “MCUXpresso IDE V11.3.0 for 2021” things are now easier to use, so here is a short tutorial how to use it.

Continue reading

Visualizing Data with Eclipse, gdb and gnuplot

The gnuplot is a versatile and powerful tool to plot and visualize all kind of data. I wish there would be a plugin for it in Eclipse. But as this is not (yet?) the case, here is how I’m using it with gdb and Eclipse, using the MCUXpresso IDE as example.

Gnuplot with Eclipse

Gnuplot with Eclipse

Continue reading

Tutorial: MCUXpresso SDK with Linux, Part 3: RAM and XiP Code on i.MX RT1064

In my previous articles I have used the command line on Linux to build and debug NXP MCUXpresso SDK applications. In this article I’m running code on NXP i.MX RT1064 in RAM or FLASH.

i.MXRT1064 board with LPC845-BRK as debug probe

i.MXRT1064 board with LPC845-BRK as debug probe

Continue reading

Different Ways of Software Configuration

Most of the time software needs some way to configure things: depending on the settings, the software will do different things. For example the software running on the microcontroller on top of the Raspberry might have the OLED LCD available or not:

Raspberry Pi and tinK22 with OLED LCD

Raspberry Pi and tinyK22 (NXP Kinetis K22FN512) with OLED LCD

How can I deal with this in my application code? Continue reading