views:

152

answers:

1

Instructions in the blinky.zip, gcc-section, Teensy++ v.2. Makefile and blinky.c are in the zip. I modified the blinky.c by defining F_CPU at the start because not using Makefile, please, see below. So why do I get the errs and how can I compile the C-files for at90usb1286 chip?

$ avr-gcc -mmcu=atmega88 blinky.c

In file included from blinky.c:28:
/usr/local/lib/gcc/avr/4.2.2/../../../../avr/include/util/delay.h:90:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"
/tmp//ccB66ecl.o: In function `main':
blinky.c:(.text+0x3e): undefined reference to `usb_init'
/tmp//ccB66ecl.o: In function `morse_character':
blinky.c:(.text+0x24c): undefined reference to `print_P'
blinky.c:(.text+0x36e): undefined reference to `print_P'
blinky.c:(.text+0x378): undefined reference to `usb_debug_putchar'
blinky.c:(.text+0x37e): undefined reference to `print_P'
blinky.c:(.text+0x386): undefined reference to `print_P'
blinky.c:(.text+0x390): undefined reference to `usb_debug_putchar'
blinky.c:(.text+0x394): undefined reference to `usb_debug_putchar'
blinky.c:(.text+0x416): undefined reference to `print_P'
blinky.c:(.text+0x4fa): undefined reference to `print_P'
blinky.c:(.text+0x6f8): undefined reference to `print_P'
/tmp//ccB66ecl.o: In function `morse_P':
blinky.c:(.text+0x834): undefined reference to `print_P'
A: 

Those are link errors. You could do a compile only (notice that I added the -c flag):

avr-gcc -c -mmcu=atmega88 blinky.c

You would then have to link that with your other objects to create a binary.

Alternately, you could provide all the source files in a single command line and the compiler will compile and link them:

avr-gcc -mmcu=atmega88 blinky.c print.c usb_debug_only.c
R Samuel Klatchko
What do you mean by "You would then have to link that with your other objects to create a binary."? AFAIU the program must be in HEX to upload it to the Atmel chip.
@user355926 - you are correct the program must be in `ihex` format before being uploaded. But you still need to link the program before you can create the `ihex` file.
R Samuel Klatchko
@R: How do you link it? I was unable to find anything about `ihex` in `$ man hexdump`. How do you get the hex-file?