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

SES Debugging the bootloader

I need to know how to set up the SES debugger to continue debugging when the program jumps from application into the bootloader.

nRF52832 SDK v15.3

Using the following code to jump to the bootloader:

    // Write to the register and reset the device
    NRF_POWER->GPREGRET = BOOTLOADER_DFU_START;
    nrf_delay_ms(500);
    NVIC_SystemReset();

Currently once it reaches the reset, the debugger crashes.

  • Hello,

    I don't think you can debug both the bootloader and the application at the same time, since they are two projects, with two different output files.

    However it is possible to debug the bootloader. In SES, just click "Target"->"Attach Debugger", and it will start when the nRF hits the bootloader. However, as mentioned, you can't have a separate SES window debugging the application at the same time. You need to choose. But only the bootloader or the application will be running at one point in time, so it should be perfectly possible to debug the bootloader project using this approach.

    NB: When you are dealing with bootloaders, don't use "build and run" or "build and debug", because this will upload a slightly different hex file to the nRF, which will generate a different CRC for the application and bootloader. Hence, just use "Attach debugger", and it should work.

    Best regards,

    Edvin

  • Hello Edvin,

      I tried what you suggested - just 'Target'->"Attach Debugger" in the bootloader.

    It seems to reach the bootloader but immediately crashes in the debug window.

  • Did you do any changes to the bootloader project (except for generating the public key)?

    Perhaps you can try the pca10040_ble_debug project (a bootloader project with a bit more flash that can fit the NRF_LOG module.

    Can you try to flash this project, and monitor the log output from the bootloader?

  • My application is taken from ble_app_uart_pca10040_s132

    The bootloader is secure_bootloader_uart_mbr_pca10040_debug with no changes except generating a private key.

    Are you indicating that I may have to move the start address of the bootloader?

  • I thought you were using the ble, bootloader, since you were using the softdevice, but that isn't a problem. I suggest that you try the pca10040_uart_debug project, and monitor the RTT log for the bootloader. Just attache the debugger as described before, and set NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED to 0 in sdk_config.h, and the RTT log should appear when you attach the debugger.

Related