2018-02-22 10:04 PM
Hello,
I have developed a IAP application based on STM32F030CCT6. The application code is received on UART and I can store it in flash, I am storing codeat 0x08010000. But I am facing problems in executing it. While trying to jump at code my code goes into HardFault interrupt. And unfortunately on this MCU there is no implementation of HFSR and VTOR. Hence I am not getting the reason for hardfault! I am using below code for jumping. And I have also remapped the Vector table in application binary. I am using Keil MDK5 and hence I have verified the addresses of code from MAP file. The application code's RESET starts at
0x08010000. and the IAP starts at0x08000000 as expected. Please guide me.
typedef void (*jumpFunction) (void);//typedef for function pointer jumpFunction JumpToFunction;
//Function pointer uint32_t JumpAddress,somaddr;//Address of function pointer
__disable_irq(); JumpAddress = *(__IO uint32_t*)(FLASH_X_START_ADDR + 4);
JumpToFunction = (jumpFunction) JumpAddress; /* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) FLASH_X_START_ADDR); /* Jump to application */
JumpToFunction();
#stm32f0-iap-multi-app Note: this post was migrated and contained many threaded conversations, some content may be missing.Solved! Go to Solution.
2018-02-26 01:39 AM
I got it working! The binary was correct, but I was writing the binary in wrong order, and hence while execution Hardfault interrupt is certain! I found this fault because of
Waclawek.Jan
comment regarding what should be in the flash after writing binary. And I examined the binary and stored flash and found it was different, after some study I found the bug was in writing the binary. I hope this will help some body in future.2018-02-22 10:18 PM
And unfortunately on this MCU there is no implementation of HFSR and VTOR.
This is why you need to keep the vector table in RAM, which is remapped to 0x0000'0000. This has been discussed here (e.g.
), try searching.JW
2018-02-22 10:23 PM
Slowly step the code observing the point at which it goes to the Hard Fault Handler, and the registers in this case.
2018-02-22 11:20 PM
Yes I did it. I remapped my Vector Table in RAM.
2018-02-22 11:22 PM
How?
And what exactly triggers the fault?
JW
2018-02-22 11:32 PM
I done this, but it directly jumps to hard fault interrupt after calling 'jumpToFunction()' . Hence I am not able to see detailed call stack. By the way I am curious about the code I am using. Its provided in example code of IAP. The MSP is set to 0x102D0020 and the 'jumpAddress' is 0x2D0020CD but I guess it should be 0x08010004 isn't it? So I think this is making problem. Please correct me if I am wrong.
2018-02-22 11:34 PM
Due to HFSR is not implement I am not able to know the reason for hardfault.
2018-02-22 11:44 PM
The jump address won't be 0x08010004, it should be loading the value FROM that address, and it should point to the Reset Handler on you app.
The numbers you are quoting don't seem to be valid. You should double check the front of you app image for the vector table.
The processor will fault if you try to jump to an invalid address, or the stack is invalid.
2018-02-22 11:50 PM
You should double check the front of you app image for the vector table.
More precisely, check the application as it physically appears in FLASH at FLASH_X_START_ADDR (which is presumably 0x0801'0000)
JW
2018-02-22 11:58 PM
It means that 'jumpAddress' is correctly set as the value stored at address 0x8010004 to 7 is that. But I am not sure about MSP its value corresponds to values at memory location 0x8010000 to 3. And MAP file has RESET at
0x8010000
, so MSP is correctly set?And I am remapping vector table after HAL_Init() and Sysconfig function, is it correct?