cancel
Showing results for 
Search instead for 
Did you mean: 

Jump from UART internal bootloader to Application code issue

Rushik_Kanabar
Associate II

Hi Everyone,

 

I am using stm32u575 microcontroller. I am facing issue of stuck the application code in Hardfault handler when jump from internal UART bootloader to the Newly written application code.

 

Lets explain you the full process. I have a application code of FreeRTOS CMSIS 2 is running. Then, I give a command for jump to the Internal UART bootloader. The application code jump function triggers. The jump function has includes Disable all interrupts along with clear pending interrupts, deinitialize all peripherals, Disable all peripheral clocks, disable systick timer and Freertos Time base timer 6, function pointer for jump to Internal UART bootloader address etc. After this jump function executes, the Stack pointer goes to internal UART bootloader. The UART bootloader erases the application code and will write new application code that captures packets via UART communication. After the whole binary file of FreeRTOS new application process has been completed, I am triggers GO command (0x21) along with new application base address that is 0x08000000. The GO command will add 0x04 to the address and jump to the newly written application code. After jump to the new FreeRTOS application code, the code directly goes to the Hardfault handler.

 

When I press the RESET button of STM32, the newly updated binary file is running properly. But it requires my manual intervention that I don't want.

 

Can anybody know what is the cause of this problem and how can I Run the newly flashed binary after DFU update?

 

If you have any queries, please let me know.

 

 

Thanks,

Rushik Kanabar

10 REPLIES 10

Dear Tesla DeLorean , Thanks for the response. 

I have tried you mentioned method, But I have to manage that RESET controller binary file during OTA process and also need to store that in the eternal flash. It is not gonna work in my case.

Furthermore, as per check in the document (cd00167594-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics) of about this, I found that, This problem is mainly related to not properly de-initialize the peripherals. You can see on the attached image. 

I am giving you below de-initialize method function. I can you check what is missing here?
I have also tried to de-initialize all peripherals, Disable PLL , Clock, sytick and timebase, Reset all GPIOs, stop timers, IRQs, suspend schedulers but still the code is not running. I found all functions from stm32u5xx_hal_rcc.h library.

void jump_to_bootloader(void)

{

uint8_t bootloader_msg[] = "Jumping to Bootloader...!!!\r\n"; //Data to send

HAL_UART_Transmit(&huart1, bootloader_msg, sizeof(bootloader_msg), 10);

 

void (*sys_mem_boot_jump)(void) = (void*)(*((volatile uint32_t*) (BOOT_ADDR + 4U)));

__set_MSP(*(uint32_t *)BOOT_ADDR);

 

 

/* Disable all interrupts */

__disable_irq();

 

/* Set the clock to the default state */

MX_GPIO_DeInit();

MX_GPDMA1_DeInit();

MX_I2C_DeInit();

MX_TIM_DeInit();

MX_USART_DeInit();

MX_SPI_DeInit();

HAL_TIM_Base_DeInit(&htim6);

ForceResetAllPeripherals();

HAL_RCC_DeInit();

HAL_DeInit();

 

/* Clear Interrupt Enable Register & Interrupt Pending Register - 240 registers*/

for (uint8_t i = 0; i < MCU_IRQS; i++)

{

NVIC->ICER[i]=0xFFFFFFFF;

NVIC->ICPR[i]=0xFFFFFFFF;

}

/* Disable Systick timer */

SysTick->CTRL = 0;

SysTick->LOAD = 0;

SysTick->VAL = 0;

 

/* Re-enable all interrupts */

__enable_irq();

 

sys_mem_boot_jump();

}