cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader in STM32H753

ranganath_b_rangaramu
Associate III

Hi Team,

 I am trying to add a Secondary/custom bootloader in SBSFU. But not able to figure it out how to do it. I changed memory for active slot area and used the same area for custom bootloader in both linker file of both SBSFU and custom bootloader application. But does not work as expected. Can you please guide me through this? 

I need to add a Custom bootloader and trigger user application from it. What are the modification that I need to do for this. I am using STM32H753 board.

@Jocelyn RICARD 

12 REPLIES 12
ranganath_b_rangaramu
Associate III

Any update on tis topic?

 

Jocelyn RICARD
ST Employee

Hello @ranganath_b_rangaramu;,

please have a look to STM32H750B-DK example:

Projects\STM32H750B-DK\Applications\2_Images_ExtFlash\

It contains a loader application. It addressed external flash but you should be able to adapt it for your own need

Best regards

Jocelyn

Hi @Jocelyn RICARD ,

       Thank you. As per my understanding, Standalone loader is used to load a user app application via YModem ?

Here in my case. I need to have a custom bootloader and use that custom bootloader to trigger my user application. 

Hi @ranganath_b_rangaramu ,

yes the example code uses Ymodem.

Then it is up to you to adapt it with another communication protocol.

You can see that Ymodem protocol is using 2 callback.

LOADER_YMODEM_HeaderPktRxCpltCallback : when first packet was received

LOADER_YMODEM_DataPktRxCpltCallback : when following packets are received

These callbacks show you how to manage incoming data and write them into flash.

Best regards

Jocelyn

Hi @Jocelyn RICARD ,

       Understood. Can we use the same loader application for STM32H753 SBSFU example ?

To do this what steps needs to be taken care? In STM32H753, SBSFU uses internal flash. And here loader is on application. Need to use above (STM32H750B-DK) standalone loader in SBSFU code for STM32H753 example. 

 

Hi @Jocelyn RICARD ,

      Any update on this? Also do we have any document to refer how to add custom loader to SBSFU?

In STM32H753 example for SBSFU (2_Images)

I changed MACRO of LOCAL loader to standalone loader. When tried to build got error for LOADER_ROM regions. 

Based on that i created a simple Standalone/Custom loader and changed my LD file as follows:

/* Swap sector in sector 0 of Bank2 : 128 kbytes */
__ICFEDIT_SWAP_start__ = 0x08100000;
__ICFEDIT_SWAP_end__ = 0x0811FFFF;

/* Active slot #1 in Sector 1 to 6 of Bank1; 6 x 128 kbytes */
__ICFEDIT_SLOT_Active_1_start__ = 0x08020000;
__ICFEDIT_SLOT_Active_1_end__ = 0x080DFFFF;
__ICFEDIT_SLOT_Active_1_header__ = __ICFEDIT_SLOT_Active_1_start__;

/* custom slot #8 of Bank1; 128 kbytes */
__ICFEDIT_SLOT_Custom_1_start__ = 0x080E0000;
__ICFEDIT_SLOT_Custom_1_end__ = 0x080FFFFF;

/* Dwl slot #1 in sector 1 to 7 of Bank2 : 7 * 128 kbytes */
__ICFEDIT_SLOT_Dwl_1_start__ = 0x08120000;
__ICFEDIT_SLOT_Dwl_1_end__ = 0x081DFFFF;

Following are the changes i made in SBSFU application:
1. #define STANDALONE_LOADER_STATE (*(uint32_t *)0x20001100) in sfu_standalone_loader.h

2. SFU_MPU_SysCall((uint32_t)SB_SYSCALL_LAUNCH_APP, 0x080E0004); in sfu_boot.c in SFU_BOOT_LaunchStandaloneLoader() function.

3. #define SFU_PROTECT_WRP_PAGE_END_1 ((uint32_t)((0x08100000 - FLASH_BASE) / (FLASH_SECTOR_SIZE))) in changed in sfu_low_level_security.h.

After doing this I am getting below error.

= [SBOOT] RuntimeProtections: 3d00
= [SBOOT] System Security Check successfully passed. Starting...
= [FWIMG] SLOT_ACTIVE_1 overlaps SBSFU code area protected by WRP

= [FWIMG] SWAP overlaps SBSFU code area protected by WRP

Let me know what is wrong in this. 

When i change 3. #define SFU_PROTECT_WRP_PAGE_END_1 ((uint32_t)((0x08100000 - FLASH_BASE) / (FLASH_SECTOR_SIZE))) in changed in sfu_low_level_security.h. to 

#define SFU_PROTECT_WRP_PAGE_END_1 ((uint32_t)((SFU_ROM_ADDR_END - FLASH_BASE) / (FLASH_SECTOR_SIZE)))   code stucks at 

= [SBOOT] RuntimeProtections: 0
= [SBOOT] System Security Check successfully passed. Starting...


======================================================================
= (C) COPYRIGHT 2017 STMicroelectronics =
= =
= Secure Boot and Secure Firmware Update =
======================================================================


= [SBOOT] SECURE ENGINE INITIALIZATION SUCCESSFUL
= [SBOOT] STATE: CHECK STATUS ON RESET
INFO: A Reboot has been triggered by a Hardware reset!
= [SBOOT] STATE: CHECK NEW FIRMWARE TO DOWNLOAD
= [SBOOT] STATE: CHECK USER FW STATUS
No valid FW found in the active slots nor new FW to be installed
Waiting for the local download to start...
= [SBOOT] STATE: DOWNLOAD NEW USER FIRMWAREStarting Custom bootloader
Jumping to application

Please let me know why user application is not triggering from my standalone loader application which is triggered from SBSFU.

 

Jocelyn RICARD
ST Employee

Hello @ranganath_b_rangaramu ,

the standalone loader is supposed to be located just next SBSFU, reason why you have:

#if (SECBOOT_LOADER == SECBOOT_USE_STANDALONE_LOADER)
/*!< Last sector of LOADER ROM area */
#define SFU_PROTECT_WRP_PAGE_END_1      ((uint32_t)((LOADER_REGION_ROM_END - FLASH_BASE) / (FLASH_SECTOR_SIZE)

So, you should be able to locate your standalone loader in the same sector as SBSFU.

SBSFU does not provide ability to update the STANDALONE loader.

Best regards

Jocelyn

Hi @Jocelyn RICARD ,

      Thank you. 

So as per linker file, 

1. the standalone loader is supposed to be located just next SBSFU - 0x0801FFFF + 1 would be starting address for standalone loader? 

2. Yes, we want to update standalone loader from SBSFU. In this case, what we can do? 

Like Update only Standalone loader by having a separate binary. Or any other suggestion if we have choice to update it?

 

Jocelyn RICARD
ST Employee

Hello @ranganath_b_rangaramu ,

yes, standalone loader is supposed to be located just after SBSFU so that write protection can be applied on the whole area.

So, in the example, yes the loader is not supposed to be updated.

If you want to have an updatable loader, you can use the multislot capability.

You put the loader in a second active slot (Application firmware stays in the master active slot), and you change SBSFU so that it can call this loader upon request.

But I don't have implementation example for that.

Best regards

Jocelyn