Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

[NRF52840] Changing Bootloader Size and need to change Linker Script to match

Hello all,

Environment: nRF52840-DK, NRF SDK V15.0.0, SoftDevice s140 v 6.0.0, ARMGCC building with Makefile

I am currently trying to combine the examples of the USB and BLE DFU bootloaders into one bootloader, and I have run into a problem at the linking stage. I have run into this problem multiple times, and more or less would just like some info on this part of the procedure.

I have started by copying the <SDK_ROOT>/examples/dfu/secure_bootloader/pca10056_ble example to another example called <SDK_ROOT>/examples/dfu/secure_bootloader/pca10056_ble_usb, and then added the appropriate source files and include files from the <SDK_ROOT>/examples/dfu/secure_bootloader/pca10056_usb example to the new example. I'm able to compile all the required files but at the linking step I get the following:

Fullscreen
1
2
3
4
5
6
7
Linking target: _build/nrf52840_xxaa_s140.out
/usr/bin/gnu-arm-embedded-toolchain/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: _build/nrf52840_xxaa_s140.out section `.text' will not fit in region `FLASH'
/usr/bin/gnu-arm-embedded-toolchain/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: region FLASH overflowed with .data and user data
/usr/bin/gnu-arm-embedded-toolchain/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: section .bootloader_settings_page VMA [00000000000ff000,00000000000fffff] overlaps section .text VMA [00000000000f8000,000000000010170f]
/usr/bin/gnu-arm-embedded-toolchain/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: region `FLASH' overflowed by 14260 bytes
collect2: error: ld returned 1 exit status
make: *** [../../../../components/toolchain/gcc/Makefile.common:294: _build/nrf52840_xxaa_s140.out] Error 1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I know I need to make changes to the bootloader flash section in the associated secure_bootloader_gcc_nrf52.ld example linker script, but this is not something I have really done before. I'd like to learn how to go about this as well as get some resources on how to understand and manipulate linker scripts.

I'm sure as I move forward I'll have more issues in regards to the proper building of this combined example, but I really want to get this fundamental understood first.

Thanks!