Confirming AVR-GCC supports for AVR Sx Series
Aloysius Indrayanto
aloysius.indrayanto@gmail.com
Fri Oct 24 23:46:01 GMT 2025
Hello,
While waiting for my chip to arrive, I would like to confirm whether
AVR-GCC fully supports the AVR32SD28. According to the following sources:
https://gcc.gnu.org/gcc-13/changes.html
https://gcc.gnu.org/gcc-14/changes.html
it appears that support is included. Searching AVR32SD28 from '
https://gcc.gnu.org/lists.html#searchbox' yields no additional meaningful
information.
However, the precompiled AVR-GCC 15.2.0 I downloaded from:
https://github.com/ZakKemble/avr-gcc-build/releases
does not seem to include the necessary headers and libraries (*.h, *.o, and
*.a) for the AVR32SD28.
Therefore I downloaded 'Microchip.AVR-Sx_DFP.1.1.17.atpack' from:
https://packs.download.microchip.com
After extracting the file, I noticed that there is no gcc directory in the
package tree.
However, since XC8 is derived from GCC, I can still do the following:
cd Microchip.AVR-Sx_DFP.1.1.17
mkdir -p gcc/dev/avr32sd28/{avrxmega3,device-specs}
cd gcc/dev/avr32sd28/avrxmega3
cp
../../../../xc8/avr/lib/avrxmega3/{crtavr32sd28.*,libavr32sd28.*} .
cd ../device-specs
cp ../../../../xc8/avr/device-specs/specs-avr32sd28 .
Then, edit the newly copied 'specs-avr32sd28' and replace:
*self_spec:
%<mmcu=* -mmcu=avrxmega3 -mdevice=avr32sd28 %<mshort-calls
-msafety-device-features %<msp8
with:
*self_spec:
%<mmcu=* -mmcu=avrxmega3 %<mshort-calls
%<msp8
Finally, I can build my program using:
/opt/avr-gcc-15.2.0-x64-linux/bin/avr-g++ -Wall -Wextra
-fmerge-constants -fmerge-all-constants -fdata-sections -ffunction-sections
-fno-threadsafe-statics -fno-exceptions -fno-unwind-tables -fno-rtti
--param=min-pagesize=0 -Werror -DNDEBUG -Os -std=c++11 -mmcu=avr32sd28
-DF_CPU=20000000UL -B$XSDK/gcc/dev/avr32sd28 -isystem$XSDK/include
-L$XSDK/gcc/dev/avr32sd28/avrxmega3 -c $PRJ/main.cpp -o
$PRJ/build/main.cpp.o
/opt/avr-gcc-15.2.0-x64-linux/bin/avr-gcc -Wl,--relax -Wl,--gc-sections
-mmcu=avr32sd28 -DF_CPU=20000000UL -B$XSDK/gcc/dev/avr32sd28
-isystem$XSDK/include -L$XSDK/gcc/dev/avr32sd28/avrxmega3 -L$PRJ/build
$PRJ/build/main.cpp.o -o $PRJ/build/main.elf
$XSDK and $PRJ are the locations of 'Microchip.AVR-Sx_DFP.1.1.17' and my
program source code.
It does produce an ELF file, from which I can then generate a HEX file.
After reviewing the XC8 source code, it appears that the
"-mdevice=avr32sd28" flag is primarily informational and is not propagated
to binutils.
However, "-msafety-device-features" is internally mapped to "--append-nop",
effectively appending NOPs as its name suggests. It also propagated to
binutils, maybe to help proper disassembly. There are references to fuse
offsets 0 and 1, as well as code offsets 74 and 94, in the .d files. The
fuse offset is not make sense because fuse 0 is WDTCFG and fuse 1 is
BODCFG. The references to code offsets 74 and 94 make sense, as they
correspond to entries in the vector table.
So my question is, what is the AVR-GCC equivalent for "mdevice=avr32sd28"
and "-msafety-device-features"?
Upon inspecting the disassembly of the AVR-GCC-generated ELF file, I
observed that each interrupt vector entry is followed by a NOP instruction:
...
74: 7c c0 rjmp .+248 ; 0x16e <__bad_interrupt>
76: 00 00 nop
...
94: 6c c0 rjmp .+216 ; 0x16e <__bad_interrupt>
96: 00 00 nop
...
Does this imply that AVR-GCC 15.2 does not require the
"-msafety-device-features" flag?
Hence, my final question is: due to AVR Sx 'Functional Safety', would the
HEX file above still be considered a valid image for the AVR32SD28,
assuming AVR-GCC generates different extra NOPs compared to XC8? Or will
the AVR32SD28's ERRCTRL module perpetually reset the MCU, mistaking it for
a fault condition?
Thank you and best regards,
Aloysius
More information about the Gcc-help
mailing list