<?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>Hardfault in freeRTOS MTU Exchange (MTU&amp;gt;=200)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35238/hardfault-in-freertos-mtu-exchange-mtu-200</link><description>I&amp;#39;m using the ble_app_grs_freertos example. I&amp;#39;m trying to maximize its thru-put potential for Central devices which can support the high data rates. For this I&amp;#39;ve used the follow GAP Setup parameters. 
 NRF_SDH_BLE_GAP_DATA_LENGTH 251 
 NRF_SDH_BLE_GAP_EVENT_LENGTH</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 04 Oct 2019 05:39:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35238/hardfault-in-freertos-mtu-exchange-mtu-200" /><item><title>RE: Hardfault in freeRTOS MTU Exchange (MTU&gt;=200)</title><link>https://devzone.nordicsemi.com/thread/213297?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2019 05:39:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2cf22ee1-5f20-4da9-95a6-9a8b1ec31c98</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Just figured that the issue with increasing the MTU size to 247 could be too little stack size when creating the Timer thread.&lt;/p&gt;
&lt;p&gt;Please look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/52048/ble_app_hrs_freertos-increassing-mtu-fatal-error"&gt;this &lt;/a&gt;thread for a possible workaround.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault in freeRTOS MTU Exchange (MTU&gt;=200)</title><link>https://devzone.nordicsemi.com/thread/187354?ContentTypeID=1</link><pubDate>Wed, 15 May 2019 16:56:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c41b92a1-a8fb-4625-bb18-58861b4e7011</guid><dc:creator>ilw</dc:creator><description>&lt;p&gt;I had the same symptoms/problem as Dave (i&amp;#39;m using v15.0 of the SDK) and i just thought i&amp;#39;d post to say that increasing the task stack depth/size&amp;nbsp;in&amp;nbsp;nrf_sdh_freertos.c from 256 to 512 solved the problem for me.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It looks like even the latest version (15.3) of the SDK still has a stack of 256.though, so i guess Dave&amp;#39;s problem must have been slightly different in some way...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault in freeRTOS MTU Exchange (MTU&gt;=200)</title><link>https://devzone.nordicsemi.com/thread/138605?ContentTypeID=1</link><pubDate>Mon, 02 Jul 2018 19:48:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61963c16-5101-45dc-b79e-b55b38d116d3</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Dave,&lt;/p&gt;
&lt;p&gt;Did you manage to solve this issue? Just curious to know what caused this if you already know the answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault in freeRTOS MTU Exchange (MTU&gt;=200)</title><link>https://devzone.nordicsemi.com/thread/136489?ContentTypeID=1</link><pubDate>Mon, 18 Jun 2018 07:56:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0001490e-893b-478d-84e1-166f8ec06028</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;nope, do i need to? but after reading your reply 5 days ago, seems that i missed to see that you are using GCC compiler, I tested with keil &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault in freeRTOS MTU Exchange (MTU&gt;=200)</title><link>https://devzone.nordicsemi.com/thread/136064?ContentTypeID=1</link><pubDate>Thu, 14 Jun 2018 07:34:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ef918b2-630d-4b9d-ba9b-c73675234721</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;did you change the nrf_ble_sdh_freertos&amp;nbsp; task size?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault in freeRTOS MTU Exchange (MTU&gt;=200)</title><link>https://devzone.nordicsemi.com/thread/136062?ContentTypeID=1</link><pubDate>Thu, 14 Jun 2018 07:30:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f795572c-1f1f-4d2e-9701-3eaedf833011</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;i did not get any hardfault .. when i changed those two macros.&amp;nbsp;I tested this on hrs freertos example on SDK15. what am i doing wrong(or right?)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault in freeRTOS MTU Exchange (MTU&gt;=200)</title><link>https://devzone.nordicsemi.com/thread/136004?ContentTypeID=1</link><pubDate>Wed, 13 Jun 2018 18:05:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72c1a312-3fad-436f-88a6-f222bcc5d7c1</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;I set the linker file to:&lt;/p&gt;
&lt;p&gt;RAM (rwx) :&amp;nbsp; ORIGIN = 0x20002d88, LENGTH = 0xC8E8&lt;/p&gt;
&lt;p&gt;After initializing the stack the ram_start shows I could reduce the App RAM start to 0x20002CC0&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also in FreeRTOSConfig.h&lt;/p&gt;
&lt;p&gt;configTOTAL_HEAP_SIZE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;( 28000 )&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault in freeRTOS MTU Exchange (MTU&gt;=200)</title><link>https://devzone.nordicsemi.com/thread/135831?ContentTypeID=1</link><pubDate>Wed, 13 Jun 2018 06:37:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d701a579-342e-4eb8-ac2e-f40287cf24e6</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I would have thought that this is FreeRTOS stack corruption, which is most likely too little stack size left for either app or freertos. How much RAM was left for the app overall?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault in freeRTOS MTU Exchange (MTU&gt;=200)</title><link>https://devzone.nordicsemi.com/thread/135434?ContentTypeID=1</link><pubDate>Sat, 09 Jun 2018 21:00:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f35fdd4-8f87-4982-81c0-f21e2c288663</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;I tried increasing the size of&amp;nbsp;NRF_BLE_FREERTOS_SDH_TASK_STACK to 4096&amp;nbsp; and even moved the definition of this to FreeRTOSConfig as it makes more sense to control it there.&amp;nbsp; However I still the same hardfault with the follow BLE settings:&lt;/p&gt;
&lt;p&gt;NRF_SDH_BLE_GAP_DATA_LENGTH 251&lt;/p&gt;
&lt;p&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH 6&lt;/p&gt;
&lt;p&gt;NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is there any guide for both setting these parameters and adjusting RAM allocation accordingly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault in freeRTOS MTU Exchange (MTU&gt;=200)</title><link>https://devzone.nordicsemi.com/thread/135422?ContentTypeID=1</link><pubDate>Sat, 09 Jun 2018 06:15:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bfcf365-0f5f-48d5-a46e-f9410aa8b509</guid><dc:creator>Austin</dc:creator><description>&lt;p&gt;This seems like a classic stack overflow symptom.&amp;nbsp; Try increasing the size of the FreeRTOS stack used to handle SoftDevice events in nrf_sdh_freertos.c.&lt;/p&gt;
&lt;p&gt;Events from the SoftDevice are polled in nrf_sdh_ble.c.&amp;nbsp; Each event is retrieved into a RAM buffer allocated on the stack prior to handling.&amp;nbsp; As you increase&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_GATT_MAX_MTU_SIZE, the size of the buffer on the stack required to receive events from the SoftDevice also increases.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The default NRF_BLE_FREERTOS_SDH_TASK_STACK size is 256, so as your MTU approaches that limit, the buffer required during event handling is likely spanning over the the allocated task stack, resulting in a stack overflow.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Although not always reliable, it&amp;#39;s probably a good idea to turn on stack overflow detection within FreeRTOS.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;It would be possible to add a compile time check in nrf_sdh_freertos.c which reports an error when the MTU is too large for the allocated stack.&amp;nbsp; The stack size needs to be larger than the MTU to allow for event handler function calls and their stack usage.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>