I’m not sure if I’m at the right place, but I need help. I’m new with
PlatformIO and with the ESP01S.
I’m getting an unaligned address exception and I can not find the reason.
The code is for an ESP01S. It consists of a TCP Server and ringbuffer
for a temperature sensor. A client can read out the ringbuffer. The code is
running for a while, but suddenly I’m getting the exception. It seems
filling the ringbuffer is not the reason for the exception. It seems the
readout or answer of the server to the client causes the issue.
The PlatformIO monitor display gives me the following:
Thank you very much. I appreciate your quick help.
Now I’m getting a map file , but the unaligned address points to the main loop area.
I try to get some more exceptions to see if it happens always in the same area.
But it takes almost an hour to get the next one. I must be patient.
Causes the compiler flags to change from -Os (optimize code for size) to -Og -g3 -ggdb3 (optimize code for debug [i.e. not that much], add debug info).
So, if you have a piece of code that works only when compiler optimizations are turned off, something is wrong with that piece of code. Might be doing undefined behavior, or doing stuff like missing volatile, etc.
Thanks a lot for your tireless help, but I got it using instrumentalized code.
I used a lot of serial output instructions in the code.
Eventually it was my own mistake. I used a too small buffer size. It
was just a calculation mistake. This causes a buffer overrun and
mislead to the unaligned access exception anyhow.