This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NCS BLE examples overflowing nRF52805 SRAM

Hi,

I'm trying to build the bluetooth/peripheral_uart sample in NCS (version 1.5.0-rc1) and was surprised to see that it requires more than the 24K SRAM available on the nRF52805, and uses nearly all the FLASH.

Do you have any suggestions to reduce the FLASH and SRAM usage of this example?

See build results below.

jason@galvani:~/Work/ncs/nrf/samples/bluetooth/peripheral_uart$ west build -b nrf52dk_nrf52805 
-- west build: generating a build system
Including boilerplate (Zephyr base): /home/jason/Work/ncs/zephyr/cmake/app/boilerplate.cmake                                                                                                              
-- Application: /home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart
-- Zephyr version: 2.4.99 (/home/jason/Work/ncs/zephyr)
-- Found Python3: /usr/bin/python3.8 (found suitable exact version "3.8.6") found components: Interpreter  
-- Found west (found suitable version "0.9.0", minimum required is "0.7.1")
-- Board: nrf52dk_nrf52805
-- Cache files will be written to: /home/jason/.cache/zephyr
ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found toolchain: zephyr (/home/jason/zephyr-sdk)
-- Found dtc: /home/jason/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/jason/Work/ncs/zephyr/boards/arm/nrf52dk_nrf52805/nrf52dk_nrf52805.dts
-- Generated zephyr.dts: /home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/build/zephyr/include/generated/device_extern.h
Parsing /home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/Kconfig
Loaded configuration '/home/jason/Work/ncs/zephyr/boards/arm/nrf52dk_nrf52805/nrf52dk_nrf52805_defconfig'
Merged configuration '/home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/prj.conf'
Configuration saved to '/home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/build/zephyr/.config'
Kconfig header saved to '/home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/jason/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
CMake Warning at /home/jason/Work/ncs/zephyr/CMakeLists.txt:1357 (message):
 __ASSERT() statements are globally ENABLED


-- Configuring done
-- Generating done
-- Build files have been written to: /home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/build
-- west build: building application
[1/204] Preparing syscall dependency handling

[199/204] Linking C executable zephyr/zephyr_prebuilt.elf
FAILED: zephyr/zephyr_prebuilt.elf  
: && ccache /home/jason/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc    zephyr/CMakeFiles/zephyr_prebuilt.dir/misc/empty_file.c.obj  -o zephyr/zephyr_prebuilt.elf  -Wl,-T  zephyr/linker.cmd  -Wl,
-Map=/home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/build/zephyr/zephyr_prebuilt.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arc
h/arch/arm/core/aarch32/libarch__arm__core__aarch32.a  zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a  zephyr/arch/arch/arm/core/aarch32/cortex_m/mpu/libarch__arm__c
ore__aarch32__cortex_m__mpu.a  zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/lib/posix/liblib__posix.a  zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a  zephyr/soc/arm/nordic_n
rf/nrf52/libsoc__arm__nordic_nrf__nrf52.a  zephyr/subsys/bluetooth/common/libsubsys__bluetooth__common.a  zephyr/subsys/bluetooth/host/libsubsys__bluetooth__host.a  zephyr/subsys/net/libsubsys__net.a  
zephyr/subsys/random/libsubsys__random.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/flash/libdrivers__flash.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/entropy/libdrivers
__entropy.a  modules/nrf/lib/dk_buttons_and_leds/lib..__nrf__lib__dk_buttons_and_leds.a  modules/nrf/lib/multithreading_lock/lib..__nrf__lib__multithreading_lock.a  modules/nrf/lib/fatal_error/lib..__n
rf__lib__fatal_error.a  modules/nrf/subsys/bluetooth/controller/lib..__nrf__subsys__bluetooth__controller.a  modules/nrf/subsys/mpsl/lib..__nrf__subsys__mpsl.a  modules/nrf/drivers/mpsl/clock_control/l
ib..__nrf__drivers__mpsl__clock_control.a  modules/hal_nordic/libmodules__hal_nordic.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.
obj  -L"/home/jason/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/9.2.0/thumb/v7e-m/nofp"  -L/home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/build/zephyr  -lgcc  -Wl,--print-memo
ry-usage  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAb
sSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -no-pie  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn  /home/jason/Work/ncs/nrfxlib/mpsl/lib/cortex-m4/soft-float/libmpsl.a  /home/jason/Work/ncs/nrfxlib
/softdevice_controller/lib/cortex-m4/soft-float/libsoftdevice_controller_peripheral.a && :
Memory region         Used Size  Region Size  %age Used
          FLASH:      185680 B       192 KB     94.44%
           SRAM:       32371 B        24 KB    131.72%
       IDT_LIST:         152 B         2 KB      7.42/home/jason/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/9.2.0/../../../../arm-zephyr-eabi/bin/ld: zephyr/zephyr_prebuilt.elf section
`noinit' will not fit in region `SRAM'
/home/jason/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/9.2.0/../../../../arm-zephyr-eabi/bin/ld: section .intList VMA [0000000020006000,0000000020006097] overlaps section noinit VMA [000
0000020003880,0000000020007e72]
/home/jason/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/9.2.0/../../../../arm-zephyr-eabi/bin/ld: region `SRAM' overflowed by 7795 bytes
collect2: error: ld returned 1 exit status
%
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/jason/Work/ncs/nrf/samples/bluetooth/peripheral_uart/build
Related