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

sd_softdevice_enable hardfault when I merge ble_app_blinky into blinky_rtc_freertos example

Hi There,

I facing one critical issue with softdevice, I cannot get it work in freertos environment.

Hardware: customized board based on PCA10056

SW: nRF5_SDK_15.2.0_9412b96

Change:

Merge ble_app_blinky example into blinky_rtc_freertos.

blinky_rtc_freertos_ble_added.zip

Problem:

when the program executed sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler) it will enter HardFault

  .thumb_func
  .weak   HardFault_Handler
HardFault_Handler:
  b     .

  • Hi.

    The first issue is that the SoftDevice is not added when you flash your device, so you try to enable the SoftDevice when there is no SoftDevice present, and you get the HardFault.

    The SoftDevice needs to be added in the Common Configuration in Options --> Select Loader --> and place the path to S140 v6.1.0, like this:

    Second issue is that the Section Placement Macros is not configured for the project to be using SoftDevice, this also has to be edited.

    You find the Section Placement Macros in the Common Configuration in Options --> Select Linker --> Edit Section Placement Macros to the following:

    FLASH_PH_START=0x0 
    FLASH_PH_SIZE=0x100000
    RAM_PH_START=0x20000000
    RAM_PH_SIZE=0x40000
    FLASH_START=0x26000
    FLASH_SIZE=0xda000
    RAM_START=0x200022e0
    RAM_SIZE=0x3dd20

    Like this:

    Hope this helps you, and a little tips: If you want to merge a peripheral example with a ble_peripheral example, its easiest to start from the ble_peripheral example. What i mean by start is that you use the ble_peripheral example as base and add the features you want from a peripheral example to the ble_peripheral example.

    Best regards.

    Andreas

  • Hi 

    I managed to flash the unit and able to detect the Nordic_Blinky using nRF Blinky app.  But when I try to discovering services (pair). The device enter app_error_weak and trigger NRF_BREAKPOINT_COND.

    blinky_rtc_freertos_ble_added.zip

    Kindly refer to the debug info below.

        F003FB93    bl 0x0002BD80 <nrfx_gpiote_in_event_enable>
    --- app_button.c -- 185 ------------------------------------
    {
    ASSERT(mp_buttons);
    uint32_t i;
    for (i = 0; i < m_button_count; i++)
        9B01        ldr r3, [sp, #4]
        3301        adds r3, #1
        9301        str r3, [sp, #4]
    --- app_button.c -- 189 ------------------------------------
    for (i = 0; i < m_button_count; i++)
        4B06        ldr r3, =0x20003984 <m_button_count>
        781B        ldrb r3, [r3]
        461A        mov r2, r3
        9B01        ldr r3, [sp, #4]
        429A        cmp r2, r3
        D8EC        bhi 0x00028646
    --- app_button.c -- 190 ------------------------------------
    {
    nrf_drv_gpiote_in_event_enable(mp_buttons[i].pin_no, true);
    }
    return NRF_SUCCESS;
        2300        movs r3, #0
    --- app_button.c -- 195 ------------------------------------
    }
        4618        mov r0, r3
        B003        add sp, sp, #12
        F85DFB04    pop.w {pc}
        BF00        nop
        3980        subs r1, #0x80
        2000        movs r0, #0
        20003984    .word 0x20003984
    --- app_button.c -- 196 ------------------------------------
    uint32_t app_button_disable(void)
    {
        B500        push {lr}
        B083        sub sp, sp, #12
    --- app_button.c -- 200 ------------------------------------
    ASSERT(mp_buttons);
    uint32_t i;
    for (i = 0; i < m_button_count; i++)
        2300        movs r3, #0
        9301        str r3, [sp, #4]
        E00B        b 0x000286A2
    --- app_button.c -- 204 ------------------------------------
    {
    nrf_drv_gpiote_in_event_disable(mp_buttons[i].pin_no);
        4B0D        ldr r3, =0x20003980 <mp_buttons>
        681A        ldr r2, [r3]
        9B01        ldr r3, [sp, #4]
        00DB        lsls r3, r3, #3
        4413        add r3, r2
        781B        ldrb r3, [r3]
        4618        mov r0, r3
        F003FBE6    bl 0x0002BE68 <nrfx_gpiote_in_event_disable>
    --- app_button.c -- 203 ------------------------------------
    for (i = 0; i < m_button_count; i++)
        9B01        ldr r3, [sp, #4]
        3301        adds r3, #1
        9301        str r3, [sp, #4]
    --- app_button.c -- 203 ------------------------------------
    for (i = 0; i < m_button_count; i++)
        4B08        ldr r3, =0x20003984 <m_button_count>
        781B        ldrb r3, [r3]
        461A        mov r2, r3
        9B01        ldr r3, [sp, #4]
        429A        cmp r2, r3
        D8ED        bhi 0x0002868A
    --- app_button.c -- 205 ------------------------------------
    nrf_drv_gpiote_in_event_disable(mp_buttons[i].pin_no);
    }
    // Make sure polling timer is not running.
    return app_timer_stop(m_detection_delay_timer_id);
        4B06        ldr r3, =0x20003988 <m_detection_delay_timer_id_data>
        4618        mov r0, r3
        F000F94B    bl 0x0002894C <app_timer_stop>
        4603        mov r3, r0
    --- app_button.c -- 210 ------------------------------------
    }
        4618        mov r0, r3
        B003        add sp, sp, #12
        F85DFB04    pop.w {pc}
        20003980    .word 0x20003980
        20003984    .word 0x20003984
        20003988    .word 0x20003988
    --- app_error.c -- 61 --------------------------------------
    * @param[in] line_num Line number where the handler is called.
    * @param[in] p_file_name Pointer to the file name.
    */
    void app_error_handler_bare(ret_code_t error_code)
    {
        B500        push {lr}
        B087        sub sp, sp, #28
        9001        str r0, [sp, #4]
    --- app_error.c -- 66 --------------------------------------
    error_info_t error_info =
        2300        movs r3, #0
        9303        str r3, [sp, #12]
        2300        movs r3, #0
        9304        str r3, [sp, #16]
        9B01        ldr r3, [sp, #4]
        9305        str r3, [sp, #20]
    --- app_error.c -- 69 --------------------------------------
    .p_file_name = NULL,
    .err_code = error_code,
    };
    app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info));
        AB03        add r3, sp, #12
        461A        mov r2, r3
        2100        movs r1, #0
        F2440001    movw r0, #0x4001
        F000F816    bl 0x00028718 <app_error_fault_handler>
    --- app_error.c -- 74 --------------------------------------
    UNUSED_VARIABLE(error_info);
    }
        BF00        nop
        B007        add sp, sp, #28
        F85DFB04    pop.w {pc}
    --- core_cm4.h -- 1787 -------------------------------------
    \brief System Reset
    \details Initiates a system reset request to reset the MCU.
    */
    __STATIC_INLINE void NVIC_SystemReset(void)
    {
        F3BF8F4F    dsb sy
    --- core_cm4.h -- 1792 -------------------------------------
    __DSB(); /* Ensure all outstanding memory accesses included
    buffered write are completed before reset */
    SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
        4905        ldr r1, =0xE000ED00
    --- core_cm4.h -- 1795 -------------------------------------
    (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
        4B05        ldr r3, =0xE000ED00
        68DB        ldr r3, [r3, #12]
        F40362E0    and r2, r3, #0x700
        4B04        ldr r3, =0x05FA0004
        4313        orrs r3, r2
    --- core_cm4.h -- 1794 -------------------------------------
    SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
        60CB        str r3, [r1, #12]
    --- cmsis_gcc.h -- 425 -------------------------------------
    It completes when all explicit memory accesses before this instruction complete.
    */
    __attribute__((always_inline)) __STATIC_INLINE void __DSB(void)
    {
    __ASM volatile ("dsb 0xF":::"memory");
        F3BF8F4F    dsb sy
    --- cmsis_gcc.h -- 375 -------------------------------------
    __ASM volatile ("nop");
        BF00        nop
    --- core_cm4.h -- 1797 -------------------------------------
    __DSB(); /* Ensure completion of memory access */
    for (;;) /* wait until reset */
    {
    __NOP();
        E7FD        b 0x0002870C
        E000ED00    .word 0xE000ED00
        05FA0004    .word 0x05FA0004
    --- app_error_weak.c -- 53 ---------------------------------
    * Function is implemented as weak so that it can be overwritten by custom application error handler
    * when needed.
    */
    __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
    {
        B500        push {lr}
        B085        sub sp, sp, #20
        9003        str r0, [sp, #12]
        9102        str r1, [sp, #8]
        9201        str r2, [sp, #4]
    --- cmsis_gcc.h -- 67 --------------------------------------
    Can only be executed in Privileged modes.
    */
    __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
    {
    __ASM volatile ("cpsid i" : : : "memory");
        B672        cpsid i
    --- app_error_weak.c -- 55 ---------------------------------
    */
    __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
    {
    __disable_irq();
    NRF_LOG_FINAL_FLUSH();
        F7FEFCCC    bl 0x000270C0 <nrf_log_panic>
        BF00        nop
    --- app_error_weak.c -- 59 ---------------------------------
    NRF_LOG_FINAL_FLUSH();
        F7FEFAF3    bl 0x00026D14 <nrf_log_frontend_dequeue>
        4603        mov r3, r0
        2B00        cmp r3, #0
        D1FA        bne 0x0002872A
    --- app_error_weak.c -- 60 ---------------------------------
    #ifndef DEBUG
    NRF_LOG_ERROR("Fatal error");
        4A11        ldr r2, =0x0002FC90 <m_nrf_log_app_logs_data_const>
        4B12        ldr r3, =0x0002FC50 <__crypto_data_load_end__>
        1AD3        subs r3, r2, r3
        08DB        lsrs r3, r3, #3
        041B        lsls r3, r3, #16
        F0430301    orr r3, r3, #1
        4910        ldr r1, =0x0002FDFC
        4618        mov r0, r3
        F7FEFAA3    bl 0x00026C90 <nrf_log_frontend_std_0>
    --- app_error_weak.c -- 96 ---------------------------------
    break;
    }
    #endif
    NRF_BREAKPOINT_COND;
        4B0F        ldr r3, =0xE000EDF0
        681B        ldr r3, [r3]
        F0030301    and r3, r3, #1
        2B00        cmp r3, #0
        D000        beq 0x00028758
    --- app_error_weak.c -- 100 --------------------------------
    NRF_BREAKPOINT_COND;
        BE00        bkpt #0

  • Hi Inghowe, 

    I am facing similar issue here. Could you please let me know the steps you followed to resolve the issue.

    I am having the ble_example project inside a freeRtos task. This is resulting in hardfault error during SVCALL. 

Related