cancel
Showing results for 
Search instead for 
Did you mean: 

SBSFU + UserApp with FreeRTOS

Zoey
Associate III

I have implemented an application with FreeRTOS. Now I want to run it as an application with SBSFU. It seemed to have a hard fault in SFU_LL_SB_SRAM_Erase(). It stuck in a place with R15(PC) 0x08008FEC ( The function HardFault_Handler for SBSFU is 0x08008ff2).

I tried to comment SFU_LL_SB_SRAM_Erase() and then it did jump to the application, but still stuck in HardFault_Handler for the application.

My application is a bit big. Its .sfb is 185KB. But it can run correctly alone without SBSFU. I also tried to make my application much smaller, to be 40KB, and then the application can running with SBSFU correctly. So, it seems to be related to the size of the application?

Any idea how to solve the problem? Thanks! 

8 REPLIES 8
Jocelyn RICARD
ST Employee

Hello Zoey,

There is a know issue related to usage of FreeRTOS: The SBSFU does not deactivate the systick before jumping to application.

So, you should first deactivate this systick in SBSFU just before jumping in application.

This should be fixed in next release.

Best regards

Jocelyn

Thanks, Jocelyn.

I just fixed the systick issue (Add SysTick->CTRL &= ~(SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk); after SFU_LL_SB_SRAM_Erase();) and edited my question a few minutes ago (I though no one had read my question yet. =) ). My problem now is that if I remove some tasks to make the application smaller (40KB), then it worked fine. But with the original 185KB application, it stayed in SBSFU ( from debug it ran into SFU_LL_SB_SRAM_Erase, but not into SysTick->CTRL &= ~(SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk);.

Any clue? Thanks in advance!

Hi Jocelyn,

Now I put the code for disabling systick before SFU_LL_SB_SRAM_Erase(). For my large application (185KB), it now can jump to the application, and the hard fault is caused by __decompress before going to my main(). I found this when debugging (KEIL).

Zoey
Associate III

The problem is solved. The cause is my application needs a large RAM region and the RAM region defined in UserApp.sct did not specify the size of the RAM region. I added the size for SRAM1 and also added a RAM region SRAM2.

Thanks for your help, Jocelyn. =)

Great! Thank you for your feedback!

Jackie Lee
Associate

Hi Zoey and Jocelyn,

I seem to be hitting the same issue, able to launch app with small userApp FW, however got hard fault when app is bigger. Could you share the changes in code & UserApp.sct to fix the issue?

thanks in advance!

The change in .sct is something like this. Have two regions and specify their start address and length.

  APP_SRAM1_region (SB_REGION_SRAM1_START) (SB_REGION_SRAM1_END - SB_REGION_SRAM1_START + 1) {
  .ANY (STACK)
  .ANY (HEAP)
  .ANY (+RW +ZI)
  }
  APP_SRAM2_region 0x10000000 0x8000 {
  .ANY (STACK)
  .ANY (HEAP)
  .ANY (+RW +ZI)
  }

It fixes the hard fault issue on my board. Thanks for the sharing.