Can you comment out lines and have firmware run? Could it be that your power supply is dropping and browning out?
On Tue, Jun 22, 2021 at 7:59 AM BERTRAND Joël <joel.bertr...@systella.fr> wrote: > Hello, > > I'm writing a firmware for a board that uses a ATMega 1284. > Firmware > continuously restarts and I'm not able to fix this bug. It looks like a > memory corruption, but after several days without finding this bug, I > doubt. Hardware seems to be bug free and runs as expected. > > I have uploaded this firmware at > https://hilbert.systella.fr/public/firmware.tar.gz > > In this tarball, firmware.elf was compiled with gcc 11.1.0 (and > crashes). > > I have removed all multitasking capabilities, mutex_* functions > don't > nothing. Firmware crashes in lora_send(). There is no memory allocation > (only one malloc() in this code but in function gnss() and this function > is not called). Firmware starts in main(), initialises some chips and > LoRa module (SX1262) and enters in a loop. > > simavr gives the same result, but avr-gdb doesn't give usable > information. I have tried to build firmware with gcc 11.1.0 (instead of > 5.4.0). Sams result, but avr-gdb now returns "internal error". Thus, I > have built a new avr-gdb (9.2). Problem : > > hilbert:[/usr/local/cross/avr/bin] > ./avr-gdb -v > Erreur de segmentation > hilbert:[/usr/local/cross/avr/bin] > > > I have tried to bissect, to add debug traces (with some debug > traces, > firmware runs as expected !) without result. I have tried -Os and -O2 > also. I no longer know how to correct the problem. > > Help will be welcome. > > Best regards, > > JB > >