<?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>Writing to a flash when receiving data via BLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68371/writing-to-a-flash-when-receiving-data-via-ble</link><description>Good health to all! I am using Ble, I need to flash received packets. The best way to do this is using sd_flash_write (). In the sdk_config.h file, I see #define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 for nRF52 (and 1024 for nRF51). But where can I set the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 19 Nov 2020 00:45:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68371/writing-to-a-flash-when-receiving-data-via-ble" /><item><title>RE: Writing to a flash when receiving data via BLE</title><link>https://devzone.nordicsemi.com/thread/280727?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2020 00:45:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70f349cc-7e96-4151-9f5d-c0b5b00284e9</guid><dc:creator>Proton</dc:creator><description>&lt;p&gt;You probably don&amp;#39;t know how the nrf_nvmc_write_bytes () and nrf_nvmc_write_words () functions work. It would be strange if they performed the same function and both wrote down words. But nrf_nvmc_write_bytes () writes individual bytes. You can verify this by writing &amp;quot;1&amp;quot; in both functions and looking at the memory:&lt;br /&gt;&lt;span style="color:#993300;"&gt;nrf_nvmc_write_bytes (addr, massss, 1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#993300;"&gt;nrf_nvmc_write_words (addr + 40, massss, 1);&lt;/span&gt;&lt;br /&gt;So I can choose whether to write to me in bytes or in words. And it&amp;#39;s a pity that softdevice is not that advanced.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to a flash when receiving data via BLE</title><link>https://devzone.nordicsemi.com/thread/280611?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 13:03:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e14e2ef7-91cd-460a-b8b6-01f07e449b5a</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Proton,&amp;nbsp;&lt;br /&gt;No you don&amp;#39;t have an option to choose between bytes or words but 32bit word is the smallest unit you can write with the NVMC on the nRF52 anyway. Here is the spec:&amp;nbsp;&lt;br /&gt;&lt;em&gt;The NVMC is only able to write 0 to bits in the flash that are erased (set to 1). It cannot rewrite a bit back&lt;/em&gt;&lt;br /&gt;&lt;em&gt;to 1. Only full 32-bit words can be written to flash using the NVMC interface. To write less than 32 bits,&lt;/em&gt;&lt;br /&gt;&lt;em&gt;write the data as a full 32-bit word and set all the bits that should remain unchanged in the word to 1.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;Note that the restriction on the number of writes (nWRITE) still applies in this case&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t use fstorage, you don&amp;#39;t have to configure&amp;nbsp;&lt;span&gt;NRF_FSTORAGE_SD_MAX_WRITE_SIZE&amp;nbsp;and can use&amp;nbsp;sd_flash_write&amp;nbsp;() directly, but as it&amp;#39;s mentioned in the other case, we have a bug that if you write 1024 words in one call you may have an issue. Try to split it to two writes for example.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to a flash when receiving data via BLE</title><link>https://devzone.nordicsemi.com/thread/280599?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 12:28:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e7d5df1-df75-4ebc-9e00-ca3f72f54ad7</guid><dc:creator>Proton</dc:creator><description>&lt;p&gt;With the nrf_nvmc_write_bytes () and nrf_nvmc_write_words () functions, I have the right to choose whether to write in words or bytes. softdevice provides no choice?&lt;br /&gt;&lt;br /&gt;I do not use the FSTORAGE functions and the file system, I want to choose where to write bytes myself.&lt;br /&gt;&lt;br /&gt;NRF_FSTORAGE_SD_MAX_WRITE_SIZE will affect the sd_flash_write () write function too ??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to a flash when receiving data via BLE</title><link>https://devzone.nordicsemi.com/thread/280432?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 16:12:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:034311f2-ec4e-4f8d-90c8-e3d782922fd0</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Proton,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The size argument in&amp;nbsp;&lt;span&gt;sd_flash_write() is actually the number of words, not the number of bytes. So if you use&amp;nbsp;1024 it means it&amp;#39;s 4096 bytes.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;And we actually have an issue with a write with such size, have a look here:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/48830/softdevice-assertion-failed"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/48830/softdevice-assertion-failed&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I would suggest to keep the number of bytes writing in one chunk to shorter. In our DFU example we use&amp;nbsp;NRF_FSTORAGE_SD_MAX_WRITE_SIZE = 20&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Note that fstorage automatically split the data into multiple&amp;nbsp;chunks if the data is bigger than&amp;nbsp;&amp;nbsp;&lt;span&gt;NRF_FSTORAGE_SD_MAX_WRITE_SIZE&amp;nbsp;.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>