cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader Firmware Update for STM32H757 using UART

Nitin007
Associate II

Hi All,

I have created two projects. One is for the bootloader and another one is for the Application and will place the bootloader in the starting position of the flash, which is 0x08000000. And application into 0x08040000.

Below is the code for bootloader and application i.e., green led will be turned on when the bootloader starts and when entering into application green led will be turned off and red led will be toggling for 1ms:

Bootloader Code:

in main()

/* USER CODE BEGIN 2 */
HAL_GPIO_WritePin(GPIOK, GPIO_PIN_3, GPIO_PIN_RESET); // Green Led On
HAL_Delay(2000);

goto_application();
/* USER CODE END 2 */

 

static void goto_application(void)
{
 
void (*app_reset_handler)(void) = (void*)(*((volatile uint32_t*) (0x08040000 + 4U)));
HAL_GPIO_WritePin(GPIOK, GPIO_PIN_3, GPIO_PIN_SET );    //Green LED OFF
 
app_reset_handler();    //call the app reset handler
}
 

MEMORY

{

  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 512K

  FLASH    (rx)    : ORIGIN = 0x8000000,   LENGTH = 64K    /* Allocating 64K for Bootloader */

}

Application Code:

 

/* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE BEGIN 3 */
  HAL_GPIO_TogglePin(GPIOK, GPIO_PIN_4);
  HAL_Delay(1000);    //1 Sec delay
    /* USER CODE END 3 */
  }
/* USER CODE END WHILE */

MEMORY

{

  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 512K

  FLASH    (rx)    : ORIGIN = 0x8040000,   LENGTH = 512K    /* Allocating 512K for Application */

}

 

How to write a code for the bootloader firmware upgrade of just a 10ms toggling LED using UART for data transfer. 

I hope I have been able to describe the problem clearly.

 

Regards,

Nithin

8 REPLIES 8
TDK
Guru

> How to write a code for the bootloader firmware upgrade of just a 10ms toggling LED using UART for data transfer. 

I hope I have been able to describe the problem clearly.

Not sure I follow. Are you looking for someone to write the entire bootloader code for you? Or is there something bad happening with the code you've already written that you're looking to get help on?

Why does toggling an LED for 10ms matter here?

If you're using UART, consider using the system bootloader instead to avoid writing your own bootloader.

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

Hi TDK,

Thank you for your reply.

Not sure I follow. Are you looking for someone to write the entire bootloader code for you? Or is there something bad happening with the code you've already written that you're looking to get help on?

Why does toggling an LED for 10ms matter here?

I have created a basic bootloader that jumps to an application where an LED toggles every 1ms that attached in the above code. Now, I want to update the bootloader application to toggle the LED every 10ms to learn how firmware updates work in a bootloader. Can anyone write the code or guide on how to perform this firmware update?

> If you're using UART, consider using the system bootloader instead to avoid writing your own bootloader.

As I mentioned, I want to update the firmware to achieve a 10ms delay for the LED toggling. To accomplish this, I will use UART for data transfer. Could you please write the code or guide on how to perform this firmware update using UART?

 

Ah, so a learning exercise. I don't think me writing code will help you in the long run.

I would suggest looking at examples of erasing and writing flash pages. If you are making your own UART bootloader, it is up to you to choose the protocol. Consider adopting a similar protocol as STM32.

cd00264342-usart-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

 

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

 Can anyone write the code or guide on how to perform this firmware update?

Sure, here you can find help and guidance.

 

ST should have some IAP (In App Programming) examples for this or other platforms, using UART and Y-MODEM

There are other FW Upgrade examples using USB Flash sticks via a USB MSC Host driver

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Can you share some sample code that demonstrate the logic I need to use? The initial PC board sends a message to the STM32 board (via UART or USB) to enter update mode, and then the initial board sends the new firmware for it to update.

In the end, there are two different pieces of code: one on the PC that acts as the master and sends a message to the STM32H757 (via UART or USB) when it needs to enter update mode. The STM32H757 enters update mode, and the PC sends it the new program for updating.

Hi, is their any sample code so that I can use and understand the things for stm32h757 board. Thanks

It's your board, who else is programming for it? As I said look at IAP examples furnished by ST as a starting point to port from.

STM32Cube_FW_H7_V1.11.2\Projects\STM32H743I-EVAL\Applications\USB_Host\FWupgrade_Standalone

STM32Cube_FW_H7_V1.11.2\Projects\STM32H743I-EVAL\Applications\ExtMem_CodeExecution\ExtMem_Boot

STM32Cube_FW_H7_V1.11.2\Projects\STM32H743I-EVAL\Applications\IAP\IAP_Main\Src\ymodem.c

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..