Properly using a bootloader on mBed when building with Platformio

Hi,

I’ve got an mbed project I am migrating from mbed studio over to platformio. Everything has been working great, except for on issue. The upload option on platformio doesn’t seem to respect the “target.mbed_app_start” and “target.mbed_app_size”. I have a custom bootloader, but, when I upload my hex file, it seems to upload it to address 0x00 and overwrites the bootloader. What is the proper way to get this working? I’ve included my mbed_app.json and platformio.ini files below.

mbed_app.json

{
    "target_overrides": {
        "*": {
            "target.lf_clock_src": "NRF_LF_SRC_RC",
            "target.lf_clock_rc_calib_mode_config": 2,
            "target.mbed_app_start":"0x15000",
            "target.mbed_app_size":"0x50000"
            }
    }
}

platform.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:nrf52840_dk]
platform = nordicnrf52
board = splitz
framework = mbed
debug_tool = jlink
upload_protocol = jlink
build_flags = -I$PROJECT_SRC_DIR/SPLITZ

As the logic in main.py says, add

board_upload.offset_address = 0x15000

to your platformio.ini and retry.

You can verify that JLink is invoked with that offset by executing the project task Advanced → Verbose Upload.

Thanks for the reply!

Unfortunately, that doesn’t appear to cause j-link to program it at the correct address, possibly because the output is a hex file rather than a bin?

The upload.jlink file does have the correct address, but jlink appears to ignore it.

loadbin .pio/build/nrf52840_dk/firmware.hex,0x15000

Can you share the first few lines of the firmware.hex?

@spinnakerdesign Hi, Have you solve your problem ? Can you share us how to figure it out ?