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

Unable to flash after adding bootloader

Hi,

So I've made a post that I was unable to debug my app with the bootloader. But I've found out that it is entirely different problem. So my app is runnning whit FreeRTOS and I am using the buttonless bootloader debug example on the SDK15.0.0 with the softdevice compiling with armgcc. When I try to flash trough eclipse, the application restart but does not change.So I think that probably the flash fails.

Then I tried it on nrfGo studio and I get the message "Unable to erase UICR" when I try to flash my application. I did try to erase the UICR before but I don't think that is the problem. I tried reajustring my linker file since I thought that maybe I was writting on the bootloader.  Since the bootloader starts at 0x72000 I've five the length of the flash.

Here is my .ld file of my application:

/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x4c000
  RAM (rwx) :  ORIGIN = 0x200057b8, LENGTH = 0xa848
  uicr_bootloader_start_address (r) : ORIGIN = 0x10001014, LENGTH = 0x4
}

SECTIONS
{
  .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
  .cli_sorted_cmd_ptrs :
  {
    PROVIDE(__start_cli_sorted_cmd_ptrs = .);
    KEEP(*(.cli_sorted_cmd_ptrs))
    PROVIDE(__stop_cli_sorted_cmd_ptrs = .);
  } > RAM

} INSERT AFTER .data;

SECTIONS
{
  .mem_section_dummy_rom :
  {
  }
  .sdh_soc_observers :
  {
    PROVIDE(__start_sdh_soc_observers = .);
    KEEP(*(SORT(.sdh_soc_observers*)))
    PROVIDE(__stop_sdh_soc_observers = .);
  } > FLASH
  .sdh_ble_observers :
  {
    PROVIDE(__start_sdh_ble_observers = .);
    KEEP(*(SORT(.sdh_ble_observers*)))
    PROVIDE(__stop_sdh_ble_observers = .);
  } > FLASH
  .log_const_data :
  {
    PROVIDE(__start_log_const_data = .);
    KEEP(*(SORT(.log_const_data*)))
    PROVIDE(__stop_log_const_data = .);
  } > FLASH
    .nrf_balloc :
  {
    PROVIDE(__start_nrf_balloc = .);
    KEEP(*(.nrf_balloc))
    PROVIDE(__stop_nrf_balloc = .);
  } > FLASH
  .sdh_state_observers :
  {
    PROVIDE(__start_sdh_state_observers = .);
    KEEP(*(SORT(.sdh_state_observers*)))
    PROVIDE(__stop_sdh_state_observers = .);
  } > FLASH
  .svc_data :
  {
    PROVIDE(__start_svc_data = .);
    KEEP(*(.svc_data))
    PROVIDE(__stop_svc_data = .);
  } > 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
    .nrf_queue :
  {
    PROVIDE(__start_nrf_queue = .);
    KEEP(*(.nrf_queue))
    PROVIDE(__stop_nrf_queue = .);
  } > FLASH
    .cli_command :
  {
    PROVIDE(__start_cli_command = .);
    KEEP(*(.cli_command))
    PROVIDE(__stop_cli_command = .);
  } > FLASH
  .crypto_data :
  {
    PROVIDE(__start_crypto_data = .);
    KEEP(*(SORT(.crypto_data*)))
    PROVIDE(__stop_crypto_data = .);
  } > FLASH
  .pwr_mgmt_data :
  {
    PROVIDE(__start_pwr_mgmt_data = .);
    KEEP(*(SORT(.pwr_mgmt_data*)))
    PROVIDE(__stop_pwr_mgmt_data = .);
  } > FLASH

} INSERT AFTER .text

INCLUDE "nrf_common.ld"

After a reset: When I flash the bootloader after a reset, if I send an image through the dfu service, it boots. If I flash direcly it doesn't since it does not pass the CRC check. So first I flash a working image through the DFU service and then I try to develop and debug the app by flashing normaly through my IDE/Jlink, but then nothing changes as described in the post.

Any help is appreciated.

  • I can now flash everything normally using nrfgo studio, I just erased all the memory on the device and it now works and an updated version of my app can run. Although, when I use eclipse to debug, I do not know how to use the .hex file instead of the .out and run and debug normally. If I use the .out file generated, it does not update the app. I tried to flash the setting instead of combining with the app using 

    nrfjprog -f nrf52 --program ./setting.hex --sectorerase

    but sadly the debugging still does not work.

  • The application should not place any data to that specific UICR register, its only the bootloader that should do this. 0x10001014 is the register that the MBR checks to see if there is a bootloader present or not.

    Do not use nRFGo Studio to flash nRF52 ICs. Use the nRF Programmer app in nRF Connect for Desktop or nrfjprog the latest version of the nRF Command Line Tools instead. See Programming nRF5x SoCs with nrfjprog on how to use nrfjprog. 

    The layout does not look right. There should be a blue section that contains the SoftDevice inbetween the MBR(orange) and the application (green). 

Related