Skip to content

Commit faca1bd

Browse files
committed
Made path store segment size/count configurable
1 parent 5c0fda9 commit faca1bd

4 files changed

Lines changed: 51 additions & 13 deletions

File tree

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Each class of allocator can be configured to use a separate type of allocator. A
2929
- `RNS_PSRAM_ALLOCATOR`: Basic allocator that uses PSRAM memory (if PSRAM is available)
3030
- `RNS_PSRAM_POOL_ALLOCATOR`: Optimized TLSF managed PSRAM buffer (if PSRAM is available)
3131

32+
NOTE: When utilizing PSRAM on ESP32 boards, preprocessor directive `-DBOARD_HAS_PSRAM=1` must be included in build flags in order to enable on-board PSRAM.
33+
3234
Each class of allocator pool can have a separate buffer size:
3335
- `RNS_HEAP_POOL_BUFFER_SIZE=N` Defines the HEAP TLSF memory pool buffer size (N bytes, default 0 which means dynamic)
3436
- `RNS_PSRAM_POOL_BUFFER_SIZE=N` Defines the PSRAM TLSF memory pool buffer size (N bytes, default 0 which means dynamic)
@@ -44,7 +46,25 @@ build_flags =
4446
-DRNS_CONTAINER_ALLOCATOR=RNS_PSRAM_POOL_ALLOCATOR
4547
```
4648

47-
NOTE: Currently `-DRNS_DEFAULT_ALLOCATOR=RNS_HEAP_POOL_ALLOCATOR` is only required on NRF52 boards since ESP32 already uses TLSF internally.
49+
NOTE: Currently "POOL" allocators are only required on NRF52 boards since ESP32 already uses TLSF internally for both SRAM and PSRAM resources.
50+
51+
## microStore Options
52+
53+
When using microReticulum to implement a transpport node, storage for the path table and other persistent data must be configured. This is accomplished using the File and FileSystem abstrctions provided in `microStore`. Several pre-build adapters are provided with the library, and optionally custom storage (e.g., external flash and SD card) can be used by deriving custom implementations from `microStore::File` and `microStore::FileSystem` and passing them to microReticulum for internal use.
54+
There are several pre-built filesystem "adapters" available in the `microStore` library that can be used without modification for the most common supported boards. These can be inluded using the following preprocessor directives:
55+
`-DUSTORE_USE_POSIXFS`: Native as well as any ESP-IDF supported POSIX file system
56+
`-DUSTORE_USE_STDIOFS`: Native STDIO file system
57+
`-DUSTORE_USE_INTERNALFS`: InternalFileSystem for adafruit nrf52
58+
`-DUSTORE_USE_LITTLEFS`: LittleFS file system
59+
`-DUSTORE_USE_SPIFFS`: SPIFFS file system
60+
`-DUSTORE_USE_FLASHFS`: Adafruit FlashFS file system
61+
`-DUSTORE_USE_UNIVERSALFS`: Best supported file system for any platform
62+
63+
Also note the following preprocessor directives used to tune `microStore::FileStore` which is the Bitcask-style storage engine used by microReticulum to persist the path table and other internal tables:
64+
`-DRNS_PATH_TABLE_SEGMENT_SIZE`
65+
`-DRNS_PATH_TABLE_SEGMENT_COUNT`
66+
Appropriate settings should be selected to match the storage and memory resources available on the target platform.
67+
Note that `RNS_PATH_TABLE_SEGMENT_COUNT` must be at least 3, and `RNS_PATH_TABLE_SEGMENT_COUNT` x `RNS_PATH_TABLE_SEGMENT_SIZE` represents the total approximate storage space available to the the path table.
4868

4969
## Building
5070

platformio.ini

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ lib_deps =
3131
ArduinoJson@^7.4.2
3232
MsgPack@^0.4.2
3333
https://github.com/attermann/Crypto.git
34-
https://github.com/attermann/microStore.git
35-
;microStore=symlink://../microStore
3634
test_framework = unity
3735
; Following property enables Unity integration testing
3836
test_build_src = true
@@ -58,6 +56,7 @@ build_flags =
5856
-DNATIVE
5957
lib_deps =
6058
${env.lib_deps}
59+
https://github.com/attermann/microStore.git
6160
lib_compat_mode = off
6261

6362
[env:native17]
@@ -71,6 +70,7 @@ build_flags =
7170
-DNATIVE
7271
lib_deps =
7372
${env.lib_deps}
73+
https://github.com/attermann/microStore.git
7474
lib_compat_mode = off
7575

7676
[env:native20]
@@ -84,6 +84,7 @@ build_flags =
8484
-DNATIVE
8585
lib_deps =
8686
${env.lib_deps}
87+
https://github.com/attermann/microStore.git
8788
lib_compat_mode = off
8889

8990
[env:native_debug]
@@ -119,6 +120,7 @@ build_flags =
119120
;-DRNS_MEM_LOG
120121
lib_deps =
121122
${env.lib_deps}
123+
https://github.com/attermann/microStore.git
122124
lib_compat_mode = off
123125

124126
[env:embedded]
@@ -133,6 +135,7 @@ build_flags =
133135
-std=gnu++17
134136
lib_deps =
135137
${env.lib_deps}
138+
https://github.com/attermann/microStore.git
136139

137140
[env:ttgo-lora32-v21]
138141
extends = env:embedded
@@ -149,6 +152,7 @@ build_flags =
149152
-DMSGPACK_USE_BOOST=OFF
150153
lib_deps =
151154
${env:embedded.lib_deps}
155+
https://github.com/attermann/microStore.git
152156
monitor_filters = esp32_exception_decoder
153157

154158
[env:ttgo-t-beam]
@@ -163,6 +167,7 @@ build_flags =
163167
-DMSGPACK_USE_BOOST=OFF
164168
lib_deps =
165169
${env:embedded.lib_deps}
170+
https://github.com/attermann/microStore.git
166171
monitor_filters = esp32_exception_decoder
167172

168173
[env:lilygo_tbeam_supreme]
@@ -177,6 +182,7 @@ build_flags =
177182
-DMSGPACK_USE_BOOST=OFF
178183
lib_deps =
179184
${env:embedded.lib_deps}
185+
https://github.com/attermann/microStore.git
180186
monitor_filters = esp32_exception_decoder
181187

182188
; also Heltec Wireless Tracker
@@ -200,6 +206,7 @@ build_flags =
200206
-DRNS_PSRAM_POOL_BUFFER_SIZE=2048000
201207
lib_deps =
202208
${env:embedded.lib_deps}
209+
https://github.com/attermann/microStore.git
203210
monitor_filters = esp32_exception_decoder
204211
upload_speed = 921600
205212

@@ -226,11 +233,18 @@ build_flags =
226233
-DMSGPACK_USE_BOOST=OFF
227234
lib_deps =
228235
${env:embedded.lib_deps}
236+
https://github.com/attermann/microStore.git
229237
adafruit/Adafruit TinyUSB Library
230238

231-
; Overrides for specific tests (not working!)
232-
[test_env:test_objects]
239+
240+
; Local build targets
241+
[env:native_local]
242+
platform = native
233243
build_flags =
234-
${env:embedded.build_flags}
235-
;-DTEST_OBJECT_DATA=1
236-
-DTEST_OBJECT_IMPL=1
244+
${env.build_flags}
245+
-std=gnu++11
246+
-DNATIVE
247+
lib_deps =
248+
${env.lib_deps}
249+
microStore=symlink://../microStore
250+
lib_compat_mode = off

src/Transport.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ using namespace RNS::Persistence;
3838
#define RNS_PATH_TABLE_MAX 100
3939
#endif
4040

41+
#ifndef RNS_PATH_TABLE_SEGMENT_SIZE
42+
#define RNS_PATH_TABLE_SEGMENT_SIZE 65536
43+
#endif
44+
45+
#ifndef RNS_PATH_TABLE_SEGMENT_COUNT
46+
#define RNS_PATH_TABLE_SEGMENT_COUNT 8
47+
#endif
48+
4149
#ifndef RNS_ANNOUNCE_TABLE_MAX
4250
#define RNS_ANNOUNCE_TABLE_MAX 100
4351
#endif
@@ -133,7 +141,7 @@ using namespace RNS::Persistence;
133141
/*static*/ bool Transport::cleaning_caches = false;
134142

135143
// CBA microStore
136-
/*static*/ PathStore Transport::_path_store;
144+
/*static*/ PathStore Transport::_path_store(RNS_PATH_TABLE_SEGMENT_SIZE, RNS_PATH_TABLE_SEGMENT_COUNT);
137145
/*static*/ NewPathTable Transport::_new_path_table(Transport::_path_store);
138146

139147
DestinationEntry empty_destination_entry;

src/Transport.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,6 @@ namespace RNS {
382382
static std::set<Bytes> _packet_hashlist; // A list of packet hashes for duplicate detection
383383
static std::list<PacketReceipt> _receipts; // Receipts of all outgoing packets for proof processing
384384

385-
// TODO: "destination_table" should really be renamed to "path_table"
386-
// Notes on memory usage: 1 megabyte of memory can store approximately
387-
// 55.100 path table entries or approximately 22.300 link table entries.
388-
389385
static AnnounceTable _announce_table; // A table for storing announces currently waiting to be retransmitted
390386
static PathTable _path_table; // A lookup table containing the next hop to a given destination
391387
static ReverseTable _reverse_table; // A lookup table for storing packet hashes used to return proofs and replies

0 commit comments

Comments
 (0)