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

sd_mbr_command not working for boot loader update

When the boot loader calls the sd_mbr_command it does not get updated.

sd_mbr_command_t sd_mbr_cmd;
sd_mbr_cmd.command               = SD_MBR_COMMAND_COPY_BL;
sd_mbr_cmd.params.copy_bl.bl_src = p_bank_entry->p_bank_addr;
sd_mbr_cmd.params.copy_bl.bl_len = p_bank_entry->length / sizeof(uint32_t);
APP_ERROR_CHECK(sd_mbr_command(&sd_mbr_cmd));

The MBR writes the instruction to the special page in my case 0xf6000. It reads the instruction and actually performs a erase flash page and write page of the boot loader. However for some reason these commands have no effect on the actual flash itself. Neither gets it erased nor does it get flashed. However the 0xf6000 page is nicely cleaned afterwards.

It looks like that the flash page protection mechanism (the alternative one) is blocking the system from writing the pages. How can I solve this problem?

The boot loader address = 0xf7000

The bank address was = 0x48000

size was 14128

I am using soft device 7.0.0

The chip on my test board id of type: N52840Q1AAD01851AA. 

The content of my 0xf6000 at the moment of the soft reset is

0xf6000:    0x6a    0x77    0x78    0x97    0xaa    0xff    0xff    0xff
0xf6008:    0x88    0xfb    0x03    0x20    0xe9    0xfe    0x03    0x20
0xf6010:    0x00    0x80    0x04    0x00    0x8b    0x03    0x00    0x00
0xf6018:    0x8c    0xf0    0x0f    0x00    0xf9    0xff    0xff    0xff
0xf6020:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6028:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6030:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6038:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6040:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6048:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6050:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6058:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6060:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6068:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6070:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6078:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6080:    0x00    0x00    0x00    0x00    0x00    0x80    0x04    0x00
0xf6088:    0xcc    0x0d    0x00    0x00    0x43    0xbb    0x56    0x2e
0xf6090:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6098:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf60a0:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf60a8:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf60b0:    0x43    0xbb    0x56    0x2e    0xcc    0x0d    0x00    0x00
0xf60b8:    0x00    0x80    0x04    0x00    0x00    0x00    0x00    0x00
0xf60c0:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf60c8:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf60d0:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf60d8:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf60e0:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf60e8:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf60f0:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf60f8:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff
0xf6100:    0xff    0xff    0xff    0xff    0xff    0xff    0xff    0xff

the rest is empty

Parents Reply Children
  • I am using SDK 15.3.

    ave you compiled it against the S140 v7.0.0 headers? No it was version 6.1.1. How much effect has this otherwise I have to run a new test.

    The bootloader is a customized version.

    Yes I changed the MBR parameter page to 0xf6000

    See linker script

    /* nRF5 SDK for Mesh Bootloader linker script. */

    SEARCH_DIR(.)
    GROUP(-lgcc -lc -lnosys)
    MEMORY
    {
       /* FLASH (rx) :           ORIGIN = 0xf8000, LENGTH = 0x6000*/
        FLASH (rx:           ORIGIN = 0xf7000, LENGTH = 0x7000
        RAM (rw:             ORIGIN = 0x20000004, LENGTH = 0x3fcfc
        CORE_BL_RAM (rw:     ORIGIN = 0x2003fd00, LENGTH = 0x300
        UICR_BOOTADDR (r:    ORIGIN = 0x10001014, LENGTH = 0x04
        UICR_MBRPARAMADDR (r): ORIGIN = 0x10001018, LENGTH = 0x04
    }

    SECTIONS
    {
        .core_data (NOLOAD) :
        {
            __core_ram_start__ = .;
            . = ALIGN(4);
            *sha256.c.obj (.data*)
            *bootloader_app_bridge.c.obj (.data*)
            *bootloader_info.c.obj (.data*)
            *uECC.c.obj (.data*)
            *dfu_mesh.c.obj (.data*)
            *dfu_transfer_mesh.c.obj (.data*)
            *dfu_bank.c.obj (.data*)
            *dfu_util.c.obj (.data*)
            . = ALIGN(4);
            __core_ram_end__ = .;
        } > CORE_BL_RAM
        .core_bss (NOLOAD) :
        {
            __core_ram_start__ = .;
            . = ALIGN(4);
            *sha256.c.obj (.bss*)
            *bootloader_app_bridge.c.obj (.bss*)
            *bootloader_info.c.obj (.bss*)
            *uECC.c.obj (.bss*)
            *dfu_mesh.c.obj (.bss*)
            *dfu_transfer_mesh.c.obj (.bss*)
            *dfu_bank.c.obj (.bss*)
            *dfu_util.c.obj (.bss*)
            . = ALIGN(4);
            __core_ram_end__ = .;
        } > CORE_BL_RAM

        /* Ensures the Bootloader start address in flash is written to UICR when flashing the image. */
        .uicrBootStartAddress :
        {
          KEEP(*(.uicrBootStartAddress))
        } > UICR_BOOTADDR

        /* The MBR used for the supported nRF52 SoftDevices expects a pointer to an empty
         * flash page written in the UICR.NRFFW[1] register.
         */
        .uicrBootMBRParamAddress :
        {
          KEEP(*(.uicrBootMBRParamAddress))
        } > UICR_MBRPARAMADDR
    }

    INCLUDE "nrf_common.ld"
  • Well, if the S140 v7.0.0 is present on the device, then you should compile the bootloader against those headers to avoid using incompatible APIs. However, the MBR API does not change very often as it must be backwards compatible with all legacy SDs. Still i would recommend you to compile the BL with  the v7.0.0 headers. 

    Looking at the Mesh bootloader code in nrf5SDKforMeshv320src\mesh\bootloader\src I only see that the uicrBootMBRParamAddress is overwritten with the uicrBootStartAddress. Are you doing the same in your bootloader?

    If you were writing to a region that is protected by the ACL then you should see a a Bus Fault exception being triggered. 

    Best regards

    Bjørn

Related