<?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>Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60504/port-fatfs-to-external-spi-flash-on-52832</link><description>Hi All, 
 We have a product that requires the use of the file system Fatfs, which is plugged into the external SPI FLASH. Therefore, the hardware platform used is: n52832 + W25x10 (NOR FLASH) The software uses SDK16.0, the path from the SDK .. \ examples</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 20 Dec 2022 05:07:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60504/port-fatfs-to-external-spi-flash-on-52832" /><item><title>RE: Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/thread/401404?ContentTypeID=1</link><pubDate>Tue, 20 Dec 2022 05:07:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1576f077-894d-469b-bbda-77c9f9451176</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/index219"&gt;Lion&lt;/a&gt;&amp;nbsp;I am working on the same application. Can you please share some example code?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/thread/246522?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 12:40:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87a67eeb-4ba5-44b7-ac4a-00d84b6cffa6</guid><dc:creator>Lion</dc:creator><description>&lt;p&gt;Hi everyone,&lt;br /&gt;After 2 ~ 3 days of hard work, it successfully read and write Fatfs files at 52832.&lt;br /&gt;See attachment &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Fatfa_5F00_wr_5F00_succ.txt"&gt;devzone.nordicsemi.com/.../Fatfa_5F00_wr_5F00_succ.txt&lt;/a&gt;&lt;br /&gt;The two functions of disk_read () and disk_write () are mainly implemented through the SPI interface.&lt;br /&gt;The main technique is to solve the interface limitation of n52832 and use 251bytes instead of 256bytes page operation. So 1MB Flash changed from the original 256Sector (1024 * 1024/4096) to 240Sector.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/thread/245951?ContentTypeID=1</link><pubDate>Wed, 22 Apr 2020 07:07:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2863fb17-3b67-4cc8-98fa-82fe50452e95</guid><dc:creator>Lion</dc:creator><description>&lt;p&gt;So,is there a good way to implement the following two driver functions?&lt;br /&gt;The n52832&amp;#39;s spi interface limits 255B, which means read up to 255B and write up to 251B, and the fatfs interface is sector (4K)&lt;/p&gt;
[quote userid="19967" url="~/f/nordic-q-a/60504/port-fatfs-to-external-spi-flash-on-52832/245934"]I found result = MMC_disk_write (buff, sector, count); and result = MMC_disk_read (buff, sector, count) in the driver file of fatfs.[/quote]
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
/**
 * @brief Function for starting the SPI data transfer.
 *
 * If an event handler was provided in the @ref nrf_drv_spi_init call, this function
 * returns immediately and the handler is called when the transfer is done.
 * Otherwise, the transfer is performed in blocking mode, which means that this function
 * returns when the transfer is finished.
 *
 * @note Peripherals using EasyDMA (for example, SPIM) require the transfer buffers
 *       to be placed in the Data RAM region. If they are not and an SPIM instance is
 *       used, this function will fail with the error code NRF_ERROR_INVALID_ADDR.
 *
 * @param[in] p_instance       Pointer to the driver instance structure.
 * @param[in] p_tx_buffer      Pointer to the transmit buffer. Can be NULL
 *                             if there is nothing to send.
 * @param     tx_buffer_length Length of the transmit buffer.
 * @param[in] p_rx_buffer      Pointer to the receive buffer. Can be NULL
 *                             if there is nothing to receive.
 * @param     rx_buffer_length Length of the receive buffer.
 *
 * @retval NRF_SUCCESS            If the operation was successful.
 * @retval NRF_ERROR_BUSY         If a previously started transfer has not finished
 *                                yet.
 * @retval NRF_ERROR_INVALID_ADDR If the provided buffers are not placed in the Data
 *                                RAM region.
 */
__STATIC_INLINE
ret_code_t nrf_drv_spi_transfer(nrf_drv_spi_t const * const p_instance,
                                uint8_t const * p_tx_buffer,
                                uint8_t         tx_buffer_length,
                                uint8_t       * p_rx_buffer,
                                uint8_t         rx_buffer_length);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/thread/245948?ContentTypeID=1</link><pubDate>Wed, 22 Apr 2020 06:57:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b836b0c4-348d-4225-b733-5d99b9971f86</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;Ok, that&amp;#39;s great. &amp;nbsp;Then it shouldn&amp;#39;t be a problem. &amp;nbsp;I didn&amp;#39;t it supports larger sector size. &amp;nbsp;good to know.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/thread/245947?ContentTypeID=1</link><pubDate>Wed, 22 Apr 2020 06:54:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3fc502e-4a6e-4a39-9a08-00f7949e02ee</guid><dc:creator>Lion</dc:creator><description>&lt;p&gt;Sorry,Fatfs for ffconf.h code:&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ffconf.h"&gt;devzone.nordicsemi.com/.../ffconf.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define	_MIN_SS		4096
