<?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>Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65583/nordic-nrf52840-usb-msc-file-corruption-issue</link><description>We found USB MSC File Corruption issue on nRF52840 SDK. It is 100% repeatable. 
 Below is the test method and result: 
 Test environment: 
 Platform: nRF52840 
 HW board used: PCA10056 
 SDK tested/used: SDK16.0 / SDK17.0 
 Example used: sdk16_0\examples</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 08 Feb 2021 21:17:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65583/nordic-nrf52840-usb-msc-file-corruption-issue" /><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/293436?ContentTypeID=1</link><pubDate>Mon, 08 Feb 2021 21:17:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a59278e6-5182-4660-967e-72786afe9fc8</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;Thanks a looooot Einar,&lt;/p&gt;
&lt;p&gt;I was facing a similar issue and this modification solved the problem!!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/278065?ContentTypeID=1</link><pubDate>Mon, 02 Nov 2020 12:53:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b0bc491-e441-4603-8c26-b101bcdbd5a8</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, there has been some progress.&amp;nbsp;We have found a bug in the QSPI backend where it does not handle all possible states when configured in writeback mode. This can be fixed by modifying nrf_block_dev_qspi.c from SDK 17.0.2 like this (same approach should also be valid for older SDK version):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0825.nrf_5F00_block_5F00_dev_5F00_qspi.c.diff"&gt;devzone.nordicsemi.com/.../0825.nrf_5F00_block_5F00_dev_5F00_qspi.c.diff&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;We have not been able to reproduce the file corruption issue with this patch applied.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/278039?ContentTypeID=1</link><pubDate>Mon, 02 Nov 2020 11:38:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64722559-cecd-48e4-89de-d4681ca36efe</guid><dc:creator>EMPConner562</dc:creator><description>&lt;p&gt;Just keeping the thread alive, and seeing if there&amp;#39;s been any progress at all&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/273905?ContentTypeID=1</link><pubDate>Fri, 09 Oct 2020 06:11:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:004d672f-326e-4801-8530-4e1aecabcb39</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This is still being actively looked into by the SDK team, but&amp;nbsp;we do not have any conclusions yet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/273662?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 08:34:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9639c7e5-6cee-4a75-88ad-3c62f04b7a5c</guid><dc:creator>EMPConner562</dc:creator><description>&lt;p&gt;Has there been any update with the team working on this?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/270383?ContentTypeID=1</link><pubDate>Fri, 18 Sep 2020 16:17:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c434e365-73e3-4dd7-abb9-32034d380c81</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Ah, yes. That makes sense. I will test and forward to the team working on this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/270199?ContentTypeID=1</link><pubDate>Fri, 18 Sep 2020 01:48:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80552963-7130-4c78-8655-03eb8eb82698</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry, the repeat method was wrong, I have corrected it. Please see below.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(1)&lt;strong&gt;Press button 3&lt;/strong&gt;, format the disk, and create two folders, which name&amp;nbsp;&amp;quot;Active&amp;quot; and &amp;quot;Totals&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(2)Press button 1, write a test1.txt in the folder&amp;nbsp;&amp;quot;Active&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(3)Press button 2.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(3-1)verify&amp;nbsp;test1.txt.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(3-2)creat&amp;nbsp;test2.txt in&amp;nbsp;the&amp;nbsp;folder&amp;nbsp;&amp;quot;Totals&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(3-3)verify&amp;nbsp;test1.txt again.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The project file(IDE: IAR 8.32.4&amp;nbsp;)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/usbd_5F00_msc_5F00_test.zip"&gt;devzone.nordicsemi.com/.../usbd_5F00_msc_5F00_test.zip&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/270040?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 10:38:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe001456-73c7-4a00-9372-9a33adff730a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am not getting the same behaviour as you when looking at the log. Pressing button 2 after button 1 gives a whole lot of Error reading file (see last part of log):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;...
[00:00:00.000,000] &amp;lt;info&amp;gt; app: 
Error reading file
[00:00:00.000,000] &amp;lt;info&amp;gt; app: 
Error reading file
[00:00:00.000,000] &amp;lt;info&amp;gt; app: 
Error reading file
[00:00:00.000,000] &amp;lt;info&amp;gt; app: 
Error reading file
[00:00:00.000,000] &amp;lt;info&amp;gt; app: 
#2Unable to close file: 9
[00:00:00.000,000] &amp;lt;info&amp;gt; app: Test2 Done#2
[00:00:00.000,000] &amp;lt;info&amp;gt; app: creating /Activi/test1.txt
[00:00:00.000,000] &amp;lt;info&amp;gt; app: 
#1Unable to open file: 13
[00:00:00.000,000] &amp;lt;info&amp;gt; app: 
#1Unable to close file: 9
[00:00:00.000,000] &amp;lt;info&amp;gt; app: Test1 Done
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Can you upload the exact project you are using including modified SDK files in case there are any differences, so that I can test the exact same configuration? Which toolchain/IDE are you using, and which version of it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/269978?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 04:13:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d03fe276-2830-4e0b-99cf-160a2b3bc5f5</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi Einar, I would like to share my finding on this issue. I have found out the line of code&amp;nbsp;that causes this bug with&amp;nbsp;&lt;span&gt;&lt;strong&gt;writeback is enabled&lt;/strong&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The bug is due to &amp;quot;block_dev_qspi_write_req()-&amp;gt;block_dev_qspi_write_start()-&amp;gt;nrf_drv_qspi_write()&amp;quot;,&amp;nbsp;after the file is created.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As I am not fully understanding the block device driver, so I have no idea to fix it.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Below is the repeat method.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(1)Press button 3, format the disk and create two folders, which name&amp;nbsp;&amp;quot;Active&amp;quot; and &amp;quot;Totals&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(2)Press button 1, write a test1.txt in the folder&amp;nbsp;&amp;quot;Active&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(3)Press button 2.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(3-1)verify&amp;nbsp;test1.txt.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(3-2)creat&amp;nbsp;test2.txt in&amp;nbsp;the&amp;nbsp;folder&amp;nbsp;&amp;quot;Totals&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(3-3)verify&amp;nbsp;test1.txt again.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;According to the test.log(line 419), you can see the&amp;nbsp;test1.txt was corrupted after&amp;nbsp;test2.txt was created.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and&amp;nbsp;the serial number of the corrupted&amp;nbsp;block is&amp;nbsp;136.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Why block 136 was&amp;nbsp;corrupted? Please find the line 365 of&amp;nbsp;&amp;nbsp;test.log, you can see there was an additional operation after creating test2.txt, writing 512 bytes into block 136. But according to line 241 of test.log, the&amp;nbsp;block 136 belongs to the&amp;nbsp;test1.txt. So the test1.txt was&amp;nbsp;corrupted after&amp;nbsp;creating&amp;nbsp;test2.txt.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;We also can see the same&amp;nbsp;operation&amp;nbsp;after creating&amp;nbsp;test1.txt, please find the line 191&amp;nbsp;of test.log.&amp;quot;src:20004804, blk_size:512, dst:D000, block:104&amp;quot;. But luckily, block 104&amp;nbsp;&lt;span class="tran highlight"&gt;happens to&lt;/span&gt; &lt;span class="tran"&gt;be part of&amp;nbsp;test1.txt, it was erased before data writing. Please see line 197 &amp;quot;00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:D000 block:104, id:13&amp;quot;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span class="tran"&gt;test.log&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span class="tran"&gt;&lt;pre class="ui-code" data-mode="text"&gt;00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: 
00&amp;gt; 
00&amp;gt; Creating filesystem...
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 63 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: src:20004804, blk_size:512, dst:3000, block:24
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 64 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: src:20004804, blk_size:512, dst:B000, block:88
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 65 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 66 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 67 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 68 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 69 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 70 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 72 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:8000 block:64, id:8
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 73 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 74 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 75 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 76 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 77 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 78 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 79 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 81 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 82 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 83 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 84 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 85 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 86 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 87 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; 20000530
00&amp;gt; 
00&amp;gt; 000, block:112
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 89 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 90 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 91 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 92 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 93 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 94 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 96 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: src:20004804, blk_size:512, dst:F000, block:120
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 97 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 98 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 99 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 100 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 101 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 102 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 103 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt;  20000530
00&amp;gt; 
00&amp;gt; 0000, block:128
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 105 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 106 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 107 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 0 size 1(x512) from 20000530
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: src:20004804, blk_size:512, dst:11000, block:136
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Mounting volume...
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 0 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 63 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Done
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: FIT_directoryInit:2
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Activi
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 76 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 64 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 64 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: src:20004804, blk_size:512, dst:4000, block:32
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 108 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:8000 block:64, id:8
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 109 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 110 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 111 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 76 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 76 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:D000 block:104, id:13
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:9000 block:72, id:9
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Totals
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 64 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 64 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: src:20004804, blk_size:512, dst:D000, block:104
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 112 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:8000 block:64, id:8
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 113 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 114 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 115 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 76 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 76 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:E000 block:112, id:14
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:9000 block:72, id:9
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: 
00&amp;gt; 
00&amp;gt; Listing directory: /
00&amp;gt; 
00&amp;gt;    &amp;lt;DIR&amp;gt;   ACTIVI
00&amp;gt; 
00&amp;gt;    &amp;lt;DIR&amp;gt;   TOTALS
00&amp;gt; 
00&amp;gt; Entries count: 3
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: creating /Activi/test1.txt
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 108 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 108 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: src:20004804, blk_size:512, dst:D000, block:104
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 64 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 116 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:D000 block:104, id:13
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 117 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 118 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 119 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 120 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: src:20004804, blk_size:512, dst:12000, block:144
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 121 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 122 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 123 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 124 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 125 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 126 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 127 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt;  20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:F000 block:120, id:15
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 129 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 130 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 131 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 132 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 133 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 134 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 135 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 136 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; 
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 137 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 138 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 139 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 140 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 141 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 142 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 143 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 144 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:11000 block:136, id:17
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 145 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 146 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 147 size 1(x512) from 20004B78
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 64 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:12000 block:144, id:18
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 108 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 108 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:8000 block:64, id:8
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:D000 block:104, id:13
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Test1 Done
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify /Activi/test1.txt before creating /Totals/test2.txt
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 76 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 108 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 116 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 117 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 118 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 119 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 64 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 120 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 121 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 122 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 123 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 124 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 125 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 126 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 127 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 128 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 129 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 130 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 131 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 132 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 133 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 134 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 135 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 136 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 137 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 138 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 139 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 140 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 141 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 142 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 143 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 144 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 145 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 146 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 147 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Test2 Done#0
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: creating /Totals/test2.txt
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 76 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 112 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Write block 112 size 1(x512) from 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: src:20004804, blk_size:512, dst:11000, block:136
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: erase:addr:E000 block:112, id:14
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Test2 Done#1
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify /Activi/test1.txt after creating /Totals/test2.txt
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 76 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 108 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 116 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 117 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 118 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 119 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 64 size 1(x512) to 20000324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 120 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 121 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 122 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 123 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 124 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 125 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 126 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 127 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 128 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 129 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 130 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 131 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 132 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 133 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 134 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 135 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 136 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1280
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1281
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1282
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1283
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1284
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1285
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1286
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1287
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1288
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1300
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1301
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1302
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1303
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1304
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1305
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1322
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1323
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1324
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1325
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1326
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1327
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: verify error:i=1328
00&amp;gt; 
00&amp;gt; 12) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 138 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 139 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 140 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 141 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 142 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 143 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 144 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 145 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 146 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Read req from block 147 size 1(x512) to 20004B60
00&amp;gt; 
00&amp;gt; [00:00:00.000,000] &amp;lt;info&amp;gt; app: Test2 Done#2
00&amp;gt; &lt;/pre&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Below is the source code which I modified&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;main.c&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;inttypes.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_block_dev.h&amp;quot;
#include &amp;quot;nrf_block_dev_ram.h&amp;quot;
#include &amp;quot;nrf_block_dev_empty.h&amp;quot;
#include &amp;quot;nrf_block_dev_qspi.h&amp;quot;
#include &amp;quot;nrf_block_dev_sdc.h&amp;quot;
#include &amp;quot;nrf_drv_usbd.h&amp;quot;
#include &amp;quot;nrf_drv_clock.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_atomic.h&amp;quot;
#include &amp;quot;nrf_drv_power.h&amp;quot;

