2022-01-19 12:00 AM
I am importing a library (which I am also building with the same toolchain), in which the errors are occuring.
Can I tell the compiler to not create unaligned addresses? Or do I have to change the source code of the library?
I have tried compiling with -mno-unaligned-access.
2022-01-19 03:44 AM
> Can I tell the compiler to not create unaligned addresses?
Cortex-M-specific toolchains tend to come with settings which do generate aligned addresses. Howevr, you can't generally prevent the *user* to generate unaligned address accesses. simply by some pointer juggling.
Debug the hardfault in the usual way (walk back manually through mixed-C-disasm while observing registers' content) to find out exactly what source lines caused the unaligned access. Post it here for further discussion.
JW
2022-12-06 07:01 AM
Hi, I am getting the same hard fault while using lwIP and Ethernet with STM32F746G DISC board.
2022-12-06 10:40 AM
And @Community member 's answer still applies. See what code is that the given PC address and see if you can determine why it generated the fault.
Generally the F7 supports unaligned access except for LDM, STM, LDRD and STRD instructions. There is a bit in the CCR register that can enable unaligned access faults when they otherwise might be allowed. See PM0253.
2022-12-06 10:45 AM
Show the actual code that's faulting, the registers, and the instructions.
It should be more apparent as to what's going on.
2022-12-09 08:43 AM
Hi, I attached my project for review I am just trying to ping my board but I don't see any response. I set up the Rx,/Tx_Descrip and Rx/Tx_Buf in SRAM1 region. Above that I give access to lwIP_Heap Memory. Please check and make it functional. Code is running but no response from board. II am using STMCubeIDE 1.6.1 with CubeMX 1.6.2
2022-12-09 08:49 AM
2023-10-02 04:42 AM
I need to parse incoming packets with structure like
{
uint8_t packet_id;
uint16_t packet_CRC;
uing8_t var1;
double var2;
...
}
For M7 core (STM32H755) CubeIDE make code that generates "unaligned access" hard fault on simple access of unaligned variables like
IncomePacked.packet_CRC = calculated_CRC;
double MyVar = IncomePacked.var2
, etc.
I have need to add "-mno-unaligned-access" compiler option to rid that faults.
Strange, but M4 core works OK with the same code without additional options.