<?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>Accessing QSPI flash simultaneously in nRF52840 program and as a USB block device</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/57676/accessing-qspi-flash-simultaneously-in-nrf52840-program-and-as-a-usb-block-device</link><description>Has anyone (tried to) simultaneously use the same QSPI Flash memory directly from an nRF52840 program and as a USB block device? 
 We have both functions running in the same hardware when used alternatively: can either read/write the QSPI memory with</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 14 Feb 2020 06:32:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/57676/accessing-qspi-flash-simultaneously-in-nrf52840-program-and-as-a-usb-block-device" /><item><title>RE: Accessing QSPI flash simultaneously in nRF52840 program and as a USB block device</title><link>https://devzone.nordicsemi.com/thread/234309?ContentTypeID=1</link><pubDate>Fri, 14 Feb 2020 06:32:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e880a25-7ea5-4220-b309-af1540e45f50</guid><dc:creator>Pertti Kasanen</dc:creator><description>&lt;p&gt;No problem. It will be interesting to hear an insider opinion on how to best implement this.&lt;br /&gt;&lt;br /&gt;I managed to write a test version for the double functionality. We need to build some test cases on top of it and test the robustness of the implementation. In an initial test, it seems to be working - tested with&amp;nbsp;reading &amp;gt;10MB data from QSPI over USB while the other functions seemed to work as before.&lt;br /&gt;&lt;br /&gt;The current implementation depends on FreeRTOS and is somewhat dependent on our other code framework. The basic method:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Bypass the QSPI init calls in&amp;nbsp;&lt;span&gt;nrfx_block_dev_qspi.c&amp;nbsp;&lt;/span&gt;if QSPI has been already initialized from our own code&lt;/li&gt;
&lt;li&gt;Added a function call that is called always before QSPI read/write/erase, both in our modified copy of nrfx_block_dev_qspi.c and our own QSPI access functions&lt;/li&gt;
&lt;li&gt;The function takes a &amp;quot;mutex&amp;quot; semaphore and sets a variable marking the caller - which QSPI handler should be called when a QSPI event occurs&lt;/li&gt;
&lt;li&gt;The QSPI event handler takes note of which event handler needs to be called, then releases the above semaphore. Makes a call to the handler that is waiting for the QSPI task completion.&lt;/li&gt;
&lt;li&gt;Modified the block device event handler to use a fixed reference to m_active_qspi_dev instead of *p_context when in this dual-mode&lt;/li&gt;
&lt;li&gt;The bit tricky part in the FreeRTOS context was setting the semaphores right (we have two other related semaphores in addition to the above). The same QSPI read/write functions get called both in ISR context and non-ISR. That needs some planning in the FreeRTOS setup to get it working right with &amp;quot;binary&amp;quot; type (not &amp;quot;mutex&amp;quot;) semaphores.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The current implementation&amp;nbsp;reads&amp;nbsp;about 215000 bytes/s from USB MSC with&amp;nbsp;Mac command line dd-command. That is about half of the speed I recall seeing when running&amp;nbsp;as a block device only. A not too bad penalty from the added semaphores - good enough for the current need.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accessing QSPI flash simultaneously in nRF52840 program and as a USB block device</title><link>https://devzone.nordicsemi.com/thread/234207?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2020 14:14:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72d71c12-68ca-42ad-8525-2f0d17eee214</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Pertti&lt;/p&gt;
&lt;p&gt;Sorry about the delayed reply, but I had to forward this issue to our development team in hopes of a good and exact reply to your requests, as I don&amp;#39;t know if this has been tried/done before or if it will be possible. I still haven&amp;#39;t heard back, but I will update you as soon as I hear something. Thank you for your patience.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accessing QSPI flash simultaneously in nRF52840 program and as a USB block device</title><link>https://devzone.nordicsemi.com/thread/234094?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2020 06:33:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1eed64ed-108d-4a0c-9151-4d3fa47d1c40</guid><dc:creator>Pertti Kasanen</dc:creator><description>&lt;p&gt;This functionality could have been relatively easy to add if the QSPI handler would get a pointer to the RAM address used in the operation that completed. We could just check from the buffer used what type of event handling is required. But the event handler does not even know wast it a read, write or erase operation that completed.&lt;br /&gt;&lt;br /&gt;Is it possible to read that information directly from the QSPI peripheral registers: would the registers&amp;nbsp;&lt;span&gt;READ.DST and&amp;nbsp;&lt;/span&gt;WRITE.SRC of QSPI be always valid at the time of the competition handler call? Or would it require some mutex that prevents another QSPI command from being issued before the event handling completes?&lt;/p&gt;
&lt;div class="page" title="Page 275"&gt;
&lt;div class="layoutArea"&gt;
&lt;div class="column"&gt;
&lt;div class="page" title="Page 275"&gt;
&lt;div class="layoutArea"&gt;
&lt;div class="column"&gt;
&lt;p&gt;&lt;span&gt;Is it possible to read from the QSPI registers&amp;nbsp;the type of the&amp;nbsp;operation&amp;nbsp;(a read, write or erase) that completed? The SDK block device code seems to keep track of that in it&amp;#39;s on structs.&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>