#include &amp;quot;ff.h&amp;quot;
#include &amp;quot;diskio_blkdev.h&amp;quot;

#include &amp;quot;app_usbd.h&amp;quot;
#include &amp;quot;app_usbd_core.h&amp;quot;
#include &amp;quot;app_usbd_string_desc.h&amp;quot;
#include &amp;quot;app_usbd_msc.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;

#include &amp;quot;bsp.h&amp;quot;


#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

/**@file
 * @defgroup usbd_msc_example main.c
 * @{
 * @ingroup usbd_msc_example
 * @brief USBD MSC example
 *
 */

#define LED_USB_RESUME   (BSP_BOARD_LED_0)
#define LED_USB_START    (BSP_BOARD_LED_1)

#define BTN_RANDOM_FILE  0
#define BTN_LIST_DIR     1
#define BTN_MKFS         2

#define KEY_EV_RANDOM_FILE_MSK (1U &amp;lt;&amp;lt; BTN_RANDOM_FILE)
#define KEY_EV_LIST_DIR_MSK    (1U &amp;lt;&amp;lt; BTN_LIST_DIR   )
#define KEY_EV_MKFS_MSK        (1U &amp;lt;&amp;lt; BTN_MKFS       )

/**
 * @brief Enable power USB detection
 *
 * Configure if example supports USB port connection
 */
#ifndef USBD_POWER_DETECTION
#define USBD_POWER_DETECTION true
#endif

/**
 * @brief SD card enable/disable
 */
#define USE_SD_CARD       0

/**
 * @brief FatFS for QPSI enable/disable
 */
#define USE_FATFS_QSPI    1

/**
 * @brief Mass storage class user event handler
 */
static void msc_user_ev_handler(app_usbd_class_inst_t const * p_inst,
                                app_usbd_msc_user_event_t     event);


/**
 * @brief Ram block device size
 *
 * @note Windows fails to format volumes smaller than 190KB
 */
#define RAM_BLOCK_DEVICE_SIZE (380 * 512)

/**
 * @brief  RAM block device work buffer
 */
static uint8_t m_block_dev_ram_buff[RAM_BLOCK_DEVICE_SIZE];

/**
 * @brief  RAM block device definition
 */
NRF_BLOCK_DEV_RAM_DEFINE(
    m_block_dev_ram,
    NRF_BLOCK_DEV_RAM_CONFIG(512, m_block_dev_ram_buff, sizeof(m_block_dev_ram_buff)),
    NFR_BLOCK_DEV_INFO_CONFIG(&amp;quot;Nordic&amp;quot;, &amp;quot;RAM&amp;quot;, &amp;quot;1.00&amp;quot;)
);


/**
 * @brief Empty block device definition
 */
NRF_BLOCK_DEV_EMPTY_DEFINE(
    m_block_dev_empty,
    NRF_BLOCK_DEV_EMPTY_CONFIG(512, 1024 * 1024),
    NFR_BLOCK_DEV_INFO_CONFIG(&amp;quot;Nordic&amp;quot;, &amp;quot;EMPTY&amp;quot;, &amp;quot;1.00&amp;quot;)
);


/**
 * @brief  QSPI block device definition
 */
NRF_BLOCK_DEV_QSPI_DEFINE(
    m_block_dev_qspi,
    NRF_BLOCK_DEV_QSPI_CONFIG(
        512,
        NRF_BLOCK_DEV_QSPI_FLAG_CACHE_WRITEBACK,
        NRF_DRV_QSPI_DEFAULT_CONFIG
     ),
     NFR_BLOCK_DEV_INFO_CONFIG(&amp;quot;Nordic&amp;quot;, &amp;quot;QSPI&amp;quot;, &amp;quot;1.00&amp;quot;)
);

#if USE_SD_CARD

#define SDC_SCK_PIN     (27)        ///&amp;lt; SDC serial clock (SCK) pin.
#define SDC_MOSI_PIN    (26)        ///&amp;lt; SDC serial data in (DI) pin.
#define SDC_MISO_PIN    (2)         ///&amp;lt; SDC serial data out (DO) pin.
#define SDC_CS_PIN      (32 + 15)   ///&amp;lt; SDC chip select (CS) pin.

/**
 * @brief  SDC block device definition
 */
NRF_BLOCK_DEV_SDC_DEFINE(
    m_block_dev_sdc,
    NRF_BLOCK_DEV_SDC_CONFIG(
        SDC_SECTOR_SIZE,
        APP_SDCARD_CONFIG(SDC_MOSI_PIN, SDC_MISO_PIN, SDC_SCK_PIN, SDC_CS_PIN)
     ),
     NFR_BLOCK_DEV_INFO_CONFIG(&amp;quot;Nordic&amp;quot;, &amp;quot;SDC&amp;quot;, &amp;quot;1.00&amp;quot;)
);


/**
 * @brief Block devices list passed to @ref APP_USBD_MSC_GLOBAL_DEF
 */
#define BLOCKDEV_LIST() (                                   \
    NRF_BLOCKDEV_BASE_ADDR(m_block_dev_ram, block_dev),     \
    NRF_BLOCKDEV_BASE_ADDR(m_block_dev_empty, block_dev),   \
    NRF_BLOCKDEV_BASE_ADDR(m_block_dev_qspi, block_dev),    \
    NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev)      \
)

#else
#define BLOCKDEV_LIST() (                                   \
    NRF_BLOCKDEV_BASE_ADDR(m_block_dev_qspi, block_dev)     \
)
#endif

/**
 * @brief Endpoint list passed to @ref APP_USBD_MSC_GLOBAL_DEF
 */
#define ENDPOINT_LIST() APP_USBD_MSC_ENDPOINT_LIST(1, 1)

/**
 * @brief Mass storage class work buffer size
 */
#define MSC_WORKBUFFER_SIZE (1024)

/*lint -save -e26 -e64 -e123 -e505 -e651*/
/**
 * @brief Mass storage class instance
 */
APP_USBD_MSC_GLOBAL_DEF(m_app_msc,
                        0,
                        msc_user_ev_handler,
                        ENDPOINT_LIST(),
                        BLOCKDEV_LIST(),
                        MSC_WORKBUFFER_SIZE);

/*lint -restore*/

/**
 * @brief Events from keys
 */
static nrf_atomic_u32_t m_key_events;

/**
 * @brief  USB connection status
 */
static bool m_usb_connected = false;


#if USE_FATFS_QSPI

static FATFS m_filesystem;

