2020-09-23 09:46 AM
Hi,
I am trying to assign an address to a pointer the following way:
#define FM_P_ADDR 0x0807F800
uint64_t * addr = ((uint64_t *)FM_P_ADDR);
However, running the line will direct the execution to the Hard Fault Handler routine.
What is happening? What am I doing wrong?
Thanks in advance.
Kind regards,
Pedro Machado
2020-09-23 10:04 AM
You need to give more context where that happened. The hard fault is not caused by the above lines. At least not on my Nuclo G431RB when using STM32CubeIDE. The assignment compiles into two instructions:
ldr r3, [pc, #4]
str r3, [r7, #4]
Nothing wrong with that.
2020-09-23 10:10 AM
Look SPECIFICALLY at the assembler code and processor registers at the fault, you'll be able to make a determination about what is being objected too.
2020-09-24 01:22 AM
Hello,
I have never been introduced to ARM assembly before (only MIPS, and that was some years ago), so I don't really understand the instructions that follow:
ldr r3, [pc, #124]
str r3, [r7, #108]
After some really quick search, I suppose the first instruction loads into register 3 what the program counter points, with an offset of 124 (Bytes?). The second stores in register 3 108 Bytes (?) starting from the address stored in register 7.
Obviously, it is an offset issue.
Also, any tips on material that might help me learn ARM assembly and architecture in more detail?
2020-09-24 01:40 AM
Constants like 0x0807F800 are stored past the end of the function using it. Therefore the load is relative to PC.
Local variables are allocated withinin a so called frame on the stack. Register r7 is used as frame pointer. Therefore, the store is relative to register r7.
If the fault occurs during str, this might indicate a stack overflow.