gcc, libc for atmega4809 ?

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm on linux, and prefer to use classic unix tools to cross compile for AVR.

My linux distro comes with avr-gcc 5.4.0, avr-libc-2.0.0, etc.

 

Has anyone found a way to cross-compile to the 4809?   I have tried stuffing the associated spec file from microchip "pack" into the installed gcc/libc but it's not working.

 

$ make
avr-gcc -DF_CPU=16000000 -mmcu=atmega4809 -Os  -o main.elf main.c
main.c:1:0: error: unknown core architecture 'avrxmega3' specified with '-mmcu='
 #include <util/delay.h>
 ^
main.c:1:0: note: supported core architectures: avr2 avr25 avr3 avr31 avr35 avr4
avr5 avr51 avr6 avrxmega2 avrxmega4 avrxmega5 avrxmega6 avrxmega7 avrtiny avr1

 

I can build gcc-8 and avr-libc from the sources, but I don't want to go down the trial-and-error path if someone else has the recipe already.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't see the -B in that you need when working with "packs"? Let me just build something in AS7 for 4809 and I'll show the build command to give you and idea.

 

EDIT: so...

		Invoking: AVR8/GNU C Compiler : 5.4.0
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG -DFOO=3  
                -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.3.300\include"  -Og -ffunction-sections -fdata-sections -fpack-struct -fshort-enums 
                -g2 -Wall -pedantic -mmcu=atmega4809 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.3.300\gcc\dev\atmega4809" 
                -c -std=gnu99 -H -save-temps -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.c" 

You need a similar kind of -B to say where your 4809 pack in unpacked.

Last Edited: Wed. May 15, 2019 - 02:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

... but if your version of gcc does not have the xmega3 architecture, then ... you need a version of gcc that knows about it :) 

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

He said 5.4.0 - are there some 5.4.0 that do know xmega3 and some that don't? How confusing!

 

Assuming it does need an "Atmel special" then I guess he needs "AVR Toolchain for Linux" from this page...  https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

... I don't know when xmega3 came into life...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A long long time ago in a place far far away.

 

EDIT And more specifically:  http://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=history;f=ld/emulparams/avrxmega3.sh;hb=9ddc1af18c31e775ae7b107779addfcde92c723f

 

So it looks like it's been around since 2011

Last Edited: Wed. May 15, 2019 - 03:31 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use GCC v8+, Binutils v2.29+ and avr-libc from SVN trunk.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should be able to copy the libraries from the Atmel "Packs", using a procedure similar to the one described here:  https://www.avrfreaks.net/comment/2526416#comment-2526416

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks all.  I'm taking a shot at building from source, using svn-repo for avr-libc.  I'll let you know how it goes.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have gcc-8.3.0 build running pretty far but still some issues.   Looking to build from source and add reference to files from the pack (1.3.300).  I will post when/if I get to completion.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have something working.  I have posted instruction in a thread here

 

#include <util/delay.h>
#include <avr/io.h>

int main(void) {
  PORTF.DIR = 5;
  for (;;) {
    PORTF.OUT |= PIN5_bm;
    _delay_ms(100);
    PORTF.OUT &= ~PIN5_bm;
    _delay_ms(100);
  }
}

 

$ avr-gcc -v -DF_CPU=16000000 -mmcu=atmega4809 -Os -B/opt/local/avr/packs/1.3.300 -B/opt/local/avr/packs/1.3.300/lib/avrxmega3 -o main.elf main.c
Using built-in specs.
Reading specs from /opt/local/avr/packs/1.3.300/device-specs/specs-atmega4809
rename spec link to old_link
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/avr/8.3.0/lto-wrapper
Target: avr
Configured with: ../gcc-8.3.0/configure --prefix=/opt/local --program-prefix=avr- --enable-languages=c,c++ --target=avr
Thread model: single
gcc version 8.3.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-D' 'F_CPU=16000000'  '-Os' '-B' '/opt/local/avr/packs/1.3.300' '-B' '/opt/local/avr/packs/1.3.300/lib/avrxmega3' '-o' 'main.elf' '-specs=device-specs/specs-atmega4809' '-mmcu=avrxmega3'
 /opt/local/libexec/gcc/avr/8.3.0/cc1 -quiet -v -imultilib avrxmega3 -isystem /opt/local/avr/packs/1.3.300/include -D__AVR_ATmega4809__ -D__AVR_DEVICE_NAME__=atmega4809 -D__AVR_DEV_LIB_NAME__=m4809 -D F_CPU=16000000 main.c -mn-flash=1 -mno-skip-bug -quiet -dumpbase main.c -mmcu=avrxmega3 -auxbase main -Os -version -o /tmp/cc7884tm.s
