Problem statement I recently came across a situation in a project where I had the following code: 1 2 3 4 5 6 7 8 9 10 struct FaultInfo final { uint32_t r0 ; uint32_t r1 ; // And all the other register state of a Cortex-M0+ processor // ... uint32_t crc ; }; [[gnu::section('.uninit')]] volatile FaultInfo fault_data ; I was using this static region of data to persist some fault information across…
One of the nice things about C++ compared to C is its ability to define reusable types and data structures. They make code reuse easier and also help with reasoning if the abstraction is high-level enough. Today we are going to talk about static_ptr from the library Ditto . Dynamic allocation is often forbidden when developing embedded systems. This leads to allocating most things either in the…
Introduction to memory-mapping Note: This section is introductory material for those who are not yet familiar with the concept of memory-mapping. If you are already experienced with memory-mapping feel free to jump to the next section. Most likely you won’t miss anything new. One of the most common ways of accessing peripherals from a CPU is memory-mapping . In short, this means that the…
Most people getting started with embedded development seem to find linker scripts just another piece of magic required to get up and running with their system. Even when they might already be familiar with memory-mapped peripherals and basic embedded concepts, the linker script and how it interacts with the GNU linker (ld) is still pretty mysterious. Today we will go through the main functions of…
In a previous blog we discussed the role of the NVIC in ARM Cortex-M microcontrollers. This peripheral will play a central role in booting our target application. First of all, we need to discuss the boot process in an ARM Cortex-M microcontroller. Boot process After Power On Reset the microcontroller assumes the NVIC table is located at address 0x00000000. The processor fetches the first two…
Welcome to the second entry of the Bootloader series! Today we are going to be discussing the design and basic architecture of the bootloader application. As we talked about on the last post, we are not going to be using any libraries, other than the C++ standard library in order to maximize portability and performance and limit code bloat. This means that we will be writing our own Hardware…
We are introducing a new series to the blog, containing all about bootloaders for small ARM Cortex-M microcontrollers. I hope you like it. What is a bootloader? A bootloader is a piece of firmware that takes care of booting the target application, as well as providing a mechanism to update the firmware on the field, where you don’t have the means to flash the device using more advanced…
After researching some alternatives for mp3 decoding on STM32 microcontrollers, I found ST’s X-CUBE-AUDIO, a set of libraries and components for audio processing. It turns out that SpiritDSP developed a version of their MP3 decoding libraries for STM microcontrollers. You can download the software expansion kit following this link. It contains much more than just the SpiritDSP MP3 decoder,…
When developing bare metal applications it is required to supply some functions that we normally take for granted when developing code for mainstream OS’s. Setting the startup code is not inherently difficult but beware: some of the nastiest bugs you will ever see on bare metal can come from the startup code. What is actually needed to start the execution of the main function? Well, there…
Developing code for embedded devices is somewhat different from code for mainstream computers. One of these differences is the development environment. Most of the target microcontrollers or microprocessors won’t usually be suited for local development. Imagine trying to build your code on the target when the target is a simple 8-bit Microcontroller. First of all you would need a compiler…
FatFs is an open source library used in many embedded devices to interface with FAT file systems in Block devices such as SD cards, flash drives, etc. It can load a FAT or ExFAT filesystem found inside a partition in an MBR partition table. However, it doesn’t provide support to find a FAT filesystem inside a GUID partition table. This blog post will provide you with the knowledge required…
There are many ways to display text on an embedded device, but not all of them may fit your HW design. This post will expose most of your options and give you a good intuition about what you need to know in order to create great graphics software. Even if you only do hardware, this will still be of interest to you, since you will get a better understanding of what the architecture of your system…
Most microcontrollers now include the options to select the GPIO speed for a certain pin inside a port. Many will announce this feature as GPIO max current control or slew-rate, but in the end they are talking about the same thing. First of all, why would you ever need to control GPIO current? Wouldn’t it be great to leave this at the maximum level at all times? Well, it is usually not that…