Re: Programming ATMega2560

Andreas Höschler <[email protected]>
Newsgroups gmane.comp.hardware.avr.gcc
Message-ID <[email protected]>
Hi Tom,

> #define F_CPU 16000000UL  /* 16 MHz CPU clock */
> #include <avr/io.h>
> #include <util/delay.h>
> #define OUTPUTPORT PORTB
> #define OUTPUTPIN PB7
> int main (void) {
>  DDRB = 0xff;          // all outputs
>  while (1)                       /* loop forever */
>        {
>      if ((PORTB & _BV(PB7)) > 0) PORTB &= ~_BV(PB7);
>      else PORTB |= _BV(PB7);
>      _delay_ms(500);
>        }
>  return (0);
> }
> 
> 
> > avr-gcc -mmcu=atmega2560 -Wall -O2 -I /usr/lib/avr/include/ main.c


I get this

-bash-3.2$  avr-gcc -mmcu=atmega2560 -Wall -O2 -I /usr/lib/avr/include/ main.c
unknown MCU 'atmega2560' specified
Known MCU names:
   avr2
   at90s2313
   at90s2323
   at90s2333
   at90s2343
   attiny22
   attiny26
   at90s4414
   at90s4433
   at90s4434
   at90s8515
   at90c8534
   at90s8535
   avr25
   attiny13
   attiny2313
   attiny24
   attiny44
   attiny84
   attiny25
   attiny45
   attiny85
   attiny261
   attiny461
   attiny861
   attiny43u
   attiny48
   attiny88
   at86rf401
   avr3
   at43usb320
   at43usb355
   at76c711
   avr31
   atmega103
   avr35
   at90usb82
   at90usb162
   avr4
   atmega8
   atmega48
   atmega48p
   atmega88
   atmega88p
   atmega8515
   atmega8535
   atmega8hva
   at90pwm1
   at90pwm2
   at90pwm2b
   at90pwm3
   at90pwm3b
   avr5
   atmega16
   atmega161
   atmega162
   atmega163
   atmega164p
   atmega165
   atmega165p
   atmega168
   atmega168p
   atmega169
   atmega169p
   atmega32
   atmega323
   atmega324p
   atmega325
   atmega325p
   atmega3250
   atmega3250p
   atmega328p
   atmega329
   atmega329p
   atmega3290
   atmega3290p
   atmega32hvb
   atmega406
   atmega64
   atmega640
   atmega644
   atmega644p
   atmega645
   atmega6450
   atmega649
   atmega6490
   atmega16hva
   at90can32
   at90can64
   at90pwm216
   at90pwm316
   at90usb646
   at90usb647
   at94k
   avr51
   atmega128
   atmega1280
   atmega1281
   atmega1284p
   at90can128
   at90usb1286
   at90usb1287
   avr1
   at90s1200
   attiny11
   attiny12
   attiny15
   attiny28
main.c:1: error: MCU 'atmega2560' supported for assembler only
In file included from main.c:4:
/usr/local/avr/lib/gcc/avr/4.3.3/../../../../avr/include/avr/io.h:530:6: warning: #warning "device type not defined"
main.c: In function 'toggleOutput':
main.c:19: error: 'PORTB' undeclared (first use in this function)
main.c:19: error: (Each undeclared identifier is reported only once
main.c:19: error: for each function it appears in.)
main.c:19: error: 'PB7' undeclared (first use in this function)
main.c: In function 'main':
main.c:34: error: 'DDRB' undeclared (first use in this function)
main.c:45: error: 'PORTB' undeclared (first use in this function)
main.c:45: error: 'PB7' undeclared (first use in this function)

Have you looked at my tool chain setup receipt (see below)? May be I need another version of one of the ingredients!?? What components contains the chip infos? Is this in avr-libc? I use v1.8.1. Which version do you have?

Thanks a lot,

 Andreas


********************************************************************************************************
We download http://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.gz:

	PREFIX=/usr/local/avr
	export PREFIX
	PATH=$PATH:$PREFIX/bin
	export PATH

	cd /usr/src
	mkdir avr
	cd avr
	scp [email protected]:/home/ahoesch/Downloads/binutils-2.24.tar.gz .
	gunzip binutils-2.24.tar.gz
	gtar xvf binutils-2.24.tar
	cd binutils-2.24
	./configure --target=avr --program-prefix="avr-" --prefix=$PREFIX
	make
	make install

We download http://gcc.cybermirror.org/releases/gcc-4.3.3/gcc-4.3.3.tar.bz2:

	cd /usr/src/
	gtar xvf mpfr-2.4.0.tar
	cd mpfr-2.4.0
	./configure
	make
	make install

	cd /usr/src/avr
	mkdir avrgcc
	scp [email protected]:/home/ahoesch/Downloads/gcc-4.3.3.tar.bz2 .
	bunzip2 gcc-4.3.3.tar.bz2
	gtar xvf gcc-4.3.3.tar
	cd avrgcc
	../gcc-4.3.3/configure --target=avr --prefix=/usr/local/avr --enable-languages=c --disable-libssp --disable-shared --disable-libada --disable-libssp --disable-nls --with-dwarf2 --with-gmp=/usr/local --with-mpfr=/usr/local --prefix=/usr/local/avr
	make 
	make install 

	pico /etc/default/login
	pico /etc/default/su

	PATH= ...:/usr/local/avr/bin
	SUPATH= ...:/usr/local/avr/bin

Relogin to get the new PATH value.

	which avr-gcc

We download http://download.savannah.gnu.org/releases/avr-libc/avr-libc-1.8.1.tar.bz2:

	cd /usr/src/avr
	scp [email protected]:/home/ahoesch/Downloads/avr-libc-1.8.1.tar.bz2 .
	bunzip2 avr-libc-1.8.1.tar.bz2
	gtar xvf avr-libc-1.8.1.tar
	cd avr-libc-1.8.1
	./configure --host=avr --prefix=/usr/local/avr
	make
	make install


We sync avrdude-5.8 and arduino.sh from the 192.168.1.2 

	rsync -avz -e ssh arduino.sh avrdude-5.8 [email protected]:/usr/src/avr

and build as follows:
	
	LIBUSB=/usr/sfw
	export CPPFLAGS="-I${LIBUSB}/include"
	export LDFLAGS="-L${LIBUSB}/lib"
	make 
	make install

This installs

	/usr/local/bin/avrdude
	/usr/local/etc/avrdude.conf

We can now do 

	avrdude -c avrispmkII -P usb -p atmega8
	...

_______________________________________________
AVR-GCC-list mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.