<?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>SPI transfer failure</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62466/spi-transfer-failure</link><description>Hi, 
 
 I have a strange issue on my device. 
 
 Once in a while, after turning on my device and connect it to the PC via NFC trigger, the device fails during writing to external flash via nrfx_spim_xfer . 
 The function nrfx_spim_xfer returns NRF_SUCCESS</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 22 Jul 2020 17:20:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62466/spi-transfer-failure" /><item><title>RE: SPI transfer failure</title><link>https://devzone.nordicsemi.com/thread/261253?ContentTypeID=1</link><pubDate>Wed, 22 Jul 2020 17:20:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:998891b6-4320-4399-a9c3-e7fff95595b9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;If you want to use it with the SPI example, you need to add the flashlog backend yourself. It is not used in that example.&lt;/p&gt;
&lt;p&gt;Add the following to the main.c file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#if NRF_LOG_BACKEND_FLASH_ENABLED
#if NRF_LOG_BACKEND_FLASHLOG_ENABLED
NRF_LOG_BACKEND_FLASHLOG_DEF(m_flash_log_backend);
#endif
#endif

#if NRF_LOG_BACKEND_FLASH_ENABLED
static void flashlog_init(void)
{
    ret_code_t ret;
    int32_t backend_id;

    NRF_LOG_INFO(&amp;quot;Initializing flashlog&amp;quot;);
    
    ret = nrf_log_backend_flash_init(&amp;amp;nrf_fstorage_sd);
    APP_ERROR_CHECK(ret);
#if NRF_LOG_BACKEND_FLASHLOG_ENABLED
    backend_id = nrf_log_backend_add(&amp;amp;m_flash_log_backend, NRF_LOG_SEVERITY_WARNING);
    APP_ERROR_CHECK_BOOL(backend_id &amp;gt;= 0);

    nrf_log_backend_enable(&amp;amp;m_flash_log_backend);
#endif
}
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And call the function from the main-function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#if NRF_LOG_BACKEND_FLASH_ENABLED
    flashlog_init();
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Enable the backend in your sdk_config.h file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//==========================================================
// &amp;lt;e&amp;gt; NRF_LOG_BACKEND_FLASH_ENABLED - nrf_log_backend_flash - Log flash backend
//==========================================================
#ifndef NRF_LOG_BACKEND_FLASH_ENABLED
#define NRF_LOG_BACKEND_FLASH_ENABLED 1
#endif
// &amp;lt;q&amp;gt; NRF_LOG_BACKEND_FLASH_CLI_CMDS  - Enable CLI commands for this module.
 

#ifndef NRF_LOG_BACKEND_FLASH_CLI_CMDS
#define NRF_LOG_BACKEND_FLASH_CLI_CMDS 0
#endif

// &amp;lt;e&amp;gt; NRF_LOG_BACKEND_FLASHLOG_ENABLED - Enable flashlog backend.
//==========================================================
#ifndef NRF_LOG_BACKEND_FLASHLOG_ENABLED
#define NRF_LOG_BACKEND_FLASHLOG_ENABLED 1
#endif
// &amp;lt;o&amp;gt; NRF_LOG_BACKEND_FLASHLOG_QUEUE_SIZE - Logger messages queue size. 
// &amp;lt;i&amp;gt; Queue holds log messages pending to be written to flash.
// &amp;lt;i&amp;gt; Note that the queue holds logger messages and thus the queue size determines
// &amp;lt;i&amp;gt; increasing the pool of logger messages (see log message pool configuration).

#ifndef NRF_LOG_BACKEND_FLASHLOG_QUEUE_SIZE
#define NRF_LOG_BACKEND_FLASHLOG_QUEUE_SIZE 8
#endif

// &amp;lt;/e&amp;gt;

// &amp;lt;e&amp;gt; NRF_LOG_BACKEND_CRASHLOG_ENABLED - Enable crashlog backend.
//==========================================================
#ifndef NRF_LOG_BACKEND_CRASHLOG_ENABLED
#define NRF_LOG_BACKEND_CRASHLOG_ENABLED 0
#endif
// &amp;lt;o&amp;gt; NRF_LOG_BACKEND_CRASHLOG_FIFO_SIZE - Number of log messages held to be flushed in panic. 
// &amp;lt;i&amp;gt; Crashlog FIFO always keeps a defined number of the most
// &amp;lt;i&amp;gt; recent logs (severity level is set on runtime).
// &amp;lt;i&amp;gt; Note that the FIFO holds logger messages and thus the FIFO size determines
// &amp;lt;i&amp;gt; increasing the pool of logger messages (see log message pool configuration).

