lancaster-university / microbit-targets

4 stars 5 forks source link

`bbc-microbit-classic-gcc-s130` build fails #4

Closed taktran closed 3 years ago

taktran commented 7 years ago

I'm trying to build the microbit-samples project with the bbc-microbit-classic-gcc-s130 target ie,

yt -t bbc-microbit-classic-gcc-s130 build

But, I get an error (see below). It seems like it is trying to link to yotta_targets/bbc-microbit-classic-gcc-s130/ld/NRF51822.ld, but the s130 target generates yotta_targets/bbc-microbit-classic-gcc-s130/ld/NRF51822_S130.ld (ie, it has an extra _S130 suffix).

I'm not sure how all this linking works, but I did hack around and change

yotta_targets/bbc-microbit/class-gcc-s130/CMake/toolchain.cmake (line 22) from

set(CMAKE_EXE_LINKER_FLAGS_INIT    "${CMAKE_EXE_LINKER_FLAGS_INIT} -mcpu=cortex-m0 -mthumb -T\"${CMAKE_CURRENT_LIST_DIR}/../ld/NRF51822.ld\"")

to

set(CMAKE_EXE_LINKER_FLAGS_INIT    "${CMAKE_EXE_LINKER_FLAGS_INIT} -mcpu=cortex-m0 -mthumb -T\"${CMAKE_CURRENT_LIST_DIR}/../ld/NRF51822_S130.ld\"")

which fixed the build.

However, copying build/bbc-microbit-classic-gcc-s130/source/microbit-samples-combined.hex to the micro:bit didn't seem to do anything (blank screen after upload). I did try the normal build (yt build) and copied build/bbc-microbit-classic-gcc/source/microbit-samples-combined.hex to the micro:bit, and it works as expected, showing the "HELLO WORLD!" text.

Any ideas? It is an issue with the toolchain.cmake file, or the default sample project? Or something I'm missing?

Thanks!


Build error

GCC version is: 5.4.1
-- The ASM compiler identification is GNU
-- Found assembler: /Users/ttt/Work/Dev/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gcc
suppressing warnings from ble-nrf51822
suppressing warnings from nrf51-sdk
suppressing ALL warnings from mbed-classic, ble, ble-nrf51822 & nrf51-sdk
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ttt/Work/Dev/SAM/microbit-samples/build/bbc-microbit-classic-gcc-s130
[164/164] Linking CXX executable source/microbit-samples
FAILED: source/microbit-samples
: && /Users/ttt/Work/Dev/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-g++  -fno-exceptions -fno-unwind-tables -Wl,--gc-sections -Wl,--sort-common -Wl,--sort-section=alignment -Wl,-wrap,main -mcpu=cortex-m0 -mthumb -T"/Users/ttt/Work/Dev/SAM/microbit-samples/yotta_targets/bbc-microbit-classic-gcc-s130/CMake/../ld/NRF51822.ld" -Wl,-Map,source/microbit-samples.map -Wl,--start-group source/CMakeFiles/microbit-samples.dir/Users/ttt/Work/Dev/SAM/microbit-samples/source/main.cpp.o  ym/microbit/source/microbit.a ym/microbit-dal/source/microbit-dal.a ym/ble/source/ble.a ym/ble-nrf51822/source/ble-nrf51822.a ym/ble/source/ble.a ym/ble-nrf51822/source/ble-nrf51822.a ym/nrf51-sdk/source/nrf51-sdk.a ym/mbed-classic/existing/mbed-classic.a -lnosys  -lstdc++ -lsupc++ -lm -lc -lgcc -lstdc++ -lsupc++ -lm -lc -lgcc -Wl,--end-group  --specs=nano.specs -o source/microbit-samples && cd /Users/ttt/Work/Dev/SAM/microbit-samples/build/bbc-microbit-classic-gcc-s130/source && arm-none-eabi-objcopy -O ihex microbit-samples microbit-samples.hex && srec_cat /Users/ttt/Work/Dev/SAM/microbit-samples/yotta_targets/bbc-microbit-classic-gcc-s130/CMake/../bootloader/BLE_BOOTLOADER_RESERVED.hex -intel /Users/ttt/Work/Dev/SAM/microbit-samples/yotta_targets/bbc-microbit-classic-gcc-s130/CMake/../softdevice/s130_nrf51_1.0.0_softdevice.hex -intel microbit-samples.hex -intel -o microbit-samples-combined.hex -intel --line-length=44 && cd /Users/ttt/Work/Dev/SAM/microbit-samples/build/bbc-microbit-classic-gcc-s130/source && /Users/ttt/Work/Dev/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-objcopy -O binary microbit-samples microbit-samples.bin
/Users/ttt/Work/Dev/gcc-arm-none-eabi-5_4-2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: cannot open linker script file /Users/ttt/Work/Dev/SAM/microbit-samples/yotta_targets/bbc-microbit-classic-gcc-s130/CMake/../ld/NRF51822.ld: No such file or directory
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
error: command ['ninja'] failed
fremiller commented 4 years ago

I've written a project using bbc-microbit-classic-s130 changing that line and it works fine. I'm not using the microbit runtime, instead I'm just using MicroBitDisplay.h to drive the display.

I would use the microbit components individually as the s130 softdevice takes up much more memory. Here is a link to my project if it would help.