interoberlin / nRF51-playground

Playground for our nRF51822 Bluetooth Low Energy experiments
https://www.interoberlin.de/blog/category/projects/ble/
9 stars 2 forks source link

arm-none-eabi-ld: cannot find nrf51_startup.o #13

Closed matthiasbock closed 8 years ago

matthiasbock commented 8 years ago

Affected code revision: Uncommitted attempt to sort the source files into subfolders

Problem description: Apparently the linker is having trouble to assemble .o-files from project subfolders.

Context: All .c and .h files except for the demo_* main routines have been sorted into subfolders arm/, nordic/ and sdk/. In the Makefile these folders have been added to the GCC include path:

CFLAGS += -I arm/
CFLAGS += -I nordic/
CFLAGS += -I sdk/

Also all references to the .o files have been extended with the corresponding subfolder name as prefix, e.g.

demo_uart.elf: sdk/nrf51_startup.o nordic/system_nrf51.o sdk/strings.o sdk/fifo.o sdk/uart.o sdk/delay.o demo_uart.o 
    $(LD) $(LDFLAGS) $^ -o $@

Relevant command and error message:

$ make clean all
rm -f *.o */*.o *.out *.bin *.elf *.hex *.map
/usr/bin/arm-none-eabi-gcc -std=gnu99 -Wall -g -mcpu=cortex-m0 -mthumb -mabi=aapcs -mfloat-abi=soft -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -I arm/ -I nordic/ -I sdk/   -c -o sdk/nrf51_startup.o sdk/nrf51_startup.c
sdk/nrf51_startup.c: In function 'Default_Handler':
sdk/nrf51_startup.c:185:14: warning: unused variable 'interrupt_pending' [-Wunused-variable]
     uint32_t interrupt_pending = INTPENDING;
              ^
sdk/nrf51_startup.c:184:14: warning: unused variable 'interrupt_active' [-Wunused-variable]
     uint32_t interrupt_active = INTACTIVE;
              ^
sdk/nrf51_startup.c:183:14: warning: unused variable 'icsr' [-Wunused-variable]
     uint32_t icsr = ICSR;
              ^
/usr/bin/arm-none-eabi-gcc -std=gnu99 -Wall -g -mcpu=cortex-m0 -mthumb -mabi=aapcs -mfloat-abi=soft -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -I arm/ -I nordic/ -I sdk/   -c -o nordic/system_nrf51.o nordic/system_nrf51.c
/usr/bin/arm-none-eabi-gcc -std=gnu99 -Wall -g -mcpu=cortex-m0 -mthumb -mabi=aapcs -mfloat-abi=soft -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -I arm/ -I nordic/ -I sdk/   -c -o sdk/strings.o sdk/strings.c
/usr/bin/arm-none-eabi-gcc -std=gnu99 -Wall -g -mcpu=cortex-m0 -mthumb -mabi=aapcs -mfloat-abi=soft -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -I arm/ -I nordic/ -I sdk/   -c -o sdk/fifo.o sdk/fifo.c
/usr/bin/arm-none-eabi-gcc -std=gnu99 -Wall -g -mcpu=cortex-m0 -mthumb -mabi=aapcs -mfloat-abi=soft -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -I arm/ -I nordic/ -I sdk/   -c -o sdk/uart.o sdk/uart.c
/usr/bin/arm-none-eabi-gcc -std=gnu99 -Wall -g -mcpu=cortex-m0 -mthumb -mabi=aapcs -mfloat-abi=soft -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -I arm/ -I nordic/ -I sdk/   -c -o sdk/delay.o sdk/delay.c
/usr/bin/arm-none-eabi-gcc -std=gnu99 -Wall -g -mcpu=cortex-m0 -mthumb -mabi=aapcs -mfloat-abi=soft -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -I arm/ -I nordic/ -I sdk/   -c -o demo_uart.o demo_uart.c
/usr/bin/arm-none-eabi-ld -T linker/nrf51-blank-xxac.ld -nostartfiles -nostdlib -lgcc -static -L /usr/lib/gcc/arm-none-eabi/4.8/armv6-m/ -L /usr/lib/arm-none-eabi/newlib/armv6-m/ sdk/nrf51_startup.o nordic/system_nrf51.o sdk/strings.o sdk/fifo.o sdk/uart.o sdk/delay.o demo_uart.o -o demo_uart.elf
/usr/bin/arm-none-eabi-ld: cannot find nrf51_startup.o
Makefile:52: recipe for target 'demo_uart.elf' failed
make: *** [demo_uart.elf] Error 1
matthiasbock commented 8 years ago

Not only in the Makefile, but also in the linker script, the path had to be changed:

SECTIONS
{
    .text :
    {
        code_begin = .;
        sdk/nrf51_startup.o(.vectors)
        *(.text*)
        code_end = .;
    } > FLASH
...