hlnd / nrf51-pure-gcc-setup

A simple and cross-platform GCC setup for nRF51-series development for Windows, OS X and Linux
BSD 3-Clause "New" or "Revised" License
131 stars 36 forks source link

error: #error "Board is not defined" #1

Closed brianfoshee closed 10 years ago

brianfoshee commented 10 years ago

First - thanks for maintaing this repo, it has been incredibly helpful in getting me up and running with gcc tools on OS X. I'm new to bare ARM development and nordic devices so I apologize if I'm asking elementary questions.

I have an nrf51822 evaluation kit, using S110 softdevice version 6.0.0, SDK version 5_1_0_36092, ARM toolchain from here. The following shell variables are defined:

export SDK_PATH=$HOME/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/
export TEMPLATE_PATH=$HOME/Development/nordic/nrf51-pure-gcc-setup/template/
export USE_SOFTDEVICE=s110

I have a couple of questions that I'm hoping you can point me in the right direction to solve, I'm trying to compile the test project blinky_example in the SDK:

➜ make main
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-objdump: '_build/.elf': No such file
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-objdump: section '.text' mentioned in a -j option, but not found in any input file
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-gcc -DBLE_STACK_SUPPORT_REQD -std=gnu99 -c -mthumb -mcpu=cortex-m0 -march=armv6-m -Wall -D -D -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/gcc -I../ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/ble/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/ble/ble_services/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/s110 -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/app_common/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/sd_common/ -MD  -mthumb -mcpu=cortex-m0 -march=armv6-m -L /Users/brian/Development/nordic/nrf51-pure-gcc-setup/template/ -T gcc_nrf51_s110.ld -Wl,-Map=_build/.Map  ../main.c   -o main
<command-line>:0:1: error: macro names must be identifiers
make: *** [main] Error 1

I noticed that the two -D compiler flags aren't showing anything. Are BOARD and DEVICE supposed to be environment variables in my shell? And do I need anything else in the pure-gcc folder besides the Makefile?

eliotstock commented 10 years ago

I'm not a contributor of this project, merely a user, so I hope Ole and friends won't mind me responding.

Yes, just use nrf6310 if that's the motherboard your nRF51822 is sitting on.

Don't run 'make main', just 'make' will do.

brianfoshee commented 10 years ago

@eliotstock thanks, that gets me further than I was.

I'm still seeing error: macro names must be identifiers but I believe that is from the blank -D -D flags in the command. In the Makefile those get filled in with BOARD and DEVICE. What should those be set to? My best guess is DEVICE=nRF51822 and BOARD=nrf6310.

➜ [pure-gcc] make
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-objdump: '_build/.elf': No such file
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-objdump: section '.text' mentioned in a -j option, but not found in any input file
mkdir -p _build/
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m0 -march=armv6-m -L /Users/brian/Development/nordic/nrf51-pure-gcc-setup/template/ -T gcc_nrf51_s110.ld -Wl,-Map=_build/.Map -DBLE_STACK_SUPPORT_REQD -std=gnu99 -c -mthumb -mcpu=cortex-m0 -march=armv6-m -Wall -D -D -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/gcc -I../ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/ble/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/ble/ble_services/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/s110 -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/app_common/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/sd_common/ -MD /Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Source/templates/system_nrf51.c -o _build/system_nrf51.o
<command-line>:0:1: error: macro names must be identifiers
make: *** [_build/system_nrf51.o] Error 1

When I set BOARD and DEVICE to the values I mentioned above, I see this:

➜ [pure-gcc] make
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-objdump: '_build/.elf': No such file
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-objdump: section '.text' mentioned in a -j option, but not found in any input file
mkdir -p _build/
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m0 -march=armv6-m -L /Users/brian/Development/nordic/nrf51-pure-gcc-setup/template/ -T gcc_nrf51_s110.ld -Wl,-Map=_build/.Map -DBLE_STACK_SUPPORT_REQD -std=gnu99 -c -mthumb -mcpu=cortex-m0 -march=armv6-m -Wall -Dnrf51822 -Dnrf6310 -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/gcc -I../ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/ble/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/ble/ble_services/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/s110 -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/app_common/ -I/Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Include/sd_common/ -MD /Users/brian/Development/nordic/nrf51_sdk_v5_1_0_36092/nrf51822/Source/templates/system_nrf51.c -o _build/system_nrf51.o
mkdir -p _build/
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-as /Users/brian/Development/nordic/nrf51-pure-gcc-setup/template/startup_nrf51.s -o _build/startup_nrf51.os
/Users/brian/Development/gcc-arm-none-eabi/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m0 -march=armv6-m -L /Users/brian/Development/nordic/nrf51-pure-gcc-setup/template/ -T gcc_nrf51_s110.ld -Wl,-Map=_build/.Map _build/startup_nrf51.os _build/system_nrf51.o  -o _build/.elf
/Users/brian/Development/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/armv6-m/crt0.o: In function `_start':
(.text+0x4e): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [_build/.hex] Error 1

Is that related to what I have those variables set to or is it something else?

brianfoshee commented 10 years ago

I got this figured out. I copied over the example Makefile from this repo's examples folder.

I'm going to close this - if I have any more trouble I'll open another issue.