FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: Manipulating SD Files with ESD  (Read 7958 times)

LOstrander

  • Newbie
  • *
  • Posts: 8
    • View Profile
Manipulating SD Files with ESD
« on: April 22, 2019, 04:27:41 PM »

I have been trying to incorporate a couple of functions into my ESD program to read and write a few text files from an SD card.

First I tried using the fopen() functions native to C.  The program compiled and ran, but when I went to check the SD card's contents, the files were nowhere to be found.

Next I tired using the FatF header included in the SD card example in the Ft9XX Toolchain.  I changed the functions over to the FatF commands, and included all of the files required in my ESD project.

For some reason, however, it refuses to recognize the typedefs for the various functions within the header (specifically the DSTATUS and DRESULT types in diskio.h), and claims a few variables/enums were undeclared because of this.

So my question is kind of two-fold:  Is there an easy way to communicate with the SD card on the FT900 through ESD for non-bitmap files, and if it involves the ff.h header, what do I change to make it function?

For reference, I'm using the ME812A WH50R and MM900EV-LITE in ESD 4.5.
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 891
    • View Profile
Re: Manipulating SD Files with ESD
« Reply #1 on: April 23, 2019, 10:20:05 AM »

Hello,

The main EVE Sample Application does include a section where it interfaces the SD card, although this only completes a read of data from the card:
Code: [Select]
#ifdef SAMAPP_ENABLE_APIS_SET13
#if defined (ARDUINO_PLATFORM) || defined (FT900_PLATFORM) || defined (FT93X_PLATFORM)
void set13_fontBufferToRAMG(uint8_t *filePath, uint32_t address) {
int chunk_size = 1024;
uint8_t buff[1024];
FIL pFile;
long int curPos = 0;
long int filesz = 0;
UINT bytesread = 0;
FRESULT fResult;

fResult = f_open(&pFile, filePath, FA_READ | FA_OPEN_EXISTING);
if (fResult != FR_OK) {
printf("Cannot open %s, please check SD card, error: %d \n", filePath, fResult);
return;
}
filesz = f_size(&pFile);
printf("Opened %s, file size: %ld\n", filePath, filesz);

while (curPos < filesz) {
bytesread = (filesz - curPos)>chunk_size?chunk_size:(filesz - curPos);

fResult = f_read(&pFile, buff, chunk_size, &bytesread);
if (fResult != FR_OK) {
printf("Error on f_read\n");
return;
}
Gpu_Hal_WrMem(phost, address + curPos, buff, bytesread);
curPos += bytesread;
}
}
#endif

The SD card example from the FT9XX toolchain (section 3.17) is the best SD card interfacing example for the FT9XX:
https://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/MCU/AN-360-FT9xx-Example-Applications.pdf

What exact errors are being thrown?

ESD 4.5 will look for an SD card to be mounted to your development board, however we don't have any examples of writing non bitmap/font data to this.

Best Regards,
FTDI Community
« Last Edit: April 23, 2019, 10:24:09 AM by FTDI Community »
Logged

LOstrander

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Manipulating SD Files with ESD
« Reply #2 on: April 23, 2019, 06:02:49 PM »

I seem to have it working now.  It looks like the emulator's C compiler doesn't like me using the ff.h header in anything besides the ESD specific functions, but when I upload the program to my FT900, it works perfectly.
Logged