GNU C17 (GCC) version 8.3.0 (avr)
	compiled by GNU C version 7.4.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/opt/local/lib/gcc/avr/8.3.0/../../../../avr/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/local/avr/packs/1.3.300/include
 /opt/local/lib/gcc/avr/8.3.0/include
 /opt/local/lib/gcc/avr/8.3.0/include-fixed
 /opt/local/lib/gcc/avr/8.3.0/../../../../avr/include
End of search list.
GNU C17 (GCC) version 8.3.0 (avr)
	compiled by GNU C version 7.4.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: e754341fb6d4a88f2a771fea0aa442b1
COLLECT_GCC_OPTIONS='-v' '-D' 'F_CPU=16000000'  '-Os' '-B' '/opt/local/avr/packs/1.3.300' '-B' '/opt/local/avr/packs/1.3.300/lib/avrxmega3' '-o' 'main.elf' '-specs=device-specs/specs-atmega4809' '-mmcu=avrxmega3'
 /opt/local/lib/gcc/avr/8.3.0/../../../../avr/bin/as -mmcu=avrxmega3 -mno-skip-bug -o /tmp/cch0dTbH.o /tmp/cc7884tm.s
COMPILER_PATH=/opt/local/avr/packs/1.3.300/:/opt/local/avr/packs/1.3.300/lib/avrxmega3/:/opt/local/libexec/gcc/avr/8.3.0/:/opt/local/libexec/gcc/avr/8.3.0/:/opt/local/libexec/gcc/avr/:/opt/local/lib/gcc/avr/8.3.0/:/opt/local/lib/gcc/avr/:/opt/local/lib/gcc/avr/8.3.0/../../../../avr/bin/
LIBRARY_PATH=/opt/local/lib/gcc/avr/8.3.0/avrxmega3/:/opt/local/lib/gcc/avr/8.3.0/../../../../avr/lib/avrxmega3/:/opt/local/avr/packs/1.3.300/:/opt/local/avr/packs/1.3.300/lib/avrxmega3/:/opt/local/lib/gcc/avr/8.3.0/:/opt/local/lib/gcc/avr/8.3.0/../../../../avr/lib/
COLLECT_GCC_OPTIONS='-v' '-D' 'F_CPU=16000000'  '-Os' '-B' '/opt/local/avr/packs/1.3.300' '-B' '/opt/local/avr/packs/1.3.300/lib/avrxmega3' '-o' 'main.elf' '-specs=device-specs/specs-atmega4809' '-mmcu=avrxmega3'
 /opt/local/libexec/gcc/avr/8.3.0/collect2 -plugin /opt/local/libexec/gcc/avr/8.3.0/liblto_plugin.so -plugin-opt=/opt/local/libexec/gcc/avr/8.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccrCsnU1.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-latmega4809 -mavrxmega3 -Tdata 0x802800 --defsym=__RODATA_PM_OFFSET__=0x4000 -o main.elf /opt/local/avr/packs/1.3.300/lib/avrxmega3/crtatmega4809.o -L/opt/local/lib/gcc/avr/8.3.0/avrxmega3 -L/opt/local/lib/gcc/avr/8.3.0/../../../../avr/lib/avrxmega3 -L/opt/local/avr/packs/1.3.300 -L/opt/local/avr/packs/1.3.300/lib/avrxmega3 -L/opt/local/lib/gcc/avr/8.3.0 -L/opt/local/lib/gcc/avr/8.3.0/../../../../avr/lib /tmp/cch0dTbH.o --start-group -lgcc -lm -lc -latmega4809 --end-group
COLLECT_GCC_OPTIONS='-v' '-D' 'F_CPU=16000000'  '-Os' '-B' '/opt/local/avr/packs/1.3.300' '-B' '/opt/local/avr/packs/1.3.300/lib/avrxmega3' '-o' 'main.elf' '-specs=device-specs/specs-atmega4809' '-mmcu=avrxmega3'

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  PORTF.DIR = 5;

That should probably be:

  PORTF.DIR = PIN5_bm;

 

better:

int main(void) {
  PORTF.DIRSET = PIN5_bm;
  for (;;) {
    PORTF.OUTTGL = PIN5_bm;
    _delay_ms(100);
  }
}

 

I wonder what "PORTF.DIRSET |= PIN5_bm;" does?  Probably exactly what it says, which is probably not what anyone wants!
So many ways to do the same thing!  Whee!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

westfw wrote:

 

I wonder what "PORTF.DIRSET |= PIN5_bm;" does?  Probably exactly what it says, which is probably not what anyone wants!

 

 

Doesn't work.  Thanks for the updated code.  That is working.   I have a verified 4809 compiler working now.