2020-07-29 12:45 AM
Hi all! I use STM32L151VDT7X, CubeMX HAL and Atollic TrueSTUDIO® for STM32 9.3.0 in my project. I need to upgrade my firmware on-the-air and so I made “bootloader + image�? application:
1) Edited in bootloader linker file:
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 80K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 0xA100
FLASH2 (rx) : ORIGIN = 0x8040000, LENGTH = 0
}
2) Edited in image linker file:
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 80K
FLASH (rx) : ORIGIN = 0x800A100, LENGTH = 192K - 0xA100
FLASH2 (rx) : ORIGIN = 0x8040000, LENGTH = 192K
}
3) Created simple test bootloader:
void JumpToApplication(uint32_t VT_Address) {
__disable_irq();
HAL_RCC_DeInit();
HAL_DeInit();
void (*Int_Entry) (void);
uint32_t sp = *(uint32_t *)(VT_Address + STACK_POINTER); // STACK_POINTER == 0
__set_MSP(sp);
// INT_PROGRAM_START == 4
Int_Entry = (void(*)())(*(uint32_t *)(VT_Address + INT_PROGRAM_START));
(*Int_Entry)();
}
int main(void)
{
/* USER CODE BEGIN 1 */
JumpToApplication(IMAGE_VECTOR_TABLE); //IMAGE_VECTOR_TABLE == 0x0800A100
return 0;
4) In image program the first action:
void RemapVectorTable(uint32_t VT_Address) {
__disable_irq();
SCB->VTOR = VT_Address;
__enable_irq();
}
int main(void)
{
//IMAGE_VECTOR_TABLE == 0x0800A100
RemapVectorTable(IMAGE_VECTOR_TABLE);
..
HAL_Init();
Program without bootloader works fine (started from 0x8000000 address). The result “bootloader + image�? program starts, works, but falls into HardFault_Handler at the point HAL_UART_ErrorCallback. I use DMA UART4. Program without bootloader passes HAL_UART_ErrorCallback and continues to work.
What’s wrong with HAL_UART_ErrorCallback or with the bootloader?
Solved! Go to Solution.
2020-07-29 01:03 AM
Double check VTOR implementation, if it needs to be 512 byte boundary to accommodate size of table.
2020-07-29 01:03 AM
Double check VTOR implementation, if it needs to be 512 byte boundary to accommodate size of table.
2020-07-29 01:23 AM
Thanks for the quick response! Could you tell me how can I check it? In map file? Do I need to edit ".isr_vector" section in the linker script?
2020-07-29 01:42 AM
Thanks!!! It works. I didn't know this limitation:
"There are also limitations on the offset address value, which must be aligned to multiples of 512 bytes."