cancel
Showing results for 
Search instead for 
Did you mean: 

hard fault error occur

Myasu.1
Senior

I use the STM32F100RB and make a bootloader.

The PC is connected to the STM32F100RB via UART, and the program to be executed is sent from the PC and extracted to the internal RAM. However, when the program is executed in the RAM, hard fault error occurs.

​The function I want to execute is located at 0x20001364, and I want to shift the execution as follows.

#define MAIN_ADDR (0x20001364)
…
f = (int(*)(void))(MAIN_ADDR);
f();
…

When stopped at 「f();�?, step execution will cause hard fault error to occur.

The value of CFSR is as follows.

0693W00000Hp8YVQAZ.png

I tried setting 0x20001364 directly to the PC register from the debugger, and it works as expected.

Is there a problem with the above method of shifting the execution?

2 REPLIES 2

Its THUMB code, add ONE to the address to make it ODD

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Myasu.1
Senior

@Community member​ 

Thank you for quick reply.

I set MAIN_ADDR to 0x20001365(0x20001364 + 1), and the program works as expected !

Thank you for your support !