<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FatFS not working in LPCOpen 2.04 for LPC4357 - see below for fix in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/FatFS-not-working-in-LPCOpen-2-04-for-LPC4357-see-below-for-fix/m-p/590288#M22050</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by kaikeraut on Wed Apr 02 05:16:58 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;can anyone send me the working code for lpc4330&amp;nbsp; freertos + sdmmc + fatfs&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 19:16:39 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T19:16:39Z</dc:date>
    <item>
      <title>FatFS not working in LPCOpen 2.04 for LPC4357 - see below for fix</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FatFS-not-working-in-LPCOpen-2-04-for-LPC4357-see-below-for-fix/m-p/590285#M22047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rgledhill on Mon Feb 24 07:36:39 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One of the several things sadly broken (and therefore clearly untested) with the LPC4357 LPCOpen2.04 build for Keil is FatFS which doesn't work with Long FileNames (LFN mode).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thankfully they also produced an App Note a while back which describes how to do it properly:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fpostar.sino-star.com%2Fpublic%2Fuploads%2F20120319112312_598.pdf" rel="nofollow" target="_blank"&gt;http://postar.sino-star.com/public/uploads/20120319112312_598.pdf&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Following these steps, and in particular the configuration settings described therein, has allowed us to use FatFS with LFN support except mysteriously when listing files, which still only works in 8.3 format.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Richard&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:16:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FatFS-not-working-in-LPCOpen-2-04-for-LPC4357-see-below-for-fix/m-p/590285#M22047</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: FatFS not working in LPCOpen 2.04 for LPC4357 - see below for fix</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FatFS-not-working-in-LPCOpen-2-04-for-LPC4357-see-below-for-fix/m-p/590286#M22048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by sundarapandian on Thu Feb 27 12:43:00 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;LPCOpen ChanFatFS is supplied with the default configuration. If you want to modify any configuration parameters you should consult the documentation pages at this &lt;/SPAN&gt;&lt;A href="http://http://elm-chan.org/fsw/ff/00index_e.html" rel="nofollow noopener noreferrer" target="_blank"&gt;link&lt;/A&gt;&lt;SPAN&gt;. Moreover LFN is a patent owned by Microsoft and may be that is the reason &lt;/SPAN&gt;&lt;STRONG&gt;elm-chan.org&lt;/STRONG&gt;&lt;SPAN&gt; decided not to enable it in the default configuration. If you want to enable unicode support you can read the documents &lt;/SPAN&gt;&lt;A href="http://http://elm-chan.org/fsw/ff/en/filename.html" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to enable LFN functionality, I would suggest you to read the documentation provided &lt;/SPAN&gt;&lt;A href="http://http://elm-chan.org/fsw/ff/en/appnote.html#lfn" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt;. According to that document to enable LFN the user must implement the functions ff_convert and ff_wtoupper you can find these functions inside (&lt;/SPAN&gt;&lt;STRONG&gt;software\filesystems\fatfs\src\ccsbcs.c&lt;/STRONG&gt;&lt;SPAN&gt;) add it to your project or you can implement your own conversion function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For your information I will provide you the steps I did to enable LFN in my projects&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Implement a simple conversion function (Unicode support is too big so I don't use the default ones)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
WCHAR ff_convert (WCHAR wch, UINT dir)
{
if (wch &amp;lt; 0x80) {
/* ASCII Char */
return wch;
}

/* I don't support unicode it is too big! */
return 0;
}

WCHAR ff_wtoupper (WCHAR wch)
{
if (wch &amp;lt; 0x80) {
/* ASCII Char */
if (wch &amp;gt;= 'a' &amp;amp;&amp;amp; wch &amp;lt;= 'z') {
wch &amp;amp;= ~0x20;
}
return wch;
}

/* I don't support unicode it is too big! */
return 0;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I enable the LFN support by (defining &lt;/SPAN&gt;&lt;STRONG&gt;_USE_LFN&lt;/STRONG&gt;&lt;SPAN&gt; as 1 in software\filesystems\fatfs\src\ffconf.h, I left &lt;/SPAN&gt;&lt;STRONG&gt;_LFN_UNICODE&lt;/STRONG&gt;&lt;SPAN&gt; as the default 0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#define_USE_LFN1
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That is it, the following works fine&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
f_open(&amp;amp;Fil, "New_Text_Document.html", FA_READ);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Although there is no good document that says how to list the files using LFN but I had little peek into the chanFATFS code and came up with the following code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
static TCHAR lfname[_MAX_LFN];
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = f_opendir(&amp;amp;dir, "");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Check result for errors */

printf("Directory listing...\r\n");
for (;; ) {
fno.lfname = lfname;
fno.lfsize = _MAX_LFN - 1;
/* Read a directory item */
rc = f_readdir(&amp;amp;dir, &amp;amp;fno);
if (rc || !fno.fname[0]) {
break;/* Error or end of dir */
}
if (fno.fattrib &amp;amp; AM_DIR) {
sprintf(debugBuf, "&amp;nbsp;&amp;nbsp; [dir]&amp;nbsp; %s\r\n", fno.lfname[0] ? fno.lfname : fno.fname);
}
else {
sprintf(debugBuf, "&amp;nbsp;&amp;nbsp; %8lu&amp;nbsp; %s\r\n", fno.fsize, fno.lfname[0] ? fno.lfname : fno.fname);
}
printf(debugBuf);
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:16:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FatFS-not-working-in-LPCOpen-2-04-for-LPC4357-see-below-for-fix/m-p/590286#M22048</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: FatFS not working in LPCOpen 2.04 for LPC4357 - see below for fix</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FatFS-not-working-in-LPCOpen-2-04-for-LPC4357-see-below-for-fix/m-p/590287#M22049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rgledhill on Fri Feb 28 01:15:08 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you, that's immensely helpful!&amp;nbsp; It would be very useful if NXP included your code above, but left the default of LFN disabled.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It would be great if this could go into next week's LPCOpen update...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll let you know how we get on, and thank you again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Richard&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:16:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FatFS-not-working-in-LPCOpen-2-04-for-LPC4357-see-below-for-fix/m-p/590287#M22049</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: FatFS not working in LPCOpen 2.04 for LPC4357 - see below for fix</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FatFS-not-working-in-LPCOpen-2-04-for-LPC4357-see-below-for-fix/m-p/590288#M22050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by kaikeraut on Wed Apr 02 05:16:58 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;can anyone send me the working code for lpc4330&amp;nbsp; freertos + sdmmc + fatfs&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:16:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FatFS-not-working-in-LPCOpen-2-04-for-LPC4357-see-below-for-fix/m-p/590288#M22050</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:16:39Z</dc:date>
    </item>
  </channel>
</rss>

