Relocating STM vector table in flash

Hello All,

I’ll be brief as I can.

I’m writing a freeRTOS app to run on a STM32L071 device. I’m also writing a boot-loader app which uses the same flash memory map. The boot-loader is not a freeRTOS app, but is at the base of flash so it is called on reset. The boot-loader then calls the main app.

In order to avoid vector table conflict at the base of flash (0x08000000) I have relocated the main app’s vector table to flash address 0x0802F800.

Without freeRTOS working (commented out the call to start the schedule) the app runs OK. Add in the call and freeRTOS fails to start.

It looks as if freeRTOS assumes the vector table is at the base of flash, but this is the location of the boot-loader vector table. Is this correct? Is it possible to ‘tell’ freeRTOS of the new location of the vector table.

Looking in the functions vPortStartFirstTask() and xPortPendSVHandler() they are assembler coded and I guess this is where the problem is(?).

Does this make sense?

Thanks,
Stephen.

The assembly code you refer to does not update the vector table offset register, but assumes that register is already set up. It does however use the vector table offset register on this line https://sourceforge.net/p/freertos/code/HEAD/tree/tags/V10.2.1/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c#l268 to find the location of the stack - which it expects to find in the first location of the vector table (as it would were the FreeRTOS application, or any application for that matter, be booted directly rather than via the bootloader). Does your copied vector table have the correct stack address as the first entry? This is a Cortex-M requirements, not a FreeRTOS requirement.

If so, then can you single step through the assembly code in the debugger to see where it goes wrong?

One other thought - make sure to disable any interrupts before jumping from the boot loader to the FreeRTOS application.

Dear rtel,

Thanks for your reply and I will investigate further.

Regards,
Stephen.