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

section `.gnu.sgstubs' will not fit in region `FLASH' in v1.5.1

ncs/zephyr/cmake/compiler/gcc/compiler_flags.cmake

#set_compiler_property(PROPERTY optimization_size -Os)
set_compiler_property(PROPERTY optimization_size -Og)

//////////

1> FAILED: : && ccache /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gcc
zephyr/CMakeFiles/zephyr_prebuilt.dir/misc/empty_file.c.obj -o zephyr/zephyr_prebuilt.elf
-Wl,-T zephyr/linker.cmd
-Wl,-Map=/root/ncs/zephyr/samples/hello_world/build_nrf9160dk_nrf9160ns/spm/zephyr/zephyr_prebuilt.map
-Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/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__core__aarch32__cortex_m__mpu.a zephyr/arch/arch/arm/core/aarch32/cortex_m/cmse/libarch__arm__core__aarch32__cortex_m__cmse.a zephyr/arch/arch/arm/core/aarch32/cortex_m/tz/libarch__arm__core__aarch32__cortex_m__tz.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/boards/boards/arm/nrf9160dk_nrf9160/libboards__arm__nrf9160dk_nrf9160.a zephyr/drivers/serial/libdrivers__serial.a modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a modules/nrf/subsys/fw_info/lib..__nrf__subsys__fw_info.a modules/nrf/drivers/hw_cc310/lib..__nrf__drivers__hw_cc310.a modules/nrfxlib/nrf_security/src/mbedtls/libmbedtls_base_vanilla.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"/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/thumb/v8-m.main+fp/hard" -L/root/ncs/zephyr/samples/hello_world/build_nrf9160dk_nrf9160ns/spm/zephyr -lgcc -Wl,--print-memory-usage zephyr/arch/common/libisr_tables.a modules/nrfxlib/nrf_security/src/mbedtls/shared/libmbedcrypto_shared.a modules/nrfxlib/nrf_security/src/mbedtls/cc310/libmbedcrypto_cc3xx.a /root/ncs/nrfxlib/crypto/nrf_cc310_platform/lib/cortex-m33/hard-float/no-interrupts/libnrf_cc310_platform_0.9.7.a -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfpu=fpv5-sp-d16 -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -no-pie -Wl,-X -Wl,-N -Wl,--orphan-handling=warn -Wl,--out-implib=/root/ncs/zephyr/samples/hello_world/build_nrf9160dk_nrf9160ns/spm/libspmsecureentries.a -Wl,--cmse-implib && :

1> Memory region Used Size Region Size %age Used
1> FLASH: 65024 B 48 KB 132.29%
1> SRAM: 8648 B 64 KB 13.20%
1> IDT_LIST: 72 B 2 KB 3.52/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/
../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: zephyr/zephyr_prebuilt.elf section `.gnu.sgstubs' will not fit in region `FLASH'
1> /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld:
SPM and app are sharing an SPU region. Cannot partition flash correctly into secure and non-secure.
Adjust partitions sizes so they are placed in separate regions.
1> /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld:
region `FLASH' overflowed by 15872 bytes
1> collect2: error: ld returned 1 exit status
1> %
1> ninja: build stopped: subcommand failed.
Build failed

Parents
  • Reason

    0x18560+0x7aa0-0x1c200 = 3e00 = 15872 

    ncs/zephyr/samples/hello_world/build_nrf9160dk_nrf9160ns/partitions.yml
    spm:
    address: 0x10200
    end_address: 0x1c200
    inside:
    - mcuboot_primary_app
    placement:
    before:
    - app
    region: flash_primary
    size: 0xc000


    ~ncs/zephyr/samples/hello_world/build_nrf9160dk_nrf9160ns/spm/zephyr/zephyr_prebuilt.map
    .gnu.sgstubs 0x0000000000018560 0x7aa0
    0x000000000001ffe0 . = ((ALIGN (0x8000) - MAX (0x20, (0x1 << LOG2CEIL (__sg_size)))) + (ABSOLUTE (.) > (ALIGN (0x8000) - MAX (0x20, (0x1 << LOG2CEIL (__sg_size)))))?0x8000:0x0)
    *fill* 0x0000000000018560 0x7a80
    0x000000000001ffe0 __sg_start = .
    .gnu.sgstubs.__stub

Reply
  • Reason

    0x18560+0x7aa0-0x1c200 = 3e00 = 15872 

    ncs/zephyr/samples/hello_world/build_nrf9160dk_nrf9160ns/partitions.yml
    spm:
    address: 0x10200
    end_address: 0x1c200
    inside:
    - mcuboot_primary_app
    placement:
    before:
    - app
    region: flash_primary
    size: 0xc000


    ~ncs/zephyr/samples/hello_world/build_nrf9160dk_nrf9160ns/spm/zephyr/zephyr_prebuilt.map
    .gnu.sgstubs 0x0000000000018560 0x7aa0
    0x000000000001ffe0 . = ((ALIGN (0x8000) - MAX (0x20, (0x1 << LOG2CEIL (__sg_size)))) + (ABSOLUTE (.) > (ALIGN (0x8000) - MAX (0x20, (0x1 << LOG2CEIL (__sg_size)))))?0x8000:0x0)
    *fill* 0x0000000000018560 0x7a80
    0x000000000001ffe0 __sg_start = .
    .gnu.sgstubs.__stub

Children
Related