HOW-TO debug Faulting Instruction Addresses

From chriesibaum wiki
Jump to navigation Jump to search

If you happen to stumble across something like this, no worries!

[00:00:00.075,000] <err> os: ***** BUS FAULT *****
[00:00:00.075,000] <err> os:   Precise data bus error
[00:00:00.075,000] <err> os:   BFAR Address: 0x0
[00:00:00.075,000] <err> os: r0/a1:  0x00000000  r1/a2:  0x00000018  r2/a3:  0x00000000
[00:00:00.075,000] <err> os: r3/a4:  0x00000000 r12/ip:  0x0000004b r14/lr:  0x08001cb9
[00:00:00.075,000] <err> os:  xpsr:  0x69000000
[00:00:00.075,000] <err> os: Faulting instruction address (r15/pc): 0x08002336
[00:00:00.075,000] <err> os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:00.075,000] <err> os: Current thread: 0x20005cd0 (main)
[00:00:01.614,000] <err> os: Halting system

Install or get the tool arm-none-eabi-addr2line

sudo aptitude install binutils-arm-none-eabi

Run the tool as follows. This will give you a filename and line number where the code caused the error.

arm-none-eabi-addr2line -e ./build/zephyr/zephyr.elf <Faulting instruction address (r15/pc): 0x########>

arm-none-eabi-addr2line -e ./build/zephyr/zephyr.elf 0x########

You can also check addr2line on the address in your link register (r14/lr):

arm-none-eabi-addr2line -e ./build/zephyr/zephyr.elf <r14/lr: 0x########>

arm-none-eabi-addr2line -e ./build/zephyr/zephyr.elf 0x########