When I try to build the solution with "Optimize for debugging (-Og)" the linker fails saying `rodata' will not fit in region `FLASH'. FLASH overflowed by 46056 bytes. This happens with both my exercise code and your solution code.
When I look at the output of the default build, which works, I see that the Zephyr.elf has used a huge amount of the FLASH and RAM, 621,984 of 704KB of the FLASH. This exercise is a very simple HTTP interface, and that's all. Why does it use up so much space? It doesn't seem like there is very much left for a serious application, or even merging in some other functionality like Wi-Fi provisioning through BLE! And it would be much more difficult to develop an application without being able to use the debugger. (Based on this exercise, I am seriously concerned about whether our planned app with HTTP server and BLE Wi-Fi provisioning will fit.) What is going on here?
The full output from a pristine build with "Optimize for debugging (-Og)" is included below:
* Executing task: nRF Connect: Build [pristine]: wififund_less5_exer3_solution/build (active) Building wififund_less5_exer3_solution west build --build-dir /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution --pristine --board nrf7002dk_nrf5340_cpuapp_ns --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DBOARD_ROOT=/Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution -DCONFIG_DEBUG_OPTIMIZATIONS=y -DCONFIG_DEBUG_THREAD_INFO=y -DCACHED_CONF_FILE=/Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/prj.conf;/Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/boards/nrf7002dk_nrf5340_cpuapp_ns.conf -- west build: generating a build system Loading Zephyr default modules (Zephyr base). -- Application: /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution -- CMake version: 3.21.0 -- Found Python3: /opt/nordic/ncs/toolchains/580e4ef81c/opt/[email protected]/bin/python3.9 (found suitable version "3.9.6", minimum required is "3.8") found components: Interpreter -- Cache files will be written to: /Users/Glen/Library/Caches/zephyr -- Zephyr version: 3.5.99 (/opt/nordic/ncs/v2.6.1/zephyr) -- Found west (found suitable version "1.2.0", minimum required is "0.14.0") -- Board: nrf7002dk_nrf5340_cpuapp_ns -- Found host-tools: zephyr 0.16.5 (/opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk) -- Found toolchain: zephyr 0.16.5 (/opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk) -- Found Dtc: /opt/nordic/ncs/toolchains/580e4ef81c/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6") -- Found BOARD.dts: /opt/nordic/ncs/v2.6.1/nrf/boards/arm/nrf7002dk_nrf5340/nrf7002dk_nrf5340_cpuapp_ns.dts -- Generated zephyr.dts: /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/zephyr/zephyr.dts -- Generated devicetree_generated.h: /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/zephyr/include/generated/devicetree_generated.h -- Including generated dts.cmake file: /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/zephyr/dts.cmake warning: NRF_SECURITY (defined at /opt/nordic/ncs/v2.6.1/nrf/subsys/nrf_security/Kconfig:33) was assigned the value 'n' but got the value 'y'. See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_NRF_SECURITY and/or look up NRF_SECURITY in the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too. warning: Experimental symbol WIFI_CREDENTIALS is enabled. warning: Experimental symbol TFM_EXPERIMENTAL is enabled. warning: Experimental symbol NET_CONNECTION_MANAGER is enabled. Parsing /opt/nordic/ncs/v2.6.1/zephyr/Kconfig Loaded configuration '/opt/nordic/ncs/v2.6.1/nrf/boards/arm/nrf7002dk_nrf5340/nrf7002dk_nrf5340_cpuapp_ns_defconfig' Merged configuration '/Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/prj.conf' Merged configuration '/Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/boards/nrf7002dk_nrf5340_cpuapp_ns.conf' Merged configuration '/Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/zephyr/misc/generated/extra_kconfig_options.conf' Configuration saved to '/Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/zephyr/.config' Kconfig header saved to '/Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/zephyr/include/generated/autoconf.h' -- Found GnuLd: /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38") -- The C compiler identification is GNU 12.2.0 -- The CXX compiler identification is GNU 12.2.0 -- The ASM compiler identification is GNU -- Found assembler: /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -- Using ccache: /opt/nordic/ncs/toolchains/580e4ef81c/bin/ccache -- Configuring done -- Generating done -- Build files have been written to: /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build -- west build: building application [1/492] Preparing syscall dependency handling [3/492] Generating include/generated/version.h -- Zephyr version: 3.5.99 (/opt/nordic/ncs/v2.6.1/zephyr), build: v3.5.99-ncs1-1-1-gef358de7de84 [9/492] Generating ../../tfm/CMakeCache.txt CMake Warning at cmake/version.cmake:22 (message): Actual TF-M version is not available from Git repository. Settled to v2.0.0 Call Stack (most recent call first): CMakeLists.txt:22 (include) -- Found Git: /opt/nordic/ncs/toolchains/580e4ef81c/bin/git (found version "2.37.3") -- The C compiler identification is GNU 12.2.0 -- The CXX compiler identification is GNU 12.2.0 -- The ASM compiler identification is GNU -- Found assembler: /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -- Found Python3: /opt/nordic/ncs/toolchains/580e4ef81c/opt/[email protected]/bin/python3.9 (found version "3.9.6") found components: Interpreter CMake Deprecation Warning at /opt/nordic/ncs/v2.6.1/zephyr/cmake/modules/FindDeprecated.cmake:121 (message): 'PYTHON_PREFER' variable is deprecated. Please use Python3_EXECUTABLE instead. Call Stack (most recent call first): /opt/nordic/ncs/v2.6.1/zephyr/cmake/modules/python.cmake:16 (find_package) /opt/nordic/ncs/v2.6.1/zephyr/cmake/modules/user_cache.cmake:30 (include) /opt/nordic/ncs/v2.6.1/zephyr/cmake/modules/extensions.cmake:5 (include) /opt/nordic/ncs/v2.6.1/nrf/subsys/nrf_security/tfm/CMakeLists.txt:38 (include) -- Found Python3: /opt/nordic/ncs/toolchains/580e4ef81c/opt/[email protected]/bin/python3.9 (found suitable version "3.9.6", minimum required is "3.8") found components: Interpreter -- Cache files will be written to: /Users/Glen/Library/Caches/zephyr -- Configuring done -- Generating done CMake Warning: Manually-specified variables were not used by the project: CRYPTO_AEAD_MODULE_ENABLED CRYPTO_ASYM_SIGN_MODULE_ENABLED CRYPTO_CIPHER_MODULE_ENABLED CRYPTO_HASH_MODULE_ENABLED CRYPTO_KEY_DERIVATION_MODULE_ENABLED CRYPTO_KEY_MODULE_ENABLED CRYPTO_MAC_MODULE_ENABLED CRYPTO_RNG_MODULE_ENABLED MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE PYTHON_PREFER -- Build files have been written to: /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/tfm [221/225] Linking C executable bin/tfm_s.axf Memory region Used Size Region Size %age Used FLASH: 163296 B 320 KB 49.83% RAM: 57692 B 96 KB 58.69% [17/492] Performing install step for 'tfm' -- Install configuration: "Debug" ----- Installing platform NS ----- [485/492] Linking C executable zephyr/zephyr_pre0.elf FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/zephyr/zephyr_pre0.map : && ccache /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj tfm/api_ns/interface/lib/s_veneers.o -fuse-ld=bfd -T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=/Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/zephyr/zephyr_pre0.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/arm/core/libarch__arm__core.a zephyr/arch/arch/arm/core/cortex_m/libarch__arm__core__cortex_m.a zephyr/arch/arch/arm/core/cortex_m/cmse/libarch__arm__core__cortex_m__cmse.a zephyr/arch/arch/arm/core/mpu/libarch__arm__core__mpu.a zephyr/lib/libc/newlib/liblib__libc__newlib.a zephyr/lib/libc/common/liblib__libc__common.a zephyr/lib/posix/liblib__posix.a zephyr/soc/soc/arm/nordic_nrf/libsoc__arm__nordic_nrf.a zephyr/subsys/random/libsubsys__random.a zephyr/subsys/net/libsubsys__net.a zephyr/subsys/net/l2/ethernet/libsubsys__net__l2__ethernet.a zephyr/subsys/net/l2/wifi/libsubsys__net__l2__wifi.a zephyr/subsys/net/ip/libsubsys__net__ip.a zephyr/subsys/net/lib/config/libsubsys__net__lib__config.a zephyr/subsys/net/lib/dns/libsubsys__net__lib__dns.a zephyr/subsys/net/lib/http/libsubsys__net__lib__http.a zephyr/subsys/net/conn_mgr/libsubsys__net__conn_mgr.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/entropy/libdrivers__entropy.a zephyr/drivers/flash/libdrivers__flash.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/mbox/libdrivers__mbox.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/timer/libdrivers__timer.a modules/nrf/lib/dk_buttons_and_leds/lib..__nrf__lib__dk_buttons_and_leds.a modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a modules/nrf/subsys/nrf_security/src/zephyr/libmbedtls_zephyr.a modules/nrf/subsys/net/lib/wifi_credentials/libwifi_credentials.a modules/nrf/subsys/net/lib/wifi_mgmt_ext/lib..__nrf__subsys__net__lib__wifi_mgmt_ext.a modules/nrf/modules/trusted-firmware-m/lib..__nrf__modules__trusted-firmware-m.a modules/nrf/modules/trusted-firmware-m/libtfm_api_nrf.a modules/nrf/modules/hostap/lib..__nrf__modules__hostap.a modules/nrf/drivers/wifi/nrf700x/lib..__nrf__drivers__wifi__nrf700x.a modules/trusted-firmware-m/libtfm_api.a modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a -L"/opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v8-m.main/nofp" -L/Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/zephyr -lgcc zephyr/arch/common/libisr_tables.a -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn -Wl,-no-pie -lm -Wl,-lc -L"/opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi"/lib/thumb/v8-m.main/nofp -Wl,-lgcc -lc modules/nrf/subsys/nrf_security/src/libmbedtls.a modules/nrf/subsys/nrf_security/src/libmbedx509.a modules/nrf/subsys/nrf_security/src/libmbedcrypto.a /opt/nordic/ncs/v2.6.1/nrfxlib/crypto/nrf_oberon/lib/cortex-m33/soft-float/liboberon_mbedtls_3.0.14.a modules/nrf/subsys/nrf_security/src/libmbedcrypto_base.a -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee /opt/nordic/ncs/v2.6.1/nrfxlib/crypto/nrf_oberon/lib/cortex-m33/soft-float/liboberon_3.0.14.a -lc && cd /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build/zephyr && /opt/nordic/ncs/toolchains/580e4ef81c/Cellar/cmake/3.21.0/bin/cmake -E true /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/zephyr_pre0.elf section `rodata' will not fit in region `FLASH' /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: region `FLASH' overflowed by 46056 bytes collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/580e4ef81c/bin/cmake --build /Users/Glen/Projects/nordic/wifi-fund/lesson5/wififund_less5_exer3_solution/build