static bool fatfs_init(void)
{
    FRESULT ff_result;
    DSTATUS disk_state = STA_NOINIT;

    memset(&amp;amp;m_filesystem, 0, sizeof(FATFS));

    // Initialize FATFS disk I/O interface by providing the block device.
    static diskio_blkdev_t drives[] =
    {
        DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_qspi, block_dev), NULL)
    };

    diskio_blockdev_register(drives, ARRAY_SIZE(drives));

    NRF_LOG_INFO(&amp;quot;Initializing disk 0 (QSPI)...&amp;quot;);
    disk_state = disk_initialize(0);
    if (disk_state)
    {
        NRF_LOG_ERROR(&amp;quot;Disk initialization failed.&amp;quot;);
        return false;
    }

    NRF_LOG_INFO(&amp;quot;Mounting volume...&amp;quot;);
    ff_result = f_mount(&amp;amp;m_filesystem, &amp;quot;&amp;quot;, 1);
    if (ff_result != FR_OK)
    {
        if (ff_result == FR_NO_FILESYSTEM)
        {
            NRF_LOG_ERROR(&amp;quot;Mount failed. Filesystem not found. Please format device.&amp;quot;);
        }
        else
        {
            NRF_LOG_ERROR(&amp;quot;Mount failed: %u&amp;quot;, ff_result);
        }
        return false;
    }

    return true;
}

static void fatfs_mkfs(void)
{
    FRESULT ff_result;

    if (m_usb_connected)
    {
        NRF_LOG_ERROR(&amp;quot;Unable to operate on filesystem while USB is connected&amp;quot;);
        return;
    }

    NRF_LOG_INFO(&amp;quot;\r\nCreating filesystem...&amp;quot;);
    static uint8_t buf[512];
    ff_result = f_mkfs(&amp;quot;&amp;quot;, FM_FAT, 2048, buf, sizeof(buf));
    if (ff_result != FR_OK)
    {
        NRF_LOG_ERROR(&amp;quot;Mkfs failed.&amp;quot;);
        return;
    }

    NRF_LOG_INFO(&amp;quot;Mounting volume...&amp;quot;);
    ff_result = f_mount(&amp;amp;m_filesystem, &amp;quot;&amp;quot;, 1);
    if (ff_result != FR_OK)
    {
        NRF_LOG_ERROR(&amp;quot;Mount failed.&amp;quot;);
        return;
    }

    NRF_LOG_INFO(&amp;quot;Done&amp;quot;);
}

static void fatfs_ls(void)
{
    DIR dir;
    FRESULT ff_result;
    FILINFO fno;

    if (m_usb_connected)
    {
        NRF_LOG_ERROR(&amp;quot;Unable to operate on filesystem while USB is connected&amp;quot;);
        return;
    }

    NRF_LOG_INFO(&amp;quot;\r\nListing directory: /&amp;quot;);
    ff_result = f_opendir(&amp;amp;dir, &amp;quot;/&amp;quot;);
    if (ff_result != FR_OK)
    {
        NRF_LOG_ERROR(&amp;quot;Directory listing failed: %u&amp;quot;, ff_result);
        return;
    }

    uint32_t entries_count = 0;
    do
    {
        ff_result = f_readdir(&amp;amp;dir, &amp;amp;fno);
        if (ff_result != FR_OK)
        {
            NRF_LOG_ERROR(&amp;quot;Directory read failed: %u&amp;quot;, ff_result);
            return;
        }

        if (fno.fname[0])
        {
            if (fno.fattrib &amp;amp; AM_DIR)
            {
                NRF_LOG_RAW_INFO(&amp;quot;   &amp;lt;DIR&amp;gt;   %s\r\n&amp;quot;,(uint32_t)fno.fname);
            }
            else
            {
                NRF_LOG_RAW_INFO(&amp;quot;%9lu  %s\r\n&amp;quot;, fno.fsize, (uint32_t)fno.fname);
            }
        }

        ++entries_count;
        NRF_LOG_FLUSH();
    } while (fno.fname[0]);


    NRF_LOG_RAW_INFO(&amp;quot;Entries count: %u\r\n&amp;quot;, entries_count);
}

static void fatfs_file_create(void)
{
    FRESULT ff_result;
    FIL file;
    char filename[16];

    if (m_usb_connected)
    {
        NRF_LOG_ERROR(&amp;quot;Unable to operate on filesystem while USB is connected&amp;quot;);
        return;
    }

    (void)snprintf(filename, sizeof(filename), &amp;quot;%08x.txt&amp;quot;, rand());

    NRF_LOG_RAW_INFO(&amp;quot;Creating random file: %s ...&amp;quot;, (uint32_t)filename);
    NRF_LOG_FLUSH();

    ff_result = f_open(&amp;amp;file, filename, FA_CREATE_ALWAYS | FA_WRITE);
    if (ff_result != FR_OK)
    {
        NRF_LOG_ERROR(&amp;quot;\r\nUnable to open or create file: %u&amp;quot;, ff_result);
        NRF_LOG_FLUSH();
        return;
    }

    ff_result = f_close(&amp;amp;file);
    if (ff_result != FR_OK)
    {
        NRF_LOG_ERROR(&amp;quot;\r\nUnable to close file: %u&amp;quot;, ff_result);
        NRF_LOG_FLUSH();
        return;
    }
    NRF_LOG_RAW_INFO(&amp;quot;done\r\n&amp;quot;);
}

static void fatfs_uninit(void)
{
    NRF_LOG_INFO(&amp;quot;Un-initializing disk 0 (QSPI)...&amp;quot;);
    UNUSED_RETURN_VALUE(disk_uninitialize(0));
}
#else //USE_FATFS_QSPI
#define fatfs_init()        false
#define fatfs_mkfs()        do { } while (0)
#define fatfs_ls()          do { } while (0)
#define fatfs_file_create() do { } while (0)
#define fatfs_uninit()      do { } while (0)
#endif

/**
 * @brief Class specific event handler.
 *
 * @param p_inst    Class instance.
 * @param event     Class specific event.
 */
static void msc_user_ev_handler(app_usbd_class_inst_t const * p_inst,
                                app_usbd_msc_user_event_t     event)
{
    UNUSED_PARAMETER(p_inst);
    UNUSED_PARAMETER(event);
}

/**
 * @brief USBD library specific event handler.
 *
 * @param event     USBD library event.
 */
static void usbd_user_ev_handler(app_usbd_event_type_t event)
{
    switch (event)
    {
        case APP_USBD_EVT_DRV_SUSPEND:
            bsp_board_led_off(LED_USB_RESUME);
            break;
        case APP_USBD_EVT_DRV_RESUME:
            bsp_board_led_on(LED_USB_RESUME);
            break;
        case APP_USBD_EVT_STARTED:
            bsp_board_led_on(LED_USB_START);
            break;
        case APP_USBD_EVT_STOPPED:
            UNUSED_RETURN_VALUE(fatfs_init());
            app_usbd_disable();
            bsp_board_leds_off();
            break;
        case APP_USBD_EVT_POWER_DETECTED:
            NRF_LOG_INFO(&amp;quot;USB power detected&amp;quot;);

            if (!nrf_drv_usbd_is_enabled())
            {
                fatfs_uninit();
                app_usbd_enable();
            }
            break;
        case APP_USBD_EVT_POWER_REMOVED:
            NRF_LOG_INFO(&amp;quot;USB power removed&amp;quot;);
            app_usbd_stop();
            m_usb_connected = false;
            break;
        case APP_USBD_EVT_POWER_READY:
            NRF_LOG_INFO(&amp;quot;USB ready&amp;quot;);
            app_usbd_start();
            m_usb_connected = true;
            break;
        default:
            break;
    }
}

static void bsp_event_callback(bsp_event_t ev)
{
    switch (ev)
    {
        /* Just set a flag to be processed in the main loop */
        case CONCAT_2(BSP_EVENT_KEY_, BTN_RANDOM_FILE):
            UNUSED_RETURN_VALUE(nrf_atomic_u32_or(&amp;amp;m_key_events, KEY_EV_RANDOM_FILE_MSK));
            break;

        case CONCAT_2(BSP_EVENT_KEY_, BTN_LIST_DIR):
            UNUSED_RETURN_VALUE(nrf_atomic_u32_or(&amp;amp;m_key_events, KEY_EV_LIST_DIR_MSK));
            break;

        case CONCAT_2(BSP_EVENT_KEY_, BTN_MKFS):
            UNUSED_RETURN_VALUE(nrf_atomic_u32_or(&amp;amp;m_key_events, KEY_EV_MKFS_MSK));
            break;

        default:
            return; // no implementation needed
    }
}



