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

Debugging Serial UART Bootloader SDK 15.3

Hi,

I am currently working on a project for which I use the Secure Serial UART Bootloader from SDK 15.3 (nRF5_SDK_15.3.0_59ac345\examples\dfu\secure_bootloader\pca10040_uart), slightly modified to fit my custom board embedding a nRF52832 chip (pinout, RX buffer size...).

My problem is, after having erased non-volatile memory and program SoftDevice 6.1.1 with nrfjprog, I can't seem to debug the bootloader with Keil. I have the error:

Error: Flash Download failed  -  "Cortex-M4"

when trying to download firmware or debug.

Settings are as follow:

- Defined "DEBUG"  as preprocessor symbol.

- Optimization level 0.

- IROM1 start address: 0x69000, size: 0xD100 (I added some files hence the size).

- Using J-LINK / J-TRACE Cortex to debug.

Thank you for your help.

Parents
  • Hi Pierre, 

    in the latest SDK v15.3.0 we have modified the bootloader code in that we write the bootloader address to the MBR region in addition to the UICR registers. When you initiate a Debug session with Keil, then the IDE will try to reflash the bootloader binary, which contains data placed in the MBR section. The MBR is included in the SoftDevice binary, and since the flash algorithm used in Keil require the entire page to be cleared prior to writing to it, then this will result in the error you now are seeing. 

    Could you try to modify the Flash Download settings as shown below to not flash the bootloader prior to initiating the debug session

    ...

  • Hi, thank you for your answer.

    I tried your solution, and it gives me the same error... But I realized I shouldn't need to have SoftDevice flashed in order for the bootloader to work, as it is not using BLE, and so neither SoftDevice. As so I tried going into debug mode after having flashed only MBR (nRF5_SDK_15.3.0_59ac345\components\softdevice\mbr\nrf52832\hex\mbr_nrf52_2.4.1_mbr.hex).

    In this case, I can go into bootloader debug mode without error. But the issue now seems that once I am in debug mode, I don't see any pointers to my code, and as soon as I try to run the code it stops by itself. Even at the beginning registers values seem a bit off:

    I still have the same settings for debugging.

    Any idea where that might come from ?

Reply
  • Hi, thank you for your answer.

    I tried your solution, and it gives me the same error... But I realized I shouldn't need to have SoftDevice flashed in order for the bootloader to work, as it is not using BLE, and so neither SoftDevice. As so I tried going into debug mode after having flashed only MBR (nRF5_SDK_15.3.0_59ac345\components\softdevice\mbr\nrf52832\hex\mbr_nrf52_2.4.1_mbr.hex).

    In this case, I can go into bootloader debug mode without error. But the issue now seems that once I am in debug mode, I don't see any pointers to my code, and as soon as I try to run the code it stops by itself. Even at the beginning registers values seem a bit off:

    I still have the same settings for debugging.

    Any idea where that might come from ?

Children
  • I think its still because Keil is erasing the MBR flash page. Could you try to do the following modifications to the bootloader code

    // Comment out the m_uicr_mbr_params_page_address declearation in nrf_dfu_settings.c, i.e. 
    
    #if defined ( __CC_ARM )
    
      //  uint32_t const m_uicr_mbr_params_page_address
      //      __attribute__((at(NRF_UICR_MBR_PARAMS_PAGE_ADDRESS))) = NRF_MBR_PARAMS_PAGE_ADDRESS;
    
    #elif defined ( __GNUC__ ) || defined ( __SES_ARM )
    
    // Change MBR_BOOTLOADER_ADDR in nrf_mbr.h from 0xFF8 to 0x10001014
    
    /** @brief Location (in the flash memory) of the bootloader address. */
    #define MBR_BOOTLOADER_ADDR      (0x10001014) //(0xFF8)

    Doing this I was able to debug the bootloader in Keil. What I have essentially done is to prevent the BL from writing to the MBR region.

  • Hi,

    Thank you for your answer, this indeed solved the problem.

Related