#define	_MAX_SS		4096
/* These options configure the range of sector size to be supported. (512, 1024,
/  2048 or 4096) Always set both 512 for most systems, all type of memory cards and
/  harddisk. But a larger value may be required for on-board flash memory and some
/  type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
/  to variable sector size and GET_SECTOR_SIZE command must be implemented to the
/  disk_ioctl() function. */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The path of the file is:..\external\fatfs\src&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/thread/245945?ContentTypeID=1</link><pubDate>Wed, 22 Apr 2020 06:49:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30d6b91f-f65d-4ff1-bb30-fb6cea085c0c</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;I didn&amp;#39;t mean the flash. &amp;nbsp;I meant the Fat Filesystem specs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/thread/245944?ContentTypeID=1</link><pubDate>Wed, 22 Apr 2020 06:46:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83fac152-cab4-430f-98ff-e8454b500c68</guid><dc:creator>Lion</dc:creator><description>&lt;p&gt;This is the FLASH DS that I used.&lt;br /&gt;The size of the sector marked above is 4k.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/8726.screen.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/XTX_5F00_SPI_5F00_NOR_5F00_XT25F08B_5F00_Rev-1.5.pdf"&gt;devzone.nordicsemi.com/.../XTX_5F00_SPI_5F00_NOR_5F00_XT25F08B_5F00_Rev-1.5.pdf&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/thread/245940?ContentTypeID=1</link><pubDate>Wed, 22 Apr 2020 06:37:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd5fa2a4-ab04-4b70-b73c-a4ece78aab7e</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;Not sure what will&amp;nbsp;to happen when you set a sector of 4KB. &amp;nbsp;A disk sector is 512 bytes and cluster can be 4KB but sector of 4KB ??? Don&amp;#39;t know. &amp;nbsp;Let me know the results.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/thread/245934?ContentTypeID=1</link><pubDate>Wed, 22 Apr 2020 04:17:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe7b43c3-5b81-4823-81a6-ed5900452353</guid><dc:creator>Lion</dc:creator><description>&lt;p&gt;Thank you for your reply, this is really a difficult task.&lt;br /&gt;FLASH capacity is 1Mbytes, sector unit is 4kbytes, block size is 64kbytes / 32kbytes, page size is 256bytes.&lt;br /&gt;Write support page, erase support sector and block.&lt;/p&gt;
&lt;p&gt;So, I have many questions, please support:&lt;br /&gt;1. How to format flash to Fat?&lt;br /&gt;Is this reasonable?&lt;br /&gt;ff_result = f_mkfs (&amp;quot;0:&amp;quot;, FM_FAT, 0, gFsWork, 4096);&lt;br /&gt;2. I understand the operation of the flash block, read it first, then erase it, and write it again.&lt;br /&gt;The block size is 64k / 32k, and the total memory size of n52832 is only 64k. This problem is too difficult. So I can choose to erase by sector, which only takes up 4k of memory.&lt;br /&gt;I found result = MMC_disk_write (buff, sector, count); and result = MMC_disk_read (buff, sector, count) in the driver file of fatfs.&lt;br /&gt;Flashes are operated by the sector, so I only need to erase the sector before disk_write?&lt;/p&gt;
&lt;p&gt;Sector operations do bring speed limitations.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Port fatfs to external SPI FLASH on 52832？</title><link>https://devzone.nordicsemi.com/thread/245932?ContentTypeID=1</link><pubDate>Wed, 22 Apr 2020 03:22:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4d5ded0-43aa-428d-a705-3d5e99dd7a1d</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;There is is a old French saying for &amp;quot;T&amp;#39;en a du pain sur la planche&amp;quot;. &amp;nbsp;Which means you got work to do. &amp;nbsp;First of, Flash is not Fat formatted so you got to format it yourself. Second Flash erasable block varies from 4KB to 64KB. &amp;nbsp;So before a write can be made. &amp;nbsp;You need to erase the whole block. You got to manually manage that too. You are going to have fun with it because each sector size is 512 bytes. &amp;nbsp;So each time you write a sector, you copy a full block from flash to Ram. Write your sector to ram block at the right offset. Erase the flash block. Write the block from ram back to flash. I would recommend you use MMC instead. It&amp;#39;s equivalent to SDCard but in form if chip.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>