<?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>write struct to flash</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74085/write-struct-to-flash</link><description>Hi guys, 
 I just want to ask you is it possible to write a struct into flash using sd_flash_write() function. I can successfully write and ready INT values, but the problem occurs when I want to write and read a structure. I have already tried to define</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 23 Apr 2021 07:30:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74085/write-struct-to-flash" /><item><title>RE: write struct to flash</title><link>https://devzone.nordicsemi.com/thread/306477?ContentTypeID=1</link><pubDate>Fri, 23 Apr 2021 07:30:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f473b18-8652-451a-93b2-ea2350fee2ae</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It&amp;#39;s perfectly fine to save a struct in flash. Regarding your choice to use the Softdevice API directly, this is not recommended, I strongly suggest that you use the flash manager instead.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write struct to flash</title><link>https://devzone.nordicsemi.com/thread/306160?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 14:33:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d290ff27-dc78-4141-b260-a996202cdb2f</guid><dc:creator>Aduka_27</dc:creator><description>&lt;p&gt;And also one extra question, my struct looks like this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;struct name1{

    (enum) enum1 enum_name;
    struct name2 xyz[2];
    int int_value;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is it possible to store it in the flash if it looks like this with&amp;nbsp;&lt;strong&gt;int, enum and another struct&amp;nbsp;&lt;/strong&gt;in itself?&lt;/p&gt;
&lt;p&gt;Br,&lt;/p&gt;
&lt;p&gt;Adnan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write struct to flash</title><link>https://devzone.nordicsemi.com/thread/306065?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 11:05:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19cc43fb-5f11-4adf-b8d0-e736623c93c7</guid><dc:creator>Aduka_27</dc:creator><description>&lt;p&gt;Is it possible to use softdevice APIs in Mesh, as I tried in my example:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Write function inside which I call sd_flash_page_erase that automatically goes inside sys callback function:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void write_Tasks(){

    if(flash_status != FLASH_IDLE){
    
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Flash is busy in status %d. Try again later! \n&amp;quot;, flash_status); 
        return 1;
    }else{
        
        uint32_t err_code = sd_flash_page_erase(pg_num_task);
        if (err_code != 0){
            
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Fatal error in task list erase function: err_code is %d \n&amp;quot;, err_code);
        }
        flash_status = LIST_WRITE; 
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This is the way how I use sd_flash_write function, but I think here is an issue:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if(flash_status == LIST_WRITE){
 
            uint32_t err_code = sd_flash_write(pointer_task, task_list, 12);
            nrf_delay_ms(100);
            if(err_code != 0){
            
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Fatal error in task list write function: err_code is %d \n&amp;quot;, err_code);
            }
            flash_status = LIST_FINISHED;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;And finally this is the way how I define a free space:&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint 32_t pg_size_task = NRF_FICR-&amp;gt;CODEPAGESIZE;
uint32_t pg_num_task = NRF_FICR-&amp;gt;CODESIZE-4;
struct TaskInstance *pointer_task = (struct TaskInstance *)(pg_size_task * pg_num_task);
&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Is it possible to finish my code in this way, keeping these functions? Thanks in advance!&lt;/p&gt;
&lt;p&gt;Br,&lt;/p&gt;
&lt;p&gt;Adnan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write struct to flash</title><link>https://devzone.nordicsemi.com/thread/306003?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 08:15:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d1645e6-bfc8-46a5-835a-6839b443e04e</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Indeed, if you use Mesh SDK then you should use the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v4.1.0%2Fmd_doc_user_guide_modules_flash_manager.html"&gt;flash manager&lt;/a&gt;&amp;nbsp;and the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v5.0.0/group__FLASH__MANAGER.html?cp=7_2_4_6_1_0"&gt;flash manager API&lt;/a&gt;.&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: write struct to flash</title><link>https://devzone.nordicsemi.com/thread/305821?ContentTypeID=1</link><pubDate>Tue, 20 Apr 2021 11:26:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:271ba339-5745-4d76-a4d6-79e6322a4538</guid><dc:creator>Aduka_27</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am using nRF Mesh SDK including softdevice. In that case, I am not sure is it possible to use the FDS module in the mesh part?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Br,&lt;/p&gt;
&lt;p&gt;Adnan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write struct to flash</title><link>https://devzone.nordicsemi.com/thread/305813?ContentTypeID=1</link><pubDate>Tue, 20 Apr 2021 11:13:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed4d91c4-3e97-42ec-88d9-5627758f9769</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Use the FDS module,&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/55153/using-fds-to-save-a-struct-structure-and-also-reading-it/223306#223306"&gt;See this case&lt;/a&gt;&amp;nbsp;on how.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>