const char *fitDirList[] = {
    &amp;quot;Activi&amp;quot;, &amp;quot;Totals&amp;quot;, /*&amp;quot;Tracks&amp;quot;, &amp;quot;Workout&amp;quot;,*/
};
int32_t FIT_directoryInit(void) {
    FRESULT ff_result;
    int32_t ret = 0;
    uint32_t dirNum = sizeof(fitDirList) / sizeof(char *);
    NRF_LOG_INFO(&amp;quot;FIT_directoryInit:%d&amp;quot;, dirNum);
    for (uint32_t i = 0; i &amp;lt; dirNum; i++) {
		NRF_LOG_INFO(&amp;quot;%s&amp;quot;, fitDirList[i]);
        ff_result = f_mkdir(fitDirList[i]);
        if (!((ff_result == FR_OK) || (ff_result == FR_EXIST))) {
            NRF_LOG_INFO(&amp;quot;mkdir %s fail&amp;quot;, fitDirList[i]);
            ret = -1;
        }
    }
    return ret;
}
void Test1(void) {
    FRESULT ff_result = FR_OK;
    FIL file1;
    uint32_t num;
    char buf[] = &amp;quot;123456\r\n&amp;quot;;
	NRF_LOG_INFO(&amp;quot;creating /Activi/test1.txt&amp;quot;);
    ff_result = f_open(&amp;amp;file1, &amp;quot;/Activi/test1.txt&amp;quot;, FA_CREATE_ALWAYS | FA_WRITE);
	if (ff_result != FR_OK) {
		NRF_LOG_INFO(&amp;quot;\r\n#1Unable to open file: %u&amp;quot;, ff_result);
    }
    for (uint32_t i = 0; i &amp;lt; (2048); i++) {
        f_write(&amp;amp;file1, buf, strlen(buf), &amp;amp;num);
    }

    ff_result = f_close(&amp;amp;file1);
    if (ff_result != FR_OK) {
		NRF_LOG_INFO(&amp;quot;\r\n#1Unable to close file: %u&amp;quot;, ff_result);
    }
	NRF_LOG_INFO(&amp;quot;Test1 Done&amp;quot;);
}
void Test2(void) {
    FRESULT ff_result = FR_OK;
    FIL file2;
    uint32_t num;
	uint8_t buf[9];
	uint32_t byte_read;
	uint32_t i=0;
#if 1
	NRF_LOG_INFO(&amp;quot;verify /Activi/test1.txt before creating /Totals/test2.txt&amp;quot;);
	ff_result = f_open(&amp;amp;file2, &amp;quot;/Activi/test1.txt&amp;quot;, FA_READ);
	for(i=0; i&amp;lt;2048; i++)
	{
		if (f_read(&amp;amp;file2, buf, 8U, &amp;amp;byte_read) != FR_OK) 
		{        
			NRF_LOG_INFO(&amp;quot;\r\nError reading file&amp;quot;);           
		}
		else
		{
			buf[8] = 0;
			if(strcmp(buf,&amp;quot;123456\r\n&amp;quot;))
			{
				NRF_LOG_INFO(&amp;quot;verify error:i=%d&amp;quot;,i);	
				NRF_LOG_FLUSH();
			}
			
		}
	}
	ff_result = f_close(&amp;amp;file2);
    if (ff_result != FR_OK) {
		NRF_LOG_INFO(&amp;quot;#2Unable to close file: %u&amp;quot;, ff_result);
    }
	NRF_LOG_INFO(&amp;quot;Test2 Done#0&amp;quot;);
#endif
	NRF_LOG_INFO(&amp;quot;creating /Totals/test2.txt&amp;quot;);
    ff_result = f_open(&amp;amp;file2, &amp;quot;/Totals/test2.txt&amp;quot;, FA_CREATE_ALWAYS | FA_WRITE);
	if (ff_result != FR_OK) {
		NRF_LOG_INFO(&amp;quot;#2Unable to open file: %u&amp;quot;, ff_result);
    }

    //f_write(&amp;amp;file2, &amp;quot;abcd\r\n&amp;quot;, 6, &amp;amp;num);

    ff_result = f_close(&amp;amp;file2);
    if (ff_result != FR_OK) {
		NRF_LOG_INFO(&amp;quot;\r\n#2Unable to close file: %u&amp;quot;, ff_result);
    }
	NRF_LOG_INFO(&amp;quot;Test2 Done#1&amp;quot;);
	
#if 1
	NRF_LOG_INFO(&amp;quot;verify /Activi/test1.txt after creating /Totals/test2.txt&amp;quot;);
	ff_result = f_open(&amp;amp;file2, &amp;quot;/Activi/test1.txt&amp;quot;, FA_READ);
	for(i=0; i&amp;lt;2048; i++)
	{
		if (f_read(&amp;amp;file2, buf, 8U, &amp;amp;byte_read) != FR_OK) 
		{        
			NRF_LOG_INFO(&amp;quot;\r\nError reading file&amp;quot;);           
		}
		else
		{
			buf[8] = 0;
			if(strcmp(buf,&amp;quot;123456\r\n&amp;quot;))
			{
				NRF_LOG_INFO(&amp;quot;verify error:i=%d&amp;quot;,i);	
				NRF_LOG_FLUSH();
			}
			
		}
	}
	ff_result = f_close(&amp;amp;file2);
    if (ff_result != FR_OK) {
		NRF_LOG_INFO(&amp;quot;\r\n#2Unable to close file: %u&amp;quot;, ff_result);
    }
	NRF_LOG_INFO(&amp;quot;Test2 Done#2&amp;quot;);
#endif	
}
int main(void)
{
    ret_code_t ret;
    static const app_usbd_config_t usbd_config = {
        .ev_state_proc = usbd_user_ev_handler
    };

    ret = NRF_LOG_INIT(app_usbd_sof_timestamp_get);
    APP_ERROR_CHECK(ret);
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    ret = nrf_drv_clock_init();
    APP_ERROR_CHECK(ret);

    /* Fill whole RAM block device buffer */
    for (size_t i = 0; i &amp;lt; sizeof(m_block_dev_ram_buff); ++i)
    {
        m_block_dev_ram_buff[i] = i;
    }

    /* Configure LEDs and buttons */
    nrf_drv_clock_lfclk_request(NULL);
    ret = app_timer_init();
    APP_ERROR_CHECK(ret);
    ret = bsp_init(BSP_INIT_BUTTONS, bsp_event_callback);
    APP_ERROR_CHECK(ret);
    bsp_board_init(BSP_INIT_LEDS);

    if (fatfs_init())
    {
        fatfs_ls();
    }

    ret = app_usbd_init(&amp;amp;usbd_config);
    APP_ERROR_CHECK(ret);

    app_usbd_class_inst_t const * class_inst_msc = app_usbd_msc_class_inst_get(&amp;amp;m_app_msc);
    ret = app_usbd_class_append(class_inst_msc);
    APP_ERROR_CHECK(ret);

    NRF_LOG_INFO(&amp;quot;USBD MSC example started.&amp;quot;);

    if (USBD_POWER_DETECTION)
    {
        ret = app_usbd_power_events_enable();
        APP_ERROR_CHECK(ret);
    }
    else
    {
        NRF_LOG_INFO(&amp;quot;No USB power detection enabled\r\nStarting USB now&amp;quot;);

        app_usbd_enable();
        app_usbd_start();
        m_usb_connected = true;
    }

    while (true)
    {
        while (app_usbd_event_queue_process())
        {
            /* Nothing to do */
        }

        /* Process BSP key events flags.*/
        uint32_t events = nrf_atomic_u32_fetch_store(&amp;amp;m_key_events, 0);
        if (events &amp;amp; KEY_EV_RANDOM_FILE_MSK)
        {
            Test1();
        }

        if (events &amp;amp; KEY_EV_LIST_DIR_MSK)
        {
            Test2();
        }

        if (events &amp;amp; KEY_EV_MKFS_MSK)
        {
            fatfs_mkfs();
			FIT_directoryInit();
            fatfs_ls();
        }

        UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
        /* Sleep CPU only if there was no interrupt since last loop processing */
        __WFE();
    }
}

/** @} */
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;nrf_block_dev_qspi.c&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
#include &amp;quot;sdk_common.h&amp;quot;
#if NRF_MODULE_ENABLED(NRF_BLOCK_DEV_QSPI)
#include &amp;quot;nrf_serial_flash_params.h&amp;quot;
#include &amp;quot;nrf_block_dev_qspi.h&amp;quot;
#include &amp;lt;inttypes.h&amp;gt;

/**@file
 *
 * @ingroup nrf_block_dev_qspi
 * @{
 *
 * @brief This module implements block device API. It should be used as a reference block device.
 */

#if NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED
#define NRF_LOG_LEVEL       NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL
#define NRF_LOG_INFO_COLOR  NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR
#define NRF_LOG_DEBUG_COLOR NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR
#else
#define NRF_LOG_LEVEL       0
#endif
#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;

#define QSPI_STD_CMD_WRSR    0x01   /**&amp;lt; Write status register command*/
#define QSPI_STD_CMD_RSTEN   0x66   /**&amp;lt; Reset enable command*/
#define QSPI_STD_CMD_RST     0x99   /**&amp;lt; Reset command*/
#define QSPI_STD_CMD_READ_ID 0x9F   /**&amp;lt; Read ID command*/

#define BD_PAGE_PROGRAM_SIZE 256    /**&amp;lt; Page program size (minimum block size)*/

#define BD_ERASE_UNIT_INVALID_ID   0xFFFFFFFF /**&amp;lt; Invalid erase unit number*/
#define BD_ERASE_UNIT_ERASE_VAL    0xFFFFFFFF /**&amp;lt; Erased memory value*/

/**
 * @brief Block to erase unit translation
 *
 * @param blk_id    Block index
 * @param blk_size  Block size
 * */
#define BD_BLOCK_TO_ERASEUNIT(blk_id, blk_size)   \
    ((blk_id) * (blk_size)) / (NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE)

/**
 * @brief Blocks per erase unit
 *
 * @param blk_size  Block size
 * */
#define BD_BLOCKS_PER_ERASEUNIT(blk_size)         \
    (NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE / (blk_size))


static ret_code_t block_dev_qspi_eunit_write(nrf_block_dev_qspi_t const * p_qspi_dev,
                                             nrf_block_req_t * p_blk_left);


static void block_dev_qspi_read_from_eunit(nrf_block_dev_qspi_t const * p_qspi_dev)
{
    nrf_block_dev_qspi_work_t const * p_work = p_qspi_dev-&amp;gt;p_work;

    /*In write-back mode data that we read might not be the same as in erase unit buffer*/
    uint32_t eunit_start = BD_BLOCK_TO_ERASEUNIT(p_work-&amp;gt;req.blk_id,
                                                 p_work-&amp;gt;geometry.blk_size);

    uint32_t eunit_end = BD_BLOCK_TO_ERASEUNIT(p_work-&amp;gt;req.blk_id + p_work-&amp;gt;req.blk_count,
                                               p_work-&amp;gt;geometry.blk_size);

    if ((eunit_start &amp;gt; p_work-&amp;gt;erase_unit_idx) || (eunit_end &amp;lt; p_work-&amp;gt;erase_unit_idx))
    {
        /*Do nothing. Read request doesn&amp;#39;t hit current cached erase unit*/
        return;
    }

    /*Case 1: Copy data from start erase unit*/
    if (eunit_start == p_work-&amp;gt;erase_unit_idx)
    {
         size_t blk = p_work-&amp;gt;req.blk_id %
                      BD_BLOCKS_PER_ERASEUNIT(p_work-&amp;gt;geometry.blk_size);
         size_t cnt = BD_BLOCKS_PER_ERASEUNIT(p_work-&amp;gt;geometry.blk_size) - blk;
         size_t off = p_work-&amp;gt;geometry.blk_size * blk;

         if (cnt &amp;gt; p_work-&amp;gt;req.blk_count)
         {
             cnt = p_work-&amp;gt;req.blk_count;
         }

         memcpy(p_work-&amp;gt;req.p_buff,
                p_work-&amp;gt;p_erase_unit_buff + off,
                cnt * p_work-&amp;gt;geometry.blk_size);

         return;
    }

    /*Case 2: Copy data from end erase unit*/
    if (eunit_end == p_work-&amp;gt;erase_unit_idx)
    {
         size_t cnt = (p_work-&amp;gt;req.blk_id + p_work-&amp;gt;req.blk_count) %
                       BD_BLOCKS_PER_ERASEUNIT(p_work-&amp;gt;geometry.blk_size);
         size_t off = (p_work-&amp;gt;erase_unit_idx * BD_BLOCKS_PER_ERASEUNIT(p_work-&amp;gt;geometry.blk_size) -
                       p_work-&amp;gt;req.blk_id) * p_work-&amp;gt;geometry.blk_size;

         if (cnt &amp;gt; p_work-&amp;gt;req.blk_count)
         {
             cnt = p_work-&amp;gt;req.blk_count;
         }

         memcpy((uint8_t *)p_work-&amp;gt;req.p_buff + off,
                p_work-&amp;gt;p_erase_unit_buff,
                cnt * p_work-&amp;gt;geometry.blk_size);

         return;
    }

    /*Case 3: Copy data from  eunit_start &amp;lt; p_work-&amp;gt;erase_unit_idx &amp;lt; eunit_end*/
    size_t off = (p_work-&amp;gt;erase_unit_idx * BD_BLOCKS_PER_ERASEUNIT(p_work-&amp;gt;geometry.blk_size) -
                  p_work-&amp;gt;req.blk_id) * p_work-&amp;gt;geometry.blk_size;

    memcpy((uint8_t *)p_work-&amp;gt;req.p_buff + off,
           p_work-&amp;gt;p_erase_unit_buff,
           NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE);
}

/**
 * @brief Active QSPI block device handle. Only one instance.
 * */
static nrf_block_dev_qspi_t const * m_active_qspi_dev;

static void qspi_handler(nrf_drv_qspi_evt_t event, void * p_context)
{
    if (m_active_qspi_dev != p_context)
    {
        return;
    }

    nrf_block_dev_qspi_t const * p_qspi_dev = p_context;
    nrf_block_dev_qspi_work_t *  p_work = p_qspi_dev-&amp;gt;p_work;
    nrf_block_req_t * p_blk_left = &amp;amp;p_work-&amp;gt;left_req;

    switch (p_work-&amp;gt;state)
    {
        case NRF_BLOCK_DEV_QSPI_STATE_READ_EXEC:
        {
            if (p_work-&amp;gt;writeback_mode)
            {
                block_dev_qspi_read_from_eunit(p_qspi_dev);
            }

            p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_IDLE;
            if (p_work-&amp;gt;ev_handler)
            {
                const nrf_block_dev_event_t ev = {
                        NRF_BLOCK_DEV_EVT_BLK_READ_DONE,
                        NRF_BLOCK_DEV_RESULT_SUCCESS,
                        &amp;amp;p_work-&amp;gt;req,
                        p_work-&amp;gt;p_context
                };

                p_work-&amp;gt;ev_handler(&amp;amp;p_qspi_dev-&amp;gt;block_dev, &amp;amp;ev);
            }

            break;
        }
        case NRF_BLOCK_DEV_QSPI_STATE_EUNIT_LOAD:
        {
            ret_code_t ret;
            uint32_t erase_unit = BD_BLOCK_TO_ERASEUNIT(p_blk_left-&amp;gt;blk_id,
                                                        p_work-&amp;gt;geometry.blk_size);
            UNUSED_VARIABLE(erase_unit);
            ASSERT(erase_unit == p_work-&amp;gt;erase_unit_idx);

            /* Check if block is in erase unit buffer*/
            ret = block_dev_qspi_eunit_write(p_qspi_dev, p_blk_left);
            ASSERT(ret == NRF_SUCCESS);
            UNUSED_VARIABLE(ret);
            break;
        }
        case NRF_BLOCK_DEV_QSPI_STATE_WRITE_ERASE:
        case NRF_BLOCK_DEV_QSPI_STATE_WRITE_EXEC:
        {
            /*Clear last programmed block*/
            uint32_t block_to_program = __CLZ(__RBIT(p_work-&amp;gt;erase_unit_dirty_blocks));

            if (p_work-&amp;gt;state == NRF_BLOCK_DEV_QSPI_STATE_WRITE_EXEC)
            {
                p_work-&amp;gt;erase_unit_dirty_blocks ^= 1u &amp;lt;&amp;lt; block_to_program;
            }

            if (p_work-&amp;gt;erase_unit_dirty_blocks == 0)
            {
                if (p_work-&amp;gt;left_req.blk_count)
                {
                    /*Load next erase unit*/
                    ret_code_t ret;
                    uint32_t eunit = BD_BLOCK_TO_ERASEUNIT(p_blk_left-&amp;gt;blk_id,
                                                           p_work-&amp;gt;geometry.blk_size);

                    p_work-&amp;gt;erase_unit_idx = eunit;
                    p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_EUNIT_LOAD;

                    ret = nrf_drv_qspi_read(p_work-&amp;gt;p_erase_unit_buff,
                                            NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE,
                                            p_work-&amp;gt;erase_unit_idx *
                                            NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE);
                    UNUSED_VARIABLE(ret);

                    break;
                }

                /*All blocks are programmed. Call event handler if required.*/
                p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_IDLE;
                if (p_work-&amp;gt;ev_handler &amp;amp;&amp;amp; !p_work-&amp;gt;cache_flushing)
                {
                    const nrf_block_dev_event_t ev = {
                            NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE,
                            NRF_BLOCK_DEV_RESULT_SUCCESS,
                            &amp;amp;p_work-&amp;gt;req,
                            p_work-&amp;gt;p_context
                    };

                    p_work-&amp;gt;ev_handler(&amp;amp;p_qspi_dev-&amp;gt;block_dev, &amp;amp;ev);
                }

                p_work-&amp;gt;cache_flushing = false;
                break;
            }

            /*Get next block to program from program mask*/
            block_to_program = __CLZ(__RBIT(p_work-&amp;gt;erase_unit_dirty_blocks));
            uint32_t dst_address = (p_work-&amp;gt;erase_unit_idx * NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE) +
                                   (block_to_program * p_work-&amp;gt;geometry.blk_size);

            const void * p_src_address = p_work-&amp;gt;p_erase_unit_buff +
                                         block_to_program * p_work-&amp;gt;geometry.blk_size;

            p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_WRITE_EXEC;
            ret_code_t ret = nrf_drv_qspi_write(p_src_address,
                                                p_work-&amp;gt;geometry.blk_size,
                                                dst_address);
            UNUSED_VARIABLE(ret);
            break;
        }
        default:
            ASSERT(0);
            break;
    }
}

static void wait_for_idle(nrf_block_dev_qspi_t const * p_qspi_dev)
{
    nrf_block_dev_qspi_work_t * p_work = p_qspi_dev-&amp;gt;p_work;
    while (p_work-&amp;gt;state != NRF_BLOCK_DEV_QSPI_STATE_IDLE)
    {
        __WFI();
    }
}

static ret_code_t block_dev_qspi_init(nrf_block_dev_t const * p_blk_dev,
                                      nrf_block_dev_ev_handler ev_handler,
                                      void const * p_context)
{
    ASSERT(p_blk_dev);
    nrf_block_dev_qspi_t const *  p_qspi_dev =
                                  CONTAINER_OF(p_blk_dev, nrf_block_dev_qspi_t, block_dev);
    nrf_block_dev_qspi_work_t *   p_work = p_qspi_dev-&amp;gt;p_work;
    nrf_drv_qspi_config_t const * p_qspi_cfg = &amp;amp;p_qspi_dev-&amp;gt;qspi_bdev_config.qspi_config;

    ret_code_t ret = NRF_SUCCESS;

    NRF_LOG_INST_DEBUG(p_qspi_dev-&amp;gt;p_log, &amp;quot;Init&amp;quot;);

    if (p_qspi_dev-&amp;gt;qspi_bdev_config.block_size % BD_PAGE_PROGRAM_SIZE)
    {
        /*Unsupported block size*/
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;Unsupported block size because of program page size&amp;quot;);
        return NRF_ERROR_NOT_SUPPORTED;
    }

    if (NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE % p_qspi_dev-&amp;gt;qspi_bdev_config.block_size)
    {
        /*Unsupported block size*/
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;Unsupported block size because of erase unit size&amp;quot;);
        return NRF_ERROR_NOT_SUPPORTED;
    }

    if (m_active_qspi_dev)
    {
        /* QSPI instance is BUSY*/
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;Cannot init because QSPI is busy&amp;quot;);
        return NRF_ERROR_BUSY;
    }

    ret = nrf_drv_qspi_init(p_qspi_cfg, qspi_handler, (void *)p_blk_dev);
    if (ret != NRF_SUCCESS)
    {
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;QSPI init error: %&amp;quot;PRIu32&amp;quot;&amp;quot;, ret);
        return ret;
    }

    nrf_qspi_cinstr_conf_t cinstr_cfg = {
        .opcode    = QSPI_STD_CMD_RSTEN,
        .length    = NRF_QSPI_CINSTR_LEN_1B,
        .io2_level = true,
        .io3_level = true,
        .wipwait   = true,
        .wren      = true
    };

    /* Send reset enable */
    ret = nrf_drv_qspi_cinstr_xfer(&amp;amp;cinstr_cfg, NULL, NULL);
    if (ret != NRF_SUCCESS)
    {
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;QSPI reset enable command error: %&amp;quot;PRIu32&amp;quot;&amp;quot;, ret);
        return ret;
    }

    /* Send reset command */
    cinstr_cfg.opcode = QSPI_STD_CMD_RST;
    ret = nrf_drv_qspi_cinstr_xfer(&amp;amp;cinstr_cfg, NULL, NULL);
    if (ret != NRF_SUCCESS)
    {
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;QSPI reset command error: %&amp;quot;PRIu32&amp;quot;&amp;quot;, ret);
        return ret;
    }

    /* Get 3 byte identification value */
    uint8_t rdid_buf[3] = {0, 0, 0};
    cinstr_cfg.opcode = QSPI_STD_CMD_READ_ID;
    cinstr_cfg.length = NRF_QSPI_CINSTR_LEN_4B;
    ret = nrf_drv_qspi_cinstr_xfer(&amp;amp;cinstr_cfg, NULL, rdid_buf);
    if (ret != NRF_SUCCESS)
    {
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;QSPI get 3 byte id error: %&amp;quot;PRIu32&amp;quot;&amp;quot;, ret);
        return ret;
    }

    nrf_serial_flash_params_t const * serial_flash_id = nrf_serial_flash_params_get(rdid_buf);

    if (!serial_flash_id)
    {
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;QSPI FLASH not supported&amp;quot;);
        return NRF_ERROR_NOT_SUPPORTED;
    }

    if (serial_flash_id-&amp;gt;erase_size != NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE)
    {
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;QSPI FLASH erase unit size not supported&amp;quot;);
        return NRF_ERROR_NOT_SUPPORTED;
    }

    /* Calculate block device geometry.... */
    uint32_t blk_size = p_qspi_dev-&amp;gt;qspi_bdev_config.block_size;
    uint32_t blk_count = serial_flash_id-&amp;gt;size / p_qspi_dev-&amp;gt;qspi_bdev_config.block_size;

    if (!blk_count || (blk_count % BD_BLOCKS_PER_ERASEUNIT(blk_size)))
    {
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;QSPI FLASH block size not supported&amp;quot;);
        return NRF_ERROR_NOT_SUPPORTED;
    }

    p_work-&amp;gt;geometry.blk_size = blk_size;
    p_work-&amp;gt;geometry.blk_count = blk_count;
    p_work-&amp;gt;p_context = p_context;
    p_work-&amp;gt;ev_handler = ev_handler;

    p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_IDLE;
    p_work-&amp;gt;erase_unit_idx = BD_ERASE_UNIT_INVALID_ID;
    p_work-&amp;gt;writeback_mode =  (p_qspi_dev-&amp;gt;qspi_bdev_config.flags &amp;amp;
                               NRF_BLOCK_DEV_QSPI_FLAG_CACHE_WRITEBACK) != 0;
    m_active_qspi_dev = p_qspi_dev;

    if (p_work-&amp;gt;ev_handler)
    {
        /*Asynchronous operation (simulation)*/
        const nrf_block_dev_event_t ev = {
                NRF_BLOCK_DEV_EVT_INIT,
                NRF_BLOCK_DEV_RESULT_SUCCESS,
                NULL,
                p_work-&amp;gt;p_context
        };

        p_work-&amp;gt;ev_handler(p_blk_dev, &amp;amp;ev);
    }

    return NRF_SUCCESS;
}

