virtualabs / btlejack-firmware

Btlejack firmware for BBC Micro:Bit
MIT License
46 stars 28 forks source link

Compilation error "region RAM overflowed with stack" #3

Open conchyliculture opened 5 years ago

conchyliculture commented 5 years ago

This is on a debian testing machine (but with gcc-arm-none-eabi (15:7-2018-q2-3) ):

$ virtualenv  -p /usr/bin/python3  btle
$ cd btle/
$ source bin/activate
$ pip install yotta
$ git clone https://github.com/virtualabs/btlejack-firmware
$ cd btlejack-firmware
$ make microbit
$ yt build
info: generate for target: bbc-microbit-classic-gcc 0.2.3 at /tmp/btle/btlejack-firmware/yotta_targets/bbc-microbit-classic-gcc
GCC version is: 7.3.1
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: /tmp/btle/btlejack-firmware/build/bbc-microbit-classic-gcc
[4/4] Linking CXX executable source/ubit-ble-sniffer
FAILED: source/ubit-ble-sniffer
: && /usr/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"/tmp/btle/btlejack-firmware/yotta_targets/bbc-microbit-classic-gcc/CMake/../ld/NRF51822.ld" -Wl,-Map,source/ubit-ble-sniffer.map -Wl,--start-group source/CMakeFiles/ubit-ble-sniffer.dir/tmp/btle/btlejack-firmware/source/helpers.cpp.o source/CMakeFiles/ubit-ble-sniffer.dir/tmp/btle/btlejack-firmware/source/radio.cpp.o source/CMakeFiles/ubit-ble-sniffer.dir/tmp/btle/btlejack-firmware/source/link.cpp.o source/CMakeFiles/ubit-ble-sniffer.dir/tmp/btle/btlejack-firmware/source/sequence.cpp.o source/CMakeFiles/ubit-ble-sniffer.dir/tmp/btle/btlejack-firmware/source/timer.cpp.o source/CMakeFiles/ubit-ble-sniffer.dir/tmp/btle/btlejack-firmware/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/ubit-ble-sniffer && cd /tmp/btle/btlejack-firmware/build/bbc-microbit-classic-gcc/source && arm-none-eabi-objcopy -O ihex ubit-ble-sniffer ubit-ble-sniffer.hex && srec_cat /tmp/btle/btlejack-firmware/yotta_targets/bbc-microbit-classic-gcc/CMake/../bootloader/BLE_BOOTLOADER_RESERVED.hex -intel /tmp/btle/btlejack-firmware/yotta_targets/bbc-microbit-classic-gcc/CMake/../softdevice/s110_nrf51822_8.0.0_softdevice.hex -intel ubit-ble-sniffer.hex -intel -o ubit-ble-sniffer-combined.hex -intel --line-length=44 && cd /tmp/btle/btlejack-firmware/build/bbc-microbit-classic-gcc/source && /usr/bin/arm-none-eabi-objcopy -O binary ubit-ble-sniffer ubit-ble-sniffer.bin
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: region RAM overflowed with stack
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
error: command ['ninja'] failed
make: *** [Makefile:11: microbit] Error 1
virtualabs commented 5 years ago

What is the version of newlib that you are using ? I had some issues with another project with recent versions of this library.

conchyliculture commented 5 years ago
$ dpkg -l | grep newlib
ii  libnewlib-arm-none-eabi                   3.0.0.20180802-2                        all          C library and math library compiled for bare metal using Cortex A/R/M
ii  libnewlib-dev                             3.0.0.20180802-2                        all          C library and math library intended for use on embedded systems
ii  libstdc++-arm-none-eabi-newlib            15:7-2018-q2-3+11                       all          GNU Standard C++ Library v3 for ARM Cortex-R/M processors (newlib)

Is there a recommended building distro/environment?

virtualabs commented 5 years ago

I am currently compiling this firmware on a out of the box Debian Stretch. New versions of newlib are known to cause this error, see https://github.com/bbcmicrobit/micropython/issues/363.

I will have a look at it again in this context (not micropython-related) and see if I can issue a fix.

bogiton commented 5 years ago

Had the same issue when trying to compile under Kali (newlib 3.0). I turned to latest Debian Stretch, which still uses newlib 2.4, and it worked perfectly.