Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Level 1
Level 1

I'm currently trying to figure out how things work, and I came across a question for which I couldn't find an answer (yet).

When I'm adjusting the area of the Flash in the linker script, (e.g. because I want to use a Bootloader) the program will still run on the XMC.

In the "C-Start and Device Initialization" Guide, it states:
Normal Boot Mode is a commonly deployed boot-mode. On execution, the on-chip firmware reads the
user application vector table, typically placed at the start of the Flash area. It extracts the start
address of the C-Start routines and then cedes control to the reset handler routine.

I was at first wondering how the on-chip firmware would find out where I'd put the Vector table, but actually the Vector table is stored both at the actual start of Flash and at my shifted start of flash.
However, when I open the hex file, all the data is located at my shifted start of Flash.

Can anyone explain to me why this happens?

1 Reply
Level 4
Level 4
First solution authored
AFAIK the vector table always needs to be at flash start. The 2nd integer value in your table contains the reset method location, which is called automatically by the boot ROM. If it's not there, your program will most likely crash.

The only way to get around this is to use the Alternate Boot Mode headers 1 or 2. Those headers are placed at fixed locations in your flash and tell the BSL where your actual program is located. You probably need something to call the startup of the ABM header beforehand, so in the end you want to place some start-up code (= your own bootloader) in the flash start section. The ABM BSL does not help much, it just does the relocation, the stack pointer initialization, the actual jump and it is usually executed after a reset, so you don't need to reset registers manually back to their defaults.

About the documentation wording "... typically placed at the start of the Flash area": I interpret "typically" as "has to be".