diff --git a/README.md b/README.md index ae537a3..0443c40 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,10 @@ ## Table of Contents +* [Important Notes for Portenta_H7](#important-notes-for-portenta_h7) * [Why do we need this LittleFS_Portenta_H7 library](#why-do-we-need-this-LittleFS_Portenta_H7-library) * [Features](#features) * [Currently supported Boards](#currently-supported-boards) -* [Changelog](#changelog) - * [Releases v1.0.1](#releases-v101) - * [Initial Releases v1.0.0](#initial-releases-v100) * [Prerequisites](#prerequisites) * [Installation](#installation) * [Use Arduino Library Manager](#use-arduino-library-manager) @@ -34,7 +32,6 @@ * [2. LittleFS_Test on PORTENTA_H7_M7](#2-littlefs_test-on-portenta_h7_m7) * [Debug](#debug) * [Troubleshooting](#troubleshooting) -* [Releases](#releases) * [Issues](#issues) * [TO DO](#to-do) * [DONE](#done) @@ -46,6 +43,17 @@ --- --- +### Important Notes for Portenta_H7 + +The LittleFS of the new **Portenta_H7** board currently tested OK with only **maximum 8 files**. The files, from 9 and up, somehow strangely can't be written and / or read. This is possibly a bug in the [`ArduinoCore-mbed mbed_portenta core`](https://github.com/arduino/ArduinoCore-mbed). The same behaviour is observed from core v2.0.0 up to v2.4.1. + +If LittleFS size is reduced to 1024KB, test is OK with only **maximum 4 files**. + +Beware and keep cheking for updates. + +--- +--- + ### Why do we need this [LittleFS_Portenta_H7 library](https://github.com/khoih-prog/littlefs_portenta_h7) ## Features @@ -63,19 +71,6 @@ The filesystem access uses normal [POSIX APIs](https://www.tutorialspoint.com/c_ --- --- -## Changelog - -### Releases v1.0.1 - -1. Change the default and minimum LITTLEFS_PORTENTA_H7_SIZE_KB to 1024KB, instead at maximum available size. This is done to avoid the cases where the code size is larger, and LittleFS size has to be changed, reformatted, leading to data loss. - -### Initial Releases v1.0.0 - -1. Initial coding to support **Portenta_H7 boards** such as Portenta_H7 Rev2 ABX00042, etc., using [**ArduinoCore-mbed mbed_portenta** core](https://github.com/arduino/ArduinoCore-mbed) - - ---- ---- ## Prerequisites @@ -521,12 +516,10 @@ The following is the sample terminal output when running example [LittleFS_Count ``` Start LittleFS_Counting on PORTENTA_H7_M7 -LittleFS_Portenta_H7 v1.0.1 +LittleFS_Portenta_H7 v1.0.2 [LFS] Flash Size: (KB) = 2048.00 [LFS] FlashIAP Start Address: = 0x0x8080000 -[LFS] New FlashIAP Start Address: = 0x0x8100000 -[LFS] Max LittleFS size (KB) = 1536.00 -[LFS] Current LittleFS size (KB) = 1024 +[LFS] LittleFS size (KB) = 1536.00 [LFS] LittleFS Mount OK Times have been run = 1 => Open to write OK @@ -536,12 +529,10 @@ Times have been run = 1 ``` Start LittleFS_Counting on PORTENTA_H7_M7 -LittleFS_Portenta_H7 v1.0.1 +LittleFS_Portenta_H7 v1.0.2 [LFS] Flash Size: (KB) = 2048.00 [LFS] FlashIAP Start Address: = 0x0x8080000 -[LFS] New FlashIAP Start Address: = 0x0x8100000 -[LFS] Max LittleFS size (KB) = 1536.00 -[LFS] Current LittleFS size (KB) = 1024 +[LFS] LittleFS size (KB) = 1536.00 [LFS] LittleFS Mount OK => Open to read OK Times have been run = 2 @@ -555,12 +546,10 @@ The following is the sample terminal output when running example [LittleFS_Test] ``` Start LittleFS_Test on PORTENTA_H7_M7 -LittleFS_Portenta_H7 v1.0.1 +LittleFS_Portenta_H7 v1.0.2 [LFS] Flash Size: (KB) = 2048.00 [LFS] FlashIAP Start Address: = 0x0x8080000 -[LFS] New FlashIAP Start Address: = 0x0x8100000 -[LFS] Max LittleFS size (KB) = 1536.00 -[LFS] Current LittleFS size (KB) = 1024 +[LFS] LittleFS size (KB) = 1536.00 [LFS] LittleFS Mount OK ==================================================== Writing file: /littlefs/hello1.txt => Open OK @@ -639,18 +628,6 @@ Sometimes, the library will only work if you update the board core to the latest --- --- -## Releases - -### Releases v1.0.1 - -1. Change the default and minimum LITTLEFS_PORTENTA_H7_SIZE_KB to 1024KB, instead at maximum available size. This is done to avoid the cases where the code size is larger, and LittleFS size has to be changed, reformatted, leading to data loss. - -### Initial Releases v1.0.0 - -1. Initial coding to support **Portenta_H7 boards** such as Portenta_H7 Rev2 ABX00042, etc., using [**ArduinoCore-mbed mbed_portenta** core](https://github.com/arduino/ArduinoCore-mbed) - ---- ---- ### Issues diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..a4716c3 --- /dev/null +++ b/changelog.md @@ -0,0 +1,37 @@ +# LittleFS_Portenta_H7 Library + +[![arduino-library-badge](https://www.ardu-badge.com/badge/LittleFS_Portenta_H7.svg?)](https://www.ardu-badge.com/LittleFS_Portenta_H7) +[![GitHub release](https://img.shields.io/github/release/khoih-prog/LittleFS_Portenta_H7.svg)](https://github.com/khoih-prog/LittleFS_Portenta_H7/releases) +[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/LittleFS_Portenta_H7/blob/main/LICENSE) +[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing) +[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/LittleFS_Portenta_H7.svg)](http://github.com/khoih-prog/LittleFS_Portenta_H7/issues) + +--- +--- + +## Table of Contents + +* [Changelog](#changelog) + * [Releases v1.0.2](#releases-v102) + * [Releases v1.0.1](#releases-v101) + * [Initial Releases v1.0.0](#initial-releases-v100) + +--- +--- + +## Changelog + +### Releases v1.0.2 + +1. Back to using auto LittleFS size to fix bug and to permit 8 LittleFS files instead of 4 in previous release. There is a bug somewhere in the [`ArduinoCore-mbed mbed_portenta core`](https://github.com/arduino/ArduinoCore-mbed) and we have to live with it. + +### Releases v1.0.1 + +1. Change the default and minimum LITTLEFS_PORTENTA_H7_SIZE_KB to 1024KB, instead at maximum available size. This is done to avoid the cases where the code size is larger, and LittleFS size has to be changed, reformatted, leading to data loss. + +### Initial Releases v1.0.0 + +1. Initial coding to support **Portenta_H7 boards** such as Portenta_H7 Rev2 ABX00042, etc., using [**ArduinoCore-mbed mbed_portenta** core](https://github.com/arduino/ArduinoCore-mbed) + + + diff --git a/examples/LittleFS_Counting/LittleFS_Counting.ino b/examples/LittleFS_Counting/LittleFS_Counting.ino index 226af8e..3bed7c9 100644 --- a/examples/LittleFS_Counting/LittleFS_Counting.ino +++ b/examples/LittleFS_Counting/LittleFS_Counting.ino @@ -7,12 +7,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_Portenta_H7 Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #define _LFS_LOGLEVEL_ 1 @@ -28,7 +29,7 @@ LittleFS_MBED *myFS; void setup() { Serial.begin(115200); - while (!Serial) + while (!Serial); delay(1000); diff --git a/examples/LittleFS_Test/LittleFS_Test.ino b/examples/LittleFS_Test/LittleFS_Test.ino index e2f44ed..40c7f50 100644 --- a/examples/LittleFS_Test/LittleFS_Test.ino +++ b/examples/LittleFS_Test/LittleFS_Test.ino @@ -1,41 +1,38 @@ /**************************************************************************************************************************** - LittleFS_Test.ino - Filesystem wrapper for LittleFS on the Mbed - + LittleFS_Test.ino - Filesystem wrapper for LittleFS on the Mbed + For MBED boards Written by Khoi Hoang Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_ Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #define _LFS_LOGLEVEL_ 1 #define FORCE_REFORMAT false -#if !defined(LITTLEFS_PORTENTA_H7_SIZE_KB) - #define LITTLEFS_PORTENTA_H7_SIZE_KB 1024 -#endif - #include LittleFS_MBED *myFS; uint32_t FILE_SIZE_KB = 64; -void readCharsFromFile(const char * path) +void readCharsFromFile(const char * path) { Serial.print("readCharsFromFile: "); Serial.print(path); FILE *file = fopen(path, "r"); - - if (file) + + if (file) { Serial.println(" => Open OK"); } @@ -47,28 +44,28 @@ void readCharsFromFile(const char * path) char c; - while (true) + while (true) { c = fgetc(file); - - if ( feof(file) ) - { + + if ( feof(file) ) + { break; } - else + else Serial.print(c); } - + fclose(file); } -void readFile(const char * path) +void readFile(const char * path) { Serial.print("Reading file: "); Serial.print(path); FILE *file = fopen(path, "r"); - - if (file) + + if (file) { Serial.println(" => Open OK"); } @@ -80,25 +77,25 @@ void readFile(const char * path) char c; uint32_t numRead = 1; - - while (numRead) + + 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) +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) + + if (file) { Serial.println(" => Open OK"); } @@ -107,26 +104,26 @@ void writeFile(const char * path, const char * message, size_t messageSize) Serial.println(" => Open Failed"); return; } - - if (fwrite((uint8_t *) message, 1, messageSize, file)) + + if (fwrite((uint8_t *) message, 1, messageSize, file)) { Serial.println("* Writing OK"); - } - else + } + else { Serial.println("* Writing failed"); } - + fclose(file); } -void appendFile(const char * path, const char * message, size_t messageSize) +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) + + if (file) { Serial.println(" => Open OK"); } @@ -136,23 +133,23 @@ void appendFile(const char * path, const char * message, size_t messageSize) return; } - if (fwrite((uint8_t *) message, 1, messageSize, file)) + if (fwrite((uint8_t *) message, 1, messageSize, file)) { Serial.println("* Appending OK"); - } - else + } + else { Serial.println("* Appending failed"); } - + fclose(file); } -void deleteFile(const char * path) +void deleteFile(const char * path) { Serial.print("Deleting file: "); Serial.print(path); - - if (remove(path) == 0) + + if (remove(path) == 0) { Serial.println(" => OK"); } @@ -163,12 +160,12 @@ void deleteFile(const char * path) } } -void renameFile(const char * path1, const char * path2) +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) + + if (rename(path1, path2) == 0) { Serial.println(" => OK"); } @@ -179,17 +176,17 @@ void renameFile(const char * path1, const char * path2) } } -void testFileIO(const char * path) +void testFileIO(const char * path) { Serial.print("Testing file I/O with: "); Serial.print(path); - #define BUFF_SIZE 512 - +#define BUFF_SIZE 512 + static uint8_t buf[BUFF_SIZE]; - + FILE *file = fopen(path, "w"); - - if (file) + + if (file) { Serial.println(" => Open OK"); } @@ -201,7 +198,7 @@ void testFileIO(const char * path) size_t i; Serial.println("- writing" ); - + uint32_t start = millis(); size_t result = 0; @@ -219,14 +216,14 @@ void testFileIO(const char * path) break; } } - + Serial.println(""); uint32_t end = millis() - start; - + Serial.print(i / 2); Serial.print(" Kbytes written in (ms) "); Serial.println(end); - + fclose(file); printLine(); @@ -234,12 +231,12 @@ void testFileIO(const char * path) ///////////////////////////////// file = fopen(path, "r"); - + start = millis(); end = start; i = 0; - - if (file) + + if (file) { start = millis(); Serial.println("- reading" ); @@ -249,7 +246,7 @@ void testFileIO(const char * path) fseek(file, 0, SEEK_SET); // Read a file with FILE_SIZE_KB - for (i = 0; i < FILE_SIZE_KB * 2; i++) + for (i = 0; i < FILE_SIZE_KB * 2; i++) { result = fread(buf, BUFF_SIZE, 1, file); @@ -261,17 +258,17 @@ void testFileIO(const char * path) break; } } - + Serial.println(""); end = millis() - start; - + Serial.print((i * BUFF_SIZE) / 1024); Serial.print(" Kbytes read in (ms) "); Serial.println(end); - + fclose(file); - } - else + } + else { Serial.println("- failed to open file for reading"); } @@ -282,30 +279,30 @@ void printLine() Serial.println("===================================================="); } -void setup() +void setup() { Serial.begin(115200); while (!Serial) - delay(1000); + delay(1000); Serial.print("\nStart LittleFS_Test on "); Serial.println(BOARD_NAME); Serial.println(LFS_MBED_PORTENTA_H7_VERSION); myFS = new LittleFS_MBED(); - if (!myFS->init()) + 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(); @@ -339,6 +336,6 @@ void setup() Serial.println( "\nTest complete" ); } -void loop() +void loop() { } diff --git a/library.json b/library.json index 96693a0..d5bd9f1 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "LittleFS_Portenta_H7", - "version": "1.0.1", + "version": "1.0.2", "keywords": "storage, data-storage, littlefs, littlefs-mbed, flash, flash-storage, posix, file-system, file, mbed, mbed-portenta, portenta-h7, portentah7, portenta-h7-m7, portenta-h7-m4, portentah7-m7, portentah7-m4", "description": "This library facilitates your usage of LittleFS for the onboard flash of Arduino MBED Portenta_H7 boards. LittleFS supports power fail safety and high performance", "authors": diff --git a/library.properties b/library.properties index b56c065..d6c5e07 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=LittleFS_Portenta_H7 -version=1.0.1 +version=1.0.2 author=Khoi Hoang maintainer=Khoi Hoang sentence=Wrapper of LittleFS for Arduino MBED Portenta_H7 boards diff --git a/src/FlashIAPLimits.h b/src/FlashIAPLimits.h index e5d68a7..d6cc9df 100644 --- a/src/FlashIAPLimits.h +++ b/src/FlashIAPLimits.h @@ -9,12 +9,13 @@ Modified from sample Code from Arduino-mbed mbed_portenta core for Portenta_H7 - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once diff --git a/src/LittleFS_Portenta_H7.h b/src/LittleFS_Portenta_H7.h index b2e14a8..fe1c513 100644 --- a/src/LittleFS_Portenta_H7.h +++ b/src/LittleFS_Portenta_H7.h @@ -7,12 +7,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_Portenta_H7 Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once @@ -40,7 +41,7 @@ #endif #ifndef LFS_MBED_PORTENTA_H7_VERSION - #define LFS_MBED_PORTENTA_H7_VERSION "LittleFS_Portenta_H7 v1.0.1" + #define LFS_MBED_PORTENTA_H7_VERSION "LittleFS_Portenta_H7 v1.0.2" #endif #ifndef LFS_PORTENTA_H7_DEBUG @@ -94,15 +95,6 @@ #endif -#if !defined(LITTLEFS_PORTENTA_H7_SIZE_KB) - #define LITTLEFS_PORTENTA_H7_SIZE_KB 1024 - #warning Force LITTLEFS_PORTENTA_H7_SIZE_KB to 1024 (KB) -#elif (LITTLEFS_PORTENTA_H7_SIZE_KB < 1024) - #undef LITTLEFS_PORTENTA_H7_SIZE_KB - #define LITTLEFS_PORTENTA_H7_SIZE_KB 1024 - #warning Correct LITTLEFS_PORTENTA_H7_SIZE_KB to 1024 (KB) -#endif - static FlashIAPBlockDevice* blockDevicePtr; static mbed::LittleFileSystem fs(MBED_LITTLEFS_FILE_NAME); diff --git a/src/LittleFS_Portenta_H7.hpp b/src/LittleFS_Portenta_H7.hpp index 1c38e30..a7808aa 100644 --- a/src/LittleFS_Portenta_H7.hpp +++ b/src/LittleFS_Portenta_H7.hpp @@ -7,41 +7,32 @@ Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_Portenta_H7 Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once #ifndef _LITTLEFS_PORTENTA_H7_HPP #define _LITTLEFS_PORTENTA_H7_HPP - + bool LittleFS_MBED::init() { // Get limits of the the internal flash of the microcontroller _flashIAPLimits = getFlashIAPLimits(); - - if (_flashIAPLimits.available_size < LITTLEFS_PORTENTA_H7_SIZE_KB * 1024) - { - LFS_LOGERROR2("Max LittleFS size (KB) = ", _flashIAPLimits.available_size / 1024.0, " is too small. Must be 1024+"); - return false; - } - - _sizeInKB = LITTLEFS_PORTENTA_H7_SIZE_KB; - - uint32_t deltaSize = _flashIAPLimits.available_size - LITTLEFS_PORTENTA_H7_SIZE_KB * 1024; LFS_LOGERROR1("Flash Size: (KB) = ", _flashIAPLimits.flash_size / 1024.0); LFS_HEXLOGERROR1("FlashIAP Start Address: = 0x", _flashIAPLimits.start_address); - LFS_HEXLOGERROR1("New FlashIAP Start Address: = 0x", _flashIAPLimits.start_address + deltaSize); - LFS_LOGERROR1("Max LittleFS size (KB) = ", _flashIAPLimits.available_size / 1024.0); - LFS_LOGERROR1("Current LittleFS size (KB) = ", LITTLEFS_PORTENTA_H7_SIZE_KB); - - blockDevicePtr = new FlashIAPBlockDevice(_flashIAPLimits.start_address + deltaSize, LITTLEFS_PORTENTA_H7_SIZE_KB * 1024); + LFS_LOGERROR1("LittleFS size (KB) = ", _flashIAPLimits.available_size / 1024.0); + + _sizeInKB = _flashIAPLimits.available_size / 1024.0; + + blockDevicePtr = new FlashIAPBlockDevice(_flashIAPLimits.start_address, _flashIAPLimits.available_size); if (!blockDevicePtr) { diff --git a/src/LittleFS_Portenta_H7_Debug.h b/src/LittleFS_Portenta_H7_Debug.h index ee25010..6d4d6b2 100644 --- a/src/LittleFS_Portenta_H7_Debug.h +++ b/src/LittleFS_Portenta_H7_Debug.h @@ -7,12 +7,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_Portenta_H7 Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once diff --git a/src_cpp/FlashIAPLimits.h b/src_cpp/FlashIAPLimits.h index e5d68a7..d6cc9df 100644 --- a/src_cpp/FlashIAPLimits.h +++ b/src_cpp/FlashIAPLimits.h @@ -9,12 +9,13 @@ Modified from sample Code from Arduino-mbed mbed_portenta core for Portenta_H7 - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once diff --git a/src_cpp/LittleFS_Portenta_H7.cpp b/src_cpp/LittleFS_Portenta_H7.cpp index a9d97ae..8dc19d7 100644 --- a/src_cpp/LittleFS_Portenta_H7.cpp +++ b/src_cpp/LittleFS_Portenta_H7.cpp @@ -7,12 +7,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_Portenta_H7 Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #include "LittleFS_Portenta_H7.h" @@ -21,24 +22,14 @@ bool LittleFS_MBED::init() { // Get limits of the the internal flash of the microcontroller _flashIAPLimits = getFlashIAPLimits(); - - if (_flashIAPLimits.available_size < LITTLEFS_PORTENTA_H7_SIZE_KB * 1024) - { - LFS_LOGERROR2("Max LittleFS size (KB) = ", _flashIAPLimits.available_size / 1024.0, " is too small. Must be 1024+"); - return false; - } - - _sizeInKB = LITTLEFS_PORTENTA_H7_SIZE_KB; - - uint32_t deltaSize = _flashIAPLimits.available_size - LITTLEFS_PORTENTA_H7_SIZE_KB * 1024; LFS_LOGERROR1("Flash Size: (KB) = ", _flashIAPLimits.flash_size / 1024.0); LFS_HEXLOGERROR1("FlashIAP Start Address: = 0x", _flashIAPLimits.start_address); - LFS_HEXLOGERROR1("New FlashIAP Start Address: = 0x", _flashIAPLimits.start_address + deltaSize); - LFS_LOGERROR1("Max LittleFS size (KB) = ", _flashIAPLimits.available_size / 1024.0); - LFS_LOGERROR1("Current LittleFS size (KB) = ", LITTLEFS_PORTENTA_H7_SIZE_KB); - - blockDevicePtr = new FlashIAPBlockDevice(_flashIAPLimits.start_address + deltaSize, LITTLEFS_PORTENTA_H7_SIZE_KB * 1024); + LFS_LOGERROR1("LittleFS size (KB) = ", _flashIAPLimits.available_size / 1024.0); + + _sizeInKB = _flashIAPLimits.available_size / 1024.0; + + blockDevicePtr = new FlashIAPBlockDevice(_flashIAPLimits.start_address, _flashIAPLimits.available_size); if (!blockDevicePtr) { diff --git a/src_cpp/LittleFS_Portenta_H7.h b/src_cpp/LittleFS_Portenta_H7.h index 9c42b64..c3e1732 100644 --- a/src_cpp/LittleFS_Portenta_H7.h +++ b/src_cpp/LittleFS_Portenta_H7.h @@ -7,12 +7,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_Portenta_H7 Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once @@ -40,7 +41,7 @@ #endif #ifndef LFS_MBED_PORTENTA_H7_VERSION - #define LFS_MBED_PORTENTA_H7_VERSION "LittleFS_Portenta_H7 v1.0.1" + #define LFS_MBED_PORTENTA_H7_VERSION "LittleFS_Portenta_H7 v1.0.2" #endif #ifndef LFS_PORTENTA_H7_DEBUG @@ -94,15 +95,6 @@ #endif -#if !defined(LITTLEFS_PORTENTA_H7_SIZE_KB) - #define LITTLEFS_PORTENTA_H7_SIZE_KB 1024 - #warning Force LITTLEFS_PORTENTA_H7_SIZE_KB to 1024 (KB) -#elif (LITTLEFS_PORTENTA_H7_SIZE_KB < 1024) - #undef LITTLEFS_PORTENTA_H7_SIZE_KB - #define LITTLEFS_PORTENTA_H7_SIZE_KB 1024 - #warning Correct LITTLEFS_PORTENTA_H7_SIZE_KB to 1024 (KB) -#endif - static FlashIAPBlockDevice* blockDevicePtr; static mbed::LittleFileSystem fs(MBED_LITTLEFS_FILE_NAME); diff --git a/src_cpp/LittleFS_Portenta_H7_Debug.h b/src_cpp/LittleFS_Portenta_H7_Debug.h index ee25010..6d4d6b2 100644 --- a/src_cpp/LittleFS_Portenta_H7_Debug.h +++ b/src_cpp/LittleFS_Portenta_H7_Debug.h @@ -7,12 +7,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_Portenta_H7 Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once diff --git a/src_h/FlashIAPLimits.h b/src_h/FlashIAPLimits.h index e5d68a7..d6cc9df 100644 --- a/src_h/FlashIAPLimits.h +++ b/src_h/FlashIAPLimits.h @@ -9,12 +9,13 @@ Modified from sample Code from Arduino-mbed mbed_portenta core for Portenta_H7 - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once diff --git a/src_h/LittleFS_Portenta_H7.h b/src_h/LittleFS_Portenta_H7.h index b2e14a8..fe1c513 100644 --- a/src_h/LittleFS_Portenta_H7.h +++ b/src_h/LittleFS_Portenta_H7.h @@ -7,12 +7,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_Portenta_H7 Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once @@ -40,7 +41,7 @@ #endif #ifndef LFS_MBED_PORTENTA_H7_VERSION - #define LFS_MBED_PORTENTA_H7_VERSION "LittleFS_Portenta_H7 v1.0.1" + #define LFS_MBED_PORTENTA_H7_VERSION "LittleFS_Portenta_H7 v1.0.2" #endif #ifndef LFS_PORTENTA_H7_DEBUG @@ -94,15 +95,6 @@ #endif -#if !defined(LITTLEFS_PORTENTA_H7_SIZE_KB) - #define LITTLEFS_PORTENTA_H7_SIZE_KB 1024 - #warning Force LITTLEFS_PORTENTA_H7_SIZE_KB to 1024 (KB) -#elif (LITTLEFS_PORTENTA_H7_SIZE_KB < 1024) - #undef LITTLEFS_PORTENTA_H7_SIZE_KB - #define LITTLEFS_PORTENTA_H7_SIZE_KB 1024 - #warning Correct LITTLEFS_PORTENTA_H7_SIZE_KB to 1024 (KB) -#endif - static FlashIAPBlockDevice* blockDevicePtr; static mbed::LittleFileSystem fs(MBED_LITTLEFS_FILE_NAME); diff --git a/src_h/LittleFS_Portenta_H7.hpp b/src_h/LittleFS_Portenta_H7.hpp index 1c38e30..a7808aa 100644 --- a/src_h/LittleFS_Portenta_H7.hpp +++ b/src_h/LittleFS_Portenta_H7.hpp @@ -7,41 +7,32 @@ Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_Portenta_H7 Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once #ifndef _LITTLEFS_PORTENTA_H7_HPP #define _LITTLEFS_PORTENTA_H7_HPP - + bool LittleFS_MBED::init() { // Get limits of the the internal flash of the microcontroller _flashIAPLimits = getFlashIAPLimits(); - - if (_flashIAPLimits.available_size < LITTLEFS_PORTENTA_H7_SIZE_KB * 1024) - { - LFS_LOGERROR2("Max LittleFS size (KB) = ", _flashIAPLimits.available_size / 1024.0, " is too small. Must be 1024+"); - return false; - } - - _sizeInKB = LITTLEFS_PORTENTA_H7_SIZE_KB; - - uint32_t deltaSize = _flashIAPLimits.available_size - LITTLEFS_PORTENTA_H7_SIZE_KB * 1024; LFS_LOGERROR1("Flash Size: (KB) = ", _flashIAPLimits.flash_size / 1024.0); LFS_HEXLOGERROR1("FlashIAP Start Address: = 0x", _flashIAPLimits.start_address); - LFS_HEXLOGERROR1("New FlashIAP Start Address: = 0x", _flashIAPLimits.start_address + deltaSize); - LFS_LOGERROR1("Max LittleFS size (KB) = ", _flashIAPLimits.available_size / 1024.0); - LFS_LOGERROR1("Current LittleFS size (KB) = ", LITTLEFS_PORTENTA_H7_SIZE_KB); - - blockDevicePtr = new FlashIAPBlockDevice(_flashIAPLimits.start_address + deltaSize, LITTLEFS_PORTENTA_H7_SIZE_KB * 1024); + LFS_LOGERROR1("LittleFS size (KB) = ", _flashIAPLimits.available_size / 1024.0); + + _sizeInKB = _flashIAPLimits.available_size / 1024.0; + + blockDevicePtr = new FlashIAPBlockDevice(_flashIAPLimits.start_address, _flashIAPLimits.available_size); if (!blockDevicePtr) { diff --git a/src_h/LittleFS_Portenta_H7_Debug.h b/src_h/LittleFS_Portenta_H7_Debug.h index ee25010..6d4d6b2 100644 --- a/src_h/LittleFS_Portenta_H7_Debug.h +++ b/src_h/LittleFS_Portenta_H7_Debug.h @@ -7,12 +7,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/LittleFS_Portenta_H7 Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 09/09/2021 Initial coding to support MBED Portenta_H7 1.0.1 K Hoang 13/09/2021 Select fix LittleFS size of 1024KB + 1.0.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug *****************************************************************************************************************************/ #pragma once