sforkowany z mirror/meshtastic-firmware
make flash filesystem work on NRF52
rodzic
829e0b6e26
commit
d39e775c95
|
@ -21,7 +21,6 @@ Needed to be fully functional at least at the same level of the ESP32 boards. At
|
||||||
|
|
||||||
- DONE get serial API working
|
- DONE get serial API working
|
||||||
- get full BLE api working
|
- get full BLE api working
|
||||||
- make a file system implementation (preferably one that can see the files the bootloader also sees) - preferably https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/libraries/InternalFileSytem/examples/Internal_ReadWrite/Internal_ReadWrite.ino else use https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_fds_usage.html?cp=7_5_0_3_55_3
|
|
||||||
- make power management/sleep work properly
|
- make power management/sleep work properly
|
||||||
- make a settimeofday implementation
|
- make a settimeofday implementation
|
||||||
- DONE increase preamble length? - will break other clients? so all devices must update
|
- DONE increase preamble length? - will break other clients? so all devices must update
|
||||||
|
@ -125,6 +124,7 @@ Nice ideas worth considering someday...
|
||||||
- DONE use SX126x::startReceiveDutyCycleAuto to save power by sleeping and briefly waking to check for preamble bits. Change xmit rules to have more preamble bits.
|
- DONE use SX126x::startReceiveDutyCycleAuto to save power by sleeping and briefly waking to check for preamble bits. Change xmit rules to have more preamble bits.
|
||||||
- scheduleOSCallback doesn't work yet - it is way too fast (causes rapid polling of busyTx, high power draw etc...)
|
- scheduleOSCallback doesn't work yet - it is way too fast (causes rapid polling of busyTx, high power draw etc...)
|
||||||
- find out why we reboot while debugging - it was bluetooth/softdevice
|
- find out why we reboot while debugging - it was bluetooth/softdevice
|
||||||
|
- make a file system implementation (preferably one that can see the files the bootloader also sees) - preferably https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/libraries/InternalFileSytem/examples/Internal_ReadWrite/Internal_ReadWrite.ino else use https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_fds_usage.html?cp=7_5_0_3_55_3
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,14 @@ DeviceState versions used to be defined in the .proto file but really only this
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
#define FS SPIFFS
|
#define FS SPIFFS
|
||||||
|
#define FSBegin() FS.begin(true)
|
||||||
|
#define FILE_O_WRITE "w"
|
||||||
|
#define FILE_O_READ "r"
|
||||||
|
#else
|
||||||
|
#include "InternalFileSystem.h"
|
||||||
|
#define FS InternalFS
|
||||||
|
#define FSBegin() FS.begin()
|
||||||
|
using namespace Adafruit_LittleFS_Namespace;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FIXME - move this somewhere else
|
// FIXME - move this somewhere else
|
||||||
|
@ -135,8 +143,15 @@ void NodeDB::init()
|
||||||
info->user = owner;
|
info->user = owner;
|
||||||
info->has_user = true;
|
info->has_user = true;
|
||||||
|
|
||||||
|
if (!FSBegin()) // FIXME - do this in main?
|
||||||
|
{
|
||||||
|
DEBUG_MSG("ERROR filesystem mount Failed\n");
|
||||||
|
// FIXME - report failure to phone
|
||||||
|
}
|
||||||
|
|
||||||
// saveToDisk();
|
// saveToDisk();
|
||||||
loadFromDisk();
|
loadFromDisk();
|
||||||
|
// saveToDisk();
|
||||||
|
|
||||||
// We set these _after_ loading from disk - because they come from the build and are more trusted than
|
// We set these _after_ loading from disk - because they come from the build and are more trusted than
|
||||||
// what is stored in flash
|
// what is stored in flash
|
||||||
|
@ -180,13 +195,7 @@ void NodeDB::loadFromDisk()
|
||||||
#ifdef FS
|
#ifdef FS
|
||||||
static DeviceState scratch;
|
static DeviceState scratch;
|
||||||
|
|
||||||
if (!FS.begin(true)) // FIXME - do this in main?
|
auto f = FS.open(preffile);
|
||||||
{
|
|
||||||
DEBUG_MSG("ERROR SPIFFS Mount Failed\n");
|
|
||||||
// FIXME - report failure to phone
|
|
||||||
}
|
|
||||||
|
|
||||||
File f = FS.open(preffile);
|
|
||||||
if (f) {
|
if (f) {
|
||||||
DEBUG_MSG("Loading saved preferences\n");
|
DEBUG_MSG("Loading saved preferences\n");
|
||||||
pb_istream_t stream = {&readcb, &f, DeviceState_size};
|
pb_istream_t stream = {&readcb, &f, DeviceState_size};
|
||||||
|
@ -220,7 +229,7 @@ void NodeDB::loadFromDisk()
|
||||||
void NodeDB::saveToDisk()
|
void NodeDB::saveToDisk()
|
||||||
{
|
{
|
||||||
#ifdef FS
|
#ifdef FS
|
||||||
File f = FS.open(preftmp, "w");
|
auto f = FS.open(preftmp, FILE_O_WRITE);
|
||||||
if (f) {
|
if (f) {
|
||||||
DEBUG_MSG("Writing preferences\n");
|
DEBUG_MSG("Writing preferences\n");
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
#include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
#include <pb_encode.h>
|
#include <pb_encode.h>
|
||||||
|
|
||||||
|
#ifdef NO_ESP32
|
||||||
|
#include "Adafruit_LittleFS.h"
|
||||||
|
using namespace Adafruit_LittleFS_Namespace; // To get File type
|
||||||
|
#endif
|
||||||
|
|
||||||
/// helper function for encoding a record as a protobuf, any failures to encode are fatal and we will panic
|
/// helper function for encoding a record as a protobuf, any failures to encode are fatal and we will panic
|
||||||
/// returns the encoded packet size
|
/// returns the encoded packet size
|
||||||
size_t pb_encode_to_bytes(uint8_t *destbuf, size_t destbufsize, const pb_msgdesc_t *fields, const void *src_struct)
|
size_t pb_encode_to_bytes(uint8_t *destbuf, size_t destbufsize, const pb_msgdesc_t *fields, const void *src_struct)
|
||||||
|
@ -36,7 +41,6 @@ bool pb_decode_from_bytes(const uint8_t *srcbuf, size_t srcbufsize, const pb_msg
|
||||||
bool readcb(pb_istream_t *stream, uint8_t *buf, size_t count)
|
bool readcb(pb_istream_t *stream, uint8_t *buf, size_t count)
|
||||||
{
|
{
|
||||||
bool status = false;
|
bool status = false;
|
||||||
#ifndef NO_ESP32
|
|
||||||
File *file = (File *)stream->state;
|
File *file = (File *)stream->state;
|
||||||
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
|
@ -45,24 +49,20 @@ bool readcb(pb_istream_t *stream, uint8_t *buf, size_t count)
|
||||||
return count == 0;
|
return count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = (file->read(buf, count) == count);
|
status = (file->read(buf, count) == (int) count);
|
||||||
|
|
||||||
if (file->available() == 0)
|
if (file->available() == 0)
|
||||||
stream->bytes_left = 0;
|
stream->bytes_left = 0;
|
||||||
#endif
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write to an arduino file
|
/// Write to an arduino file
|
||||||
bool writecb(pb_ostream_t *stream, const uint8_t *buf, size_t count)
|
bool writecb(pb_ostream_t *stream, const uint8_t *buf, size_t count)
|
||||||
{
|
{
|
||||||
#ifndef NO_ESP32
|
|
||||||
File *file = (File *)stream->state;
|
File *file = (File *)stream->state;
|
||||||
// DEBUG_MSG("writing %d bytes to protobuf file\n", count);
|
// DEBUG_MSG("writing %d bytes to protobuf file\n", count);
|
||||||
return file->write(buf, count) == count;
|
return file->write(buf, count) == count;
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_in_helper(uint32_t n, const uint32_t *array, pb_size_t count)
|
bool is_in_helper(uint32_t n, const uint32_t *array, pb_size_t count)
|
||||||
|
|
Ładowanie…
Reference in New Issue