2020-07-05 12:01 AM
Hello,
I am trying to get SBSFU working on my G071RB Nucleo board with my own test application.
So far I have used the X-Cube-SBSFU examples and have the UserApp running as expected, it boots and I can run the tests. All good.
I now want to replace the UserApp wit my own application and test with that.
I have built SBSFU and have been able to use the postbuild.sh script to merge my application with SBSFU ok.
SBFU runs, but I am getting a watchdog reset everytime it comes to execute the user firmware as below:
= [SBOOT] SECURE ENGINE INITIALIZATION SUCCESSFUL
= [SBOOT] STATE: CHECK STATUS ON RESET
WARNING: A Reboot has been triggered by a Watchdog reset!
Consecutive Boot on error counter = 5
INFO: Last execution detected error was:Watchdog error.
= [EXCPT] WATCHDOG RESET FAULT!
= [SBOOT] STATE: CHECK NEW FIRMWARE TO DOWNLOAD
= [SBOOT] STATE: CHECK USER FW STATUS
A valid FW is installed in the active slot - version: 5
= [SBOOT] STATE: VERIFY USER FW SIGNATURE
= [SBOOT] STATE: EXECUTE USER FIRMWARE
= [SBOOT] System Security Check successfully passed. Starting...
= [FWIMG] Slot #0 @: 8010000 / Slot #1 @: 8018000 / Swap @: 8017000
Initially I thought this maybe be due to me not having a watchdog in my test application, so I have gone back added a watchdog to my application and know that works ok outside of SBSFU.
I'm wondering if maybe SBSFU isn't able to find my application at the correct Vector Table offset and then a wtatchdog is tripping and reseting the device maybe?
When I looked at Drivers/CMSIS/system_stm32g0xx.c in the UserApp example included with the SBFU example, the VECT_TAB_OFFSET is 0x00, so this must be beign set somewhere else for the USerApp example to work? Maybe STM32G071RBTx.id?
For my application I have taken the STM32G071RBTx.id memory mapping from the UserApp project but it's still giving the same error?
Solved! Go to Solution.
2020-07-06 12:47 AM
Hello,
You should have a look to the system_stm32g0xx.c file located in 2_Images_UserApp\src :
You will find following code that setup the interrupt vector of the beginning of your application slot define in Linker_Commono
#if defined(__ICCARM__)||defined(__GNUC__)
extern uint32_t __ICFEDIT_intvec_start__;
#define INTVECT_START ((uint32_t)& __ICFEDIT_intvec_start__)
#elif defined(__CC_ARM)
extern uint32_t Image$$vector_start$$Base;
#define INTVECT_START ((uint32_t)& Image$$vector_start$$Base)
#endif
/**
* @brief Setup the microcontroller system.
* @param None
* @retval None
*/
void SystemInit(void)
{
/* default RCC clock configuration is restored after reset ------------*/
/* Configure the Vector Table location add offset address ------------------*/
SCB->VTOR = INTVECT_START;
}
Best regards
Jocelyn
2020-07-05 11:21 PM
Hi,
You don't need to configure the watchdog in your user application because it is still configured from the bootloader but you must reload the watchdog value at regular intervals. If you have a loop in your code make sure to add a line to reload the watchdog value, something like this:
WRITE_REG(IWDG->KR, IWDG_KEY_RELOAD);
Also, you should try adding a printf("%s", __func__); or something similar to the fault interrupts in the file stm32g0xx_it.c. That will help you to find out the cause of such issues. This, however, depends on the UART being configured before the fault occurs so may not always be helpful.
2020-07-06 12:47 AM
Hello,
You should have a look to the system_stm32g0xx.c file located in 2_Images_UserApp\src :
You will find following code that setup the interrupt vector of the beginning of your application slot define in Linker_Commono
#if defined(__ICCARM__)||defined(__GNUC__)
extern uint32_t __ICFEDIT_intvec_start__;
#define INTVECT_START ((uint32_t)& __ICFEDIT_intvec_start__)
#elif defined(__CC_ARM)
extern uint32_t Image$$vector_start$$Base;
#define INTVECT_START ((uint32_t)& Image$$vector_start$$Base)
#endif
/**
* @brief Setup the microcontroller system.
* @param None
* @retval None
*/
void SystemInit(void)
{
/* default RCC clock configuration is restored after reset ------------*/
/* Configure the Vector Table location add offset address ------------------*/
SCB->VTOR = INTVECT_START;
}
Best regards
Jocelyn
2020-07-06 01:59 AM
Thak you @Jocelyn RICARD that did the trick! Working now. :thumbs_up: :party_popper:
2021-08-18 04:45 AM
Hello @Jocelyn RICARD . In order to Implement custom feature (mainly azure RTOS, ThreadX and NetxDuo) in the active FW, do you recommend to implement the code inside the UserApp example? If yes, which topics must I make attention about the most?
I have tried to import the libreries without calling the custom FW (so the main.c is the same of UserApp) but after the FW installation the MCU reboots to SBSFU signaling that the startup has been triggered by a Software reset
Thank you!
2021-08-18 10:36 AM
Hello @matteochen
First I would advice creating a specific post for your question, just to keep things clean.
Regarding your question, the UserApp example is just an example. You can start from it but it would be better to separate the bootloader (SBSFU/SE project) from your main project.
You have an example how to deal with scripts in that case in the SBSFU Workshop MOOC here
Best regards
Jocelyn
2021-08-19 01:09 AM
Hello @Jocelyn RICARD
Sorry for have created a little confusion inside this post; thank you very much for your hint, I didn't know the presence of that MOOC.
Best regards,
Matteo