static ret_code_t block_dev_qspi_uninit(nrf_block_dev_t const * p_blk_dev)
{
    ASSERT(p_blk_dev);
    nrf_block_dev_qspi_t const * p_qspi_dev =
                                 CONTAINER_OF(p_blk_dev, nrf_block_dev_qspi_t, block_dev);
    nrf_block_dev_qspi_work_t * p_work = p_qspi_dev-&amp;gt;p_work;

    NRF_LOG_INST_DEBUG(p_qspi_dev-&amp;gt;p_log, &amp;quot;Uninit&amp;quot;);
	
	if ((p_work-&amp;gt;state != NRF_BLOCK_DEV_QSPI_STATE_IDLE))
	{
	 	wait_for_idle(p_qspi_dev);
	}

    if (m_active_qspi_dev != p_qspi_dev)
    {
        /* QSPI instance is BUSY*/
        return NRF_ERROR_BUSY;
    }

    if (p_work-&amp;gt;state != NRF_BLOCK_DEV_QSPI_STATE_IDLE)
    {
        /* Previous asynchronous operation in progress*/
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;Cannot uninit because QSPI is busy&amp;quot;);
        return NRF_ERROR_BUSY;
    }

    if (p_work-&amp;gt;ev_handler)
    {
        /*Asynchronous operation*/
        const nrf_block_dev_event_t ev = {
                NRF_BLOCK_DEV_EVT_UNINIT,
                NRF_BLOCK_DEV_RESULT_SUCCESS,
                NULL,
                p_work-&amp;gt;p_context
        };

        p_work-&amp;gt;ev_handler(p_blk_dev, &amp;amp;ev);
    }

    p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_DISABLED;
    nrf_drv_qspi_uninit();

    memset(p_work, 0, sizeof(nrf_block_dev_qspi_work_t));
    m_active_qspi_dev = NULL;
    return NRF_SUCCESS;
}

