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 Reply
  • hi actually i got the log enable in ble secure dfu example but im getting somthing fault error in log after adding the log files

    <info> app: gpio main

    <info> app: Inside main

    <debug> app: In nrf_bootloader_init

    <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...

    <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.

    <debug> nrf_dfu_settings: Using settings page.

    <debug> nrf_dfu_settings: Copying forbidden parts from backup page.

    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.

    <info> nrf_dfu_settings: Backing up settings page to address 0xFE000.

    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.

    <debug> app: Enter nrf_bootloader_fw_activate

    <info> app: No firmware to activate.

    <info> app: Boot validation failed. No valid app to boot.

    <debug> app: DFU mode because app is not valid.

    <info> nrf_bootloader_wdt: WDT is not enabled

    <info> app: Entered gpio init

    <debug> app: in weak nrf_dfu_init_user

    <debug> app: timer_stop (0x20005994)

    <debug> app: timer_activate (0x20005994)

    <error> app: Received a fault! id: 0x00004002, pc: 0x00000000, info: 0x2003FF90

    i think this is going to some fault handler..but why is it causing after enabling log..

    pls reply

Children
  • Hi,

    Please make the following changes to main.c and your Segger project to get a more verbose crash log:

    ff --git a/secure_bootloader/main.c b/secure_bootloader/main.c
    index 788970e..3585d9c 100644
    --- a/secure_bootloader/main.c
    +++ b/secure_bootloader/main.c
    
    +#ifndef DEBUG
     void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name)
     {
         NRF_LOG_ERROR("%s:%d", p_file_name, line_num);
     }
    
     void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
     {
         NRF_LOG_ERROR("Received a fault! id: 0x%08x, pc: 0x%08x, info: 0x%08x", id, pc, info);
         on_error();
     }
    
     void app_error_handler_bare(uint32_t error_code)
     {
         NRF_LOG_ERROR("Received an error: 0x%08x!", error_code);
         on_error();
     }
    +#endif
    
    diff --git a/secure_bootloader/pca10056_s140_ble_debug/ses/secure_bootloader_ble_s140_pca10056_debug.emProject b/secure_bootloader/pca10056_s140_ble_debug/ses/secure_bootloader_ble_s140_pca10056_debug.emProject
    index 220d382..f8b9bd1 100644
    --- a/secure_bootloader/pca10056_s140_ble_debug/ses/secure_bootloader_ble_s140_pca10056_debug.emProject
    +++ b/secure_bootloader/pca10056_s140_ble_debug/ses/secure_bootloader_ble_s140_pca10056_debug.emProject
    @@ -15,27 +18,27 @@
           arm_simulator_memory_simulation_parameter="RWX 00000000,00100000,FFFFFFFF;RWX 20000000,00010000,CDCDCDCD"
           arm_target_device_name="nRF52840_xxAA"
           arm_target_interface_type="SWD"
    +      c_preprocessor_definitions="DEBUG;BLE_STACK_SUPPORT_REQD;BOARD_PCA10056;CONFIG_GPIO_AS_PINRESET;DEBUG_NRF;FLOAT_ABI_HARD;INITIALIZE_USER_SECTIONS;NO_VTOR_CONFIG;NRF52840_XXAA;NRF_DFU_DEBUG_VERSION;NRF_DFU_SETTINGS_VERSION=2;NRF_DFU_SVCI_ENABLED;NRF_SD_BLE_API_VERSION=7;S140;SOFTDEVICE_PRESENT;SVC_INTERFACE_CALL_AS_NORMAL_FUNCTION"
    -      c_preprocessor_definitions="BLE_STACK_SUPPORT_REQD;BOARD_PCA10056;CONFIG_GPIO_AS_PINRESET;DEBUG_NRF;FLOAT_ABI_HARD;INITIALIZE_USER_SECTIONS;NO_VTOR_CONFIG;NRF52840_XXAA;NRF_DFU_DEBUG_VERSION;NRF_DFU_SETTINGS_VERSION=2;NRF_DFU_SVCI_ENABLED;NRF_SD_BLE_API_VERSION=7;S140;SOFTDEVICE_PRESENT;SVC_INTERFACE_CALL_AS_NORMAL_FUNCTION;"
    @@ -63,6 +66,8 @@
           <file file_name="../../../../../components/libraries/ringbuf/nrf_ringbuf.c" />
           <file file_name="../../../../../components/libraries/experimental_section_vars/nrf_section_iter.c" />
           <file file_name="../../../../../components/libraries/strerror/nrf_strerror.c" />
    +      <file file_name="../../../../../components/libraries/util/app_error.c" />
    +      <file file_name="../../../../../components/libraries/util/app_error_handler_gcc.c" />

    Summary of changes:

    1. Exclude app_error_handler(), app_error_fault_handler, and app_error_handler_bare() in main.c if DEBUG flag is set.

    2. Add the app_error_handler_gcc.c and app_error.c source file to the project

    3. Define "DEBUG" in the list of pre-processor symbols:

  • 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.

Related