<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Unaligned memory access Fault</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114910/unaligned-memory-access-fault</link><description>Hi, I am using LittleFS with some external flash. This works great on it&amp;#39;s own, but when part of our growing program it has started crashing with the &amp;quot;Unaligned memory access&amp;quot; fault. It was fine before our project grew in size. This may be a memory issue</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 30 Sep 2024 14:12:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114910/unaligned-memory-access-fault" /><item><title>RE: Unaligned memory access Fault</title><link>https://devzone.nordicsemi.com/thread/504389?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 14:12:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb3ff4db-2d4d-4faa-8251-442dc0375fcb</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you see this on all your boards, or on one specifically?&lt;/p&gt;
&lt;p&gt;If this happens on more than one board:&lt;/p&gt;
&lt;p&gt;Could you try to set a breakpoint in main, then when that has hit, a bp in &amp;quot;C:/ncs/v2.6.1/zephyr/kernel/mutex.c:57&amp;quot;, and then check the input memory to see if the variable is unaligned?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unaligned memory access Fault</title><link>https://devzone.nordicsemi.com/thread/503992?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2024 13:05:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:534827e9-955b-413e-a53a-fc59b0c51b20</guid><dc:creator>daThinkingOne</dc:creator><description>&lt;p&gt;Changing the t-exit-dpd to 30000 didn&amp;#39;t work.&amp;nbsp; Slowing the SPI speed didn&amp;#39;t work either.&amp;nbsp; The fault message keeps pointing to the same place in that mutex.c file.&amp;nbsp; Maybe I&amp;#39;ll try changing the mutex structure to be packed.&amp;nbsp; Somehow that var in the structure ends up being mis-aligned in the memory when compiling for size.&amp;nbsp; If I can&amp;#39;t solve this soon, I&amp;#39;ll just compile for speed from now on.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unaligned memory access Fault</title><link>https://devzone.nordicsemi.com/thread/503885?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2024 07:52:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6165610-3257-49af-8306-f17a536e5ede</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for sharing the files.&lt;/p&gt;
&lt;p&gt;Based on your DT file, it seems that you are using w25q32jv external flash. The t-exit-dpd parameter seems to be a bit short?&lt;/p&gt;
&lt;p&gt;As per the other declarations, it seems that 30 us (30000ns) is needed?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.6.99-ncs2/boards/circuitdojo/feather/circuitdojo_feather_nrf9160_common.dtsi#L170-L171"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.6.99-ncs2/boards/circuitdojo/feather/circuitdojo_feather_nrf9160_common.dtsi#L170-L171&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, could you try to reduce the SPI speed to for instance 1 MHz for testing purposes?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unaligned memory access Fault</title><link>https://devzone.nordicsemi.com/thread/503650?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2024 02:16:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb51aaa0-9170-41f6-aa4f-831c469588cc</guid><dc:creator>daThinkingOne</dc:creator><description>&lt;p&gt;Increasing the&amp;nbsp;&lt;span&gt;CONFIG_MAIN_STACK_SIZE from 4096 to 8192 didn&amp;#39;t work.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a title="zephyr.dts" href="https://www.dropbox.com/scl/fi/karrr6c63l7907xhy9hlp/zephyr.dts?rlkey=9nd03fmmxbuq9hheizxtihun3&amp;amp;st=cqupu032&amp;amp;dl=0"&gt;https://www.dropbox.com/scl/fi/karrr6c63l7907xhy9hlp/zephyr.dts?rlkey=9nd03fmmxbuq9hheizxtihun3&amp;amp;st=cqupu032&amp;amp;dl=0&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a title=".Config" href="https://www.dropbox.com/scl/fi/tjwo86kdzmkubkbwkfknk/.config?rlkey=nzfocrrd12e9r425m69joi2s7&amp;amp;st=p6kab7s5&amp;amp;dl=0"&gt;https://www.dropbox.com/scl/fi/tjwo86kdzmkubkbwkfknk/.config?rlkey=nzfocrrd12e9r425m69joi2s7&amp;amp;st=p6kab7s5&amp;amp;dl=0&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I can&amp;#39;t seem to find a partitions.yml&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unaligned memory access Fault</title><link>https://devzone.nordicsemi.com/thread/503580?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2024 12:31:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1557b5d1-fdb2-4be9-899f-5b42dff1ba3d</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Given that it fails only on one specific compiler optimization hints that this has to do with memory usage - could you try adjusting CONFIG_MAIN_STACK_SIZE higher just to ensure that this is not overflowing?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you also share the partitions.yml + zephyr.dts + .config file generated in your build folder?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unaligned memory access Fault</title><link>https://devzone.nordicsemi.com/thread/503482?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2024 02:33:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e92d480-fdbb-479a-80ee-9ef8f0dd622c</guid><dc:creator>daThinkingOne</dc:creator><description>&lt;p&gt;[00:00:00.603,668] &amp;lt;err&amp;gt; os: ***** USAGE FAULT *****&lt;br /&gt;[00:00:00.603,668] &amp;lt;err&amp;gt; os: Unaligned memory access&lt;br /&gt;[00:00:00.603,698] &amp;lt;err&amp;gt; os: r0/a1: 0x00000000 r1/a2: 0x00000001 r2/a3: 0x00000001&lt;br /&gt;[00:00:00.603,729] &amp;lt;err&amp;gt; os: r3/a4: 0x200009ce r12/ip: 0x00000000 r14/lr: 0x00016cad&lt;br /&gt;[00:00:00.603,729] &amp;lt;err&amp;gt; os: xpsr: 0x61000000&lt;br /&gt;[00:00:00.603,759] &amp;lt;err&amp;gt; os: s[ 0]: 0x200008bd s[ 1]: 0x00000001 s[ 2]: 0x2000420c s[ 3]: 0x20008db8&lt;br /&gt;[00:00:00.603,790] &amp;lt;err&amp;gt; os: s[ 4]: 0x00000004 s[ 5]: 0x0002f048 s[ 6]: 0x00000000 s[ 7]: 0x0001667f&lt;br /&gt;[00:00:00.603,790] &amp;lt;err&amp;gt; os: s[ 8]: 0x20001bf8 s[ 9]: 0x200008bd s[10]: 0x20008e40 s[11]: 0x20008e40&lt;br /&gt;[00:00:00.603,820] &amp;lt;err&amp;gt; os: s[12]: 0x000257e1 s[13]: 0x00000000 s[14]: 0x00000000 s[15]: 0x0001223d&lt;br /&gt;[00:00:00.603,820] &amp;lt;err&amp;gt; os: fpscr: 0x200040e8&lt;br /&gt;[00:00:00.603,851] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x0002e07a&lt;br /&gt;[00:00:00.603,881] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 31: Unknown error on CPU 0&lt;br /&gt;[00:00:00.603,912] &amp;lt;err&amp;gt; os: Current thread: 0x20003f18 (unknown)&lt;br /&gt;[00:00:01.047,760] &amp;lt;err&amp;gt; fatal_error: Resetting system&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;thread: 0x20003f18 = .bss.z_main_thread&lt;br /&gt;0x0000000020003f18 0xc8 zephyr/kernel/libkernel.a(init.c.obj)&lt;br /&gt;0x0000000020003f18 z_main_thread&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;(r15/pc): 0x0002e07a = C:/ncs/v2.6.1/zephyr/kernel/mutex.c:57&lt;br /&gt; mutex-&amp;gt;lock_count = 0U; //int z_impl_k_mutex_init(struct k_mutex *mutex)&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;(r14/lr): 0x00016cad = C:/ncs/v2.6.1/zephyr/subsys/fs/littlefs_fs.c:890&lt;br /&gt; fs_lock(fs); //static int littlefs_mount(struct fs_mount_t *mountp)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So it&amp;#39;s in the main thread.&amp;nbsp; Looks like setting the lock_count to 0U is not aligned to 32-bits?&amp;nbsp; Is there a way to align it?&amp;nbsp; Maybe a compiler switch?&lt;/p&gt;
&lt;p&gt;It looks like optimizing the build for speed or debug solves the problem. Optimizing for size gives the &amp;quot;unaligned memory access&amp;quot; fault. Is there another way around this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unaligned memory access Fault</title><link>https://devzone.nordicsemi.com/thread/503418?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2024 13:43:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fc9e59e-5649-4280-8892-50a5e8359f64</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]&lt;p&gt;addr2line = C:/ncs/v2.6.1/zephyr/kernel/mutex.c:57&lt;/p&gt;
&lt;p&gt;line 57 = mutex-&amp;gt;lock_count = 0U;&lt;/p&gt;
&lt;p&gt;variable&amp;nbsp;mutex is at 0x200009ce &amp;lt;flash_storage+240&amp;gt; while debugging.&lt;/p&gt;[/quote]
&lt;p&gt;Is this the resolved r15/PC value? What about the r14/LR content? This can tell you where you branched from.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In addition, you can check the build/zephyr/zephyr.map file and search for the current thread address (omit the 0x, ie. if&amp;nbsp;0x20005688 is listed as failing thread, then search for&amp;nbsp;20005688)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>