I guess this is a continuation of this question. I've compiled my intermediate bootloader library and have verified it working, now it's time to write some application code against it.
I'm able to generate a symbol list from the bootloader's generated .hex
file using $(OBJCOPY) --wildcard --strip-symbol=main --strip-symbol="_*" $(TARGET).elf $(TARGET).syms
, this gives me bootloader.syms
.
I've written a test application that uses a few of the functions in the library section of memory, and I compile it as follows:
I pass GCC the location of all the header files used in the bootloader/library as well as the symbol file generated above. I've tested that GCC picks up the header files as intended.
Makefile invocation:
Making: obj/main.o
avr-gcc -Os -std=gnu99 -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -static -DF_CPU=8000000UL -DBAUD= -iquote../firmware/src/ -I. -I../firmware/src/ -MP -MD -mmcu=atmega16 -c -o obj/main.o src/main.c;
avr-gcc -Wl,-Map,app.map -Wl,--just-symbols=../firmware/bootloader.syms -T ld_script_app.x -mmcu=atmega16 obj/main.o -o app.elf
obj/main.o: In function `main':
main.c:(.text.startup.main+0x14): undefined reference to `lcd_init'
main.c:(.text.startup.main+0x8e): undefined reference to `lcd_fill'
main.c:(.text.startup.main+0x142): undefined reference to `gfx_draw_line'
collect2: error: ld returned 1 exit status
make: *** [app.elf] Error 1
I'm not sure what's causing the undefined references though. I was under the impression that they would be referenced through the symbols file.