#ifndef NRF_LOG_BACKEND_CRASHLOG_FIFO_SIZE
#define NRF_LOG_BACKEND_CRASHLOG_FIFO_SIZE 8
#endif

// &amp;lt;/e&amp;gt;

// &amp;lt;o&amp;gt; NRF_LOG_BACKEND_FLASH_SER_BUFFER_SIZE - Size of the buffer used for serialize log message. 
// &amp;lt;i&amp;gt; Message is trimmed if it is longer. It may happen in case of 
// &amp;lt;i&amp;gt; hexdump message. Buffer size must be multiple of 4.

#ifndef NRF_LOG_BACKEND_FLASH_SER_BUFFER_SIZE
#define NRF_LOG_BACKEND_FLASH_SER_BUFFER_SIZE 64
#endif

// &amp;lt;h&amp;gt; Flash log location - Configuration of flash area used for storing the logs.

//==========================================================
// &amp;lt;o&amp;gt; NRF_LOG_BACKEND_FLASH_START_PAGE - Starting page.  
// &amp;lt;i&amp;gt; If 0, then pages directly after the application are used.

#ifndef NRF_LOG_BACKEND_FLASH_START_PAGE
#define NRF_LOG_BACKEND_FLASH_START_PAGE 0
#endif

// &amp;lt;o&amp;gt; NRF_LOG_BACKEND_PAGES - Number of pages. 
#ifndef NRF_LOG_BACKEND_PAGES
#define NRF_LOG_BACKEND_PAGES 1
#endif

// &amp;lt;/h&amp;gt; 
//==========================================================

// &amp;lt;/e&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The flashlog only stores the address of the string in code-flash, to avoid duplicating long strings. To read the logs it is easiest to use the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__nrf__log__backend__flash.html#ga7fe718a650e593a5ef6f229b30487473"&gt;nrf_log_backend_flash_next_entry_get&lt;/a&gt;&amp;nbsp;function. You can have a look at how this function is used in the CLI example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI transfer failure</title><link>https://devzone.nordicsemi.com/thread/255383?ContentTypeID=1</link><pubDate>Wed, 17 Jun 2020 05:36:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af44563d-3dec-4329-8c6f-06a12013be8c</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure I understood correctly how to use that. Should I set any flag?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;After that - is that a command line I need to operate in order to see the logs?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI transfer failure</title><link>https://devzone.nordicsemi.com/thread/255199?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2020 09:28:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd8d0e18-5bcb-463b-b7e4-0e7f867c9615</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, the flashlog/crashlog will be stored in Non-Volatile Memory (flash) and is not removed until you explicitly remove it from flash (using the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__log__backend__flash.html#ga8a98eee6d90d90574a26ad0f308bbb65"&gt;provided API&lt;/a&gt; or erasing the flash pages). Note that flashlogs are dropped if the allocated flash area is full, as described in the previously linked documentation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI transfer failure</title><link>https://devzone.nordicsemi.com/thread/255193?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2020 09:15:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8373d4e7-6bb3-4500-84bb-6105d805da5d</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Can I use this in order to debug a failures from one or two days ago? After my device was already shut down?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI transfer failure</title><link>https://devzone.nordicsemi.com/thread/255191?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2020 09:08:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6caa25e-b214-487f-b7a8-7f0659b024d1</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;We do not have any examples of using only flashlog/crashlog, but it is used in the&amp;nbsp;&lt;a title="Command Line Interface (CLI) Example" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/cli_example.html?cp=7_1_4_6_7"&gt;Command Line Interface (CLI) Example&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI transfer failure</title><link>https://devzone.nordicsemi.com/thread/255188?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2020 09:04:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf9dcee6-6725-4e7e-a49e-0e55b241aa80</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t understand how to use that - do you have any example?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI transfer failure</title><link>https://devzone.nordicsemi.com/thread/255103?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2020 20:21:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ac216cc-fe12-4dce-8596-1898dca1ac87</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You can use the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_nrf_log.html#nrf_log_backend_flash"&gt;flashlog/crashlog backend&lt;/a&gt; for NRF_LOG.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI transfer failure</title><link>https://devzone.nordicsemi.com/thread/255101?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2020 19:52:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fc4402d-776a-4604-8bc1-0c688123ea66</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Do I have an option to save the file name and line number of an error? The problem is that it doesn&amp;#39;t happen often.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI transfer failure</title><link>https://devzone.nordicsemi.com/thread/254685?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2020 11:05:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73b3551c-7992-4364-81b0-2ea541538a8d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If the device resets, it is typically due to an error code. Have you debugged the code to see what is causing the error code, and what error code it is reporting?&lt;/p&gt;
&lt;p&gt;It is very hard to say anything specific without knowing the error, and/or looking into your code.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>