Hallo Ich bin seit einiger Zeit von Windows auf Linux (Ubuntu, derzeit 12.04) umgestiegen. Ich möchte jetzt auch meine Controller unter Linux programmieren. Aber irgendwie bekomme ich das mit den Headerfiles nicht hin. Mein Makefile und den Kommandozeilen Output den ich bei make bekomme habe ich angehängt. So wie ich das sehe, findet er die avr/io.h nicht. Bzw. es wird die falsche genommen. Diese existiert aber auf meinem System unter /usr/lib/avr/include. Ich habe diesen Pfad auch schon an die PATH Variable angehängt und als INC im Makefile an den Compiler übergeben. Habt ihr mir einen Tipp? Gruß Bean
Ach ja, was ich noch vergessen hab: Es wird ja angezeigt, dass der Controller Typ nicht definiert ist. Ich habe in meine main.h folgendes eingefügt: #define _AVR_ATmega8U2_ Auch das hat keine Verbesserung gebracht. _AVR_ATmega8U2_ habe ich aus der io.h herauskopiert. Gruß Bean
Beim Aufruf des avr-gcc muss ein Controller-Typ angegeben werden, z.B. avr-gcc -mmcu=atmega8 ...
Vermutlich hast Du im Makefile versäumt, anzugeben, dass er mit avr-gcc anstatt mit gcc compilieren soll. Das folgende Makefile nutze ich gerne als Kopiervorlage, weil es sich bisher unter Windows und Linux bewährt hat. # make code Compiles the source code into hex files. # make fuses Program fuses # make program Program flash (and eeprom, if enabled) # make list Create generated code listing # make clean Delete all generated files # Name of the program without extension PRG = ledBlinker # Programmer hardware settings for avrdude # Linux: /dev/ttyUSB0 is the first virtual serial port # Windows: //./COM20 is the virtual port COM20 AVRDUDE_HW = -c avr910 -P /dev/ttyUSB0 -b 115200 # Please note that the xmega-D microcontrollers are not supported by avrdude. # The setting above does not matter when you use a graphical application to # transfer the firmware into the microcontroller. # Clock frequency in Hz F_CPU = 14745600 # Bitrates above 115200 require a 14,745600 Mhz chrystal. SERIAL_BITRATE = 115200 # Source files, separated by space. SRC = main.c some_directory/whatever.c # Micorocontroller tmodel MCU = atmega8 # Fuse settings LFUSE = 0xF7 HFUSE = 0x9 # Larger AVR's have additional fuses: # EFUSE = 0xD9 # FUSE0 = 0xFF # FUSE1 = 0x00 # FUSE2 = 0xFF # FUSE4 = 0xFF # FUSE5 = 0xFF ################################################################### # You possibly do not need to change settings below this marker ################################################################### # Binaries to be used # You may add the path to them if they are not in the PATH variable. CC = avr-gcc OBJCOPY = avr-objcopy OBJDUMP = avr-objdump AVRDUDE = avrdude # Do we need to write Eeprom? (yes/no) EEPROM = no # Libraries #LIBS = -L path/to/libraries -llibrary1 -llibrary2 # Includes #INCLUDES = -Ipath/to/include/files # Compiler options for all c source files CFLAGS = -std=c99 -Wall -Os -mmcu=$(MCU) -DF_CPU=$(F_CPU) $(INCLUDES) -D$(LAYOUT) # Linker options LDFLAGS = -Wl,-Map,$(PRG).map # Enable floating-point support in printf #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm # Collect fuse operations for avrdude ifdef FUSE FUSES += -U fuse:w:$(FUSE):m endif ifdef LFUSE FUSES += -U lfuse:w:$(LFUSE):m endif ifdef HFUSE FUSES += -U hfuse:w:$(HFUSE):m endif ifdef EFUSE FUSES += -U efuse:w:$(EFUSE):m endif ifdef FUSE0 FUSES += -U fuse0:w:$(FUSE0):m endif ifdef FUSE1 FUSES += -U fuse1:w:$(FUSE1):m endif ifdef FUSE2 FUSES += -U fuse2:w:$(FUSE2):m endif ifdef FUSE3 FUSES += -U fuse3:w:$(FUSE3):m endif ifdef FUSE4 FUSES += -U fuse4:w:$(FUSE4):m endif ifdef FUSE5 FUSES += -U fuse5:w:$(FUSE5):m endif ifdef FUSE6 FUSES += -U fuse6:w:$(FUSE6):m endif ifdef FUSE7 FUSES += -U fuse7:w:$(FUSE7):m endif # Default sections ifeq ($(EEPROM),yes) all: code eeprom else all: code endif # Program code code: $(PRG).hex # Alias for AVR Studio USB-IO-Modul: $(PRG).hex # Eeprom content eeprom: $(PRG)_eeprom.hex # Generated code listing list: $(PRG).lst # Remove all generated files clean: rm -rf *.o $(PRG).hex $(PRG).elf $(PRG).lst $(PRG).map $(PRG)_eeprom.hex # Program flash memory with or without eeprom ifeq ($(EEPROM),yes) program: code eeprom $(AVRDUDE) -p $(MCU) $(AVRDUDE_HW) -U flash:w:$(PRG).hex:i -U eeprom:w:$(PRG)_eeprom.hex:i else program: code $(AVRDUDE) -p $(MCU) $(AVRDUDE_HW) -U flash:w:$(PRG).hex:i endif # Program fuses fuses: $(AVRDUDE) -p $(MCU) $(AVRDUDE_HW) $(FUSES) $(PRG).elf: $(SRC:.c=.o) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) %.lst: %.elf $(OBJDUMP) -h -S $< > $@ %.hex: %.elf $(OBJCOPY) -j .text -j .data -O ihex $< $@ %_eeprom.hex: %.elf $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
Mr Bean schrieb: > Ich habe diesen Pfad auch schon an die PATH Variable angehängt und als > INC im Makefile an den Compiler übergeben. Unnötig, der Compiler kennt den Ort seiner Include-Dateien. Die PATH-Umgebungsvariable listet nur Verzeichnisse, in denen nach ausführbaren Dateien gesucht wird. Dein Makefile übergibt die INC-Variable nicht an den Compiler. Wie der Compiler letztendlich aufgerufen wurde, siehst du in deiner output.txt.
Stefan Frings schrieb: > Vermutlich hast Du im Makefile versäumt, anzugeben, dass er mit avr-gcc > anstatt mit gcc compilieren soll. Nein, das ist schon OK.
># Compile: create object files from C source files. >%.o : %.c > @echo > @echo $(MSG_COMPILING) $< > $(CC) -c $(ALL_CFLAGS) $< -o $@ > wird zu >avr-gcc -c main.c -o main.o Da fehlen sämtliche Compilerflags im Aufruf, da die Defnition von ALL_CFLAGS im makefile (und auch aller anderen make-Variablen) fehlt. Das makefile ist kaputt und unvollständig, da fehlt einiges, warum auch immer. Erzeuge dir mal mit MFile eine neues makefile, dann sollte das funktionieren. Oliver
Ah ja, ok habe grad gesehen dass bei CC ALL_FLAGS übergeben wird. Die fehlen natürlich noch. Hab das Makefile ja auch aus der Vorlage hier aus dem Forum zusammen kopiert. Wollte halt ein paar Sachen weg lassen, weil es mir etwas oversized erschien. Ich kenne das noch nicht, dass man die ganzen Flags über eine weitere Variable (ALL_FLAGS) zusammen fasst. Kenne das nur mit CFLAGS etc. Vielen Dank schonmal für die Hilfe. Kann die Änderungen leider erst heute Abend ausprobieren. Gruß Bean
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.