Skip to main content
Myasu.1
Associate III
December 19, 2021
Question

hard fault error occur

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?

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
December 19, 2021

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

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Myasu.1
Myasu.1Author
Associate III
December 19, 2021

@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 !