2019-02-07 03:36 AM
Hi all,
I have a problem when jumping from one application to another within my new STM32H7 system.
Explaination:
All my systems can be updated via my own bootloader (running on 0x800 0000) application, which communicates via USB port with a PC to my special Universal Flash Loader tool.
The bootloader is located at 0x8000000 (startup application) and the actual application of the system is located at 0x8080000.
At startup the bootloader checks in a separate location (0x8020000) if an application has been successfully loaded (a flag and the application start address are read from 0x8020000).
Then it jumps to the application and runs the code. In case the application should be updated, this application jumps back into the bootloader who will take care for the update procedure.
This works very well on all of my STM32F4 and F7 projects.
Now I face a hard fault error when jumping to the application from the bootloader after the application has been flashed for the first time.
In the first place I tested the final application without the separate bootloader . So the application itself is running!
I checked that the hex file is flashed to the correct areas (0x8080000 and external SPI-Flash on 0x90000000)
Before I jump to the application I disable all previously initialized peripherals and perform the following sequence:
SCB_DisableICache();
SCB_DisableDCache();
HAL_MPU_Disable();
HAL_DisableCompensationCell();
ulStartAppl = 0x8080000;
__DI();
/* Jump to application */
JumpAddress = *(__IO uint32_t*) (ulStartAppl + 4);
Jump_To_Application = (pFunction)JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) ulStartAppl);
Jump_To_Application();
After the jump the system goes to Hardfault and I can't figure out, what the reason might be.
P.S: When loading the bootloader and the application using the Keil ULINK Pro with ARM Compiler into the system, everything boots up correctly into the application)
Any ideas what could cause the hard fault when flashing the software separately?
Solved! Go to Solution.
2019-02-07 11:52 AM
The system isn't going to unwind NVIC stacking or privilege levels. I use NVIC_SystemReset()
Your situation sounds like you're trying to use a privileged instruction and the Computer says No!
2019-02-07 05:26 AM
I don't see interrupts disabled.
2019-02-07 05:31 AM
__DI();
this is defined as:
#define __DI __disable_irq
2019-02-07 05:59 AM
Have the Hard Fault report effectively, and then examine the listing file in that context to see what the processor is objecting too. A random location would be indicative of an interrupt. See how deep it gets before failure, it will scope what you're looking for. RAM allocations will be different.
Perhaps look for a race condition the debugger is hiding.
Not sure the value of disabling the cache.
2019-02-07 07:22 AM
Thank you for your help!
Now problem is solved. I added the following two missing instruction which disable the QuadSPI before jumping to the application.
(The QuadSPI Flash actually caused multiple headaches for my flash tool already...):
QSPI_CLK_DISABLE();
/* Reset the QuadSPI memory interface */
QSPI_FORCE_RESET();
Now the bootloader jumps to the application as desired without problems.
Maybe this information helps others.
2019-02-07 10:59 AM
Ok, now the initial loading of an application through the bootloader app is working fine.
Also when powering up the system it jumps correctly to the application. Everything fine.
Now when I want to install an update the bootloader is called again and then the system goes into hard fault after a short period of time. The bootloader is called correctly and initializes until some point. But actually I can not track the exact position as it happens at different positions in the code every time I step through the code.
Now I am thinking that it might be caused by the installed RTOS which is running in the final application.
I must admit: I am new to RTOS so I don't know how to finish and stop the tasks... (2 tasks are stated for TouchGFX and my DataHandling).
Is this possible at all to stop the tasks? And how?
2019-02-07 11:52 AM
The system isn't going to unwind NVIC stacking or privilege levels. I use NVIC_SystemReset()
Your situation sounds like you're trying to use a privileged instruction and the Computer says No!
2019-02-07 11:54 AM
Use an SVC# to generate the NVIC_SystemReset() if appropriate
2019-02-07 12:44 PM
Going through reset is the safest way, as it solves deinitialization problems and is much simpler overall. I described such a solution here:
2019-02-08 12:50 AM
Hello Piranha,
thank you very much for your post. Hopefully this will also work on the STM32H743. I will try this later today and will let you know then.