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

Commit

Permalink
v1.2.0 to use correct NANO33BLE_FS_START
Browse files Browse the repository at this point in the history
### Releases v1.2.0

1. Use correct NANO33BLE_FS_START address without wasting flash space. Check [Half size of flash #2](#2)
2. Enforce min 64KB / max 512KB of flash used for LittleFS by auto-adjusting NANO33BLE_FS_SIZE_KB if defined smaller than 64KB or larger than 512KB
3. Enforce 512KB of flash used for FATFS by auto-adjusting NANO33BLE_FS_SIZE_KB if defined different from 512KB
4. Update all examples
  • Loading branch information
khoih-prog authored Jan 15, 2022
1 parent 2d13d7c commit ed72d21
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 44 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Arduino IDE version: 1.8.19
Arduino mbed_nano core v2.6.1
Nano_33_BLE board
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.4.0-94-generic #106-Ubuntu SMP Thu Jan 6 23:58:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered a crash while using TimerInterrupt.
Expand Down
54 changes: 41 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## Table of Contents

* [Why do we need this FS_Nano33BLE library](#why-do-we-need-this-FS_Nano33BLE-library)
* [Important Notes](#Important-Notes)
* [Features](#features)
* [Currently supported Boards](#currently-supported-boards)
* [Changelog](changelog.md)
Expand Down Expand Up @@ -43,6 +44,11 @@

### Why do we need this [FS_Nano33BLE library](https://github.com/khoih-prog/FS_Nano33BLE)

## Important Notes

Avoid using FATFS because the somehow (issue with the core ???) it's OK to use only with 512KB. Please use the better LittleFS, where you can select the size anywhere from 64KB to 512KB.


## Features

This library is just a simple LittleFS wrapper to facilitate your usage of LittleFS for the onboard flash on **MBED nRF52840-based boards such as Nano_33_BLE, Nano_33_BLE_Sense**, using [**Arduino-mbed mbed_nano** core](https://github.com/arduino/ArduinoCore-mbed)
Expand All @@ -60,7 +66,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. [`Arduino mbed_nano core 2.6.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) MBED nRF52840-based boards such as **Nano_33_BLE, Nano_33_BLE_Sense**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest)

---
Expand Down Expand Up @@ -105,11 +111,14 @@ Another way to install is to:
### Example [FS_Test](examples/FS_Test)

```
#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.1.0"
#define FS_NANO33BLE_VERSION_MIN 1001000
#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.2.0"
#define FS_NANO33BLE_VERSION_MIN 1002000
#define _FS_LOGLEVEL_ 1
#define NANO33BLE_FS_SIZE_KB 256
// Min NANO33BLE_FS_SIZE_KB must be 64KB. If defined smalller => auto adjust to 64KB
// Max NANO33BLE_FS_SIZE_KB must be 512KB. If defined larger => auto adjust to 512KB
#define NANO33BLE_FS_SIZE_KB 64
#define FORCE_REFORMAT false
Expand Down Expand Up @@ -391,6 +400,9 @@ void setup()
}
#endif
Serial.print("FS_size (KB) = "); Serial.println(NANO33BLE_FS_SIZE_KB);
Serial.print("FS_ Start Address = 0x"); Serial.println(NANO33BLE_FS_START, HEX);
myFS = new FileSystem_MBED();
if (!myFS->init())
Expand Down Expand Up @@ -453,23 +465,25 @@ The following is the sample terminal output when running example [FS_Counting](e

```
Start FS_Test on Nano 33 BLE
LittleFS_Nano33BLE v1.1.0
[LFS] LittleFS size (KB) = 256
LittleFS_Nano33BLE v1.2.0
FS_size (KB) = 256
FS_ Start Address = 0xC0000
[FS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
Deleting file: /littlefs/counts.txt => OK
Times have been run = 1
=> Open to write OK
Start FS_Test on Nano 33 BLE
LittleFS_Nano33BLE v1.1.0
LittleFS_Nano33BLE v1.2.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
=> Open to read OK
Times have been run = 2
=> Open to write OK
Start FS_Test on Nano 33 BLE
LittleFS_Nano33BLE v1.1.0
LittleFS_Nano33BLE v1.2.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
=> Open to read OK
Expand All @@ -486,8 +500,10 @@ The following is the sample terminal output when running example [FS_Test](examp

```
Start FS_Test on Nano 33 BLE
LittleFS_Nano33BLE v1.1.0
[LFS] LittleFS size (KB) = 256
LittleFS_Nano33BLE v1.2.0
FS_size (KB) = 256
FS_ Start Address = 0xC0000
[FS] LittleFS size (KB) = 256
[LFS] LittleFS Mount Fail
[LFS] Formatting...
[LFS]
Expand Down Expand Up @@ -545,15 +561,17 @@ Test complete

---

### 3. FS_Test on Nano 33 BLE with FATFS size 256KB
### 3. FS_Test on Nano 33 BLE with FATFS size 512KB

The following is the sample terminal output when running example [FS_Test](examples/FS_Test) on MBED Nano_33_BLE using **FATFS**


```
Start FS_Test on Nano 33 BLE
FATFS_Nano33BLE v1.1.0
[LFS] FATFS size (KB) = 256
FATFS_Nano33BLE v1.2.0
FS_size (KB) = 512
FS_ Start Address = 0x80000
[FS] LittleFS size (KB) = 512
[LFS] FATFS Mount OK
====================================================
Writing file: /fs/hello1.txt => Open OK
Expand Down Expand Up @@ -654,6 +672,8 @@ Submit issues to: [FS_Nano33BLE issues](https://github.com/khoih-prog/FS_Nano33B
2. Add Version String
3. Add Table of Contents
4. Fix `multiple-definitions` linker error
5. Use correct `NANO33BLE_FS_START` address for `LittleFS` without wasting flash space. Check [Half size of flash #2](https://github.com/khoih-prog/FS_Nano33BLE/discussions/2)


---
---
Expand All @@ -662,6 +682,14 @@ Submit issues to: [FS_Nano33BLE issues](https://github.com/khoih-prog/FS_Nano33B

Many thanks for everyone for bug reporting, new feature suggesting, testing and contributing to the development of this library.

1. Thanks to [Rob Probin](https://github.com/robzed) to report issue [Half size of flash #2](https://github.com/khoih-prog/FS_Nano33BLE/discussions/2) leading to v1.2.0

<table>
<tr>
<td align="center"><a href="https://github.com/robzed"><img src="https://github.com/robzed.png" width="100px;" alt="robzed"/><br /><sub><b>Rob Probin</b></sub></a><br /></td>
</tr>
</table>


---

Expand Down
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Releases v1.2.0](#releases-v120)
* [Releases v1.1.0](#releases-v110)
* [Initial Releases v1.0.0](#initial-releases-v100)

Expand All @@ -20,6 +21,13 @@

## Changelog

### Releases v1.2.0

1. Use correct NANO33BLE_FS_START address without wasting flash space. Check [Half size of flash #2](https://github.com/khoih-prog/FS_Nano33BLE/discussions/2)
2. Enforce min 64KB / max 512KB of flash used for LittleFS by auto-adjusting NANO33BLE_FS_SIZE_KB if defined smaller than 64KB or larger than 512KB
3. Enforce 512KB of flash used for FATFS by auto-adjusting NANO33BLE_FS_SIZE_KB if defined different from 512KB
4. Update all examples

### Releases v1.1.0

1. Fix `multiple-definitions` linker error. Check [Different behaviour using the src_cpp or src_h lib #80](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/80)
Expand Down
19 changes: 10 additions & 9 deletions examples/FS_Counting/FS_Counting.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@
Built by Khoi Hoang https://github.com/khoih-prog/FS_Nano33BLE
Licensed under MIT license
Version: 1.0.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 29/08/2021 Initial coding to support MBED nRF52840-based boards such as Nano_33_BLE, etc.
*****************************************************************************************************************************/

#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.1.0"
#define FS_NANO33BLE_VERSION_MIN 1001000
#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.2.0"
#define FS_NANO33BLE_VERSION_MIN 1002000

#define _FS_LOGLEVEL_ 1

// Min NANO33BLE_FS_SIZE_KB must be 64KB. If defined smalller => auto adjust to 64KB
// Max NANO33BLE_FS_SIZE_KB must be 512KB. If defined larger => auto adjust to 512KB
#define NANO33BLE_FS_SIZE_KB 256

#define FORCE_REFORMAT false

// Default USING_LITTLEFS. Uncomment to not USING_LITTLEFS => USING_FATFS.
// Default USING_LITTLEFS. Uncomment to not USING_LITTLEFS => USING_FATFS.
// It's advisable not to use FATFS, as the NANO33BLE_FS_SIZE_KB must be auto-adjusted to 512KB
//#define USING_LITTLEFS false

#include <FS_Nano33BLE.h>
Expand All @@ -49,6 +47,9 @@ void setup()
}
#endif

Serial.print("FS_size (KB) = "); Serial.println(NANO33BLE_FS_SIZE_KB);
Serial.print("FS_ Start Address = 0x"); Serial.println(NANO33BLE_FS_START, HEX);

myFS = new FileSystem_MBED();

if (!myFS->init())
Expand Down
19 changes: 10 additions & 9 deletions examples/FS_Test/FS_Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@
Built by Khoi Hoang https://github.com/khoih-prog/FS_Nano33BLE
Licensed under MIT license
Version: 1.0.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 29/08/2021 Initial coding to support MBED nRF52840-based boards such as Nano_33_BLE, etc.
*****************************************************************************************************************************/

#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.1.0"
#define FS_NANO33BLE_VERSION_MIN 1001000
#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.2.0"
#define FS_NANO33BLE_VERSION_MIN 1002000

#define _FS_LOGLEVEL_ 1

// Min NANO33BLE_FS_SIZE_KB must be 64KB. If defined smalller => auto adjust to 64KB
// Max NANO33BLE_FS_SIZE_KB must be 512KB. If defined larger => auto adjust to 512KB
#define NANO33BLE_FS_SIZE_KB 256

#define FORCE_REFORMAT false

// Default USING_LITTLEFS. Uncomment to not USING_LITTLEFS => USING_FATFS.
// Default USING_LITTLEFS. Uncomment to not USING_LITTLEFS => USING_FATFS.
// It's advisable not to use FATFS, as the NANO33BLE_FS_SIZE_KB must be auto-adjusted to 512KB
//#define USING_LITTLEFS false

#include <FS_Nano33BLE.h>
Expand Down Expand Up @@ -300,6 +298,9 @@ void setup()
}
#endif

Serial.print("FS_size (KB) = "); Serial.println(NANO33BLE_FS_SIZE_KB);
Serial.print("FS_ Start Address = 0x"); Serial.println(NANO33BLE_FS_START, HEX);

myFS = new FileSystem_MBED();

if (!myFS->init())
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FS_Nano33BLE",
"version": "1.1.0",
"version": "1.2.0",
"keywords": "storage, data-storage, littlefs, littlefs-mbed, fatfs, fatfs-mbed, flash, flash-storage, posix, file-system, file, mbed, nano-33-ble, nano-33-ble-sense, nrf52840",
"description": "This library facilitates your usage of FS (FATFS or LittleFS) for the onboard flash. FS supports power fail safety and high performance",
"authors":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=FS_Nano33BLE
version=1.1.0
version=1.2.0
author=Khoi Hoang <[email protected]>
maintainer=Khoi Hoang <[email protected]>
sentence=Wrapper of FS (FATFS or LittleFS) for Arduino MBED nRF52840-based boards, such as Nano_33_BLE boards
Expand Down
47 changes: 38 additions & 9 deletions src/FS_Nano33BLE.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
Built by Khoi Hoang https://github.com/khoih-prog/FS_Nano33BLE
Licensed under MIT license
Version: 1.0.0
Version: 1.2.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 29/08/2021 Initial coding to support MBED nRF52840-based boards such as Nano_33_BLE, etc.
1.1.0 K Hoang 31/12/2021 Fix `multiple-definitions` linker error
1.2.0 K Hoang 15/01/2022 Use correct NANO33BLE_FS_START address without wasting flash space
*****************************************************************************************************************************/

#ifndef _FS_NANO33BLE_H
Expand Down Expand Up @@ -52,13 +54,13 @@

////////////////////////////////////////////////

#define FS_NANO33BLE_VERSION FS_NAME "_Nano33BLE v1.1.0"
#define FS_NANO33BLE_VERSION FS_NAME "_Nano33BLE v1.2.0"

#define FS_NANO33BLE_VERSION_MAJOR 1
#define FS_NANO33BLE_VERSION_MINOR 1
#define FS_NANO33BLE_VERSION_MINOR 2
#define FS_NANO33BLE_VERSION_PATCH 0

#define FS_NANO33BLE_VERSION_INT 1001000
#define FS_NANO33BLE_VERSION_INT 1002000

////////////////////////////////////////////////

Expand Down Expand Up @@ -122,9 +124,20 @@
#else
#warning Using NANO33BLE_FS_SIZE_KB defined in external code

// KH, New from v1.2.0
#if (NANO33BLE_FS_SIZE_KB > (NANO33BLE_FLASH_SIZE / (2 * 1024)))
#error FlashSize too large. Max is (NANO33BLE_FLASH_SIZE / 2) = 512KB
#warning FlashSize too large. Adjust to 512KB

#undef NANO33BLE_FS_SIZE_KB
#define NANO33BLE_FS_SIZE_KB (512)

#elif (NANO33BLE_FS_SIZE_KB < 64)
#warning FlashSize too small. Adjust to 64KB

#undef NANO33BLE_FS_SIZE_KB
#define NANO33BLE_FS_SIZE_KB (64)
#endif
//
#endif

#if !defined(NANO33BLE_FS_START)
Expand All @@ -148,12 +161,28 @@

#if USING_LITTLEFS
static mbed::LittleFileSystem fs(MBED_FS_FILE_NAME);
static FlashIAPBlockDevice wholeBD(FLASH_BASE, 0x80000);
static FlashIAPBlockDevice bd(FLASH_BASE, (NANO33BLE_FS_SIZE_KB * 1024));

// KH, New from v1.2.0
static FlashIAPBlockDevice bd(NANO33BLE_FS_START, (NANO33BLE_FS_SIZE_KB * 1024));
//////
#elif USING_FATFS
static mbed::FATFileSystem fs(MBED_FS_FILE_NAME);
static FlashIAPBlockDevice bd(FLASH_BASE, NANO33BLE_FLASH_SIZE / 2);
//static FlashIAPBlockDevice bd(FLASH_BASE, (NANO33BLE_FS_SIZE_KB * 1024)); // Crash ??

#if (NANO33BLE_FS_SIZE_KB != 512)
#warning Auto-adjust FATFS size to 512KB or crash

#undef NANO33BLE_FS_SIZE_KB
#define NANO33BLE_FS_SIZE_KB (512)
#endif

// KH, Note for v1.2.0
// Don't use FATFS now or to use only with 512KB
//static FlashIAPBlockDevice bd(NANO33BLE_FS_START, (NANO33BLE_FS_SIZE_KB * 1024)); // Still Crash, issue with the core ??
//static FlashIAPBlockDevice bd(FLASH_BASE, (NANO33BLE_FS_SIZE_KB * 1024)); // Still Crash, issue with the core ??

static FlashIAPBlockDevice bd(FLASH_BASE, (NANO33BLE_FS_SIZE_KB * 1024));
//static FlashIAPBlockDevice bd(FLASH_BASE, NANO33BLE_FLASH_SIZE / 2);
//////
#endif

class FileSystem_MBED
Expand Down
4 changes: 3 additions & 1 deletion src/FS_Nano33BLE_Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
Built by Khoi Hoang https://github.com/khoih-prog/FS_Nano33BLE
Licensed under MIT license
Version: 1.0.0
Version: 1.2.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 29/08/2021 Initial coding to support MBED nRF52840-based boards such as Nano_33_BLE, etc.
1.1.0 K Hoang 31/12/2021 Fix `multiple-definitions` linker error
1.2.0 K Hoang 15/01/2022 Use correct NANO33BLE_FS_START address without wasting flash space
*****************************************************************************************************************************/

#ifndef FS_NANO33BLE_Debug_h
Expand Down

0 comments on commit ed72d21

Please sign in to comment.