Bootloader and Application Code
Hello
I recently started with a small project. The idea is to have the first few KB of the memory reserved for the bootloader and after that, the application code:
Bootloader: 0x08000000 - 0x08010000
Application: 0x08012000 - 0x0803FFF
The bootloader and the application are two different projects. When the bootloader is exited the following code is executed:
typedef void (*pFunction)(void);
volatile pFunction SysMemBootJump;
void jump_to (volatile uint32_t memoryAddress)
{
if ((memoryAddress < MEMORY_START_ADDRESS) || (memoryAddress > MEMORY_END_ADDRESS)) return; // Check if valid address
volatile uint32_t stackPointer = (*(volatile uint32_t *)memoryAddress);
// Init boot jump
SysMemBootJump = (void(*)(void)) (*((volatile uint32_t *) (memoryAddress+4u)));
// reset
HAL_RCC_DeInit();
HAL_DeInit();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__disable_irq(); // disable interrupt
__set_PRIMASK(1);
__set_MSP(stackPointer); // set stack pointer
SysMemBootJump(); // jump
while (1); // should never be reached
}
In the application code I put the following lines:
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
ROM (rx) : ORIGIN = 0x8012000, LENGTH = 128K-0x12000
}
- define VECT_TAB_OFFSET 0x00012000U /*!< Vector Table base offset field. This value must be a multiple of 0x200. */
After the jump is done, the system locks up and does not run any code of the application.
Both the application and the bootloader are present (I checked with the STM32 Link Utility)
Am I doing an obvious mistake or am I missing something?
I know this topic has been discussed a few times already, but I could not find any solution.
Thanks in advance
Luca