2026-04-02 10:31 AM - last edited on 2026-04-06 1:11 AM by Gyessine
Hi Team
I am trying to do UART bootloader, using cli command.
The MCU used is STM32F446RET6 and dev kit used is nucleo-f446re.I am using USART1, for printf and cli command with interrupt. CLI command is used to enter system memory /bootloader but as shared above the programmer is not giving timeout error.
void jump_to_bootloader(void)
{
void (*SysMemBootJump)(void);
//system address defined
volatile uint32_t addr = 0x1FFF0000;
// //introduce delay before switcing to bootloader after printf.
// HAL_Delay(200);
//disable all interrupt request and stop SysTick
__disable_irq();
// SysTick->CTRL = 0;
// SysTick->VAL = 0;
//
// __HAL_RCC_SYSCFG_CLK_ENABLE();
// SYSCFG->MEMRMP = 0x01;
//Deinit HAL and all peripheral
// HAL_UART_DeInit(&huart1);
//reset uart pins and gpio
// __HAL_RCC_USART1_FORCE_RESET();
// __HAL_RCC_USART1_RELEASE_RESET();
// HAL_GPIO_DeInit(GPIOA,GPIO_PIN_9 | GPIO_PIN_10);
HAL_RCC_DeInit();
HAL_DeInit();
// Disable all interrupts in NVIC
// for(int i =0; i <8 ; i++) {
// NVIC -> ICER[i] = 0xFFFFFFFF;
// NVIC->ICPR[i] = 0xFFFFFFFF;
// }
//set msp
__set_MSP(*(uint32_t*)addr);
//jump system_memory
SysMemBootJump = (void (*)(void))(*(uint32_t*)(addr + 4));
SysMemBootJump();
while(1)
;
}
Hardware connection - NUCLEO PA9,PA10-UART1 connected to FTDI cable,USB cable connected for power supply the nucleo board which is used for STLINK.
Solved! Go to Solution.
2026-04-02 11:32 PM
Resolved the issue,My code was disabling systick timer before deinit the clock
void jump_to_bootloader(void)
{
void (*SysMemBootJump)(void);
//system address defined
volatile uint32_t addr = 0x1FFF0000;
//disable all interrupt request and stop SysTick
__disable_irq();
//set the clock to default state
HAL_RCC_DeInit();
//disable systick imer
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
HAL_DeInit();
//clear interrupt enable register and interrupt pending register
for(int i =0; i < sizeof(NVIC->ICER) / sizeof(NVIC->ICER[0]) ; i++) {
NVIC -> ICER[i] = 0xFFFFFFFF;
NVIC->ICPR[i] = 0xFFFFFFFF;
}
//jump system_memory
SysMemBootJump = (void (*)(void))(*((uint32_t*)((addr + 4))));
//set msp
__set_MSP(*(uint32_t*)addr);
// REMAP
// SYSCFG->MEMRMP = 0x01;
//re-enable all interupts
__enable_irq();
SysMemBootJump();
while(1)
{
//code should not reach here
}
}
2026-04-02 10:55 AM - edited 2026-04-02 11:17 AM
Use this code:
Don't jump from within an interrupt.
(Note: "DFU" is a USB class. There is no "USART DFU" bootloader, just "USART bootloader".)
2026-04-02 11:41 AM
after running my project ,as suggested by the document the Debugger suggest that my MCU is inside System Memeory (0x1fff0000).but i still get timeout error.
Is there any hardware change required for Nucleo board
2026-04-02 11:46 AM
Do i have remove the usb power supply(STLINK -default )
and use external power supply.
2026-04-02 2:26 PM
Did you change your code as I suggested? Show your updated code.
2026-04-02 8:54 PM
yes i have used the same code mentioned in the Docs
void jump_to_bootloader(void)
{
void (*SysMemBootJump)(void);
//system address defined
volatile uint32_t addr = 0x1FFF0000;
//disable all interrupt request and stop SysTick
__disable_irq();
//disable systick imer
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
//set the clock to default state
HAL_RCC_DeInit();
HAL_DeInit();
//clear interrupt enable register and interrupt pending register
for(int i =0; i < sizeof(NVIC->ICER) / sizeof(NVIC->ICER[0]) ; i++) {
NVIC -> ICER[i] = 0xFFFFFFFF;
NVIC->ICPR[i] = 0xFFFFFFFF;
}
// REMAP
//SYSCFG->MEMRMP = 0x01;
//re-enable all interupts
__enable_irq();
//jump system_memory
SysMemBootJump = (void (*)(void))(*((uint32_t*)((addr + 4))));
//set msp
__set_MSP(*(uint32_t*)addr);
SysMemBootJump();
while(1)
{
//code should not reach here
}
}
Note:SYSCFG->MEMRMP = 0x01; is commented out because i found that when i set this in above code makes my board enter application rather than than BOOTLOADER
2026-04-02 11:32 PM
Resolved the issue,My code was disabling systick timer before deinit the clock
void jump_to_bootloader(void)
{
void (*SysMemBootJump)(void);
//system address defined
volatile uint32_t addr = 0x1FFF0000;
//disable all interrupt request and stop SysTick
__disable_irq();
//set the clock to default state
HAL_RCC_DeInit();
//disable systick imer
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
HAL_DeInit();
//clear interrupt enable register and interrupt pending register
for(int i =0; i < sizeof(NVIC->ICER) / sizeof(NVIC->ICER[0]) ; i++) {
NVIC -> ICER[i] = 0xFFFFFFFF;
NVIC->ICPR[i] = 0xFFFFFFFF;
}
//jump system_memory
SysMemBootJump = (void (*)(void))(*((uint32_t*)((addr + 4))));
//set msp
__set_MSP(*(uint32_t*)addr);
// REMAP
// SYSCFG->MEMRMP = 0x01;
//re-enable all interupts
__enable_irq();
SysMemBootJump();
while(1)
{
//code should not reach here
}
}