static ret_code_t block_dev_qspi_read_req(nrf_block_dev_t const * p_blk_dev,
                                          nrf_block_req_t const * p_blk)
{
    ASSERT(p_blk_dev);
    ASSERT(p_blk);
    nrf_block_dev_qspi_t const * p_qspi_dev =
                                 CONTAINER_OF(p_blk_dev, nrf_block_dev_qspi_t, block_dev);
    nrf_block_dev_qspi_work_t *  p_work = p_qspi_dev-&amp;gt;p_work;

    ret_code_t ret = NRF_SUCCESS;

    NRF_LOG_INFO(
        //p_qspi_dev-&amp;gt;p_log,
        &amp;quot;Read req from block %&amp;quot;PRIu32&amp;quot; size %&amp;quot;PRIu32&amp;quot;(x%&amp;quot;PRIu32&amp;quot;) to %&amp;quot;PRIXPTR,
        p_blk-&amp;gt;blk_id,
        p_blk-&amp;gt;blk_count,
        p_blk_dev-&amp;gt;p_ops-&amp;gt;geometry(p_blk_dev)-&amp;gt;blk_size,
        p_blk-&amp;gt;p_buff);
	NRF_LOG_FLUSH();
    if ((p_blk-&amp;gt;blk_id + p_blk-&amp;gt;blk_count) &amp;gt; p_work-&amp;gt;geometry.blk_count)
    {
       NRF_LOG_INST_ERROR(
           p_qspi_dev-&amp;gt;p_log,
           &amp;quot;Out of range read req block %&amp;quot;PRIu32&amp;quot; count %&amp;quot;PRIu32&amp;quot; while max is %&amp;quot;PRIu32,
           p_blk-&amp;gt;blk_id,
           p_blk-&amp;gt;blk_count,
           p_blk_dev-&amp;gt;p_ops-&amp;gt;geometry(p_blk_dev)-&amp;gt;blk_count);
       return NRF_ERROR_INVALID_ADDR;
    }

    if (m_active_qspi_dev != p_qspi_dev)
    {
        /* QSPI instance is BUSY*/
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;Cannot read because QSPI is busy&amp;quot;);
        return NRF_ERROR_BUSY;
    }

    if (p_work-&amp;gt;state != NRF_BLOCK_DEV_QSPI_STATE_IDLE)
    {
        /* Previous asynchronous operation in progress*/
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;Cannot read because of ongoing previous operation&amp;quot;);
        return NRF_ERROR_BUSY;
    }

    p_work-&amp;gt;left_req = *p_blk;
    p_work-&amp;gt;req = *p_blk;
    nrf_block_req_t * p_blk_left = &amp;amp;p_work-&amp;gt;left_req;

    p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_READ_EXEC;
    ret = nrf_drv_qspi_read(p_blk_left-&amp;gt;p_buff,
                            p_blk_left-&amp;gt;blk_count * p_work-&amp;gt;geometry.blk_size,
                            p_blk_left-&amp;gt;blk_id * p_work-&amp;gt;geometry.blk_size);

    if (ret != NRF_SUCCESS)
    {
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;QSPI read error: %&amp;quot;PRIu32&amp;quot;&amp;quot;, ret);
        p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_IDLE;
        return ret;
    }

    p_blk_left-&amp;gt;p_buff = NULL;
    p_blk_left-&amp;gt;blk_count = 0;

    if (!p_work-&amp;gt;ev_handler &amp;amp;&amp;amp; (p_work-&amp;gt;state != NRF_BLOCK_DEV_QSPI_STATE_IDLE))
    {
        /*Synchronous operation*/
        wait_for_idle(p_qspi_dev);
    }

    return ret;
}

