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

Commit ed72d21

Browse files
authored
v1.2.0 to use correct NANO33BLE_FS_START
### 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
1 parent 2d13d7c commit ed72d21

File tree

9 files changed

+113
-44
lines changed

9 files changed

+113
-44
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Arduino IDE version: 1.8.19
3131
Arduino mbed_nano core v2.6.1
3232
Nano_33_BLE board
3333
OS: Ubuntu 20.04 LTS
34-
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
34+
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
3535
3636
Context:
3737
I encountered a crash while using TimerInterrupt.

README.md

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Why do we need this FS_Nano33BLE library](#why-do-we-need-this-FS_Nano33BLE-library)
15+
* [Important Notes](#Important-Notes)
1516
* [Features](#features)
1617
* [Currently supported Boards](#currently-supported-boards)
1718
* [Changelog](changelog.md)
@@ -43,6 +44,11 @@
4344

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

47+
## Important Notes
48+
49+
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.
50+
51+
4652
## Features
4753

4854
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)
@@ -60,7 +66,7 @@ The filesystem access uses normal [POSIX APIs](https://www.tutorialspoint.com/c_
6066

6167
## Prerequisites
6268

63-
1. [`Arduino IDE 1.8.19+` for Arduino](https://www.arduino.cc/en/Main/Software)
69+
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)
6470
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)
6571

6672
---
@@ -105,11 +111,14 @@ Another way to install is to:
105111
### Example [FS_Test](examples/FS_Test)
106112

107113
```
108-
#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.1.0"
109-
#define FS_NANO33BLE_VERSION_MIN 1001000
114+
#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.2.0"
115+
#define FS_NANO33BLE_VERSION_MIN 1002000
110116
111117
#define _FS_LOGLEVEL_ 1
112-
#define NANO33BLE_FS_SIZE_KB 256
118+
119+
// Min NANO33BLE_FS_SIZE_KB must be 64KB. If defined smalller => auto adjust to 64KB
120+
// Max NANO33BLE_FS_SIZE_KB must be 512KB. If defined larger => auto adjust to 512KB
121+
#define NANO33BLE_FS_SIZE_KB 64
113122
114123
#define FORCE_REFORMAT false
115124
@@ -391,6 +400,9 @@ void setup()
391400
}
392401
#endif
393402
403+
Serial.print("FS_size (KB) = "); Serial.println(NANO33BLE_FS_SIZE_KB);
404+
Serial.print("FS_ Start Address = 0x"); Serial.println(NANO33BLE_FS_START, HEX);
405+
394406
myFS = new FileSystem_MBED();
395407
396408
if (!myFS->init())
@@ -453,23 +465,25 @@ The following is the sample terminal output when running example [FS_Counting](e
453465

454466
```
455467
Start FS_Test on Nano 33 BLE
456-
LittleFS_Nano33BLE v1.1.0
457-
[LFS] LittleFS size (KB) = 256
468+
LittleFS_Nano33BLE v1.2.0
469+
FS_size (KB) = 256
470+
FS_ Start Address = 0xC0000
471+
[FS] LittleFS size (KB) = 256
458472
[LFS] LittleFS Mount OK
459473
Deleting file: /littlefs/counts.txt => OK
460474
Times have been run = 1
461475
=> Open to write OK
462476
463477
Start FS_Test on Nano 33 BLE
464-
LittleFS_Nano33BLE v1.1.0
478+
LittleFS_Nano33BLE v1.2.0
465479
[LFS] LittleFS size (KB) = 256
466480
[LFS] LittleFS Mount OK
467481
=> Open to read OK
468482
Times have been run = 2
469483
=> Open to write OK
470484
471485
Start FS_Test on Nano 33 BLE
472-
LittleFS_Nano33BLE v1.1.0
486+
LittleFS_Nano33BLE v1.2.0
473487
[LFS] LittleFS size (KB) = 256
474488
[LFS] LittleFS Mount OK
475489
=> Open to read OK
@@ -486,8 +500,10 @@ The following is the sample terminal output when running example [FS_Test](examp
486500

487501
```
488502
Start FS_Test on Nano 33 BLE
489-
LittleFS_Nano33BLE v1.1.0
490-
[LFS] LittleFS size (KB) = 256
503+
LittleFS_Nano33BLE v1.2.0
504+
FS_size (KB) = 256
505+
FS_ Start Address = 0xC0000
506+
[FS] LittleFS size (KB) = 256
491507
[LFS] LittleFS Mount Fail
492508
[LFS] Formatting...
493509
[LFS]
@@ -545,15 +561,17 @@ Test complete
545561

546562
---
547563

548-
### 3. FS_Test on Nano 33 BLE with FATFS size 256KB
564+
### 3. FS_Test on Nano 33 BLE with FATFS size 512KB
549565

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

552568

553569
```
554570
Start FS_Test on Nano 33 BLE
555-
FATFS_Nano33BLE v1.1.0
556-
[LFS] FATFS size (KB) = 256
571+
FATFS_Nano33BLE v1.2.0
572+
FS_size (KB) = 512
573+
FS_ Start Address = 0x80000
574+
[FS] LittleFS size (KB) = 512
557575
[LFS] FATFS Mount OK
558576
====================================================
559577
Writing file: /fs/hello1.txt => Open OK
@@ -654,6 +672,8 @@ Submit issues to: [FS_Nano33BLE issues](https://github.com/khoih-prog/FS_Nano33B
654672
2. Add Version String
655673
3. Add Table of Contents
656674
4. Fix `multiple-definitions` linker error
675+
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)
676+
657677

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

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

685+
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
686+
687+
<table>
688+
<tr>
689+
<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>
690+
</tr>
691+
</table>
692+
665693

666694
---
667695

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.2.0](#releases-v120)
1516
* [Releases v1.1.0](#releases-v110)
1617
* [Initial Releases v1.0.0](#initial-releases-v100)
1718

@@ -20,6 +21,13 @@
2021

2122
## Changelog
2223

24+
### Releases v1.2.0
25+
26+
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)
27+
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
28+
3. Enforce 512KB of flash used for FATFS by auto-adjusting NANO33BLE_FS_SIZE_KB if defined different from 512KB
29+
4. Update all examples
30+
2331
### Releases v1.1.0
2432

2533
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)

examples/FS_Counting/FS_Counting.ino

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,21 @@
66
77
Built by Khoi Hoang https://github.com/khoih-prog/FS_Nano33BLE
88
Licensed under MIT license
9-
10-
Version: 1.0.0
11-
12-
Version Modified By Date Comments
13-
------- ----------- ---------- -----------
14-
1.0.0 K Hoang 29/08/2021 Initial coding to support MBED nRF52840-based boards such as Nano_33_BLE, etc.
159
*****************************************************************************************************************************/
1610

17-
#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.1.0"
18-
#define FS_NANO33BLE_VERSION_MIN 1001000
11+
#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.2.0"
12+
#define FS_NANO33BLE_VERSION_MIN 1002000
1913

2014
#define _FS_LOGLEVEL_ 1
15+
16+
// Min NANO33BLE_FS_SIZE_KB must be 64KB. If defined smalller => auto adjust to 64KB
17+
// Max NANO33BLE_FS_SIZE_KB must be 512KB. If defined larger => auto adjust to 512KB
2118
#define NANO33BLE_FS_SIZE_KB 256
2219

2320
#define FORCE_REFORMAT false
2421

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

2826
#include <FS_Nano33BLE.h>
@@ -49,6 +47,9 @@ void setup()
4947
}
5048
#endif
5149

50+
Serial.print("FS_size (KB) = "); Serial.println(NANO33BLE_FS_SIZE_KB);
51+
Serial.print("FS_ Start Address = 0x"); Serial.println(NANO33BLE_FS_START, HEX);
52+
5253
myFS = new FileSystem_MBED();
5354

5455
if (!myFS->init())

examples/FS_Test/FS_Test.ino

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,21 @@
66
77
Built by Khoi Hoang https://github.com/khoih-prog/FS_Nano33BLE
88
Licensed under MIT license
9-
10-
Version: 1.0.0
11-
12-
Version Modified By Date Comments
13-
------- ----------- ---------- -----------
14-
1.0.0 K Hoang 29/08/2021 Initial coding to support MBED nRF52840-based boards such as Nano_33_BLE, etc.
159
*****************************************************************************************************************************/
1610

17-
#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.1.0"
18-
#define FS_NANO33BLE_VERSION_MIN 1001000
11+
#define FS_NANO33BLE_VERSION_MIN_TARGET "FS_Nano33BLE v1.2.0"
12+
#define FS_NANO33BLE_VERSION_MIN 1002000
1913

2014
#define _FS_LOGLEVEL_ 1
15+
16+
// Min NANO33BLE_FS_SIZE_KB must be 64KB. If defined smalller => auto adjust to 64KB
17+
// Max NANO33BLE_FS_SIZE_KB must be 512KB. If defined larger => auto adjust to 512KB
2118
#define NANO33BLE_FS_SIZE_KB 256
2219

2320
#define FORCE_REFORMAT false
2421

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

2826
#include <FS_Nano33BLE.h>
@@ -300,6 +298,9 @@ void setup()
300298
}
301299
#endif
302300

301+
Serial.print("FS_size (KB) = "); Serial.println(NANO33BLE_FS_SIZE_KB);
302+
Serial.print("FS_ Start Address = 0x"); Serial.println(NANO33BLE_FS_START, HEX);
303+
303304
myFS = new FileSystem_MBED();
304305

305306
if (!myFS->init())

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "FS_Nano33BLE",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"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",
55
"description": "This library facilitates your usage of FS (FATFS or LittleFS) for the onboard flash. FS supports power fail safety and high performance",
66
"authors":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=FS_Nano33BLE
2-
version=1.1.0
2+
version=1.2.0
33
author=Khoi Hoang <[email protected]>
44
maintainer=Khoi Hoang <[email protected]>
55
sentence=Wrapper of FS (FATFS or LittleFS) for Arduino MBED nRF52840-based boards, such as Nano_33_BLE boards

src/FS_Nano33BLE.h

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
Built by Khoi Hoang https://github.com/khoih-prog/FS_Nano33BLE
88
Licensed under MIT license
99
10-
Version: 1.0.0
10+
Version: 1.2.0
1111
1212
Version Modified By Date Comments
1313
------- ----------- ---------- -----------
1414
1.0.0 K Hoang 29/08/2021 Initial coding to support MBED nRF52840-based boards such as Nano_33_BLE, etc.
15+
1.1.0 K Hoang 31/12/2021 Fix `multiple-definitions` linker error
16+
1.2.0 K Hoang 15/01/2022 Use correct NANO33BLE_FS_START address without wasting flash space
1517
*****************************************************************************************************************************/
1618

1719
#ifndef _FS_NANO33BLE_H
@@ -52,13 +54,13 @@
5254

5355
////////////////////////////////////////////////
5456

55-
#define FS_NANO33BLE_VERSION FS_NAME "_Nano33BLE v1.1.0"
57+
#define FS_NANO33BLE_VERSION FS_NAME "_Nano33BLE v1.2.0"
5658

5759
#define FS_NANO33BLE_VERSION_MAJOR 1
58-
#define FS_NANO33BLE_VERSION_MINOR 1
60+
#define FS_NANO33BLE_VERSION_MINOR 2
5961
#define FS_NANO33BLE_VERSION_PATCH 0
6062

61-
#define FS_NANO33BLE_VERSION_INT 1001000
63+
#define FS_NANO33BLE_VERSION_INT 1002000
6264

6365
////////////////////////////////////////////////
6466

@@ -122,9 +124,20 @@
122124
#else
123125
#warning Using NANO33BLE_FS_SIZE_KB defined in external code
124126

127+
// KH, New from v1.2.0
125128
#if (NANO33BLE_FS_SIZE_KB > (NANO33BLE_FLASH_SIZE / (2 * 1024)))
126-
#error FlashSize too large. Max is (NANO33BLE_FLASH_SIZE / 2) = 512KB
129+
#warning FlashSize too large. Adjust to 512KB
130+
131+
#undef NANO33BLE_FS_SIZE_KB
132+
#define NANO33BLE_FS_SIZE_KB (512)
133+
134+
#elif (NANO33BLE_FS_SIZE_KB < 64)
135+
#warning FlashSize too small. Adjust to 64KB
136+
137+
#undef NANO33BLE_FS_SIZE_KB
138+
#define NANO33BLE_FS_SIZE_KB (64)
127139
#endif
140+
//
128141
#endif
129142

130143
#if !defined(NANO33BLE_FS_START)
@@ -148,12 +161,28 @@
148161

149162
#if USING_LITTLEFS
150163
static mbed::LittleFileSystem fs(MBED_FS_FILE_NAME);
151-
static FlashIAPBlockDevice wholeBD(FLASH_BASE, 0x80000);
152-
static FlashIAPBlockDevice bd(FLASH_BASE, (NANO33BLE_FS_SIZE_KB * 1024));
164+
165+
// KH, New from v1.2.0
166+
static FlashIAPBlockDevice bd(NANO33BLE_FS_START, (NANO33BLE_FS_SIZE_KB * 1024));
167+
//////
153168
#elif USING_FATFS
154169
static mbed::FATFileSystem fs(MBED_FS_FILE_NAME);
155-
static FlashIAPBlockDevice bd(FLASH_BASE, NANO33BLE_FLASH_SIZE / 2);
156-
//static FlashIAPBlockDevice bd(FLASH_BASE, (NANO33BLE_FS_SIZE_KB * 1024)); // Crash ??
170+
171+
#if (NANO33BLE_FS_SIZE_KB != 512)
172+
#warning Auto-adjust FATFS size to 512KB or crash
173+
174+
#undef NANO33BLE_FS_SIZE_KB
175+
#define NANO33BLE_FS_SIZE_KB (512)
176+
#endif
177+
178+
// KH, Note for v1.2.0
179+
// Don't use FATFS now or to use only with 512KB
180+
//static FlashIAPBlockDevice bd(NANO33BLE_FS_START, (NANO33BLE_FS_SIZE_KB * 1024)); // Still Crash, issue with the core ??
181+
//static FlashIAPBlockDevice bd(FLASH_BASE, (NANO33BLE_FS_SIZE_KB * 1024)); // Still Crash, issue with the core ??
182+
183+
static FlashIAPBlockDevice bd(FLASH_BASE, (NANO33BLE_FS_SIZE_KB * 1024));
184+
//static FlashIAPBlockDevice bd(FLASH_BASE, NANO33BLE_FLASH_SIZE / 2);
185+
//////
157186
#endif
158187

159188
class FileSystem_MBED

src/FS_Nano33BLE_Debug.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
Built by Khoi Hoang https://github.com/khoih-prog/FS_Nano33BLE
88
Licensed under MIT license
99
10-
Version: 1.0.0
10+
Version: 1.2.0
1111
1212
Version Modified By Date Comments
1313
------- ----------- ---------- -----------
1414
1.0.0 K Hoang 29/08/2021 Initial coding to support MBED nRF52840-based boards such as Nano_33_BLE, etc.
15+
1.1.0 K Hoang 31/12/2021 Fix `multiple-definitions` linker error
16+
1.2.0 K Hoang 15/01/2022 Use correct NANO33BLE_FS_START address without wasting flash space
1517
*****************************************************************************************************************************/
1618

1719
#ifndef FS_NANO33BLE_Debug_h

0 commit comments

Comments
 (0)