Re: Memory corruption (?) I don't understand

Trampas Stern <[email protected]> Tue, 22 Jun 2021 09:28:08 -0400
Newsgroups gmane.comp.hardware.avr.gcc
Message-ID <CADqjcyhNvT2uHrBQpAF29misLd6OhiQOCb0tHe5HfzUqmtv7Jw@mail.gmail.com>
--0000000000005a02bd05c55ac384
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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=C3=ABl <joel.bertrand@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
>
>

--0000000000005a02bd05c55ac384
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Can you comment out lines and have firmware=C2=A0run?=
=C2=A0=C2=A0</div><div><br></div><div>Could it be that your power supply is=
 dropping and browning out?=C2=A0</div><div><br></div><div><br></div><div d=
ir=3D"ltr"><span style=3D"background-color:rgb(30,30,30);color:rgb(212,212,=
212);font-family:Consolas,&quot;Courier New&quot;,monospace;font-size:14px;=
white-space:pre"><br></span></div><div dir=3D"ltr"><span style=3D"backgroun=
d-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Consolas,&quot;Cou=
rier New&quot;,monospace;font-size:14px;white-space:pre"><br></span></div><=
div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, Jun=
 22, 2021 at 7:59 AM BERTRAND Jo=C3=ABl &lt;<a href=3D"mailto:joel.bertrand=
@systella.fr">[email protected]</a>&gt; wrote:<br></div><blockquote=
 class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px so=
lid rgb(204,204,204);padding-left:1ex">=C2=A0 =C2=A0 =C2=A0 =C2=A0 Hello,<b=
r>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 I&#39;m writing a firmware for a board that use=
s a ATMega 1284. Firmware<br>
continuously restarts and I&#39;m not able to fix this bug. It looks like a=
<br>
memory corruption, but after several days without finding this bug, I<br>
doubt. Hardware seems to be bug free and runs as expected.<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 I have uploaded this firmware at<br>
<a href=3D"https://hilbert.systella.fr/public/firmware.tar.gz" rel=3D"noref=
errer" target=3D"_blank">https://hilbert.systella.fr/public/firmware.tar.gz=
</a><br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 In this tarball, firmware.elf was compiled with=
 gcc 11.1.0 (and crashes).<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 I have removed all multitasking capabilities, m=
utex_* functions don&#39;t<br>
nothing. Firmware crashes in lora_send(). There is no memory allocation<br>
(only one malloc() in this code but in function gnss() and this function<br=
>
is not called). Firmware starts in main(), initialises some chips and<br>
LoRa module (SX1262) and enters in a loop.<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 simavr gives the same result, but avr-gdb doesn=
&#39;t give usable<br>
information. I have tried to build firmware with gcc 11.1.0 (instead of<br>
5.4.0). Sams result, but avr-gdb now returns &quot;internal error&quot;. Th=
us, I<br>
have built a new avr-gdb (9.2). Problem :<br>
<br>
hilbert:[/usr/local/cross/avr/bin] &gt; ./avr-gdb -v<br>
Erreur de segmentation<br>
hilbert:[/usr/local/cross/avr/bin] &gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 I have tried to bissect, to add debug traces (w=
ith some debug traces,<br>
firmware runs as expected !) without result. I have tried -Os and -O2<br>
also. I no longer know how to correct the problem.<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Help will be welcome.<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Best regards,<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 JB<br>
<br>
</blockquote></div></div>

--0000000000005a02bd05c55ac384--