Bus Fault caused by write data to fds

I'm developing my application with nrf 52832 and nrf SDK v17.

I know NCS is more powerful. I'm currently learning how to use it.

But now.I still need my application with nrf SDK.

When I was running my application, I found that the peer_manager returned PM_EVT_CONN_SEC_SUCCEEDED while using fds to write the bond data.So my operations on the linked list led to a Bus fault.

I attempted to use the critical section protection to avoid this problem, but it seemed to have no effect.

My code is as follows:

ETCV.rar

I used the cmbacktrace tool in the code.

The analysis output is as follows:

00> Firmware name: nrf52832_xxaa, hardware version: V1.0.0, software version: V0.0.1
00> Fault on interrupt or bare metal(no OS) environment
00> ===== Thread stack information =====
00>   addr: 2000F020    data: 00000000
00>   addr: 2000F024    data: 2000F178
00>   addr: 2000F028    data: 00000000
00>   addr: 2000F02C    data: 00000000
00>   addr: 2000F030    data: 00000001
00>   addr: 2000F06C    data: 00000000
00>   addr: 2000F070    data: 00000000
00>   addr: 2000F074    data: 000313EF
00>   addr: 2000F078    data: 00000000
00>   addr: 2000F07C    data: 2000A534
00>   addr: 2000F080    data: 00061064
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00>   addr: 2000F0F0    data: 0007F020
00>   addr: 2000F0F4    data: 0000001D
00>   addr: 2000F0F8    data: 00000006
00>   addr: 2000F0FC    data: 0007F020
00>   addr: 2000F100    data: 00000000
00>   addr: 2000F104    data: 00000000
00>   addr: 2000F108    data: 0000000F
00>   addr: 2000F10C    data: 00000000
00>   addr: 2000F110    data: 2000F178
00>   addr: 2000F114    data: 00000000
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00>   addr: 2000F14C    data: 00000000
00>   addr: 2000F150    data: 00000000
00>   addr: 2000F154    data: 0002C6AF
00>   addr: 2000F158    data: 2000F178
00>   addr: 2000F15C    data: 0003C599
00>   addr: 2000F160    data: 2000F178
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00>   addr: 2000F1D0    data: 2000F1FC
00>   addr: 2000F1D4    data: 00029597
00>   addr: 2000F1D8    data: 00000000
00>   addr: 2000F1DC    data: 2000F1FC
00>   addr: 2000F1E0    data: 00040634
00>   addr: 2000F1E4    data: 00032877
00>   addr: 2000F1E8    data: 00000018
00>   addr: 2000F1EC    data: 0003E72C
00>   addr: 2000F1F0    data: 0003E714
00>   addr: 2000F1F4    data: 00040634
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00>   addr: 2000F22C    data: 20001E70
00>   addr: 2000F230    data: 00000001
00>   addr: 2000F234    data: 20000840
00>   addr: 2000F238    data: 20001D90
00>   addr: 2000F23C    data: 000166E9
00>   addr: 2000F240    data: 20001E70
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00>   addr: 2000F2A8    data: 2000F39C
00>   addr: 2000F2AC    data: 0000000D
00>   addr: 2000F2B0    data: 00000008
00>   addr: 2000F2B4    data: 00000011
00>   addr: 2000F2B8    data: 00000000
00>   addr: 2000F2BC    data: 00014483
00>   addr: 2000F2C0    data: 20001E70
00>   addr: 2000F2C4    data: 20001E48
00>   addr: 2000F2C8    data: 00000001
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00>   addr: 2000F324    data: 200004BC
00>   addr: 2000F328    data: 20002968
00>   addr: 2000F32C    data: 00014483
00>   addr: 2000F330    data: 00000000
00>   addr: 2000F334    data: 20001E7C
00>   addr: 2000F338    data: 20001E48
00>   addr: 2000F33C    data: 0001450B
00>   addr: 2000F340    data: 20002E0A
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00>   addr: 2000F390    data: 00000008
00>   addr: 2000F394    data: 000059F5
00>   addr: 2000F398    data: 20001E48
00>   addr: 2000F39C    data: 00000005
00>   addr: 2000F3A0    data: 00000009
00>   addr: 2000F3A4    data: 000105E7
00>   addr: 2000F3A8    data: 00000001
00>   addr: 2000F3AC    data: 00000000
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00> 
00>   addr: 2000F444    data: 21000000
00>   addr: 2000F448    data: 00000000
00>   addr: 2000F44C    data: 00026589
00> ====================================
00> =================== Registers information ====================
00>   R0 : 00000000  R1 : 20009B1C  R2 : FFFFFFFF  R3 : 00000081
00>   R12: 0000001B  LR : 000278B3  PC : 000278C8  PSR: 41000026
00> ==============================================================
00> VECTBL:0 mfsr:0 bfsr:536916996 ufsr:-65536 dfsr:0
00> 
00> Show more call stack info by run: addr2line -e nrf52832_xxaa.axf -a -f 000278c8 000278b2 00035b92 00036d1e 0003db54 000313ee 0003711e 0003dfe0 0002c83e 00036626 0002c88e 0002c6ae 0003c598 0002c86e 00034ae8 00028234

//addr2line
add_spi_queue
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\application\/w25q16.c:91
0x000278b2
add_spi_queue
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\application\/w25q16.c:88
0x00035b92
pm_evt_handler
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\/main.c:941
0x00036d1e
queue_start
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\libraries\fstorage\/nrf_fstorage_sd.c:310
0x0003db54
write
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\libraries\fstorage\/nrf_fstorage_sd.c:439
0x000313ee
nrf_fstorage_write
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\libraries\fstorage\/nrf_fstorage.c:149
0x0003711e
record_header_write_begin
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\libraries\fds\/fds.c:774
0x0003dfe0
write_execute
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\libraries\fds\/fds.c:1274
0x0002c83e
evt_send
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\ble\peer_manager\/peer_manager.c:93
0x00036626
pm_sm_evt_handler
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\ble\peer_manager\/peer_manager.c:260
0x0002c88e
evt_send
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\ble\peer_manager\/security_manager.c:114
0x0002c6ae
evt_forward
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\ble\peer_manager\/security_manager.c:461
0x0003c598
sm_smd_evt_handler
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\ble\peer_manager\/security_manager.c:482
0x0002c86e
evt_send
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\ble\peer_manager\/security_dispatcher.c:129
0x00034ae8
pairing_success_evt_send
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\ble\peer_manager\/security_dispatcher.c:503
0x00028234
auth_status_success_process
C:\蓝牙测试程序库\ETCV\examples\ble_peripheral\ble_app_hids_mouse\pca10040\s132\arm5_no_packs/..\..\..\..\..\..\components\ble\peer_manager\/security_dispatcher.c:580

I located the code that caused the problem at line 92 of the w25q16.c file by making line-by-line annotations.

Related