<?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>Implement flashlog backend</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/58111/implement-flashlog-backend</link><description>Hello, 
 I am working on an nRF52840 with S140SD chip. 
 I am currently using the RTT as a backend for logs. I tried adding the Flashlog backend in order to save the logs in non-volatile memory however it doesn&amp;#39;t appear to be saving them in the flash</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 11 Jun 2021 11:09:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/58111/implement-flashlog-backend" /><item><title>RE: Implement flashlog backend</title><link>https://devzone.nordicsemi.com/thread/314881?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2021 11:09:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27c379fc-e4cb-4f51-b6b1-dea44c3d5c77</guid><dc:creator>gilbertjuly</dc:creator><description>&lt;p&gt;Thank you, Vidar, that&amp;#39;s helpful.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implement flashlog backend</title><link>https://devzone.nordicsemi.com/thread/314853?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2021 08:39:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba4b565b-70a5-4110-9709-6a0fa1f68e82</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The log entry stored at address 0x52000 is referencing a text string stored at 0x0004e41c in this case. Remember that you can have multiple log entries referencing the same text string. This makes it so that you don&amp;#39;t have to write the same text string over and over again in flash.&lt;/p&gt;
&lt;p&gt;As an example, lets say you have periodic logging of some sensor value and the data is logged with this line of code:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_LOG_INFO( &amp;quot;sensor value :%d&amp;quot;, sensor_value)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here the string &amp;quot;sensor value :&amp;quot; will be stored at some other location in flash and only referenced with a pointer from the log entry. the&amp;nbsp; sensor value argument will be stored each time with the log data, because it isn&amp;#39;t a constant value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implement flashlog backend</title><link>https://devzone.nordicsemi.com/thread/314808?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2021 02:19:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96fccb7c-8670-4576-a55a-b41ec2055203</guid><dc:creator>gilbertjuly</dc:creator><description>&lt;p&gt;Vidar, I don&amp;#39;t understand... from the picture, the address to where log is stored is 0x0004e41c, how come 0x52000 is the log entry? Could you please explain more? Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implement flashlog backend</title><link>https://devzone.nordicsemi.com/thread/236269?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 13:32:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e46d35dc-3b0c-4ed7-9509-30b35c9f646d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;NRF_LOG_FLUSH() may&amp;nbsp;cause the program to hang if called from an&amp;nbsp;interrupt context as the asynchronous logger backends rely on various interrupts to come through to signal completion of a transfer (e.g., Softdevice use interrupt to notify the result of a flash operation to the app). Could that explain what happens here, or does the program&amp;nbsp;appear to continue after the log flush? &lt;span style="font-size:1.125rem;letter-spacing:0px;"&gt;Also, have you tried to not start advertising/scanning in case BLE activity is interfering with the flash operations (&lt;/span&gt;&lt;a style="font-size:1.125rem;letter-spacing:0px;" href="https://infocenter.nordicsemi.com/topic/sds_s132/SDS/s1xx/flash_mem_api/flash_mem_api.html?cp=4_5_2_0_7"&gt;flash scheduling with Softdevice&lt;/a&gt;&lt;span style="font-size:1.125rem;letter-spacing:0px;"&gt;)?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I have tried to replicate this here as well. I took the ble_app_hrs from SDK 16.0.0 and added the code you posted here. It&amp;#39;s attached below if you wish to compare it against yours.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-36a138310d6444eca12afe45d0d9f431/ble_5F00_app_5F00_hrs_5F00_w_5F00_flashlog.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_hrs_5F00_w_5F00_flashlog.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implement flashlog backend</title><link>https://devzone.nordicsemi.com/thread/236098?ContentTypeID=1</link><pubDate>Mon, 24 Feb 2020 23:06:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b327536c-68fd-46d2-8562-e0ea58c8a536</guid><dc:creator>corentind</dc:creator><description>&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;I added some logging to the nrf_fstorage_write(). It looks like it gets called the first time I do an NRF_LOG_FLUSH() but not after. If I try to read the flash I still get &amp;quot;Flash end reached&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implement flashlog backend</title><link>https://devzone.nordicsemi.com/thread/235910?ContentTypeID=1</link><pubDate>Mon, 24 Feb 2020 10:17:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:355a2d7a-e57c-4657-94f0-62de7c67d7e8</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The flash log area starts directly after the application (ie first page aligned address) when&amp;nbsp;NRF_LOG_BACKEND_FLASH_START_PAGE==0. But you can specify any fixed page address for&amp;nbsp;&lt;span&gt;NRF_LOG_BACKEND_FLASH_START_PAGE as long as it doesn&amp;#39;t overlap with something else.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Are you able to debug the code and check if nrf_fstorage_write() calls are being made in the nrf_log_backend_flash.c?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implement flashlog backend</title><link>https://devzone.nordicsemi.com/thread/235804?ContentTypeID=1</link><pubDate>Sat, 22 Feb 2020 00:40:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25040390-a2da-453b-87e8-089a349e4331</guid><dc:creator>corentind</dc:creator><description>&lt;p&gt;Thanks for the clarification regarding the format.&lt;/p&gt;
&lt;p&gt;I see the firmware including the strings being stored in the flash but I don&amp;#39;t think the logs are here.&lt;/p&gt;
&lt;p&gt;I have been using the following function to test the flash:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void test_flashlog()
{

    // Test log reader
    ret_code_t error_code;
    uint32_t token = 0;
    nrf_log_header_t * p_header = NULL;
    uint8_t * p_data = NULL;
    NRF_LOG_INFO(&amp;quot;Reading flash&amp;quot;);

    while(true)
    {
        error_code = nrf_log_backend_flash_next_entry_get(&amp;amp;token, &amp;amp;p_header, &amp;amp;p_data);
        if(error_code != NRF_SUCCESS)
        {
            if(error_code == NRF_ERROR_NOT_FOUND)
            {
                NRF_LOG_INFO(&amp;quot;Flash end reached&amp;quot;);
            }
            else
            {
                NRF_LOG_WARNING(&amp;quot;Read flash error code %d&amp;quot;, error_code);
        }
        break;
        }
        else
        {
            NRF_LOG_INFO(&amp;quot;Location %d&amp;quot;, token);
            NRF_LOG_INFO(&amp;quot;Read Data: %s&amp;quot;, p_data);
            log_entry_process(p_header, p_data);
        }
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It returns that the flash end was reached straightaway as if it was empty.&lt;/p&gt;
&lt;p&gt;I have a question -- Is the address where the logs are stored always at 0x52000? If not how to determine the address?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implement flashlog backend</title><link>https://devzone.nordicsemi.com/thread/235662?ContentTypeID=1</link><pubDate>Fri, 21 Feb 2020 09:39:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2cee412b-9990-4c02-9f1b-dd01e385c5ad</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Do you see anything stored in this flash page? The format of the log data might be different from what you expect - instead of storing log messages in cleartext we store it as serialized logger objects with pointers referencing&amp;nbsp;hardcoded messages inside the application image itself. This is to avoid duplication of log messages in flash.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-36a138310d6444eca12afe45d0d9f431/pastedimage1582277139774v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>