Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

SAFERTOS+BLE

I have been trying to make SAFERTOS based BLE example working on nRF52832 (PCA10040) similar to the one provided by Nordic SDK 17.1.0 at `examples\ble_peripheral\ble_app_hrs_freertos`

I had taken the SAFERTOS evaluation example as base and tried to enable BLE as shown in the freertos example. I had created SAFERTOS versions of files/code where FREERTOS functions were getting used (nrf_sdh_freertos.c, app_timer_freertos.c) and updated timer and task creation.

I also fixed the IAR settings to include softdevice and changed the icf to get correct ram and rom addresses and included preprocessor defined symbols.

However, I was still getting a hardfault during initialization of softdevice. The application code is giving error code `536899764 (0x200070B4) ` instead of success (0x0) from sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler).

As Nordic doesn't provide source for softdevice I am unable to debug this.

Can anyone help/point to right resources on what am I doing wrong or what should I check to fix this issue.

I would appreciate any help.

Thanks.

Parents
  • Hi Vidar

    Yes, I have the preprocessor `SOFTDEVICE_PRESENT` defined, also now I can't recover the development board even by using Programmer v4.6.2

    The board is now continuously printing


    <error> hardfault: HARD FAULT at 0x00031722
    <error> hardfault: R0: 0x00004001 R1: 0x00000000 R2: 0x200078A8 R3: 0x00000000
    <error> hardfault: R12: 0x00000000 LR: 0x0002E05D PSR: 0x21000000

    And when I try to program another example from sdk nRF5 v17.1.0, I am getting below error log, and it seems I cannot recover this board.

    10:30:13.816
    Recovering Application core
    10:30:13.816
    Recovering Application core 0%
    10:30:15.569
    Recovering Application core 100%
    10:30:15.570
    Recovering Application core completed
    10:30:15.570
    Loading core information for Application core
    10:30:15.571
    Loading core information for Application core 0%
    10:30:15.572
    Update files regions according to Application core
    10:30:15.572
    Parse memory regions for file
    10:30:15.572
    SoftDevice detected, id 0x101 (S132 v7.2.0)
    10:30:15.609
    Failed "loading core information for application core". Error: code: 1, description: Generic, message: Batch task core-info failed, Device error: Failed to read from memory address 0x10000130: Failed to write DebugPort register 0x08: Unknown Error in J-Link DLL (error code =-1)
    10:30:15.619
    Error: Failed with exit code 1. One or more batch tasks failed: * 1050373515: Device error: Failed to read from memory address 0x10000130: Failed to write DebugPort register 0x08: Unknown Error in J-Link DLL (error code =-1) (Generic) Message: Batch task core-info failed, Device error: Failed to read from memory address 0x10000130: Failed to write DebugPort register 0x08: Unknown Error in J-Link DLL (error code =-1).

    I would appreciate any help.
    Thanks.
  • Hello,

    The errors could indicate an unreliable connection between the debugger and the nRF52832. This can happen if the nRF is not properly powered. However, it is unusual to experience this on a development kit, and it doesn't make sense to me that you're able to both recover and load the firmware before the errors occur as the log shows.

    Please try programming the hex file from the command line using nrfutil device  (make sure it is up to date) to see if it makes any difference.

    nrfutil device recover
    nrfutil device program --firmware HEXFILE --options chip_erase_mode=ERASE_ALL,verify=VERIFY_READ,reset=RESET_SOFT

  • No worries. But are you not able to run or debug any of the BLE examples with your IAR setup? The softdevice function itself will not return a RAM address. Maybe you can post some screenshots showing the disassembly and CPU register view when stepping into and exiting the sd_softdevice_enable() function so I can try to look for clues for this behavior.

  • I did not face any issue with running freertos sample example from sdk, but when I ported the application to SAFERTOS I was facing error as seen in attached snapshot. 

    Also in the IAR, I have .intvec start @ 0x26000, ROM start @ 0x26000 end 0x7fffff and RAM start 0x2000986c and end as 0x2000ffff

  • Sorry, I misread your previous reply and thought you were seeing the same issue with the SDK example. Please try single stepping from the SVC instruction to confirm whether program execution reaches the corresponding SVCall in the SoftDevice. There is no debug info for the softdevice image, so you would need to rely on the PC to see if it's in the SD's memory range.

  • Thanks Vidar, Sorry to ask but could you elaborate more, what do you mean here?

  • Of course. The sd_* API functions trigger a SVC exception by executing the SVC instruction shown in the disassembly view (please refer to "Application programming interface" for more details). This is supposed to invoke the Supervisor Call handler inside the SoftDevice. But my current suspicion is that safertos is changing the interrupt forwarding and causing the SVC interrupt to be forwarded directly to the application instead. Hope this helps.

Reply Children
No Data
Related