I'm using Keil (Scatter file, not lnker) and I have a bootloader and a place for two images (one active and other is for the over the air update).
i use Cortex M0 processor where there is no Vector Table Offset Register and i used to copy the vector table from flash to sram.
The problem here:
1. I do the ota update using the application and not using the bootloader.
2. I build the firmware for a specific location and when the ota update is happening the active application (which is in slot A) is downloading the new image in Slot B (but the image is built using the linker script for slot A).
3. When I jump from bootloader to app using the function pointer (I see the function ptr is holding the right address.)
4. But when jumping it is creating a hard fault.
5. So the image built for a specific place should only be used there? Can't I use it for other slots (I also look for page alignment)? if not what can be the possible reason for hard fault?
(I see the function ptr is holding the right address.)
With the low bit set to indicate "Thumb"?
Hi Vmere.
Usually how OTA is done in systems like yours is:
1. The OTA Agent connects to the cloud and detects there is a new application available
2. The OTA Agent writes new application version to a free flash space (like bank B in your case) and it resets the MCU
3. The Bootloader detects it has new version of the application (in the bank B in your case) and it either copies application and replaces the one in bank A or it swaps banks and starts execution of the new application
3. The OTA Agent (from the new application) connects to the cloud and confirms update was successful.
BTW, if you have 2 banks and a bootloader then you probably will not use swapping mechanism but your bootloader will replace application in bank A and leave the bootloader. For example MCUboot has that option.