Firmware interrupt vector table relocation by bootloader considered harmful

I have developed in the past month or so a way to have position-independent-code (PIC) firmware image (on ARM Cortex-M0 and Cortex-M4) which can be put (almost) anywhere in flash. I’m still refining the concept and will write an in-depth-article about it. There is a part of the PIC stuff that I can discuss briefly to get us going about THIS article.

Part of the PIC firmware + bootloader has been interrupt vector table relocation. Basically the bootloader needs to read from flash the firmware vector table and copy it to RAM and then point the MCU to use the vector table from RAM. Some of tutorials, videos and comments suggest that bootloader should do the relocation. I have, however, come to the conclusion that this is actually wrong way to proceed. I will try to demonstrate now why.

Continue reading “Firmware interrupt vector table relocation by bootloader considered harmful”

Dynamically generated MCU binary image header (Arm Cortex-M4)

Every seasoned embedded systems engineer faces at some point of their career a problem about needing to put a header to their built firmware image binaries. This header usually contains at least information about what device the image is for and what version number the image is. Checksums are also common.

There are multiple ways of implementing the header. One solution is to just glue it on top of the image and peel it off while updating the firmware via IAP or external programmer means.

Another approach is to place it actually in firmware flash, to a known location, possibly even start of the image, but use a bootloader to jump past the header.

There is however yet another solution I’m going to demonstrate. It is about generating the header template directly into the flash image, and even surprisingly in a way that the MCU can start executing actually from the beginning of the header (template). An external tool is used later to fill in checksum data.

But before continuing, heres a big fat warning:

WE ARE MANIPULATING VECTOR TABLE OFFSETS WHICH IS CONSIDERED DANGEROUS PRACTICE REGARDING ULTIMATE RELIABILITY OF THE RUNNING CODE. YOU HAVE BEEN WARNED.

There. Now lets go on.

We will be working on our trusty old STM32 Nucleo-L432KC and STM32CubeIDE. Example codes are available at https://github.com/usvi/L432KC-dynamic-header .

Continue reading “Dynamically generated MCU binary image header (Arm Cortex-M4)”

Properly offsetting relocated (Arm Cortex-M4) code in STM32CubeIDE GDB

In my previous post I was showing a very elementary but outright inefficient way to debug tricky (Arm Cortex-M4) code which was relocated. The full case was/is: There is a bootloader which loads actual firmware binary. Bootloader is at 0x8000000, firmware at 0x8005000. We used a method to load debug values to registers we were monitoring. It worked but was complex and did not address the root cause of mismatched symbols. There is however a way to make the relocated firmware binary to correspond 100% to the debug symbols and debugger screen. Read below to know more.

Continue reading “Properly offsetting relocated (Arm Cortex-M4) code in STM32CubeIDE GDB”

Debugging tricky (Arm Cortex-M4) code with register values

Sometimes you may run into problems when debugging tricky code. This is the case especially with microcontroller code if you are implementing a bootloader+firmware image solution. Debugger started in bootloader goes haywire and displays garbage or nothing at all when jumping to firmware.

Normally one should invest some time in getting debugger symbols aligned properly with source code, but if there are for example some barring deficiencies in environment or debugger UI, one can still figure out a bit more what is going on by using spare register values. Following shows a somewhat obvious, but still possibly helpful technique in brief for aforementioned debugging situations.

UPDATE 2021-08-16:
To get the job actually done, see my follow-up post

But in any case, the rest of the earlier post is here for posterity.

Continue reading “Debugging tricky (Arm Cortex-M4) code with register values”

Fixing snapped Turtle Beach X12 headset with a secret weapon – a metal ruler!

Turtle Beach headphones are notoriously easy to break and so was the case with my Turtle Beach X12 headset also. They snapped apart:

Actually this was probably my 3rd pair to get busted. I got very angry at Turtle Beach because they designed such a weak point in the product, and angry at myself for buying the same product after every breakage.

With local retail store valuing new set some 100 USD and me wanting to save a bit of environment, I decided to try fixing them.

Continue reading “Fixing snapped Turtle Beach X12 headset with a secret weapon – a metal ruler!”

PC Engines APU2E0 – a tiny fanless server with Intel NICs

My earlier gateway box, the Lanner NCA-1010B decided to stop working, leaving everything as a messy chaos. I gobbled up my retired Zotac Zbox and hastily built a makeshift router.

A long term solution was however needed. I had heard good things from this no-bullshit-geeky Swiss company called PC Engines GmbH. They make a board called APU2E0, among other things. It is a AMD GX-412TC-based SOC product with 2 Intel i211AT NICs. And it does not have regular monitor connections. Instead, there is a DB9 serial port for installation purposes.

The board’s sister version is pictured below for reference.

Continue reading “PC Engines APU2E0 – a tiny fanless server with Intel NICs”

Complicatedly authorizing WhatsApp Web clients for VMware ESXi (6.7) Android x86 7.1

UPDATE 2023-07-20: I wrote earlier that WhatsApp might have broken this functionality. But actually my installation has been working just fine after I emptied my 70GB Firefox profile.

We have arrived to the last part of our ESXi WhatsApp saga. This blog post will tell a very cumbersome way of authorizing WhatsApp Web clients so you can enjoy the benefits of the application with you preferred computer and browser. Follow on!

This post is the last part (so far) in the 3-part series:

Installing Android x86 7.1 on VMware ESXi 6.7

Installing WhatsApp on VMware ESXi (6.7) Android x86 7.1

Complicatedly Authorizing WhatsApp Web clients for VMware ESXi (6.7) Android x86 7.1

Continue reading “Complicatedly authorizing WhatsApp Web clients for VMware ESXi (6.7) Android x86 7.1”

Installing WhatsApp on VMware ESXi (6.7) Android x86 7.1

The journey continues. In this blog post we learn how to get WhatsApp installed on our freshly installed Android x86 7.1 . This article exists for 2 reasons:

  1. To offer completeness in our efforts to get virtualized WhatsApp instances to authorize regular WhatsApp web clients
  2. To show the minor differences there are involved in the process compared to normal WhatsApp install

This is the second article in our 3 article series:

Installing Android x86 7.1 on VMware ESXi 6.7

Installing WhatsApp on VMware ESXi (6.7) Android x86 7.1

Complicatedly authorizing WhatsApp Web clients for VMware ESXi (6.7) Android x86 7.1

Again, as always, lets get started.

Continue reading “Installing WhatsApp on VMware ESXi (6.7) Android x86 7.1”