Skip to main content
Alexor
Associate
July 29, 2020
Solved

STM32L151 custom bootloader problem with HAL_UART_ErrorCallback

  • July 29, 2020
  • 3 replies
  • 1097 views

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?

This topic has been closed for replies.
Best answer by Tesla DeLorean

Double check VTOR implementation, if it needs to be 512 byte boundary to accommodate size of table.

3 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
July 29, 2020

Double check VTOR implementation, if it needs to be 512 byte boundary to accommodate size of table.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Alexor
AlexorAuthor
Associate
July 29, 2020

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?

Alexor
AlexorAuthor
Associate
July 29, 2020

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."