cancel
Showing results for 
Search instead for 
Did you mean: 

USART DFU timeout issue-STM32F446RET6 controller

sneha_giby
Associate III

programmer_tool_error.png

 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.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
sneha_giby
Associate III

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

}

}

View solution in original post

6 REPLIES 6
TDK
Super User

Use this code:

https://community.st.com/t5/stm32-mcus/how-to-jump-to-system-bootloader-from-application-code-on-stm32/ta-p/49424

Don't jump from within an interrupt.

 

(Note: "DFU" is a USB class. There is no "USART DFU" bootloader, just "USART bootloader".)

If you feel a post has answered your question, please click "Accept as Solution".
sneha_giby
Associate III
 

debug_entry.png

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

 

sneha_giby
Associate III

Do i have remove the usb power supply(STLINK -default )

and use external power supply.

TDK
Super User

Did you change your code as I suggested? Show your updated code.

If you feel a post has answered your question, please click "Accept as Solution".
sneha_giby
Associate III

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

 

sneha_giby
Associate III

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

}

}