Merge pull request #185 from geeksville/bringup

nrf52 backmerge into master
This commit is contained in:
Kevin Hester 2020-06-15 14:53:11 -07:00 committed by GitHub
commit fba676fc07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 79 additions and 29 deletions

View File

@ -1,19 +1,17 @@
# High priority # High priority
- why is the net so chatty now?
- modem sleep should work if we lower serial rate to 115kb? - modem sleep should work if we lower serial rate to 115kb?
- device wakes, turns BLE on and phone doesn't notice (while phone was sitting in auto-connect) - device wakes, turns BLE on and phone doesn't notice (while phone was sitting in auto-connect)
- E22 bringup
- encryption review findings writeup - encryption review findings writeup
- turn on modem-sleep mode - https://github.com/espressif/arduino-esp32/issues/1142#issuecomment-512428852 - turn on modem-sleep mode - https://github.com/espressif/arduino-esp32/issues/1142#issuecomment-512428852
last EDF release in arduino is: https://github.com/espressif/arduino-esp32/commit/1977370e6fc069e93ffd8818798fbfda27ae7d99 last EDF release in arduino is: https://github.com/espressif/arduino-esp32/commit/1977370e6fc069e93ffd8818798fbfda27ae7d99
IDF release/v3.3 46b12a560 IDF release/v3.3 46b12a560
IDF release/v3.3 367c3c09c IDF release/v3.3 367c3c09c
https://docs.espressif.com/projects/esp-idf/en/release-v3.3/get-started/linux-setup.html https://docs.espressif.com/projects/esp-idf/en/release-v3.3/get-started/linux-setup.html
kevinh@kevin-server:~/development/meshtastic/esp32-arduino-lib-builder$ python /home/kevinh/development/meshtastic/esp32-arduino-lib-builder/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dout --flash_freq 40m --flash_size detect 0x1000 /home/kevinh/development/meshtastic/esp32-arduino-lib-builder/build/bootloader/bootloader.bin kevinh@kevin-server:~/development/meshtastic/esp32-arduino-lib-builder\$ python /home/kevinh/development/meshtastic/esp32-arduino-lib-builder/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dout --flash_freq 40m --flash_size detect 0x1000 /home/kevinh/development/meshtastic/esp32-arduino-lib-builder/build/bootloader/bootloader.bin
cp -a out/tools/sdk/* components/arduino/tools/sdk cp -a out/tools/sdk/_ components/arduino/tools/sdk
cp -ar components/arduino/* ~/.platformio/packages/framework-arduinoespressif32@src-fba9d33740f719f712e9f8b07da6ea13/ cp -ar components/arduino/_ ~/.platformio/packages/framework-arduinoespressif32@src-fba9d33740f719f712e9f8b07da6ea13/
# Medium priority # Medium priority

View File

@ -2,11 +2,19 @@
## Misc work items ## Misc work items
platform.json
"framework-arduinoadafruitnrf52": {
"type": "framework",
"optional": true,
"version": "https://github.com/meshtastic/Adafruit_nRF52_Arduino.git"
},
## Initial work items ## Initial work items
Minimum items needed to make sure hardware is good. Minimum items needed to make sure hardware is good.
- set power UICR per https://devzone.nordicsemi.com/f/nordic-q-a/28562/nrf52840-regulator-configuration - DONE set power UICR per https://devzone.nordicsemi.com/f/nordic-q-a/28562/nrf52840-regulator-configuration
- switch charge controller into / out of performance mode (see 8.3.1 in datasheet) - switch charge controller into / out of performance mode (see 8.3.1 in datasheet)
- write UC1701 wrapper - write UC1701 wrapper
- Test hardfault handler for null ptrs (if one isn't already installed) - Test hardfault handler for null ptrs (if one isn't already installed)

View File

@ -156,8 +156,6 @@ debug_init_break =
[env:nrf52dk] [env:nrf52dk]
extends = nrf52_base extends = nrf52_base
board = nrf52840_dk_modified board = nrf52840_dk_modified
lib_deps =
UC1701 ; for temp testing
; The PPR board ; The PPR board
[env:ppr] [env:ppr]
@ -166,7 +164,7 @@ board = ppr
lib_deps = lib_deps =
${env.lib_deps} ${env.lib_deps}
UC1701 UC1701
https://github.com/meshtastic/BQ25703A.git

View File

@ -152,7 +152,10 @@ void setup()
#else #else
Wire.begin(); Wire.begin();
#endif #endif
// i2c still busted on new board
#ifndef ARDUINO_NRF52840_PPR
scanI2Cdevice(); scanI2Cdevice();
#endif
// Buttons & LED // Buttons & LED
#ifdef BUTTON_PIN #ifdef BUTTON_PIN
@ -234,7 +237,7 @@ void setup()
new SimRadio(); new SimRadio();
#endif #endif
if (!rIf->init()) if (!rIf || !rIf->init())
recordCriticalError(ErrNoRadio); recordCriticalError(ErrNoRadio);
else else
router.addInterface(rIf); router.addInterface(rIf);

View File

@ -91,9 +91,6 @@ class RadioLibInterface : public RadioInterface, private PeriodicTask
virtual void startReceive() = 0; virtual void startReceive() = 0;
private: private:
/** start an immediate transmit */
void startSend(MeshPacket *txp);
/** if we have something waiting to send, start a short random timer so we can come check for collision before actually doing /** if we have something waiting to send, start a short random timer so we can come check for collision before actually doing
* the transmit * the transmit
* *
@ -114,6 +111,11 @@ class RadioLibInterface : public RadioInterface, private PeriodicTask
/// \return true if initialisation succeeded. /// \return true if initialisation succeeded.
virtual bool init(); virtual bool init();
/** start an immediate transmit
* This method is virtual so subclasses can hook as needed, subclasses should not call directly
*/
virtual void startSend(MeshPacket *txp);
/** /**
* Convert our modemConfig enum into wf, sf, etc... * Convert our modemConfig enum into wf, sf, etc...
* *

View File

@ -14,7 +14,19 @@ bool SX1262Interface::init()
{ {
RadioLibInterface::init(); RadioLibInterface::init();
#ifdef SX1262_RXEN // set not rx or tx mode
pinMode(SX1262_RXEN, OUTPUT);
pinMode(SX1262_TXEN, OUTPUT);
digitalWrite(SX1262_RXEN, LOW);
digitalWrite(SX1262_TXEN, LOW);
#endif
#ifndef SX1262_E22
float tcxoVoltage = 0; // None - we use an XTAL float tcxoVoltage = 0; // None - we use an XTAL
#else
float tcxoVoltage =
2.4; // E22 uses DIO3 to power tcxo per https://github.com/jgromes/RadioLib/issues/12#issuecomment-520695575
#endif
bool useRegulatorLDO = false; // Seems to depend on the connection to pin 9/DCC_SW - if an inductor DCDC? bool useRegulatorLDO = false; // Seems to depend on the connection to pin 9/DCC_SW - if an inductor DCDC?
applyModemConfig(); applyModemConfig();
@ -23,6 +35,12 @@ bool SX1262Interface::init()
int res = lora.begin(freq, bw, sf, cr, syncWord, power, currentLimit, preambleLength, tcxoVoltage, useRegulatorLDO); int res = lora.begin(freq, bw, sf, cr, syncWord, power, currentLimit, preambleLength, tcxoVoltage, useRegulatorLDO);
DEBUG_MSG("LORA init result %d\n", res); DEBUG_MSG("LORA init result %d\n", res);
#ifdef SX1262_RXEN
// lora.begin assumes Dio2 is RF switch control, which is not true if we are manually controlling RX and TX
if (res == ERR_NONE)
res = lora.setDio2AsRfSwitch(false);
#endif
if (res == ERR_NONE) if (res == ERR_NONE)
res = lora.setCRC(SX126X_LORA_CRC_ON); res = lora.setCRC(SX126X_LORA_CRC_ON);
@ -81,6 +99,11 @@ void SX1262Interface::setStandby()
int err = lora.standby(); int err = lora.standby();
assert(err == ERR_NONE); assert(err == ERR_NONE);
#ifdef SX1262_RXEN // we have RXEN/TXEN control - turn off RX and TX power
digitalWrite(SX1262_RXEN, LOW);
digitalWrite(SX1262_TXEN, LOW);
#endif
isReceiving = false; // If we were receiving, not any more isReceiving = false; // If we were receiving, not any more
disableInterrupt(); disableInterrupt();
completeSending(); // If we were sending, not anymore completeSending(); // If we were sending, not anymore
@ -94,6 +117,19 @@ void SX1262Interface::addReceiveMetadata(MeshPacket *mp)
mp->rx_snr = lora.getSNR(); mp->rx_snr = lora.getSNR();
} }
/** start an immediate transmit
* We override to turn on transmitter power as needed.
*/
void SX1262Interface::startSend(MeshPacket *txp)
{
#ifdef SX1262_RXEN // we have RXEN/TXEN control - turn on TX power / off RX power
digitalWrite(SX1262_RXEN, LOW);
digitalWrite(SX1262_TXEN, HIGH);
#endif
RadioLibInterface::startSend(txp);
}
// For power draw measurements, helpful to force radio to stay sleeping // For power draw measurements, helpful to force radio to stay sleeping
// #define SLEEP_ONLY // #define SLEEP_ONLY
@ -102,6 +138,12 @@ void SX1262Interface::startReceive()
#ifdef SLEEP_ONLY #ifdef SLEEP_ONLY
sleep(); sleep();
#else #else
#ifdef SX1262_RXEN // we have RXEN/TXEN control - turn on RX power / off TX power
digitalWrite(SX1262_RXEN, HIGH);
digitalWrite(SX1262_TXEN, LOW);
#endif
setStandby(); setStandby();
// int err = lora.startReceive(); // int err = lora.startReceive();
int err = lora.startReceiveDutyCycleAuto(); // We use a 32 bit preamble so this should save some power by letting radio sit in int err = lora.startReceiveDutyCycleAuto(); // We use a 32 bit preamble so this should save some power by letting radio sit in

