Raspberry Pi Pico target (with sparkfun lora hat) does compile but needs further work.

Also contains a small fix to make PRIVATE_HW targets build again for nRF52 architectures
This commit is contained in:
Thomas Göttgens
2022-08-08 23:11:19 +02:00
parent 22a5cf04d3
commit 0c8fb6e27f
11 changed files with 179 additions and 6 deletions

View File

@@ -44,7 +44,7 @@ bool renameFile(const char* pathFrom, const char* pathTo)
void listDir(const char * dirname, uint8_t levels)
{
#ifdef FSCom
File root = FSCom.open(dirname);
File root = FSCom.open(dirname, FILE_O_READ);
if(!root){
return;
}
@@ -71,7 +71,7 @@ void listDir(const char * dirname, uint8_t levels)
void rmDir(const char * dirname)
{
#ifdef FSCom
File file = FSCom.open(dirname);
File file = FSCom.open(dirname, FILE_O_READ);
if(!file){
return;
}

View File

@@ -13,6 +13,15 @@
#define FILE_O_READ "r"
#endif
#if defined(ARCH_RP2040)
// RP2040
#include "LittleFS.h"
#define FSCom LittleFS
#define FSBegin() FSCom.begin()
#define FILE_O_WRITE "w"
#define FILE_O_READ "r"
#endif
#if defined(ARCH_ESP32)
// ESP32 version
#include "LITTLEFS.h"

View File

@@ -297,7 +297,7 @@ bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_
#ifdef FSCom
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
auto f = FSCom.open(filename);
auto f = FSCom.open(filename, FILE_O_READ);
if (f) {
DEBUG_MSG("Loading %s\n", filename);

View File

@@ -40,6 +40,8 @@
#define HW_VENDOR HardwareModel_T_ECHO
#elif defined(NORDIC_PCA10059)
#define HW_VENDOR HardwareModel_NRF52840_PCA10059
#elif defined(PRIVATE_HW)
#define HW_VENDOR HardwareModel_PRIVATE_HW
#else
#define HW_VENDOR HardwareModel_NRF52_UNKNOWN
#endif

View File

@@ -0,0 +1,7 @@
#pragma once
#define ARCH_RP2040
#if defined(PRIVATE_HW)
#define HW_VENDOR HardwareModel_PRIVATE_HW
#endif

View File

@@ -0,0 +1,30 @@
#include "configuration.h"
#include <stdio.h>
#include <pico/unique_id.h>
void setBluetoothEnable(bool on)
{
// not needed
}
void cpuDeepSleep(uint64_t msecs)
{
// not needed
}
void updateBatteryLevel(uint8_t level)
{
// not needed
}
void getMacAddr(uint8_t *dmac)
{
pico_unique_board_id_t src;
pico_get_unique_board_id(&src);
dmac[5] = src.id[0];
dmac[4] = src.id[1];
dmac[3] = src.id[2];
dmac[2] = src.id[3];
dmac[1] = src.id[4];
dmac[0] = src.id[5];
}

View File

@@ -0,0 +1,36 @@
#include "configuration.h"
#include "CryptoEngine.h"
#include "aes.hpp"
class RP2040CryptoEngine : public CryptoEngine
{
public:
RP2040CryptoEngine() {}
~RP2040CryptoEngine() {}
/**
* Encrypt a packet
*
* @param bytes is updated in place
*/
virtual void encrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override
{
if (key.length > 0) {
AES_ctx ctx;
initNonce(fromNode, packetNum);
AES_init_ctx_iv(&ctx, key.bytes, nonce);
AES_CTR_xcrypt_buffer(&ctx, bytes, numBytes);
}
}
virtual void decrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override
{
// For CTR, the implementation is the same
encrypt(fromNode, packetNum, numBytes, bytes);
}
private:
};
CryptoEngine *crypto = new RP2040CryptoEngine();