nRF51822: extract line number and file name from app_error_fault_handler

Hello, guys!

We are using nRF51822 SoC with nRF5 SDK v12.3.0 and s130 SoftDevice. For the devices in the wild, we would like to implement the following health monitoring strategy:

  1. Detect when the fault events happen (e.g. HardFaults, App Error Faults, Watchdog reset),
  2. Store the info about the fault event
  3. Report the info about the fault event(s) to the app over the BLE link, once the connection is established.

Currently, we are not sure how to find the line_number and file_name that caused the AppErrorFault. As you have advised us in this thread, we store the fault identifier (id) as well as the info field of the instruction that caused the AppErrorFault.

My question is how can we get the line_number and file_name externally, once we know the values of id and info parameters? Is there any script or tool that can help us extract that information somehow?

For example, in the case of HardFaults, we can use addr2line tool of the arm compiler to find out more about which function/module is behind the p_stack_address->pc we extract from the HardFault_Handler(). Is there any similar approach in the case of AppErrorFault?

Thanks in advance for your time and efforts.

Sincerely,
Bojan.

Parents Reply Children
  • Hi, .

    We can extract the line number and file name locally by applying the code you shared with us.

    My question relates to the devices in the field. Imagine a scenario when some device restarts due to the app error fault. We are gonna:

    1. Get the id and info parameters with the app_error_fault_handler() and the device will restart.
    2. Once the device reboots and the BLE connection establishes, we are gonna transfer the id and info parameters to the Server.

    Now that we know the id and info parameters on the Server side, how we can figure out the line number and the file name of the app error that caused the restart?

    Regards,
    Bojan.

  • bojan said:
    Now that we know the id and info parameters on the Server side, how we can figure out the line number and the file name of the app error that caused the restart?

    Not sure I understand...You send the file_name and line the error occurred on to the other device, so you can read it there(?)

  • No.

    Every device in the field should catch the id and info parameters of the app error fault and send those two over BLE to the smartphone/Server.

    Then, on the Server side, I would like to somehow be able to get the line number and file name based on id and info parameters. Is that possible?

  • Hi,

    bojan said:
    Is that possible?

    No, info is just a pointer(RAM location) where you can find p_file_name and line_num stored. You need to "decode" it on-chip, and send file_name and line_num, instead of info.

Related