static bool block_dev_qspi_update_eunit(nrf_block_dev_qspi_t const * p_qspi_dev,
                                        size_t off,
                                        const void * p_src,
                                        size_t len)
{
    ASSERT((len % sizeof(uint32_t)) == 0)
    nrf_block_dev_qspi_work_t *  p_work = p_qspi_dev-&amp;gt;p_work;

    uint32_t *       p_dst32 = (uint32_t *)(p_work-&amp;gt;p_erase_unit_buff + off);
    const uint32_t * p_src32 = p_src;

    bool erase_required = false;
    len /= sizeof(uint32_t);

    /*Do normal copying until erase unit is not required*/
    do
    {
        if (*p_dst32 != *p_src32)
        {
            if (*p_dst32 != BD_ERASE_UNIT_ERASE_VAL)
            {
                erase_required = true;
            }

            /*Mark block as dirty*/
            p_work-&amp;gt;erase_unit_dirty_blocks |= 1u &amp;lt;&amp;lt; (off / p_work-&amp;gt;geometry.blk_size);
        }

        *p_dst32++ = *p_src32++;
        off += sizeof(uint32_t);
    } while (--len);

    return erase_required;
}

static ret_code_t block_dev_qspi_write_start(nrf_block_dev_qspi_t const * p_qspi_dev)
{
    nrf_block_dev_qspi_work_t *  p_work = p_qspi_dev-&amp;gt;p_work;

    if (!p_work-&amp;gt;erase_required)
    {
        /*Get first block to program from program mask*/
        uint32_t block_to_program = __CLZ(__RBIT(p_work-&amp;gt;erase_unit_dirty_blocks));
        uint32_t dst_address = (p_work-&amp;gt;erase_unit_idx * NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE) +
                               (block_to_program * p_work-&amp;gt;geometry.blk_size);

        const void * p_src_address = p_work-&amp;gt;p_erase_unit_buff +
                                     block_to_program * p_work-&amp;gt;geometry.blk_size;

        p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_WRITE_EXEC;
		NRF_LOG_INFO(&amp;quot;src:%x, blk_size:%d, dst:%x, block:%d&amp;quot;,p_src_address, p_work-&amp;gt;geometry.blk_size, dst_address, dst_address/512);
		NRF_LOG_FLUSH();
        return nrf_drv_qspi_write(p_src_address,
                                  p_work-&amp;gt;geometry.blk_size,
                                  dst_address);
    }

    /*Erase is required*/
    uint32_t address = (p_work-&amp;gt;erase_unit_idx * NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE);
    p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_WRITE_ERASE;
    p_work-&amp;gt;erase_required = false;
	NRF_LOG_INFO(&amp;quot;erase:addr:%x block:%d, id:%d&amp;quot;,address, address/512, BD_BLOCK_TO_ERASEUNIT(address/512,512));
	NRF_LOG_FLUSH();
    return nrf_drv_qspi_erase(NRF_QSPI_ERASE_LEN_4KB, address);
}

static ret_code_t block_dev_qspi_eunit_write(nrf_block_dev_qspi_t const * p_qspi_dev,
                                             nrf_block_req_t * p_blk_left)
{
    nrf_block_dev_qspi_work_t *  p_work = p_qspi_dev-&amp;gt;p_work;

    size_t blk = p_blk_left-&amp;gt;blk_id %
                 BD_BLOCKS_PER_ERASEUNIT(p_work-&amp;gt;geometry.blk_size);
    size_t cnt = BD_BLOCKS_PER_ERASEUNIT(p_work-&amp;gt;geometry.blk_size) - blk;
    size_t off = p_work-&amp;gt;geometry.blk_size * blk;

    if (cnt &amp;gt; p_blk_left-&amp;gt;blk_count)
    {
        cnt = p_blk_left-&amp;gt;blk_count;
    }

    bool erase_required = block_dev_qspi_update_eunit(p_qspi_dev,
                                                      off,
                                                      p_blk_left-&amp;gt;p_buff,
                                                      cnt * p_work-&amp;gt;geometry.blk_size);
    if (erase_required)
    {
        p_work-&amp;gt;erase_required = true;
    }

    p_blk_left-&amp;gt;blk_count -= cnt;
    p_blk_left-&amp;gt;blk_id += cnt;
    p_blk_left-&amp;gt;p_buff = (uint8_t *)p_blk_left-&amp;gt;p_buff + cnt * p_work-&amp;gt;geometry.blk_size;

    if (p_work-&amp;gt;erase_required)
    {
        uint32_t blk_size = p_work-&amp;gt;geometry.blk_size;
        p_work-&amp;gt;erase_unit_dirty_blocks |= (1u &amp;lt;&amp;lt; BD_BLOCKS_PER_ERASEUNIT(blk_size)) - 1;
    }

    if (p_work-&amp;gt;erase_unit_dirty_blocks == 0 || p_work-&amp;gt;writeback_mode)
    {
        /*No dirty blocks detected. Write end.*/
        if (p_work-&amp;gt;ev_handler &amp;amp;&amp;amp; p_blk_left-&amp;gt;blk_count == 0)
        {
            const nrf_block_dev_event_t ev = {
                    NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE,
                    NRF_BLOCK_DEV_RESULT_SUCCESS,
                    &amp;amp;p_work-&amp;gt;req,
                    p_work-&amp;gt;p_context
            };


            p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_IDLE;
            p_work-&amp;gt;ev_handler(&amp;amp;p_qspi_dev-&amp;gt;block_dev, &amp;amp;ev);
            return NRF_SUCCESS;
        }
    }

    return block_dev_qspi_write_start(p_qspi_dev);
}

static ret_code_t block_dev_qspi_write_req(nrf_block_dev_t const * p_blk_dev,
                                           nrf_block_req_t const * p_blk)
{
    ASSERT(p_blk_dev);
    ASSERT(p_blk);
    nrf_block_dev_qspi_t const * p_qspi_dev =
                                 CONTAINER_OF(p_blk_dev, nrf_block_dev_qspi_t, block_dev);
    nrf_block_dev_qspi_work_t *  p_work = p_qspi_dev-&amp;gt;p_work;

    ret_code_t ret = NRF_SUCCESS;

    NRF_LOG_INFO(
        //p_qspi_dev-&amp;gt;p_log,
        &amp;quot;Write block %&amp;quot;PRIu32&amp;quot; size %&amp;quot;PRIu32&amp;quot;(x%&amp;quot;PRIu32&amp;quot;) from %&amp;quot;PRIXPTR,
        p_blk-&amp;gt;blk_id,
        p_blk-&amp;gt;blk_count,
        p_blk_dev-&amp;gt;p_ops-&amp;gt;geometry(p_blk_dev)-&amp;gt;blk_size,
        p_blk-&amp;gt;p_buff);
	NRF_LOG_FLUSH();
    if ((p_blk-&amp;gt;blk_id + p_blk-&amp;gt;blk_count) &amp;gt; p_work-&amp;gt;geometry.blk_count)
    {
       NRF_LOG_INST_ERROR(
           p_qspi_dev-&amp;gt;p_log,
           &amp;quot;Out of range write req block %&amp;quot;PRIu32&amp;quot; count %&amp;quot;PRIu32&amp;quot; while max is %&amp;quot;PRIu32,
           p_blk-&amp;gt;blk_id,
           p_blk-&amp;gt;blk_count,
           p_blk_dev-&amp;gt;p_ops-&amp;gt;geometry(p_blk_dev)-&amp;gt;blk_count);
       return NRF_ERROR_INVALID_ADDR;
    }

    if (m_active_qspi_dev != p_qspi_dev)
    {
        /* QSPI instance is BUSY*/
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;Cannot write because QSPI is busy&amp;quot;);
        return NRF_ERROR_BUSY;
    }

    if (p_work-&amp;gt;state != NRF_BLOCK_DEV_QSPI_STATE_IDLE)
    {
        /* Previous asynchronous operation in progress*/
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;Cannot write because of ongoing previous operation&amp;quot;);
        return NRF_ERROR_BUSY;
    }

    p_work-&amp;gt;left_req = *p_blk;
    p_work-&amp;gt;req = *p_blk;

    nrf_block_req_t * p_blk_left = &amp;amp;p_work-&amp;gt;left_req;

    uint32_t erase_unit = BD_BLOCK_TO_ERASEUNIT(p_blk_left-&amp;gt;blk_id,
                                                p_work-&amp;gt;geometry.blk_size);

    /* Check if block is in erase unit buffer*/
    if (erase_unit == p_work-&amp;gt;erase_unit_idx)
    {
        ret = block_dev_qspi_eunit_write(p_qspi_dev, p_blk_left);
    }
    else
    {
        if (p_work-&amp;gt;writeback_mode)
        {
            ret = block_dev_qspi_write_start(p_qspi_dev);
        }
        else
        {
            p_work-&amp;gt;erase_unit_idx = erase_unit;
            p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_EUNIT_LOAD;

            ret = nrf_drv_qspi_read(p_work-&amp;gt;p_erase_unit_buff,
                    NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE,
                    erase_unit * NRF_BLOCK_DEV_QSPI_ERASE_UNIT_SIZE);
        }
    }

    if (ret != NRF_SUCCESS)
    {
        NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;QSPI write error: %&amp;quot;PRIu32&amp;quot;&amp;quot;, ret);
        p_work-&amp;gt;state = NRF_BLOCK_DEV_QSPI_STATE_IDLE;
        return ret;
    }

    if (!p_work-&amp;gt;ev_handler &amp;amp;&amp;amp; (p_work-&amp;gt;state != NRF_BLOCK_DEV_QSPI_STATE_IDLE))
    {
        /*Synchronous operation*/
        wait_for_idle(p_qspi_dev);
    }
    return ret;
}

