mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-03 04:23:52 +00:00
make apollo decent again
This commit is contained in:
parent
93d7f24d74
commit
9be3b7bdc5
@ -3,9 +3,11 @@ 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
|
||||
build_type = debug
|
||||
build_flags =
|
||||
build_flags =
|
||||
${arduino_base.build_flags}
|
||||
-Isrc/platform/apollo3 -g
|
||||
-I"${platformio.packages_dir}/framework-arduinoapollo3/libraries/SPI/src"
|
||||
-DRADIOLIB_EEPROM_UNSUPPORTED
|
||||
build_src_filter =
|
||||
${arduino_base.build_src_filter}
|
||||
-<platform/nrf52>
|
||||
@ -19,14 +21,12 @@ build_src_filter =
|
||||
-<mesh/wifi/>
|
||||
-<modules/esp32>
|
||||
-<mesh/eth/>
|
||||
-<mqtt/>
|
||||
-<graphics>
|
||||
-<input>
|
||||
-<buzz>
|
||||
-<modules/Telemetry>
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
jgromes/RadioLib@^6.3.0
|
||||
charlesbaynham/OSFS@^1.2.3
|
||||
rweather/Crypto
|
||||
lib_ignore =
|
||||
mathertel/OneButton
|
||||
|
@ -24,6 +24,35 @@ SPIClass SPI1(HSPI);
|
||||
|
||||
#endif // HAS_SDCARD
|
||||
|
||||
#if defined(ARCH_APOLLO3)
|
||||
// Apollo series 2 Kbytes (8 rows of 256 bytes)
|
||||
|
||||
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
|
||||
|
||||
/**
|
||||
* @brief Copies a file from one location to another.
|
||||
*
|
||||
|
@ -25,30 +25,18 @@ using namespace LittleFS_Namespace;
|
||||
#include <EEPROM.h>
|
||||
#include <OSFS.h>
|
||||
|
||||
uint16_t OSFS::startOfEEPROM = 1;
|
||||
uint16_t OSFS::endOfEEPROM = 2048;
|
||||
extern uint16_t OSFS::startOfEEPROM;
|
||||
extern uint16_t OSFS::endOfEEPROM;
|
||||
|
||||
// Useful consts
|
||||
const OSFS::result noerr = OSFS::result::NO_ERROR;
|
||||
const OSFS::result notfound = OSFS::result::FILE_NOT_FOUND;
|
||||
extern const OSFS::result noerr;
|
||||
extern const OSFS::result notfound;
|
||||
|
||||
// 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++;
|
||||
}
|
||||
}
|
||||
void OSFS::readNBytes(uint16_t address, unsigned int num, byte *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++;
|
||||
}
|
||||
}
|
||||
void OSFS::writeNBytes(uint16_t address, unsigned int num, const byte *input);
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_RP2040)
|
||||
|
@ -213,4 +213,6 @@ extern uint32_t error_address;
|
||||
#define Module_Config_size \
|
||||
(ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \
|
||||
ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \
|
||||
ModuleConfig_TelemetryConfig_size + ModuleConfig_size)
|
||||
ModuleConfig_TelemetryConfig_size + ModuleConfig_size)
|
||||
|
||||
// Please do not remove this comment, it makes trunk and compiler happy at the same time.
|
||||
|
66
src/platform/apollo3/Apollo3CryptoEngine.cpp
Normal file
66
src/platform/apollo3/Apollo3CryptoEngine.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
#include "AES.h"
|
||||
#include "CTR.h"
|
||||
#include "CryptoEngine.h"
|
||||
#include "configuration.h"
|
||||
|
||||
class Apollo3CryptoEngine : public CryptoEngine
|
||||
{
|
||||
|
||||
CTRCommon *ctr = NULL;
|
||||
|
||||
public:
|
||||
Apollo3CryptoEngine() {}
|
||||
|
||||
~Apollo3CryptoEngine() {}
|
||||
|
||||
virtual void setKey(const CryptoKey &k) override
|
||||
{
|
||||
CryptoEngine::setKey(k);
|
||||
LOG_DEBUG("Installing AES%d key!\n", key.length * 8);
|
||||
if (ctr) {
|
||||
delete ctr;
|
||||
ctr = NULL;
|
||||
}
|
||||
if (key.length != 0) {
|
||||
if (key.length == 16)
|
||||
ctr = new CTR<AES128>();
|
||||
else
|
||||
ctr = new CTR<AES256>();
|
||||
|
||||
ctr->setKey(key.bytes, key.length);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Encrypt a packet
|
||||
*
|
||||
* @param bytes is updated in place
|
||||
*/
|
||||
virtual void encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||
{
|
||||
if (key.length > 0) {
|
||||
initNonce(fromNode, packetId);
|
||||
if (numBytes <= MAX_BLOCKSIZE) {
|
||||
static uint8_t scratch[MAX_BLOCKSIZE];
|
||||
memcpy(scratch, bytes, numBytes);
|
||||
memset(scratch + numBytes, 0,
|
||||
sizeof(scratch) - numBytes); // Fill rest of buffer with zero (in case cypher looks at it)
|
||||
|
||||
ctr->setIV(nonce, sizeof(nonce));
|
||||
ctr->setCounterSize(4);
|
||||
ctr->encrypt(bytes, scratch, numBytes);
|
||||
} else {
|
||||
LOG_ERROR("Packet too large for crypto engine: %d. noop encryption!\n", numBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||
{
|
||||
// For CTR, the implementation is the same
|
||||
encrypt(fromNode, packetId, numBytes, bytes);
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CryptoEngine *crypto = new Apollo3CryptoEngine();
|
@ -13,7 +13,9 @@ void getMacAddr(uint8_t *dmac)
|
||||
dmac[i] = i;
|
||||
}
|
||||
|
||||
void cpuDeepSleep(uint64_t msecToWake) {}
|
||||
void cpuDeepSleep(uint32_t msecToWake) {}
|
||||
|
||||
void initVariant() {}
|
||||
|
||||
/* pacify libc_nano */
|
||||
extern "C" {
|
||||
|
1
variants/rak11720/mbed/.ld-flags
Normal file
1
variants/rak11720/mbed/.ld-flags
Normal file
@ -0,0 +1 @@
|
||||
-DMBED_BOOT_STACK_SIZE=1024 -DXIP_ENABLE=0 -Wl,--gc-sections -Wl,--wrap,_calloc_r -Wl,--wrap,_memalign_r -Wl,--wrap,atexit -Wl,--wrap,exit -Wl,--wrap,fprintf -Wl,--wrap,main -Wl,--wrap,printf -Wl,--wrap,snprintf -Wl,--wrap,sprintf -Wl,--wrap,vfprintf -Wl,--wrap,vprintf -Wl,--wrap,vsnprintf -Wl,--wrap,vsprintf -Wl,-n -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb
|
1
variants/rak11720/mbed/.ld-macros
Normal file
1
variants/rak11720/mbed/.ld-macros
Normal file
@ -0,0 +1 @@
|
||||
ARDUINO_BLE_FIX
|
1
variants/rak11720/mbed/.ld-symbols
Normal file
1
variants/rak11720/mbed/.ld-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 -DMBED_BUILD_TIMESTAMP=1701297259.6592317 -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
|
BIN
variants/rak11720/mbed/libmbed-os.a
Normal file
BIN
variants/rak11720/mbed/libmbed-os.a
Normal file
Binary file not shown.
@ -2,4 +2,4 @@
|
||||
extends = apollo3_base
|
||||
board = wiscore_rak11720
|
||||
board_level = extra
|
||||
build_flags = ${apollo3_base.build_flags} -Ivariants/rak11720
|
||||
build_flags = ${apollo3_base.build_flags} -Ivariants/rak11720 -DDEVICE_LOCALFILESYSTEM
|
||||
|
17
variants/rak11720/variant.cpp
Normal file
17
variants/rak11720/variant.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "variant.h"
|
||||
|
||||
const pin_size_t variantPinCount = 22;
|
||||
|
||||
PinState variantPinStates[variantPinCount] = {
|
||||
{D0, 0, NULL, /*NULL, NULL, NULL,*/ NULL}, {D1, 1, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
{D2, 2, NULL, /*NULL, NULL, NULL,*/ NULL}, {D3, 3, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
{D4, 4, NULL, /*NULL, NULL, NULL,*/ NULL}, {D5, 5, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
{D6, 6, NULL, /*NULL, NULL, NULL,*/ NULL}, {D7, 7, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
{D8, 8, NULL, /*NULL, NULL, NULL,*/ NULL}, {D9, 9, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
{D10, 10, NULL, /*NULL, NULL, NULL,*/ NULL}, {D11, 11, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
{D12, 12, NULL, /*NULL, NULL, NULL,*/ NULL}, {D13, 13, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
{D14, 14, NULL, /*NULL, NULL, NULL,*/ NULL}, {D15, 15, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
{D16, 16, NULL, /*NULL, NULL, NULL,*/ NULL}, {D17, 17, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
{D18, 18, NULL, /*NULL, NULL, NULL,*/ NULL}, {D19, 19, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
{D20, 20, NULL, /*NULL, NULL, NULL,*/ NULL}, {D21, 21, NULL, /*NULL, NULL, NULL,*/ NULL},
|
||||
};
|
@ -162,6 +162,10 @@ static const uint8_t AREF = PIN_AREF;
|
||||
#define PIN_SPI_MOSI WB_SPI_MOSI
|
||||
#define PIN_SPI_SCK WB_SPI_CLK
|
||||
|
||||
#define VARIANT_SPI_SDI PIN_SPI_MISO
|
||||
#define VARIANT_SPI_SDO PIN_SPI_MOSI
|
||||
#define VARIANT_SPI_CLK PIN_SPI_SCK
|
||||
|
||||
static const uint8_t SS = PIN_SPI_CS;
|
||||
static const uint8_t MOSI = PIN_SPI_MOSI;
|
||||
static const uint8_t MISO = PIN_SPI_MISO;
|
||||
|
Loading…
Reference in New Issue
Block a user