GNU Linker Wizardry: Wrapping printf() with Timestamps

If one is using a dedicated logger module like the McuLog, then you don’t have to worry or care about timestamp support. But if your application is using normal printf() calls for for logging purpose, you will face issues to adding timestamps to it. You might consider to change all prinft() calls. This might be a lot of work, or not possible in all cases if you cannot change the source code.

But there is a really cool feature of the GNU linker to solve that problem. It allows to ‘wrap’ around any symbol or function, including the ones in the standard library. That way I can add my mode to the printf() code as a wrapper, for example adding a timestamp for every call.

In the example below you can see this in action:

printf() calls with added timestamps

In this article I’ll show how you can wrap any function with custom code.

Continue reading

How to get Data off an Embedded System: FatFS with USB MSD Host and FreeRTOS Direct Task Notification

This is a follow-up article of my earlier project presented in “FatFS, MinIni, Shell and FreeRTOS for the NXP K22FN512“. I wanted to extend it with a USB MSD (memory stick) device: The USB storage device gets automatically mounted, and depending on a configuration (.ini) file on the memory device I can perform various actions, for example automatically copy data from the SD card to the USB device. For example the system logs data, and to get the data I insert the memory stick, it copies the data on it and automatically unmounts it, and I can remove the memory stick.

FRDM-K22F USB Host Mode with Memory Sticks

FRDM-K22F USB Host Mode with Memory Sticks

Continue reading

Log2Ram: Extending SD Card Lifetime for Raspberry Pi LoRaWAN Gateway

My LoRaWAN gateway (“Contributing an IoT LoRaWAN Raspberry Pi RAK831 Gateway to The Things Network” is running and working great now for more than a month and it already has transmitted more than 30k messages:

Gateway Overview

Gateway Overview

This creates a lot of log entries on the micro SD card of the Raspberry Pi. To avoid writing too many times log data, I have installed Log2Ram.

Continue reading