<?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 at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63559/hardfault-at-enabled-disabled-softdevice</link><description>I use SDK16 with softdevice. Some of its features require hard timings. But it causes hardfault sometimes. It happened at function of gcm_init. My source code is as follows. Does anyone know how to solve it? Please help me, thank you. 
 void ble_tt02_app_stop</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Oct 2022 12:16:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63559/hardfault-at-enabled-disabled-softdevice" /><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/392821?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2022 12:16:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ee64282-6b35-425a-94d0-90414996cc19</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you explain why you need to deactivate the stack in your case? While it is possible to do, it will often just lead to increased complexity in the code. Everything initialized in the Softdevice is reset when you disable it, so you have to start the BLE initialization over again when you want to re-enable BLE.&amp;nbsp;&lt;/p&gt;
[quote user="Beldramma"]It seems also that we should not call app_timer_init each time Stack is initialized,[/quote]
&lt;p&gt;The app timer module can safely remain initialized when you disable the Softdevice, but there may be timer instances that you will won&amp;#39;t to stop before doing so.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/392699?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2022 17:47:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed909a76-839b-4b29-b432-0842615e53d9</guid><dc:creator>Beldramma</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt; . &lt;/p&gt;
&lt;p&gt;It seems that I have something that works :&lt;/p&gt;
&lt;p&gt;When I want to activate Stack and BLE modules it is what I call:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void ble_init( void )
{
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();     
    advertising_init();
    conn_params_init();
#if SECURITY_MODE
    if( !peer_manager_enabled )
    {
        peer_manager_init();
        peer_manager_enabled = true;
    }
#endif
    
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When I have to deactivate the Stack, here is what I call:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t ble_deinit( void )
{
    ret_code_t err_code;
    err_code = ble_conn_params_stop();
    if( err_code != NRF_SUCCESS ) return err_code;
    advertising_stop();
    err_code = ble_stack_stop();
    return err_code;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Trick is to call peer_manager_init only at first boot, and not call it after.&lt;/p&gt;
&lt;p&gt;After disabling/enabling stack multiples times, I have tried connecting and pairing to my device ( Legacy connection with Passkey ), and there was apparently no problem.&lt;/p&gt;
&lt;p&gt;It seems also that we should not call app_timer_init each time Stack is initialized, because it will reset all timers. Also, when deactivating Stack, I activate LFClock to permit to my timers to continue to work.&lt;/p&gt;
&lt;p&gt;Even though it seems to work, I don&amp;#39;t know if the deactivation of the stack is really done properly, that&amp;#39;s why I asked for a tutorial to deactivate/reactivate the stack properly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/392632?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2022 13:04:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47c1a88d-3e22-48b6-a5d0-df9c082435ee</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/beldramma"&gt;Beldramma&lt;/a&gt; , please include details about your setup along with some screenshots of what you see when you try to debug this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/391499?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 15:27:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e172440-d698-4fe6-9f54-b591b84dd6b0</guid><dc:creator>Beldramma</dc:creator><description>&lt;p&gt;Hi ! I have this need too, are there some updates on this subject ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/261545?ContentTypeID=1</link><pubDate>Fri, 24 Jul 2020 09:23:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ef09217-4bb8-4ea1-a00b-5c5f0d0b7aba</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;I&amp;#39;m sorry I see that my previous answer wasn&amp;#39;t typed correctly. I meant to say could you try to NOT&amp;nbsp;&lt;span&gt;initialize it several times i.e just disable the softdevice by calling the&amp;nbsp;nrf_sdh_disable_request()?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/260476?ContentTypeID=1</link><pubDate>Fri, 17 Jul 2020 06:51:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a924950b-d676-494c-a729-eec279dca393</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;I use a timer interrupt to sample 9600 bps serial data. It isn&amp;#39;t UART data. Its synchronous data is 0x55, 0x55, 0x01,0x01. So it needs hard timing. The softdevice will make sample time not fixed if I don&amp;#39;t disable it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/260156?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 13:01:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec8d6d3e-48fa-4c06-8b6b-135687efcaf7</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;I don&amp;#39;t think the Peer manager module is designed to be re-initialized several times as it doesn&amp;#39;t have a API for doing this. However, could you try to initializing it several times i.e just disable the softdevice by calling the&amp;nbsp;nrf_sdh_disable_request().&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there a specific reason for why you would like to disable the Softdevice?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/260028?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 05:44:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:959b15a8-5d61-4bb4-870f-04b01e32dd12</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Calling&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;ble_conn_state_init() before calling peer_manager_init(); It will solve the problem. But it&amp;nbsp;has an app_fault issue at&amp;nbsp;pds_init() when I enable/disable softdevice 6 times. Can I change my code to the following? But at the function of&amp;nbsp;pm_init() also&amp;nbsp;calling the sub-functions of&amp;nbsp;pds_init(), pdb_init(), sm_init(), smd_init(), gcm_init() and gscm_init(). How to modified them? Do you have the example code of enable/disable softdevice? What is the correct method to enable/disable softdevice?&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;ret_code_t pds_init()&lt;br /&gt;{&lt;br /&gt;ret_code_t ret;&lt;br /&gt;// Check for re-initialization if debugging.&lt;br /&gt;//NRF_PM_DEBUG_CHECK(!m_module_initialized);&lt;br /&gt;if(m_module_initialized)&lt;br /&gt;return;&lt;br /&gt;ret = fds_register(fds_evt_handler);&lt;br /&gt;if (ret != NRF_SUCCESS)&lt;br /&gt;{&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/259917?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2020 13:01:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03b2f561-e8b0-4a68-86d3-45c975a9d604</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you try calling&amp;nbsp;&lt;span&gt;ble_conn_state_init() before you call peer_manager_init();&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/259593?ContentTypeID=1</link><pubDate>Mon, 13 Jul 2020 00:34:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f27b327-38ae-43b6-ab17-91d6212ff906</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;Hi Jared,&lt;/p&gt;
&lt;p&gt;I am not using FreeRTOS. The softdevice is s140_nrf52_7.0.1_softdevice.hex.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/259362?ContentTypeID=1</link><pubDate>Fri, 10 Jul 2020 08:23:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03074d0c-bf1d-43ee-8e4d-d7f09e1ef996</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank your the information from debugging. Which Softdevice and version are you using? And are you using FreeRTOS?&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/259290?ContentTypeID=1</link><pubDate>Fri, 10 Jul 2020 00:44:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0922dbf0-986b-4013-b892-b5bc5cb9da9b</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;After enabling/ disabling softdevice. It causes hardfault when I re-enable the softdevice at the third time. The member of&amp;nbsp;m_flag_service_changed_pending&amp;nbsp; is equal to&amp;nbsp;BLE_CONN_STATE_USER_FLAG_INVALID. So the function of gcm_init will&amp;nbsp;return NRF_ERROR_INTERNAL. And the program goes to&amp;nbsp;app_error_fault_handler. Do I need to clear connect state? And how to clear it correctly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault at Enabled/Disabled Softdevice</title><link>https://devzone.nordicsemi.com/thread/259219?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2020 13:53:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68061244-4355-48fa-b4f4-dac6f033c7b8</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you set a breakpoint in&amp;nbsp;&lt;span&gt;gcm_init() and see where it asserts inside the function?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Jared&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>