We have a multi-app bootloader. The application starts with bootloader.uvprojx and then switches to one of the two applications namely: fw2000 and fw3000. So we have 3 binaries/executables on our controller at following addresses of the flash program/code memory space: bootloader at 0x0, fw2000 at 0x2000 and fw3000 at 0x3000 . fw2000 and fw3000 are the same code but these two app firmwares here are compiled using absolute ROM addresses to create fw2000.bin and fw3000.bin. This is done in Keil by setting the address in "Options for target"->"Target"->"IROM1:" -> "Start" address to respective start address .
We have this architecture to update firmware. For that creating bin/hex specific to absolute address is not desirable.
Is there a way to compile a fwXXXX which can be relocatable at both the addresses? Such that, fwXXXX is compiled and the .bin ot .hex can be written at any address (in this case 0x2000 or 0x3000).
"So your concern of the vector table being called from an absolute address is handled by the micro-controller's feature of force remap."
Umh, no.
The Cortex-M3/M4 have SCB->VTOR, the Cortex-M0 requires an alternate shadowing at address zero to achieve a similar effect.
STILL, the vectors IN THE TABLE point to ABSOLUTE addresses. Which, by definition, is NOT address-independent. If the rest of your code/data is address-independent you can fudge/patch the vector table entries as you write them to FLASH or RAM to account for the specific address they are now situated at.
Thanks! I got what what u were telling about the absolute address entries in the vector table. I'll figure out a way to fix that.
I did NOT understand : "If the rest of your code/data is address-independent". How do I know this? Doesn't checking the "Read-Only Position Independent" box ensure that?
Hi Pier, I tried shifted the vector table to the RAM in the firmware. The ISR funtion pointers are copied in the vector table in RAM. The program runs through the init and then stops working. I'm not able to debug this code.
The reason could be that when the fw2000 is running, it is provided with fw3000.bin . The fw2000 copies the .bin file in the internal flash @ 0x3000. After fw2000 is done writing and veryfying the firmware, the MCU restarts and the bootloader will now boot only fw3000. fw3000 runs though init, I get a few led blinks as expected and then I can't tell what's happening. Is there a way to debug the fw3000 using Keil?
Hi Pier, Out of curiosity I compiled 3 bin files: 1)IROM1 0x2000 2)IROM1 0x3000 3)IROM1 0x3000, I checked the ROPI box in C/C++ tab.
The bin files created using 2) and 3) are identical.
I was thinking that: checking ROPI would make the bin position independent and then even if it is loaded at any address in the flash, it should work.
Correct me if I'm wrong.