Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
v1.2.0 to fix multiple-definitions linker error
Browse files Browse the repository at this point in the history
### Releases v1.2.0

1. Fix `multiple-definitions` linker error in some cases
2. Update `Packages_Patches`
  • Loading branch information
khoih-prog authored May 13, 2022
1 parent 1e32004 commit f18bb72
Showing 1 changed file with 3 additions and 337 deletions.
340 changes: 3 additions & 337 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The filesystem access uses normal [POSIX APIs](https://www.tutorialspoint.com/c_

## Prerequisites

1. [`Arduino IDE 1.8.19+` for Arduino](https://www.arduino.cc/en/Main/Software)
1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest)
2. [`ArduinoCore-mbed mbed_portenta core 3.0.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino **Portenta_H7** boards, such as **Portenta_H7 Rev2 ABX00042, etc.**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest)

---
Expand Down Expand Up @@ -155,344 +155,10 @@ This file must be copied into the directory:
---
---

### Example [Littlefs_Test](examples/Littlefs_Test)
### Example [LittleFS_Test](examples/LittleFS_Test)

```
#define LFS_MBED_PORTENTA_H7_VERSION_MIN_TARGET "LittleFS_Portenta_H7 v1.2.0"
#define LFS_MBED_PORTENTA_H7_VERSION_MIN 1002000
#define _LFS_LOGLEVEL_ 1
#define FORCE_REFORMAT false
#include <LittleFS_Portenta_H7.h>
LittleFS_MBED *myFS;
uint32_t FILE_SIZE_KB = 64;
void readCharsFromFile(const char * path)
{
Serial.print("readCharsFromFile: "); Serial.print(path);
FILE *file = fopen(path, "r");
if (file)
{
Serial.println(" => Open OK");
}
else
{
Serial.println(" => Open Failed");
return;
}
char c;
while (true)
{
c = fgetc(file);
if ( feof(file) )
{
break;
}
else
Serial.print(c);
}
fclose(file);
}
void readFile(const char * path)
{
Serial.print("Reading file: "); Serial.print(path);
FILE *file = fopen(path, "r");
if (file)
{
Serial.println(" => Open OK");
}
else
{
Serial.println(" => Open Failed");
return;
}
char c;
uint32_t numRead = 1;
while (numRead)
{
numRead = fread((uint8_t *) &c, sizeof(c), 1, file);
if (numRead)
Serial.print(c);
}
fclose(file);
}
void writeFile(const char * path, const char * message, size_t messageSize)
{
Serial.print("Writing file: "); Serial.print(path);
FILE *file = fopen(path, "w");
if (file)
{
Serial.println(" => Open OK");
}
else
{
Serial.println(" => Open Failed");
return;
}
if (fwrite((uint8_t *) message, 1, messageSize, file))
{
Serial.println("* Writing OK");
}
else
{
Serial.println("* Writing failed");
}
fclose(file);
}
void appendFile(const char * path, const char * message, size_t messageSize)
{
Serial.print("Appending file: "); Serial.print(path);
FILE *file = fopen(path, "a");
if (file)
{
Serial.println(" => Open OK");
}
else
{
Serial.println(" => Open Failed");
return;
}
if (fwrite((uint8_t *) message, 1, messageSize, file))
{
Serial.println("* Appending OK");
}
else
{
Serial.println("* Appending failed");
}
fclose(file);
}
void deleteFile(const char * path)
{
Serial.print("Deleting file: "); Serial.print(path);
if (remove(path) == 0)
{
Serial.println(" => OK");
}
else
{
Serial.println(" => Failed");
return;
}
}
void renameFile(const char * path1, const char * path2)
{
Serial.print("Renaming file: "); Serial.print(path1);
Serial.print(" to: "); Serial.print(path2);
if (rename(path1, path2) == 0)
{
Serial.println(" => OK");
}
else
{
Serial.println(" => Failed");
return;
}
}
void testFileIO(const char * path)
{
Serial.print("Testing file I/O with: "); Serial.print(path);
#define BUFF_SIZE 512
static uint8_t buf[BUFF_SIZE];
FILE *file = fopen(path, "w");
if (file)
{
Serial.println(" => Open OK");
}
else
{
Serial.println(" => Open Failed");
return;
}
size_t i;
Serial.println("- writing" );
uint32_t start = millis();
size_t result = 0;
// Write a file with FILE_SIZE_KB
for (i = 0; i < FILE_SIZE_KB * 2; i++)
{
result = fwrite(buf, BUFF_SIZE, 1, file);
if ( result != 1)
{
Serial.print("Write result = "); Serial.println(result);
Serial.print("Write error, i = "); Serial.println(i);
break;
}
}
Serial.println("");
uint32_t end = millis() - start;
Serial.print(i / 2);
Serial.print(" Kbytes written in (ms) ");
Serial.println(end);
fclose(file);
printLine();
/////////////////////////////////
file = fopen(path, "r");
start = millis();
end = start;
i = 0;
if (file)
{
start = millis();
Serial.println("- reading" );
result = 0;
fseek(file, 0, SEEK_SET);
// Read a file with FILE_SIZE_KB
for (i = 0; i < FILE_SIZE_KB * 2; i++)
{
result = fread(buf, BUFF_SIZE, 1, file);
if ( result != 1 )
{
Serial.print("Read result = "); Serial.println(result);
Serial.print("Read error, i = "); Serial.println(i);
break;
}
}
Serial.println("");
end = millis() - start;
Serial.print((i * BUFF_SIZE) / 1024);
Serial.print(" Kbytes read in (ms) ");
Serial.println(end);
fclose(file);
}
else
{
Serial.println("- failed to open file for reading");
}
}
https://github.com/khoih-prog/LittleFS_Portenta_H7/blob/1e320047022d4f9b1dd66b18a8fc26b59883c20f/examples/LittleFS_Test/LittleFS_Test.ino#L11-L344

void printLine()
{
Serial.println("====================================================");
}
void setup()
{
Serial.begin(115200);
while (!Serial)
delay(1000);
Serial.print("\nStart LittleFS_Test on "); Serial.println(BOARD_NAME);
Serial.println(LFS_MBED_PORTENTA_H7_VERSION);
#if defined(LFS_MBED_PORTENTA_H7_VERSION_MIN)
if (LFS_MBED_PORTENTA_H7_VERSION_INT < LFS_MBED_PORTENTA_H7_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(LFS_MBED_PORTENTA_H7_VERSION_MIN_TARGET);
}
#endif
myFS = new LittleFS_MBED();
if (!myFS->init())
{
Serial.println("LITTLEFS Mount Failed");
return;
}
char fileName1[] = MBED_LITTLEFS_FILE_PREFIX "/hello1.txt";
char fileName2[] = MBED_LITTLEFS_FILE_PREFIX "/hello2.txt";
char message[] = "Hello from " BOARD_NAME "\n";
printLine();
writeFile(fileName1, message, sizeof(message));
printLine();
readFile(fileName1);
printLine();
appendFile(fileName1, message, sizeof(message));
printLine();
readFile(fileName1);
printLine();
renameFile(fileName1, fileName2);
printLine();
readCharsFromFile(fileName2);
printLine();
deleteFile(fileName2);
printLine();
readFile(fileName2);
printLine();
testFileIO(fileName1);
printLine();
testFileIO(fileName2);
printLine();
deleteFile(fileName1);
printLine();
deleteFile(fileName2);
printLine();
Serial.println( "\nTest complete" );
}
void loop()
{
}
```
---
---

Expand Down

0 comments on commit f18bb72

Please sign in to comment.