View File

@ -43,6 +43,12 @@ class SX1262Interface : public RadioLibInterface
* Start waiting to receive a message * Start waiting to receive a message
*/ */
virtual void startReceive(); virtual void startReceive();
/** start an immediate transmit
* We override to turn on transmitter power as needed.
*/
virtual void startSend(MeshPacket *txp);
/** /**
* Add SNR data to received messages * Add SNR data to received messages
*/ */

View File

@ -59,12 +59,6 @@ void setBluetoothEnable(bool on)
} }
} }
#ifdef ARDUINO_NRF52840_PPR
#include "PmuBQ25703A.h"
PmuBQ25703A pmu;
#endif
void nrf52Setup() void nrf52Setup()
{ {

View File

@ -129,7 +129,7 @@ static void waitEnterSleep()
if (millis() - now > 30 * 1000) { // If we wait too long just report an error and go to sleep if (millis() - now > 30 * 1000) { // If we wait too long just report an error and go to sleep
recordCriticalError(ErrSleepEnterWait); recordCriticalError(ErrSleepEnterWait);
ESP.restart(); // FIXME - for now we just restart, need to fix bug #167 assert(0); // FIXME - for now we just restart, need to fix bug #167
break; break;
} }
} }
@ -289,8 +289,6 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
return cause; return cause;
} }
#endif
// not legal on the stock android ESP build // not legal on the stock android ESP build
@ -310,4 +308,4 @@ void enableModemSleep()
config.light_sleep_enable = false; config.light_sleep_enable = false;
DEBUG_MSG("Sleep request result %x\n", esp_pm_configure(&config)); DEBUG_MSG("Sleep request result %x\n", esp_pm_configure(&config));
} }
#endif

View File

@ -137,6 +137,7 @@ static const uint8_t SCK = PIN_SPI_SCK;
// #define SX1262_ANT_SW (32 + 10) // #define SX1262_ANT_SW (32 + 10)
#define SX1262_RXEN (22) #define SX1262_RXEN (22)
#define SX1262_TXEN (24) #define SX1262_TXEN (24)
#define SX1262_E22 // Indicates this SX1262 is inside of an ebyte E22 module and special config should be done for that
// ERC12864-10 LCD // ERC12864-10 LCD
#define ERC12864_CS (32 + 4) #define ERC12864_CS (32 + 4)