NRF Connect SDK, build elf with Softdevice

I am using the NRF Connect SDK package provided by Qorvo, and adding BLE functions to their package. 
I am now trying to debug my added code. 

I am using Ozone as the debugger. 

if I locate my code at 0, it boots and crashes when it want to talk to the softdevice.. (good, as expected) but I can use ozone to step thru the code, 

the app entrypoint is correct., 

if I locate my code at x027000 (S140) for the softdevice blob to be at 0, 

and use both files in the NRF Connect programmer, the layout looks as expected with the correct location and sizes

but it doesn't setup as expected (without debugging) which means I have a bug somewhere (not unexpected) 

so I want to use Ozone, but the LD builds only my app
I have found other instructions that say I can load the softdevice binary in the build and place it at 0, and have the combined ELF
https://m0agx.eu/nordic-softdevice-unofficial-survival-guide.html


BUT the linker freaks out with the INPUT(binary_file) and produces a mess

ld file 

TARGET(binary)
INPUT("../../../../SDK_BSP/Nordic/NORDIC_SDK_17_1_0/components/softdevice/s140/hex/s140_blob_and_mbr.bin")
OUTPUT_FORMAT(default)

MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1M
CALIB_SHA (rw) : ORIGIN = 0x000FE000, LENGTH = 4K
CALIB (rw) : ORIGIN = 0x000FF000, LENGTH = 4K
RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 256K - 8k
}

SECTIONS
{
.text 0x0 : {
"../../../../SDK_BSP/Nordic/NORDIC_SDK_17_1_0/components/softdevice/s140/hex/s140_blob_and_mbr.bin"
}
/* start with interrupt vectors */
.text 0x27000 :
{
/*. = ALIGN(4); */
KEEP(*(.isr_vector)) /* Startup code */

...

from the map file 

.text 0x0000000000000000 0x26634
../../../../SDK_BSP/Nordic/NORDIC_SDK_17_1_0/components/softdevice/s140/hex/s140_blob_and_mbr.bin()
.data 0x0000000000000000 0x26634 ../../../../SDK_BSP/Nordic/NORDIC_SDK_17_1_0/components/softdevice/s140/hex/s140_blob_and_mbr.bin
0x0000000000000000 _binary_____________SDK_BSP_Nordic_NORDIC_SDK_17_1_0_components_softdevice_s140_hex_s140_blob_and_mbr_bin_start
0x0000000000026634 _binary_____________SDK_BSP_Nordic_NORDIC_SDK_17_1_0_components_softdevice_s140_hex_s140_blob_and_mbr_bin_end

.glue_7 0x0000000000000000 0x0
.glue_7 0x0000000000000000 0x0 linker stubs

.glue_7t 0x0000000000000000 0x0
.glue_7t 0x0000000000000000 0x0 linker stubs

.vfp11_veneer 0x0000000000000000 0x0
.vfp11_veneer 0x0000000000000000 0x0 linker stubs

.v4_bx 0x0000000000000000 0x0
.v4_bx 0x0000000000000000 0x0 linker stubs

.iplt 0x0000000000000000 0x0
.iplt 0x0000000000000000 0x0 /opt/gcc/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m+fp/hard/crtbegin.o

.text 0x0000000000027000 0xc048
*(.isr_vector)
0x0000000000030000 . = ALIGN (0x10000)

Memory region Used Size Region Size %age Used
FLASH: 208968 B 1 MB 19.93%
CALIB_SHA: 32 B 4 KB 0.78%
CALIB: 4 KB 4 KB 100.00%
RAM: 248198188 B 248 KB 97734.29%

I've also tried with 

FLASH (rx)     : ORIGIN = 0x00027000, LENGTH = 1M - 156K - 4K - 4K */ /* 1M minus calib_sha/calib sections. */

as soon as the INPUT(binary file) is added, the build falls apart. ld 2.38 is the latest for my platform. 

are there any other guides for this? 

Parents
  • I havent solved the elf build issue, but using the Ozone startup script I can get both loaded..

    now I am trying to figure out what rc=2 means 

    I copied the startup code from the SDK_BSP/Nordic/NORDIC_SDK_17_1_0/examples/ble_central_and_peripheral/experimental/ble_app_multirole_lesc/main.c

    using this layout from the ld file 

    MEMORY
    {
    FLASH (rwx) : ORIGIN = 0x00027000, LENGTH = 1M - 156K - 4K - 4K
    CALIB_SHA (rw) : ORIGIN = 0x000FE000, LENGTH = 4K
    CALIB (rw) : ORIGIN = 0x000FF000, LENGTH = 4K
    RAM (rwx) : ORIGIN = 0x20002ae8, LENGTH = 0x3d518
    }

    ```
    /**@brief Function for initializing the BLE stack.
    *
    * @details Initializes the SoftDevice and the BLE event interrupts.
    */
    static void ble_stack_init(void)
    {
    ret_code_t err_code;

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    // Configure the BLE stack by using the default settings.
    // Fetch the start address of the application RAM.
    uint32_t app_ram_base = 0;
    err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &app_ram_base);
           // this got the value from the RAM stmt in the ld file.
    0x20002AE8
    APP_ERROR_CHECK(err_code);

    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&app_ram_base);
    APP_ERROR_CHECK(err_code); <---------- (my code below)

    // Register a handler for BLE events.
    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
    }
    ```

    and get to here

    app_ram_base = 0x20002ea8;

    err_code = nrf_sdh_ble_enable(&app_ram_base);

    APP_ERROR_CHECK(err_code);

    and err_code = 2 

  • I think Softdevice was at lesat initialized at boot, 

    the Ozone startup gets the info from address 0 in flash 

    Target.LoadMemory ("/home/sam/Downloads/DW3_QM33_SDK_1.0.2.new/SDK/Firmware/SDK_BSP/Nordic/NORDIC_SDK_17_1_0/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex", 0x00000000);
    J-Link: Flash download: Bank 0 @ 0x00000000: Skipped. Contents already match
    Target.ReadU32 (0x00000000); // returns 0x4, data is 0x20000400
    Target.SetReg ("SP", 0x20000400);
    Target.ReadU32 (0x00000004); // returns 0x4, data is 0xA81

    Target.SetReg ("PC", 0xA81);

    the app startup addresses  are different(at 0x27000)

Reply
  • I think Softdevice was at lesat initialized at boot, 

    the Ozone startup gets the info from address 0 in flash 

    Target.LoadMemory ("/home/sam/Downloads/DW3_QM33_SDK_1.0.2.new/SDK/Firmware/SDK_BSP/Nordic/NORDIC_SDK_17_1_0/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex", 0x00000000);
    J-Link: Flash download: Bank 0 @ 0x00000000: Skipped. Contents already match
    Target.ReadU32 (0x00000000); // returns 0x4, data is 0x20000400
    Target.SetReg ("SP", 0x20000400);
    Target.ReadU32 (0x00000004); // returns 0x4, data is 0xA81

    Target.SetReg ("PC", 0xA81);

    the app startup addresses  are different(at 0x27000)

Children
Related