mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-24 09:26:52 +00:00
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:
parent
22a5cf04d3
commit
0c8fb6e27f
@ -92,7 +92,7 @@ lib_deps =
|
|||||||
extends = arduino_base
|
extends = arduino_base
|
||||||
platform = espressif32@3.5.0
|
platform = espressif32@3.5.0
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
${arduino_base.build_src_filter} -<nrf52/> -<stm32wl>
|
${arduino_base.build_src_filter} -<nrf52/> -<stm32wl> -<rp2040>
|
||||||
upload_speed = 115200
|
upload_speed = 115200
|
||||||
debug_init_break = tbreak setup
|
debug_init_break = tbreak setup
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ build_flags =
|
|||||||
${arduino_base.build_flags} -Wno-unused-variable
|
${arduino_base.build_flags} -Wno-unused-variable
|
||||||
-Isrc/nrf52
|
-Isrc/nrf52
|
||||||
build_src_filter =
|
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 =
|
lib_ignore =
|
||||||
BluetoothOTA
|
BluetoothOTA
|
||||||
|
|
||||||
@ -165,3 +165,23 @@ board = nrf52840_dk
|
|||||||
[env:feather_nrf52832]
|
[env:feather_nrf52832]
|
||||||
extends = nrf52_base
|
extends = nrf52_base
|
||||||
board = adafruit_feather_nrf52832
|
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> -<../.pio/libdeps/pico/tiny-AES-c/test.*>
|
||||||
|
lib_ignore =
|
||||||
|
BluetoothOTA
|
||||||
|
lib_deps =
|
||||||
|
${arduino_base.lib_deps}
|
||||||
|
${environmental_base.lib_deps}
|
||||||
|
https://github.com/kokke/tiny-AES-c.git
|
@ -44,7 +44,7 @@ bool renameFile(const char* pathFrom, const char* pathTo)
|
|||||||
void listDir(const char * dirname, uint8_t levels)
|
void listDir(const char * dirname, uint8_t levels)
|
||||||
{
|
{
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
File root = FSCom.open(dirname);
|
File root = FSCom.open(dirname, FILE_O_READ);
|
||||||
if(!root){
|
if(!root){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ void listDir(const char * dirname, uint8_t levels)
|
|||||||
void rmDir(const char * dirname)
|
void rmDir(const char * dirname)
|
||||||
{
|
{
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
File file = FSCom.open(dirname);
|
File file = FSCom.open(dirname, FILE_O_READ);
|
||||||
if(!file){
|
if(!file){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,15 @@
|
|||||||
#define FILE_O_READ "r"
|
#define FILE_O_READ "r"
|
||||||
#endif
|
#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)
|
#if defined(ARCH_ESP32)
|
||||||
// ESP32 version
|
// ESP32 version
|
||||||
#include "LITTLEFS.h"
|
#include "LITTLEFS.h"
|
||||||
|
@ -297,7 +297,7 @@ bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
|||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
// 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) {
|
if (f) {
|
||||||
DEBUG_MSG("Loading %s\n", filename);
|
DEBUG_MSG("Loading %s\n", filename);
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#define HW_VENDOR HardwareModel_T_ECHO
|
#define HW_VENDOR HardwareModel_T_ECHO
|
||||||
#elif defined(NORDIC_PCA10059)
|
#elif defined(NORDIC_PCA10059)
|
||||||
#define HW_VENDOR HardwareModel_NRF52840_PCA10059
|
#define HW_VENDOR HardwareModel_NRF52840_PCA10059
|
||||||
|
#elif defined(PRIVATE_HW)
|
||||||
|
#define HW_VENDOR HardwareModel_PRIVATE_HW
|
||||||
#else
|
#else
|
||||||
#define HW_VENDOR HardwareModel_NRF52_UNKNOWN
|
#define HW_VENDOR HardwareModel_NRF52_UNKNOWN
|
||||||
#endif
|
#endif
|
||||||
|
7
src/rp2040/architecture.h
Normal file
7
src/rp2040/architecture.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define ARCH_RP2040
|
||||||
|
|
||||||
|
#if defined(PRIVATE_HW)
|
||||||
|
#define HW_VENDOR HardwareModel_PRIVATE_HW
|
||||||
|
#endif
|
30
src/rp2040/main-rp2040.cpp
Normal file
30
src/rp2040/main-rp2040.cpp
Normal 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];
|
||||||
|
}
|
36
src/rp2040/rp2040CryptoEngine.cpp
Normal file
36
src/rp2040/rp2040CryptoEngine.cpp
Normal 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();
|
17
variants/pico/platformio.ini
Normal file
17
variants/pico/platformio.ini
Normal file
@ -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}
|
52
variants/pico/variant.h
Normal file
52
variants/pico/variant.h
Normal file
@ -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>
|
@ -3,7 +3,7 @@
|
|||||||
extends = nrf52840_base
|
extends = nrf52840_base
|
||||||
board = t-echo
|
board = t-echo
|
||||||
debug_tool = jlink
|
debug_tool = jlink
|
||||||
upload_protocol = jlink
|
upload_protocol = nrfutil
|
||||||
# add our variants files to the include and src paths
|
# add our variants files to the include and src paths
|
||||||
# define build flags for the TFT_eSPI library - NOTE: WE NOT LONGER USE TFT_eSPI, it was for an earlier version of the TTGO eink screens
|
# define build flags for the TFT_eSPI library - NOTE: WE NOT LONGER USE TFT_eSPI, it was for an earlier version of the TTGO eink screens
|
||||||
# -DBUSY_PIN=3 -DRST_PIN=2 -DDC_PIN=28 -DCS_PIN=30
|
# -DBUSY_PIN=3 -DRST_PIN=2 -DDC_PIN=28 -DCS_PIN=30
|
||||||
|
Loading…
Reference in New Issue
Block a user