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

Bootloader causes NRF52840 to stop advertising

Hi,

I am trying to program the bootloader for the nrf52840. I am trying to create a settings for the specific hex file, and then programming using the nrfjprog commands. But for some reason, whenever i upload the bootloader on top of the soft device and the program, the device stops advertising.

Here are the commands i am using:

 

nrfutil settings generate --family NRF52840 --application ..\Firmware\version\s140\armgcc\_build\nrf52840_xxaa.hex --application-version 2 --bootloader-version 2 --bl-settings-version 1 settingsV10.hex --no-backup

mergehex -m secure_bootloader\pca10056_ble\armgcc\_build\nrf52840_xxaa_s140.hex settingsV10.hex -o bootloaderV10.hex

nrfjprog --family NRF52 -e
nrfjprog --reset --program ..\..\components\softdevice\s140\hex\s140_nrf52_6.0.0_softdevice.hex --family NRF52 --sectoranduicrerase
nrfjprog --reset --program ..\Firmware\version\s140\armgcc\_build\nrf52840_xxaa.hex --family NRF52 --sectoranduicrerase
nrfjprog --reset --program bootloaderV10.hex --family NRF52 --sectoranduicrerase


Parents Reply Children
  • Could you explain more about what commands you are using now then? If you want you can upload the files and we can take a look at them.

  • Hi,

    I installed the micro_ecc directory in external directory in the SDK 15.0

    I generated a private key, and then a public key corresponding to that private key using these commands.

    nrfutil.exe keys generate private.key
    
    nrfutil keys display --key pk --format code private.key --out_file public_key.c

    Then, i am using these commands to make the bootloader, and merge the settings file with it. And then program it into the custom NRF52840 board.

    nrfutil settings generate --family NRF52840 --application ..\Firmware\Version\s140\armgcc\_build\nrf52840_xxaa.hex --application-version 2 --bootloader-version 1 --bl-settings-version 1  settingsV10.hex
    cd secure_bootloader\Version_ble\armgcc
    make
    cd ..\..\..
    mergehex -m secure_bootloader\Version_ble\armgcc\_build\nrf52840_xxaa_s140.hex settingsV10.hex -o bootloader.hex

    nrfjprog --family NRF52 -e
    nrfjprog --program ..\..\components\softdevice\s140\hex\s140_nrf52_6.0.0_softdevice.hex --family NRF52 --sectoranduicrerase --reset
    nrfjprog --program ..\Firmware\Version\s140\armgcc\_build\nrf52840_xxaa.hex --family NRF52 --sectoranduicrerase --reset
    nrfjprog --program bootloader.hex --family NRF52 --sectoranduicrerase --reset

    rm settingsV10.hex
    rmdir secure_bootloader\Version_ble\armgcc\_build /s /Q

  • Can you send me the linker script for you application? I want to make sure that you're allocating enough memory for the BL. If the bootloader advertises when you only flash the BL+SD, then its highly likely that the issue is in the application. So could you try to debug the application after you have flashed the SD+BL+Settings+ APP?

  • /* Linker script to configure memory regions. */
    
    SEARCH_DIR(.)
    GROUP(-lgcc -lc -lnosys)
    
    MEMORY
    {
      FLASH (rx) : ORIGIN = 0xf8000, LENGTH = 0x6000
      RAM (rwx) :  ORIGIN = 0x200057b8, LENGTH = 0x3a848
      uicr_mbr_params_page (r) : ORIGIN = 0x10001018, LENGTH = 0x4
      mbr_params_page (r) : ORIGIN = 0x000FE000, LENGTH = 0x1000
      bootloader_settings_page (r) : ORIGIN = 0x000FF000, LENGTH = 0x1000
      uicr_bootloader_start_address (r) : ORIGIN = 0x10001014, LENGTH = 0x4
    }
    
    SECTIONS
    {
      .uicr_mbr_params_page :
      {
        PROVIDE(__start_uicr_mbr_params_page = .);
        KEEP(*(SORT(.uicr_mbr_params_page*)))
        PROVIDE(__stop_uicr_mbr_params_page = .);
      } > uicr_mbr_params_page
      .mbr_params_page(NOLOAD) :
      {
        PROVIDE(__start_mbr_params_page = .);
        KEEP(*(SORT(.mbr_params_page*)))
        PROVIDE(__stop_mbr_params_page = .);
      } > mbr_params_page
      .bootloader_settings_page(NOLOAD) :
      {
        PROVIDE(__start_bootloader_settings_page = .);
        KEEP(*(SORT(.bootloader_settings_page*)))
        PROVIDE(__stop_bootloader_settings_page = .);
      } > bootloader_settings_page
      .uicr_bootloader_start_address :
      {
        PROVIDE(__start_uicr_bootloader_start_address = .);
        KEEP(*(SORT(.uicr_bootloader_start_address*)))
        PROVIDE(__stop_uicr_bootloader_start_address = .);
      } > uicr_bootloader_start_address
    }
    
    SECTIONS
    {
      . = ALIGN(4);
      .mem_section_dummy_ram :
      {
      }
      .log_dynamic_data :
      {
        PROVIDE(__start_log_dynamic_data = .);
        KEEP(*(SORT(.log_dynamic_data*)))
        PROVIDE(__stop_log_dynamic_data = .);
      } > RAM
      .fs_data :
      {
        PROVIDE(__start_fs_data = .);
        KEEP(*(.fs_data))
        PROVIDE(__stop_fs_data = .);
      } > RAM
    
    } INSERT AFTER .data;
    
    SECTIONS
    {
      .mem_section_dummy_rom :
      {
      }
      .crypto_data :
      {
        PROVIDE(__start_crypto_data = .);
        KEEP(*(SORT(.crypto_data*)))
        PROVIDE(__stop_crypto_data = .);
      } > FLASH
      .log_const_data :
      {
        PROVIDE(__start_log_const_data = .);
        KEEP(*(SORT(.log_const_data*)))
        PROVIDE(__stop_log_const_data = .);
      } > FLASH
        .nrf_queue :
      {
        PROVIDE(__start_nrf_queue = .);
        KEEP(*(.nrf_queue))
        PROVIDE(__stop_nrf_queue = .);
      } > FLASH
      .dfu_trans :
      {
        PROVIDE(__start_dfu_trans = .);
        KEEP(*(SORT(.dfu_trans*)))
        PROVIDE(__stop_dfu_trans = .);
      } > FLASH
        .nrf_balloc :
      {
        PROVIDE(__start_nrf_balloc = .);
        KEEP(*(.nrf_balloc))
        PROVIDE(__stop_nrf_balloc = .);
      } > FLASH
        .svc_data :
      {
        PROVIDE(__start_svc_data = .);
        KEEP(*(.svc_data))
        PROVIDE(__stop_svc_data = .);
      } > FLASH
      .sdh_ble_observers :
      {
        PROVIDE(__start_sdh_ble_observers = .);
        KEEP(*(SORT(.sdh_ble_observers*)))
        PROVIDE(__stop_sdh_ble_observers = .);
      } > FLASH
      .sdh_state_observers :
      {
        PROVIDE(__start_sdh_state_observers = .);
        KEEP(*(SORT(.sdh_state_observers*)))
        PROVIDE(__stop_sdh_state_observers = .);
      } > FLASH
      .sdh_stack_observers :
      {
        PROVIDE(__start_sdh_stack_observers = .);
        KEEP(*(SORT(.sdh_stack_observers*)))
        PROVIDE(__stop_sdh_stack_observers = .);
      } > FLASH
      .sdh_req_observers :
      {
        PROVIDE(__start_sdh_req_observers = .);
        KEEP(*(SORT(.sdh_req_observers*)))
        PROVIDE(__stop_sdh_req_observers = .);
      } > FLASH
      .sdh_soc_observers :
      {
        PROVIDE(__start_sdh_soc_observers = .);
        KEEP(*(SORT(.sdh_soc_observers*)))
        PROVIDE(__stop_sdh_soc_observers = .);
      } > FLASH
    
    } INSERT AFTER .text
    
    INCLUDE "nrf_common.ld"
    

    I have tried flashing BL+SD, and it does advertise. 

    I also tried BL+SD+Settings+ APP, and Bootloader advertises in this occasion too, when i switch it using a button, to put it into bootloader mode.

    And, i ALSO tried SD+APP, and the application works.

    The problem is, when the application is flashed along with the bootloader, it does not advertise, i can still see the blue LED, (but it does not blink, which is how i know whether it is advertising or not).   

  • Hi,

    Firstly, you should use the nRF Connect app to see if the device is advertising or not, the LED not blinking can be a consequence of something else. You should check if the device is advertising in bootloader mode.

    You can also enable the logging option via RTT and copy the logs in here.

    You should also not do a reset in each programming stage, just run a single reset at the end and see if that helps.

    Best Regards,

    Marjeris

Related