logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

AVR Studio łączenie C i asm

mack23 05 Mar 2009 18:22 4418 8
REKLAMA
  • #1 6240428
    mack23
    Poziom 17  
    Witam!
    Problem jak w temacie. Próbuje odpalić przykład ze
    strony i dostaje komunikaty w bulid typu:
    Cytat:
    C:/WinAVR/avr/include/stdint.h:116: Error: unknown opcode `typedef'


    i w message:
    Cytat:
    gcc plug-in: Error: Object file not found on expected location E:\dyplom\moje_programy\gpsLocalize\default\gpsLocalize.elf


    Ktoś wie jak to ugryźć?
  • REKLAMA
  • #2 6240628
    Freddie Chopin
    Specjalista - Mikrokontrolery
    tego typu kod assemblerowy trzeba kompilowac w szczegolny sposob - pokaz jakiego makefile'a ci AVR Studio generuje.

    istotne jest, aby assemblerem nie bylo avr-as tylko avr-gcc z konkretnymi opcjami.

    4\/3!!
  • #3 6240685
    mack23
    Poziom 17  
    Cytat:
    ###############################################################################
    # Makefile for the project gpsLocalize
    ###############################################################################

    ## General Flags
    PROJECT = gpsLocalize
    MCU = atmega8
    TARGET = gpsLocalize.elf
    CC = avr-gcc.exe

    ## Options common to compile, link and assembly rules
    COMMON = -mmcu=$(MCU)

    ## Compile options common for all C compilation units.
    CFLAGS = $(COMMON)
    CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
    CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d

    ## Assembly specific flags
    ASMFLAGS = $(COMMON)
    ASMFLAGS += $(CFLAGS)
    ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2

    ## Linker flags
    LDFLAGS = $(COMMON)
    LDFLAGS += -Wl,-Map=gpsLocalize.map


    ## Intel Hex file production flags
    HEX_FLASH_FLAGS = -R .eeprom

    HEX_EEPROM_FLAGS = -j .eeprom
    HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
    HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings


    ## Include Directories
    INCLUDES = -I"C:\Program Files\Atmel\AVR Tools\AvrAssembler\Appnotes"

    ## Objects that must be built in order to link
    OBJECTS = main.o uartSw.o

    ## Objects explicitly added by the user
    LINKONLYOBJECTS =

    ## Build
    all: $(TARGET) gpsLocalize.hex gpsLocalize.eep gpsLocalize.lss size

    ## Compile
    main.o: ../main.c
    $(CC) $(INCLUDES) $(CFLAGS) -c $<

    uartSw.o: ../uartSw.c
    $(CC) $(INCLUDES) $(CFLAGS) -c $<

    ##Link
    $(TARGET): $(OBJECTS)
    $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)

    %.hex: $(TARGET)
    avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@

    %.eep: $(TARGET)
    -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0

    %.lss: $(TARGET)
    avr-objdump -h -S $< > $@

    size: ${TARGET}
    @Echo.
    @AVR-size -C --mcu=${MCU} ${TARGET}

    ## Clean target
    .PHONY: clean
    clean:
    -rm -rf $(OBJECTS) gpsLocalize.elf dep/* gpsLocalize.hex gpsLocalize.eep gpsLocalize.lss gpsLocalize.map


    ## Other dependencies
    -include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
  • REKLAMA
  • #4 6241187
    Freddie Chopin
    Specjalista - Mikrokontrolery
    w skrypcie nigdzie nie ma dyrektyw ktore skompiluja twoj plik assemblerowy (albo ja jestem slepy), wiec ogolnie ten makefile jest zly.

    dodales plik assemblera do projektu? moze powinienes mu zmienic rozszerzenie na duza litere S (jesli jest male)?

    4\/3!!
  • REKLAMA
  • #5 6242444
    mack23
    Poziom 17  
    sory za pomyłkę, wkleiłem makefile po kilku kombinacjach, ten jest prawidłowy
    Cytat:
    ###############################################################################
    # Makefile for the project softUart
    ###############################################################################

    ## General Flags
    PROJECT = softUart
    MCU = atmega8
    TARGET = softUart.elf
    CC = avr-gcc.exe

    ## Options common to compile, link and assembly rules
    COMMON = -mmcu=$(MCU)

    ## Compile options common for all C compilation units.
    CFLAGS = $(COMMON)
    CFLAGS += -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
    CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d

    ## Assembly specific flags
    ASMFLAGS = $(COMMON)
    ASMFLAGS += $(CFLAGS)
    ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2

    ## Linker flags
    LDFLAGS = $(COMMON)
    LDFLAGS += -Wl,-Map=softUart.map


    ## Intel Hex file production flags
    HEX_FLASH_FLAGS = -R .eeprom

    HEX_EEPROM_FLAGS = -j .eeprom
    HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
    HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings


    ## Objects that must be built in order to link
    OBJECTS = softUart.o extraasm.o

    ## Objects explicitly added by the user
    LINKONLYOBJECTS =

    ## Build
    all: $(TARGET) softUart.hex softUart.eep softUart.lss size

    ## Compile
    extraasm.o: ../extraasm.S
    $(CC) $(INCLUDES) $(ASMFLAGS) -c $<

    softUart.o: ../softUart.c
    $(CC) $(INCLUDES) $(CFLAGS) -c $<

    ##Link
    $(TARGET): $(OBJECTS)
    $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)

    %.hex: $(TARGET)
    avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@

    %.eep: $(TARGET)
    -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0

    %.lss: $(TARGET)
    avr-objdump -h -S $< > $@

    size: ${TARGET}
    @Echo.
    @AVR-size -C --mcu=${MCU} ${TARGET}

    ## Clean target
    .PHONY: clean
    clean:
    -rm -rf $(OBJECTS) softUart.elf dep/* softUart.hex softUart.eep softUart.lss softUart.map


    ## Other dependencies
    -include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)

  • REKLAMA
  • #6 6242645
    Freddie Chopin
    Specjalista - Mikrokontrolery
    ten makefile jest jakis dziwny, niemniej jednak w wiekszosci powinien byc poprawny.

    pokaz jeszcze przebieg calej kompilacji (w sensie jak wszystkie narzedzia zostaja wywolane i jaki daja efekt).

    ciekawa sprawa jest taka, ze twoj blad dotyczacy typedef wskazuje raczej na plik C, w ktorym dolaczasz plik stdint.h. poogladaj ten plik naglowkowy, moze cos masz w nim przypadkiem zwalone? jesli skompilowalbys calosc bez tego pliku assemblerowego, to przejdzie poprawnie?

    4\/3!!
  • #7 6243148
    mack23
    Poziom 17  
    no więc jak tylko wyrzuce plik S to kompiluje się poprawnie. W pliku nagłowkowym wszystko jest ok, na pewno nie było nic zmieniane.
    Załączam jeszcze obydwa pliki źródłowe, może coś nie tak z moim avr studio? (dodałem rozszerzenie txt ponieważ S jest niedopuszczalne)

    to jest log z okna build:
    Cytat:
    rm -rf softUart.o extraasm.o softUart.elf dep/* softUart.hex softUart.eep softUart.lss softUart.map
    Build succeeded with 0 Warnings...
    avr-gcc.exe -mmcu=atmega8 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT softUart.o -MF dep/softUart.o.d -c ../softUart.c
    avr-gcc.exe -mmcu=atmega8 -mmcu=atmega8 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT extraasm.o -MF dep/extraasm.o.d -x assembler-with-cpp -Wa,-gdwarf2 -c ../extraasm.S
    ../extraasm.S:1:24: warning: extra tokens at end of #include directive
    C:/WinAVR/avr/include/stdint.h: Assembler messages:
    C:/WinAVR/avr/include/stdint.h:116: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:117: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:118: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:119: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:120: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:121: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:122: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:123: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:135: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:140: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:152: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:157: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:162: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:167: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:172: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:177: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:182: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:187: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:200: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:205: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:210: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:215: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:220: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:225: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:230: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:235: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:249: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/stdint.h:254: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/inttypes.h:76: Error: unknown opcode `typedef'
    C:/WinAVR/avr/include/inttypes.h:80: Error: unknown opcode `typedef'
    ../extraasm.S:13: Error: bad expression
    ../extraasm.S:13: Error: missing ')'
    ../extraasm.S:13: Error: missing ')'
    ../extraasm.S:13: Error: missing ')'
    ../extraasm.S:13: Error: missing ')'
    ../extraasm.S:13: Error: constant value required
    ../extraasm.S:13: Error: `,' required
    ../extraasm.S:13: Error: constant value required
    ../extraasm.S:13: Error: garbage at end of line
    ../extraasm.S:27: Error: bad expression
    ../extraasm.S:27: Error: missing ')'
    ../extraasm.S:27: Error: missing ')'
    ../extraasm.S:27: Error: missing ')'
    ../extraasm.S:27: Error: missing ')'
    ../extraasm.S:27: Error: constant value required
    ../extraasm.S:27: Error: `,' required
    ../extraasm.S:27: Error: constant value required
    ../extraasm.S:27: Error: garbage at end of line
    make: *** [extraasm.o] Error 1
    Build succeeded with 1 Warnings...
  • Pomocny post
    #8 6243213
    szelus
    Poziom 34  
    Moim zdaniem wygląda to tak, jakby brakowało define-a, który przełączyłby (na zasadzie ifdef-ów) pliki nagłówkowe na włączanie tylko definicji stałych zrozumiałych dla asemblera. Może to kwestia wersji AVRStudio?

    Spróbuj dodać do ASMFLAGS opcję: -D__ASSEMBLER__ (po dwa podkreślniki).
  • #9 6243249
    mack23
    Poziom 17  
    wielkie dzięki za pomoc, dodanie wspomnianej flagi rozwiązało problem
REKLAMA