6 years, 12 months ago.

EA LPC4088 QuickStart LocalFileSystem

Hello,

I'm trying to port a program from the LPC1768 to the EA LPC4088 QuickStart board. I put a .cfg file on the LPC1768 and read the paramterers by creating a LocalFileSystem and opening the .cfg file. This method doesn't work on the LPC4088, and I'm looking for a similar way for the LPC4088. I need to easily edit the file when connected to the computer and read it when starting the program.

Maybe the solution is obvious but I'm not seeing it.

Thanks for your help.

2 Answers

6 years, 12 months ago.

As far as I am aware only the two original mbeds (LPC1768 and LPC11u24) have the LocalFileSystem implemented.

The demand is really to put a file on it via usb mass storage? The only library I am aware of which could be used for that is: http://mbed.org/users/Sissors/code/USBFileSystem/.

Short summary: Implements a kinda like LocalFileSystem via the host microcontroller (instead of the interface microcontroller that the LocalFileSystem runs on). So you got to use the USB connector/pins of the LPC4088 itself, not the one used for programming (I assume they are also on the LPC4088 seperate ones). Aditionally the library requires you to still give it space to store stuff on, just like the USB MSD and the FATFileSystem libraries. This can be for example an SD card, but also a flash chip (they should be available on the LPC4088 Quickstart thing, but I don't know if there are already libraries to use.

An alternative is that I see it has EEPROM memory. You could also use that to store the files on. (You can also do it in a very limitted fashion on the program flash, but if you have EEPROM that should be superior). Due to the limitted storage space on the EEPROM you might need to hack it together a bit. The IAP library has EEPROM code for the LPC11u24, good chance it is at least similar for the LPC4088: http://mbed.org/users/okano/code/IAP/

Small warning: this will be quite some programming, if you aren't too familiar with it, an alternative solution might be better.

Thanks for the answer, I will consider using a SD Card, but it's not planned in the PCB yet.

posted by Hannes Schenk 06 Dec 2013
6 years, 12 months ago.

What Erik has written is correct. The LocalFileSystem can only be used with the "original" mbed boards. Boards with the new HDK doesn't have any local storage.

The LPC4088 also has an 8MB QSPI flash you can use for storage. In the EALib library we have a simple file system implementation (QSPIFileSystem)

Import libraryEALib

A library with drivers for different peripherals on the LPC4088 QuickStart Board or related add-on boards.

Import programapp_qspi_memstick

The purpose of this application is to allow easy manipulation of the QSPI file system from a PC

Import programapp_qspi_format

Example showing how to create a file system on the QSPI flash.

Andreas @ Embedded Artists

Thanks for the answer, I forgot to mention that I tried the QSPI flash before. It works well, I was just looking for an alternative because I wanted to edit the files simply from the computer without loading the memstick app. But if there's no other easy solution I'll stick to this.

posted by Hannes Schenk 06 Dec 2013

Andreas,

I am having a problem getting QSPI to work. Im sure I missed a step somewhere. In the example given in http://mbed.org/users/embeddedartists/notebook/lpc4088-quickstart-board---software-information/ , there are a few compiler errors.

#include "mbed.h"
#include "QSPIFileSystem.h"
 
QSPIFileSystem qspifs("/qspi/");
int main() {
    if (!qspifs.isFormatted()) {    //kb - s/b isformatted()
        qspifs.format();
    }
    
    FILE* fh = fopen("/qspi/hello.txt");  //kb - s/b fopen("/qspi/hello.txt", "w")
    if (fh != NULL) {
        fwrite("Hello World!", 12, 1, fh);
        fclose();                                       //kb - s/b fclose(fh);
    }
}

In the example given in https://mbed.org/compiler/#nav:/LPC4088-105/EALib/Classes/QSPIFileSystem.doc; , there are also a compiler errors.

#include "mbed.h"
#include "QSPIFileSystem.h"
 
QSPIFileSystem qspi("qspi");
 
int main() {
    if (!qspifs.isFormatted()) {   //kb - same error as above
        qspifs.format();
    }
 
    FILE *fp = fopen("/qspi/myfile.txt", "w");
    if (fp != NULL) {
        fprintf(fp, "Hello World!\n");   //kb - fprintf is not a valid function
        fclose(fp);
    }
}

I am not having luck with opening/writing a file without a return error. The code has never entered the formatting stage.

1. Is there more detail on how fwrite works?

2. Can fprintf be made to work?

Regards,

...kevin

posted by Kevin Braun 09 Jan 2014

Kevin,

Thanks for pointing out those errors. I have updated the Software Information page and published a new version of the EALib with corrected documentation of the QSPIFileSystem class.

1. The fwrite and fprintf are the standard C functions and you can find documentation e.g here

2. The fprintf function does work (just tested it with the online compiler and this program (you need to add EALib as well):

main.cpp

#include "mbed.h"
#include "QSPIFileSystem.h"

QSPIFileSystem qspifs("qspi");

static void cat(const char* fname)
{
    char buff[513];
    int num;
    
    FILE *fp = fopen(fname, "r");
    if (fp == NULL) {
        printf("Failed to open %s\n", fname);
        return;
    }
    
    printf("\n----- Content of %s -----\n", fname);
    while ((num = fread(buff, 1, 512, fp)) > 0)
    {
        buff[num] = '\0';
        printf(buff);
    }
    fclose(fp);
}
 
int main() {
    if (!qspifs.isformatted()) {
        qspifs.format();
    }

    FILE *fp = fopen("/qspi/myfile.txt", "a");
    if (fp != NULL) {
        fprintf(fp, "Hello World Again!\n");
        fclose(fp);
    }
    
    cat("/qspi/myfile.txt");
}


Anders @ Embedded Artists

posted by EmbeddedArtists AB 10 Jan 2014

I found my problem Anders,

In copying the first example, I left the "/" on the name:

QSPIFileSystem qspifs("/qspi/");  //broken

QSPIFileSystem qspifs("qspi");  //works

Now I can access the files

...kevin

posted by Kevin Braun 10 Jan 2014