Merge pull request #1611 from meshtastic/RP2040-Platform

Raspberry Pi Pico target (with sparkfun lora hat)
pull/1614/head
Thomas Göttgens 2022-08-10 10:14:43 +02:00 zatwierdzone przez GitHub
commit bbc0baa31d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
11 zmienionych plików z 179 dodań i 5 usunięć

Wyświetl plik

@ -92,7 +92,7 @@ lib_deps =
extends = arduino_base
platform = espressif32@3.5.0
build_src_filter =
${arduino_base.build_src_filter} -<nrf52/> -<stm32wl>
${arduino_base.build_src_filter} -<nrf52/> -<stm32wl> -<rp2040>
upload_speed = 115200
debug_init_break = tbreak setup
@ -144,7 +144,7 @@ build_flags =
${arduino_base.build_flags} -Wno-unused-variable
-Isrc/nrf52
build_src_filter =
${arduino_base.build_src_filter} -<esp32/> -<stm32wl> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/>
${arduino_base.build_src_filter} -<esp32/> -<stm32wl> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/> -<rp2040>
lib_ignore =
BluetoothOTA
@ -165,3 +165,23 @@ board = nrf52840_dk
[env:feather_nrf52832]
extends = nrf52_base
board = adafruit_feather_nrf52832
; Common settings for rp2040 Processor based targets
[rp2040_base]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
extends = arduino_base
board_build.core = earlephilhower
board_build.filesystem_size = 0.5m
build_flags =
${arduino_base.build_flags} -Wno-unused-variable
-Isrc/rp2040
-D__PLAT_RP2040__
# -D _POSIX_THREADS
build_src_filter =
${arduino_base.build_src_filter} -<esp32/> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/> -<nrf52/> -<stm32wl>
lib_ignore =
BluetoothOTA
lib_deps =
${arduino_base.lib_deps}
${environmental_base.lib_deps}
https://github.com/kokke/tiny-AES-c.git

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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"

Wyświetl plik

@ -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);

Wyświetl plik

@ -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

Wyświetl plik

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

Wyświetl plik

@ -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];
}

Wyświetl plik

@ -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();

Wyświetl plik

@ -0,0 +1,17 @@
[env:pico]
extends = rp2040_base
board = pico
upload_protocol = picotool
# add our variants files to the include and src paths
build_flags = ${rp2040_base.build_flags}
-DPRIVATE_HW
-Ivariants/pico
-DARDUINO_AVR_NANO_EVERY
-DDEBUG_RP2040_WIRE
-DDEBUG_RP2040_SPI
-DDEBUG_RP2040_CORE
-DDEBUG_RP2040_PORT=Serial
-DUSE_TINYUSB
lib_deps =
${rp2040_base.lib_deps}

Wyświetl plik

@ -0,0 +1,52 @@
// #define RADIOLIB_CUSTOM_ARDUINO 1
// #define RADIOLIB_TONE_UNSUPPORTED 1
// #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED 1
#define ARDUINO_ARCH_AVR
#define CBC 0
#define CTR 1
#define ECB 0
#define NO_GPS 1
#define USE_SH1106 1
#undef GPS_SERIAL_NUM
// #define I2C_SDA 6
// #define I2C_SCL 7
#define BUTTON_PIN 17
#define EXT_NOTIFY_OUT 4
#define BATTERY_PIN 26
// ratio of voltage divider = 3.0 (R17=200k, R18=100k)
#define ADC_MULTIPLIER 3.1 // 3.0 + a bit for being optimistic
#define USE_RF95
#define USE_SX1262
#undef RF95_SCK
#undef RF95_MISO
#undef RF95_MOSI
#undef RF95_NSS
#define RF95_SCK 10
#define RF95_MISO 12
#define RF95_MOSI 11
#define RF95_NSS 3
#define LORA_DIO0 RADIOLIB_NC
#define LORA_RESET 15
#define LORA_DIO1 20
#define LORA_DIO2 2
#define LORA_DIO3 RADIOLIB_NC
#ifdef USE_SX1262
#define SX126X_CS RF95_NSS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_DIO2
#define SX126X_RESET LORA_RESET
#define SX126X_E22
#endif
#include <Adafruit_TinyUSB.h>

Wyświetl plik

@ -6,6 +6,7 @@ build_src_filter =
-<nimble/>
-<nrf52/>
-<stm32wl/>
-<rp2040>
-<mesh/http/>
-<modules/esp32>
-<modules/Telemetry>