How to enable logging in Ble secure DFU example pca10056

Dear nordic team,

                            i want to take log from dfu example i tried using rtt veiwer but it doesnt work.im using sdk version 17.0.2 and soft device 7.2.0 and nrf52840 DK

in nrf drivers/ folder there is no uart related files do we need this for taking logs.pls help

Parents
  • ble_secure_dfu_debug has the dfu working..how can i enable it in ble_secure_dfu  

  • Hi,

    You have to increase the size of the bootloader and then add the logger module and its RTT dependencies like in the ble_secure_dfu_debug project. But it would probably be quicker to just add enable the SPIS code in the ble_secure_dfu_debug project.

  • i also having error when  calling

    nrf_power_gpregret_set(nrf_power_gpregret_get() & ~BOOTLOADER_DFU_START);

    <error> app: Received a fault! id: 0x00001001, pc: 0x0000F4D2C, info: 0x00000001

  • after adding this it is giving me

    00> <debug> app: DFU mode requested via GPREGRET.
    00>
    00> <info> nrf_bootloader_wdt: WDT is not enabled
    00>
    00> <info> app: Entered gpio init
    00>
    00> <debug> app: in weak nrf_dfu_init_user
    00>
    00> <debug> app: timer_stop (0x20005994)
    00>
    00> <debug> app: timer_activate (0x20005994)
    00>
    00> <info> app: Entering DFU mode.
    00>
    00> <debug> app: Initializing transports (found: 1)
    00>
    00> <debug> nrf_dfu_ble: Initializing BLE DFU transport
    00>
    00> <debug> nrf_dfu_ble: Setting up vector table: 0x000F1000
    00>
    00> <debug> nrf_dfu_ble: Enabling SoftDevice.
    00>
    00> <debug> nrf_dfu_ble: Configuring BLE stack.
    00>
    00> <debug> nrf_dfu_ble: Enabling the BLE stack.
    00>
    00> <debug> nrf_dfu_ble: No advertising name found
    00>
    00> <debug> nrf_dfu_ble: Using default advertising name
    00>
    00> <debug> nrf_dfu_ble: Advertising...
    00>
    00> <debug> nrf_dfu_ble: BLE DFU transport initialized.
    00>
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
    00>
    00> <debug> app: Enter main loop
    00>
    00> <info> app: Transfer completed. Received:
    00>
    00> <info> app: 0xEE00,
    00>
    00> <info> app: 0xEF00,
    00>
    00> <info> app: 0x100,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: mac id transfer
    00>
    00> <info> app: Transfer completed. Received:
    00>
    00> <info> app: 0xEE00,
    00>
    00> <info> app: 0xEF00,
    00>
    00> <info> app: 0x2000,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: exit to app
    00>
    00> <error> app: Fatal error

    fatal error

  • You can't write directly to the POWER->GPREGRET register when the BLE transport is enabled. Instead you have to use sd_power_gpregret_set()

  • Looks like you haven't added the DEBUG flag as shown in my screenshot.

  • OK  thanks now i added everything and get error code as

    SOFTDEVICE: INVALID MEMORY ACCESS

    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: 0x0,
    00>
    00> <info> app: exit to app
    00>
    00> <error> app: SOFTDEVICE: INVALID MEMORY ACCESS

Reply Children
  • This assert indicates that the program has tried to access on of the peripherals reserved to the Softdevice (Hardware peripherals). While debugging, please read the 'info' value as the picture below shows. This will tell us which peripheral it was.

  • But dfu code without debug is working fine.that was my doubt and by adding these lines

    sd_power_gpregret_clr(0, 0xffffffff);
    sd_power_gpregret_set(0, ~BOOTLOADER_DFU_START);

    NVIC_SystemReset();

    it is working fine instead of this

    nrf_power_gpregret_set(nrf_power_gpregret_get() & ~BOOTLOADER_DFU_START);

    NVIC_SystemReset();

    i think when enabling debug is making the issue

  • The difference between the original debug and release project is that the debug variant includes logging and more relaxed security requirements (with regards to version validation), and that doesn't explain the INVALID MEMORY ACCESS assertion.

  • thanks for your response vidar.i have one more doubt that when enable the debug in bootloader i cant get logging from application code.with out enabling debug im getting log from application code

    ie.

    00> <info> app: Inside main
    00>
    00> <debug> app: In nrf_bootloader_init
    00>
    00> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    00>
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    00>
    00> <debug> nrf_dfu_settings: Using settings page.
    00>
    00> <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
    00>
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00>
    00> <info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
    00>
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00>
    00> <debug> app: Enter nrf_bootloader_fw_activate
    00>
    00> <info> app: No firmware to activate.
    00>
    00> <debug> app: App is valid
    00>
    00> <info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
    00>
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00>
    00> <debug> app: Running nrf_bootloader_app_start with address: 0x00001000
    00>
    00> <debug> app: Disabling interrupts. NVIC->ICER[0]: 0x10
    00>

    up to this im getting log but after this switching to app log is not coming from application

  • It may be better to use UART for logging in the application. I can be tricky to get RTT logging to work across different applications. Here is another forum thread that covers the issue in more detail: https://devzone.nordicsemi.com/f/nordic-q-a/20708/rtt-logging-from-application-started-by-bootloader 

Related