Unaligned memory access Fault

Hi, I am using LittleFS with some external flash.  This works great on it's own, but when part of our growing program it has started crashing with the "Unaligned memory access" fault.  It was fine before our project grew in size.  This may be a memory issue somewhere.  I am not sure how to locate the problem.

Here is the fault message:

[00:00:00.603,668] <err> os: ***** USAGE FAULT *****
[00:00:00.603,668] <err> os:   Unaligned memory access
[00:00:00.603,698] <err> os: r0/a1:  0x00000000  r1/a2:  0x00000001  r2/a3:  0x00000001
[00:00:00.603,698] <err> os: r3/a4:  0x200009ce r12/ip:  0x00000000 r14/lr:  0x00016cad
[00:00:00.603,729] <err> os:  xpsr:  0x61000000
[00:00:00.603,729] <err> os: s[ 0]:  0x200008bd  s[ 1]:  0x00000001  s[ 2]:  0x2000597c  s[ 3]:  0x2000a538
[00:00:00.603,790] <err> os: s[ 4]:  0x00000004  s[ 5]:  0x0002f048  s[ 6]:  0x00000000  s[ 7]:  0x0001667f
[00:00:00.603,790] <err> os: s[ 8]:  0x20001bf8  s[ 9]:  0x200008bd  s[10]:  0x2000a5c0  s[11]:  0x2000a5c0
[00:00:00.603,820] <err> os: s[12]:  0x000257e1  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x0001223d
[00:00:00.603,820] <err> os: fpscr:  0x20005858
[00:00:00.603,851] <err> os: Faulting instruction address (r15/pc): 0x0002e07a
[00:00:00.603,881] <err> os: >>> ZEPHYR FATAL ERROR 31: Unknown error on CPU 0
[00:00:00.603,912] <err> os: Current thread: 0x20005688 (unknown)
[00:00:01.046,905] <err> fatal_error: Resetting system
*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***

addr2line = C:/ncs/v2.6.1/zephyr/kernel/mutex.c:57

line 57 = mutex->lock_count = 0U;

variable mutex is at 0x200009ce <flash_storage+240> while debugging.

This happens while mounting the littlefs on the external flash chip

Some more info:

CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_LOG_BUFFER_SIZE=4000
I'm not sure where else to look next.  Any suggestions?
Parents Reply
  • Changing the t-exit-dpd to 30000 didn't work.  Slowing the SPI speed didn't work either.  The fault message keeps pointing to the same place in that mutex.c file.  Maybe I'll try changing the mutex structure to be packed.  Somehow that var in the structure ends up being mis-aligned in the memory when compiling for size.  If I can't solve this soon, I'll just compile for speed from now on.

Children
Related