mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-29 11:01:15 +00:00
Making progress with OSFS, still WIP
This commit is contained in:
parent
dcae45d287
commit
55a75d2f58
@ -1,7 +1,7 @@
|
||||
[apollo3_base]
|
||||
extends = arduino_base
|
||||
platform = https://github.com/nigelb/platform-apollo3blue.git#2e8a9895cf82f2836c483885e6f89b3f83d3ade4
|
||||
platform_packages=framework-arduinoapollo3@https://github.com/sparkfun/Arduino_Apollo3#v2.2.2rc2
|
||||
framework = arduino
|
||||
build_type = debug
|
||||
build_flags =
|
||||
${arduino_base.build_flags}
|
||||
@ -16,6 +16,7 @@ build_src_filter =
|
||||
-<nimble/>
|
||||
-<mesh/api/>
|
||||
-<mesh/http/>
|
||||
-<mesh/wifi/>
|
||||
-<modules/esp32>
|
||||
-<mesh/eth/>
|
||||
-<mqtt/>
|
||||
@ -26,5 +27,6 @@ build_src_filter =
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
jgromes/RadioLib@^6.3.0
|
||||
charlesbaynham/OSFS@^1.2.3
|
||||
lib_ignore =
|
||||
mathertel/OneButton
|
||||
|
@ -33,7 +33,33 @@ SPIClass SPI1(HSPI);
|
||||
*/
|
||||
bool copyFile(const char *from, const char *to)
|
||||
{
|
||||
#ifdef FSCom
|
||||
#if defined(ARCH_STM32WL) || defined(ARCH_APOLLO3)
|
||||
unsigned char cbuffer[2048];
|
||||
|
||||
// Var to hold the result of actions
|
||||
OSFS::result r;
|
||||
|
||||
r = OSFS::getFile(from, cbuffer);
|
||||
|
||||
if (r == notfound) {
|
||||
LOG_ERROR("Failed to open source file %s\n", from);
|
||||
return false;
|
||||
} else if (r == noerr) {
|
||||
r = OSFS::newFile(to, cbuffer, true);
|
||||
if (r == noerr) {
|
||||
return true;
|
||||
} else {
|
||||
LOG_ERROR("OSFS Error %d\n", r);
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
LOG_ERROR("OSFS Error %d\n", r);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
#elif defined(FSCom)
|
||||
unsigned char cbuffer[16];
|
||||
|
||||
File f1 = FSCom.open(from, FILE_O_READ);
|
||||
@ -56,8 +82,8 @@ bool copyFile(const char *from, const char *to)
|
||||
f2.flush();
|
||||
f2.close();
|
||||
f1.close();
|
||||
#endif
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +96,13 @@ bool copyFile(const char *from, const char *to)
|
||||
*/
|
||||
bool renameFile(const char *pathFrom, const char *pathTo)
|
||||
{
|
||||
#ifdef FSCom
|
||||
#if defined(ARCH_STM32WL) || defined(ARCH_APOLLO3)
|
||||
if (copyFile(pathFrom, pathTo) && (OSFS::deleteFile(pathFrom) == OSFS::result::NO_ERROR)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
#elif defined(FSCom)
|
||||
#ifdef ARCH_ESP32
|
||||
// rename was fixed for ESP32 IDF LittleFS in April
|
||||
return FSCom.rename(pathFrom, pathTo);
|
||||
@ -82,7 +114,6 @@ bool renameFile(const char *pathFrom, const char *pathTo)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,10 +21,32 @@ using namespace LittleFS_Namespace;
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_APOLLO3)
|
||||
#include "platform/apollo3/InternalFileSystem.h" // Apollo3
|
||||
#define FSCom InternalFS
|
||||
#define FSBegin() FSCom.begin()
|
||||
using namespace LittleFS_Namespace;
|
||||
// Apollo series 2 Kbytes (8 rows of 256 bytes)
|
||||
#include <EEPROM.h>
|
||||
#include <OSFS.h>
|
||||
|
||||
uint16_t OSFS::startOfEEPROM = 1;
|
||||
uint16_t OSFS::endOfEEPROM = 2048;
|
||||
|
||||
// Useful consts
|
||||
const OSFS::result noerr = OSFS::result::NO_ERROR;
|
||||
const OSFS::result notfound = OSFS::result::FILE_NOT_FOUND;
|
||||
|
||||
// 3) How do I read from the medium?
|
||||
void OSFS::readNBytes(uint16_t address, unsigned int num, byte* output) {
|
||||
for (uint16_t i = address; i < address + num; i++) {
|
||||
*output = EEPROM.read(i);
|
||||
output++;
|
||||
}
|
||||
}
|
||||
|
||||
// 4) How to I write to the medium?
|
||||
void OSFS::writeNBytes(uint16_t address, unsigned int num, const byte* input) {
|
||||
for (uint16_t i = address; i < address + num; i++) {
|
||||
EEPROM.update(i, *input);
|
||||
input++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_RP2040)
|
||||
|
@ -12,8 +12,7 @@
|
||||
#include <freertos/task.h>
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_NRF52_ADAFRUIT) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_RP2040) || \
|
||||
defined(ARDUINO_ARCH_APOLLO3)
|
||||
#if defined(ARDUINO_NRF52_ADAFRUIT) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_RP2040)
|
||||
#define HAS_FREE_RTOS
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
|
@ -748,7 +748,7 @@ int GPS::prepareDeepSleep(void *unused)
|
||||
|
||||
GnssModel_t GPS::probe(int serialSpeed)
|
||||
{
|
||||
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040)
|
||||
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040) || defined(ARCH_APOLLO3)
|
||||
_serial_gps->end();
|
||||
_serial_gps->begin(serialSpeed);
|
||||
#else
|
||||
@ -803,7 +803,7 @@ GnssModel_t GPS::probe(int serialSpeed)
|
||||
_serial_gps->write(_message_prt, sizeof(_message_prt));
|
||||
delay(500);
|
||||
serialSpeed = 9600;
|
||||
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040)
|
||||
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040) || defined(ARCH_APOLLO3)
|
||||
_serial_gps->end();
|
||||
_serial_gps->begin(serialSpeed);
|
||||
#else
|
||||
|
@ -79,7 +79,7 @@ NRF52Bluetooth *nrf52Bluetooth;
|
||||
#endif
|
||||
#include "PowerFSMThread.h"
|
||||
|
||||
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
||||
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(ARCH_APOLLO3)
|
||||
#include "AccelerometerThread.h"
|
||||
#include "AmbientLightingThread.h"
|
||||
#endif
|
||||
@ -610,7 +610,7 @@ void setup()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
||||
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(ARCH_APOLLO3)
|
||||
if (rgb_found.type != ScanI2C::DeviceType::NONE) {
|
||||
ambientLightingThread = new AmbientLightingThread(rgb_found.type);
|
||||
}
|
||||
|
@ -36,7 +36,9 @@ void PhoneAPI::handleStartConfig()
|
||||
if (!isConnected()) {
|
||||
onConnectionChanged(true);
|
||||
observe(&service.fromNumChanged);
|
||||
#ifdef FSCom
|
||||
observe(&xModem.packetReady);
|
||||
#endif
|
||||
}
|
||||
|
||||
// even if we were already connected - restart our state machine
|
||||
@ -53,7 +55,9 @@ void PhoneAPI::close()
|
||||
state = STATE_SEND_NOTHING;
|
||||
|
||||
unobserve(&service.fromNumChanged);
|
||||
#ifdef FSCom
|
||||
unobserve(&xModem.packetReady);
|
||||
#endif
|
||||
releasePhonePacket(); // Don't leak phone packets on shutdown
|
||||
releaseQueueStatusPhonePacket();
|
||||
releaseMqttClientProxyPhonePacket();
|
||||
@ -99,7 +103,9 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
||||
break;
|
||||
case meshtastic_ToRadio_xmodemPacket_tag:
|
||||
LOG_INFO("Got xmodem packet\n");
|
||||
#ifdef FSCom
|
||||
xModem.handlePacket(toRadioScratch.xmodemPacket);
|
||||
#endif
|
||||
break;
|
||||
case meshtastic_ToRadio_mqttClientProxyMessage_tag:
|
||||
LOG_INFO("Got MqttClientProxy message\n");
|
||||
@ -423,12 +429,14 @@ bool PhoneAPI::available()
|
||||
if (hasPacket)
|
||||
return true;
|
||||
|
||||
#ifdef FSCom
|
||||
if (xmodemPacketForPhone.control == meshtastic_XModem_Control_NUL)
|
||||
xmodemPacketForPhone = xModem.getForPhone();
|
||||
if (xmodemPacketForPhone.control != meshtastic_XModem_Control_NUL) {
|
||||
xModem.resetForPhone();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!packetForPhone)
|
||||
packetForPhone = service.getForPhone();
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "CryptoEngine.h"
|
||||
#include "MeshRadio.h"
|
||||
#include "NodeDB.h"
|
||||
#include "RTC.h"
|
||||
#include "gps/RTC.h"
|
||||
#include "configuration.h"
|
||||
#include "main.h"
|
||||
#include "mesh-pb-constants.h"
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "SinglePortModule.h"
|
||||
#include "concurrency/OSThread.h"
|
||||
#include "configuration.h"
|
||||
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
||||
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(ARCH_APOLLO3)
|
||||
#include <NonBlockingRtttl.h>
|
||||
#else
|
||||
// Noop class for portduino.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "NeighborInfoModule.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "RTC.h"
|
||||
#include "gps/RTC.h"
|
||||
|
||||
#define MAX_NUM_NEIGHBORS 10 // also defined in NeighborInfo protobuf options
|
||||
NeighborInfoModule *neighborInfoModule;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "GPS.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "RTC.h"
|
||||
#include "gps/RTC.h"
|
||||
#include "Router.h"
|
||||
#include "TypeConversions.h"
|
||||
#include "airtime.h"
|
||||
|
@ -50,6 +50,8 @@
|
||||
|
||||
#include "xmodem.h"
|
||||
|
||||
#ifdef FSCom
|
||||
|
||||
XModemAdapter xModem;
|
||||
|
||||
XModemAdapter::XModemAdapter() {}
|
||||
@ -248,4 +250,6 @@ void XModemAdapter::handlePacket(meshtastic_XModem xmodemPacket)
|
||||
// Unknown control character
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -38,6 +38,8 @@
|
||||
|
||||
#define MAXRETRANS 25
|
||||
|
||||
#ifdef FSCom
|
||||
|
||||
class XModemAdapter
|
||||
{
|
||||
public:
|
||||
@ -59,7 +61,7 @@ class XModemAdapter
|
||||
|
||||
uint16_t packetno = 0;
|
||||
|
||||
#if defined(ARCH_NRF52) || defined(ARCH_STM32WL)
|
||||
#if defined(ARCH_NRF52)
|
||||
File file = File(FSCom);
|
||||
#else
|
||||
File file;
|
||||
@ -75,3 +77,4 @@ class XModemAdapter
|
||||
};
|
||||
|
||||
extern XModemAdapter xModem;
|
||||
#endif // FSCom
|
1
variants/rak11720/mbed/.c-flags
Normal file
1
variants/rak11720/mbed/.c-flags
Normal file
@ -0,0 +1 @@
|
||||
-c -std=gnu11 -DMBED_MINIMAL_PRINTF -DMBED_TRAP_ERRORS_ENABLED=1 -Os -fdata-sections -ffunction-sections -fmessage-length=0 -fno-exceptions -fomit-frame-pointer -funsigned-char -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb
|
1
variants/rak11720/mbed/.c-symbols
Normal file
1
variants/rak11720/mbed/.c-symbols
Normal file
@ -0,0 +1 @@
|
||||
-DAM_CUSTOM_BDADDR -DAM_PACKAGE_BGA -DARDUINO_BLE_FIX -DARM_MATH_CM4 -DCOMPONENT_FLASHIAP=1 -DCORDIO_ZERO_COPY_HCI -DDEVICE_FLASH=1 -DDEVICE_I2C=1 -DDEVICE_INTERRUPTIN=1 -DDEVICE_LPTICKER=1 -DDEVICE_MPU=1 -DDEVICE_SERIAL=1 -DDEVICE_SPI=1 -DDEVICE_STDIO_MESSAGES=1 -DDEVICE_USTICKER=1 -DFEATURE_BLE=1 -DTARGET_AMA3B1KK -DTARGET_Ambiq_Micro -DTARGET_Apollo3 -DTARGET_CORDIO -DTARGET_CORTEX -DTARGET_CORTEX_M -DTARGET_FAMILY_Apollo3 -DTARGET_LIKE_CORTEX_M4 -DTARGET_LIKE_MBED -DTARGET_M4 -DTARGET_NAME=SFE_ARTEMIS -DTARGET_RELEASE -DTARGET_RTOS_M4_M7 -DTARGET_SFE_ARTEMIS -DTOOLCHAIN_GCC -DTOOLCHAIN_GCC_ARM -D__CMSIS_RTOS -D__CORTEX_M4 -D__FPU_PRESENT=1 -D__MBED_CMSIS_RTOS_CM -D__MBED__=1
|
@ -176,6 +176,9 @@ static const uint8_t SCK = PIN_SPI_SCK;
|
||||
#define PIN_WIRE_SDA WB_I2C1_SDA
|
||||
#define PIN_WIRE_SCL WB_I2C1_SCL
|
||||
|
||||
#define VARIANT_Wire_SDA PIN_WIRE_SDA
|
||||
#define VARIANT_Wire_SCL PIN_WIRE_SCL
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user