I am analyzing code written for STM32H730 microcontroller. I find the below snippet of code which is giving hardfault when the BootHoldRequest(&fnBoot) is called.
#define BOOTBLOCK_ADD 0x08000000L
#define BootHoldRequest (*((BOOTLOAD_PROCEED_TYPE *) (BOOTBLOCK_ADD + 0x200)))
typedef void (* CALLBACK_PTR)(void);
typedef uint16_t BOOTLOAD_PROCEED_TYPE(CALLBACK_PTR *);
typedef void (* VOID_FUN_TYPE)(void);
static VOID_FUN_TYPE fnBoot;
if (BootHoldRequest(&fnBoot)) //<--------- HARDFAULT
{
}
As it is impossible to answer your question not seeing the whole project (including linker scripts etc) I will only show how to debug this issue.
if (BootHoldRequest(&fnBoot))
ldr r0, .L6
ldr r3, .L6+4
bx r3
.L6:
.word .LANCHOR0
.word 0x8000200
It loads the 4 bytes address from the BOOTBLOCK_ADD + 0x200
location and then next calls code located at this address. I do not know if you have the correct data there so you need to check it yourself.
If you use IDE (in my example Atollic - which is almost identical with STM32Cube IDE) you can easily check it.
Two methods: Set the breakpoint at this line.
And follow the code one assembly instruction at the time. You will see if the code does what it is supposing to do. It is not your code. It is the code from my project I work on.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.