<?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>Hard fault in Connection Parameter Update when changing ATT_MTU</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59498/hard-fault-in-connection-parameter-update-when-changing-att_mtu</link><description>Hi! 
 I started to modify the ble_app_blinky example. I need to increase ATT_MTU, so I modified NRF_SDH_BLE_GATT_MAX_MTU_SIZE. For this, I needed to increase the RAM of the softdevice. Now, the firmware is hard faults, exactly when FIRST_CONN_PARAMS_UPDATE_DELAY</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Mar 2020 13:41:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59498/hard-fault-in-connection-parameter-update-when-changing-att_mtu" /><item><title>RE: Hard fault in Connection Parameter Update when changing ATT_MTU</title><link>https://devzone.nordicsemi.com/thread/241859?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2020 13:41:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad0de835-ea1e-4f2f-817b-b8dba3934cdf</guid><dc:creator>Gergely Hollosi</dc:creator><description>&lt;p&gt;Okay, I have managed to solve the problem, but I think it is a BUG in the nRF SDK. I have used the scheduler, so the BLE Connection Parameter Update timer (the APP_TIMER) used the scheduler also.&lt;/p&gt;
&lt;p&gt;The main problem is the&amp;nbsp;interaction between APP_TIMER and APP_SCHEDULER. If we choose APP_SCHEDULER&amp;#39;s event size not mod 4 (i. e. 62, as I did), the APP_TIMER&amp;#39;s timeout_handler is not forced to fall on 32 bit boundary, see app_scheduler.c:&lt;/p&gt;
&lt;pre&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;app_sched_event_put&lt;/span&gt;(&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt;              &lt;/span&gt;*&lt;span&gt; &lt;/span&gt;&lt;span&gt;p_event_data&lt;/span&gt;,&lt;/pre&gt;
&lt;pre&gt;&lt;span&gt;                             &lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt;                  &lt;/span&gt;&lt;span&gt;event_data_size&lt;/span&gt;,&lt;/pre&gt;
&lt;pre&gt;&lt;span&gt;                             &lt;/span&gt;&lt;span&gt;app_sched_event_handler_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;handler&lt;/span&gt;)&lt;/pre&gt;
&lt;pre&gt;{&lt;br /&gt;...&lt;/pre&gt;
&lt;pre&gt;&lt;span&gt;memcpy&lt;/span&gt;(&amp;amp;&lt;span&gt;m_queue_event_data&lt;/span&gt;[&lt;span&gt;event_index&lt;/span&gt;&lt;span&gt; &lt;/span&gt;*&lt;span&gt; &lt;/span&gt;&lt;span&gt;m_queue_event_size&lt;/span&gt;],&lt;/pre&gt;
&lt;pre&gt;&lt;span&gt;                       &lt;/span&gt;&lt;span&gt;p_event_data&lt;/span&gt;,&lt;/pre&gt;
&lt;pre&gt;&lt;span&gt;                       &lt;/span&gt;&lt;span&gt;event_data_size&lt;/span&gt;);&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Of course, scheduler callbacks are properly aligned, however, app_timer callbacks stored in scheduler queues are not.&lt;/p&gt;
&lt;p&gt;The solution for the problem is using event_size multiple of 4 bytes (words). I would be pleased if the SDK would not allow using event_size in scheduler not multiple of 4 bytes!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard fault in Connection Parameter Update when changing ATT_MTU</title><link>https://devzone.nordicsemi.com/thread/241807?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2020 11:56:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcb3d11e-a325-4cea-b69a-e1c687c34ca4</guid><dc:creator>Gergely Hollosi</dc:creator><description>&lt;p&gt;I have some new information about the topic. When using -O3, compiler generates code as this:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;0002b850 &amp;lt;scheduled_timeout_handler&amp;gt;: &lt;br /&gt; &amp;nbsp;&amp;nbsp;2b850: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e9d0 3000 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ldrd &amp;nbsp;&amp;nbsp;&amp;nbsp;r3, r0, [r0] &lt;br /&gt; &amp;nbsp;&amp;nbsp;2b854: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4718 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bx &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r3 &lt;br /&gt; &amp;nbsp;&amp;nbsp;2b856: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bf00 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nop&lt;br /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The hard fault is at 2b850, having the issue:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;lt;error&amp;gt; hardfault: HARD FAULT at 0x0002B850 &lt;br /&gt;&amp;lt;error&amp;gt; hardfault: &amp;nbsp;&amp;nbsp;R0: &amp;nbsp;0x20003052 &amp;nbsp;R1: &amp;nbsp;0x00000008 &amp;nbsp;R2: &amp;nbsp;0x20002EC4 &amp;nbsp;R3: &amp;nbsp;0x0002B851 &lt;br /&gt;&amp;lt;error&amp;gt; hardfault: &amp;nbsp;&amp;nbsp;R12: 0x20002EEC &amp;nbsp;LR: &amp;nbsp;0x0002B7F3 &amp;nbsp;PSR: 0x810B0000 &lt;br /&gt;&amp;lt;error&amp;gt; hardfault: Cause: The processor has made an unaligned memory access.&lt;br /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Of course, R0 cannot be divided by 4 bytes, so unaligned access is present. However, I&amp;#39;m still searching for the solution.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>