static ret_code_t block_dev_qspi_ioctl(nrf_block_dev_t const * p_blk_dev,
                                       nrf_block_dev_ioctl_req_t req,
                                       void * p_data)
{
    ASSERT(p_blk_dev);
    nrf_block_dev_qspi_t const * p_qspi_dev =
                                 CONTAINER_OF(p_blk_dev, nrf_block_dev_qspi_t, block_dev);
    nrf_block_dev_qspi_work_t *  p_work = p_qspi_dev-&amp;gt;p_work;

    switch (req)
    {
        case NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH:
        {
            bool * p_flushing = p_data;
            NRF_LOG_INST_DEBUG(p_qspi_dev-&amp;gt;p_log, &amp;quot;IOCtl: Cache flush&amp;quot;);
            if (p_work-&amp;gt;state != NRF_BLOCK_DEV_QSPI_STATE_IDLE)
            {
                return NRF_ERROR_BUSY;
            }

            if (!p_work-&amp;gt;writeback_mode || p_work-&amp;gt;erase_unit_dirty_blocks == 0)
            {
                if (p_flushing)
                {
                    *p_flushing = false;
                }

                return NRF_SUCCESS;
            }

            ret_code_t ret =  block_dev_qspi_write_start(p_qspi_dev);
            if (ret == NRF_SUCCESS)
            {
                if (p_flushing)
                {
                    *p_flushing = true;
                }
                p_work-&amp;gt;cache_flushing = true;
            }

            return ret;
        }
        case NRF_BLOCK_DEV_IOCTL_REQ_INFO_STRINGS:
        {
            if (p_data == NULL)
            {
                return NRF_ERROR_INVALID_PARAM;
            }

            nrf_block_dev_info_strings_t const * * pp_strings = p_data;
            *pp_strings = &amp;amp;p_qspi_dev-&amp;gt;info_strings;
            return NRF_SUCCESS;
        }
        default:
            break;
    }

    return NRF_ERROR_NOT_SUPPORTED;
}

static nrf_block_dev_geometry_t const * block_dev_qspi_geometry(nrf_block_dev_t const * p_blk_dev)
{
    ASSERT(p_blk_dev);
    nrf_block_dev_qspi_t const * p_qspi_dev =
                                 CONTAINER_OF(p_blk_dev, nrf_block_dev_qspi_t, block_dev);
    nrf_block_dev_qspi_work_t const * p_work = p_qspi_dev-&amp;gt;p_work;

    return &amp;amp;p_work-&amp;gt;geometry;
}

const nrf_block_dev_ops_t nrf_block_device_qspi_ops = {
        .init = block_dev_qspi_init,
        .uninit = block_dev_qspi_uninit,
        .read_req = block_dev_qspi_read_req,
        .write_req = block_dev_qspi_write_req,
        .ioctl = block_dev_qspi_ioctl,
        .geometry = block_dev_qspi_geometry,
};

/** @} */
#endif // NRF_MODULE_ENABLED(NRF_BLOCK_DEV_QSPI)
&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sdk_config.h&lt;/strong&gt; (use RTT as the debug output, because if using uart, it will affect the MSC recognition)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/269106?ContentTypeID=1</link><pubDate>Fri, 11 Sep 2020 08:55:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28c0714d-a55c-4207-9ce4-70a54ceba161</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;&lt;span&gt;Thanks, Looking forward to your&amp;nbsp;updates.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/268945?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 11:41:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d02c554-6a85-49f6-9c8d-cce317fab367</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I understand. We are looking into how this can be properly fixed, but I do not have any updates yet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/268831?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 03:07:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80d305f1-3eb7-440d-83a9-0be54c650f47</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi, our product is a bicycle computer. After training starts, it will record sensor data every second, such as speed, cadence, heart rate, etc. &lt;br /&gt;All data will be formatted as fit files and stored in MSC after training finishes.&lt;br /&gt;I have been testing on our product boards for a long time yesterday, and this problem still occurs.&lt;br /&gt;I copy the files from MSC to the local disk as a backup after every training finished.&lt;br /&gt;This issue occurred after the thirteenth training finished, the ninth file was corrupted. &lt;br /&gt;This problem is fatal to our products, please help to solve this problem completely. Thanks!&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x0/__key/communityserver-discussions-components-files/4/6087.test_5F00_result.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/268743?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 12:21:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5cb19710-b796-4dbf-b02b-9b8c6772f703</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It look like the same corruption issue as we have discussed in previous posts,&amp;nbsp;but it is easily triggered during the formatting process. I do not have any specific reason for suspecting that the formatting code in itself is the problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/268616?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 03:03:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1aca9ff1-db5f-4e32-a3c5-dc61ceadca94</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi, Thanks for your answers. Could you let me know what is the error in the formatting process？ Because we also need formatting from the nRF in our product?&lt;br /&gt;For the file corruption issue, as it is a probability issue, I am implementing a test routine to confirm if it is fixed completely.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/268540?ContentTypeID=1</link><pubDate>Tue, 08 Sep 2020 13:15:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92d0f8fc-90d9-4563-bd4e-bebae26c6057</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="greyorbit"]what I understand, the root cause is that DMA leads to cache coherency problems, and disable cache write-back can fix this problem in theory.&lt;br /&gt;Am I correct?[/quote]
&lt;p&gt;There is coherency problems, and disabling cache write-back seems an effective workaround. The problem is not fully understood, though.&lt;/p&gt;
[quote user="greyorbit"]1：Is there somewhere else cause the cache coherency problems?[/quote]
&lt;p&gt;Not that I am aware of, though I cannot make any guarantees given that the problem is not fully understood.&lt;/p&gt;
[quote user="greyorbit"]2：There is not D-cache inside NRF52 MCU, then what is the cache write-back mode used for?[/quote]
&lt;p&gt;It is used for optimizing QSPI accesses.&lt;/p&gt;
&lt;p&gt;We have seen that the issue is easier to reproduce in some situations where there is more writing. For instance, using the example the formating process is where we see the error. Formatting from the PC instead of from the nRF (following button 3 press) also seems to prevent the issue from manifesting itself.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/268480?ContentTypeID=1</link><pubDate>Tue, 08 Sep 2020 11:11:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c16f94a-d205-4bbf-8748-27850fdf323c</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi Einar, Thank you for the workaround. I am Jason. John&amp;#39;s colleague. I have tried this workaround and took a test for about three hours on our actual product, there&amp;#39;s been a lot of improvement. but unfortunately, this problem still came up once, but I checked the raw data of the corrupted file, only two bytes were broken, so I am not sure if it is caused by our software. I will double-check it. &lt;br /&gt;what I understand, the root cause is that DMA leads to cache coherency problems, and disable cache write-back can fix this problem in theory.&lt;br /&gt;Am I correct?&lt;br /&gt;Besides, I have two questions.&lt;br /&gt;1：Is there somewhere else cause the cache coherency problems?&lt;br /&gt;2：There is not D-cache inside NRF52 MCU, then what is the cache write-back mode used for?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/268460?ContentTypeID=1</link><pubDate>Tue, 08 Sep 2020 09:29:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4d24d0d-00a6-4d89-bf10-3b15c208ceeb</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for the detailed description and simple way to reproduce. I see the same on my side. A possible workaround is to disable writeback, by inserting 0 instead of&amp;nbsp;NRF_BLOCK_DEV_QSPI_FLAG_CACHE_WRITEBACK on line 167.&amp;nbsp;Does that work as a workaround for you?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/268309?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 12:30:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1dbc2f0b-65cb-4ea6-aa38-71676ade4a6a</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;We also tried the attached main.c. It auto write log_entry to a file every 0.5sec.&lt;/p&gt;
&lt;p&gt;When data reord reach to about 256, the file corruption issue happens.&lt;/p&gt;
&lt;p&gt;Please see my attached main.c and the debug log.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;Repeat Sequence:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Press Button 3 &amp;nbsp;to format disk and reset the record_number to 0.&lt;/li&gt;
&lt;li&gt;Wait until the data record count &amp;nbsp;reach to &amp;nbsp;256.&lt;/li&gt;
&lt;li&gt;Connect PC to check the LOG_DATA.TXT.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Platform: nRF52840&lt;/p&gt;
&lt;p&gt;HW board used: PCA10056&lt;/p&gt;
&lt;p&gt;SDK tested/used: SDK16.0 / SDK17.0&lt;/p&gt;
&lt;p&gt;Example used: sdk16_0\examples\peripheral\usbd_msc&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2678.main.c"&gt;devzone.nordicsemi.com/.../2678.main.c&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/deblug_5F00_log.txt"&gt;devzone.nordicsemi.com/.../deblug_5F00_log.txt&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/LOG_5F00_DATA.TXT"&gt;devzone.nordicsemi.com/.../LOG_5F00_DATA.TXT&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic nRF52840 USB MSC File Corruption Issue</title><link>https://devzone.nordicsemi.com/thread/268295?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 12:04:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33955b5e-26ce-4a05-9dd1-6314f1dc1528</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for reporting this issue. I do not immediately have a workaround, but we are looking into it. I will get back to you with more information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>