From ce21859ada7da5529da046b643be0719cb6201e1 Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 27 Mar 2020 12:08:05 -0700 Subject: [PATCH 1/8] toto updates --- docs/software/TODO.md | 1 + docs/software/mesh-alg.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/software/TODO.md b/docs/software/TODO.md index 01a939fe1..38523a33b 100644 --- a/docs/software/TODO.md +++ b/docs/software/TODO.md @@ -17,6 +17,7 @@ Items to complete soon (next couple of alpha releases). Items to complete before the first beta release. +- possibly switch to https://github.com/SlashDevin/NeoGPS for gps comms - good source of battery/signal/gps icons https://materialdesignicons.com/ - research and implement better mesh algorithm - investigate changing routing to https://github.com/sudomesh/LoRaLayer2 ? - check fcc rules on duty cycle. we might not need to freq hop. https://www.sunfiretesting.com/LoRa-FCC-Certification-Guide/ diff --git a/docs/software/mesh-alg.md b/docs/software/mesh-alg.md index 193f0aef9..d0935d34f 100644 --- a/docs/software/mesh-alg.md +++ b/docs/software/mesh-alg.md @@ -10,7 +10,7 @@ TODO: * DONE read about mesh routing solutions (DSR and AODV) * DONE read about general mesh flooding solutions (naive, MPR, geo assisted) * DONE reread the disaster radio protocol docs - seems based on Babel (which is AODVish) -* possibly dash7? https://www.slideshare.net/MaartenWeyn1/dash7-alliance-protocol-technical-presentation https://github.com/MOSAIC-LoPoW/dash7-ap-open-source-stack +* possibly dash7? https://www.slideshare.net/MaartenWeyn1/dash7-alliance-protocol-technical-presentation https://github.com/MOSAIC-LoPoW/dash7-ap-open-source-stack - does the opensource stack implement multihop routing? flooding? their discussion mailing list looks dead-dead * update duty cycle spreadsheet for our typical usecase * generalize naive flooding on top of radiohead or disaster.radio? (and fix radiohead to use my new driver) From cc3bac7ea0d2e48219ecbb1fa0094e8bf692d6bd Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 27 Mar 2020 12:29:51 -0700 Subject: [PATCH 2/8] Fix AXP192 handling by @spattinson. yay! fix #48 Also - now that he fixed that, we can leave PMU interrupts on across sleep Hopefully the following line will properly credit him in the magic github universe... Co-authored-by: spattinson --- src/main.cpp | 31 +++++++++++++++++++++++++++---- src/sleep.cpp | 15 +++++---------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 127a23146..18b094f71 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -158,13 +158,15 @@ void axp192Init() axp.debugCharging(); #ifdef PMU_IRQ - pinMode(PMU_IRQ, INPUT_PULLUP); + pinMode(PMU_IRQ, INPUT); attachInterrupt( - PMU_IRQ, [] { pmu_irq = true; }, RISING); + PMU_IRQ, [] { pmu_irq = true; }, FALLING); axp.adc1Enable(AXP202_BATT_CUR_ADC1, 1); - axp.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ, + axp.enableIRQ(AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ | AXP202_CHARGING_FINISHED_IRQ | AXP202_CHARGING_IRQ | + AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_PEK_SHORTPRESS_IRQ, 1); + axp.clearIRQ(); #endif @@ -349,9 +351,30 @@ void loop() DEBUG_MSG("pmu irq!\n"); + if (axp.isChargingIRQ()) { + DEBUG_MSG("Battery start charging\n"); + } + if (axp.isChargingDoneIRQ()) { + DEBUG_MSG("Battery fully charged\n"); + } + if (axp.isVbusRemoveIRQ()) { + DEBUG_MSG("USB unplugged\n"); + } + if (axp.isVbusPlugInIRQ()) { + DEBUG_MSG("USB plugged In\n"); + } + if (axp.isBattPlugInIRQ()) { + DEBUG_MSG("Battery inserted\n"); + } + if (axp.isBattRemoveIRQ()) { + DEBUG_MSG("Battery removed\n"); + } + if (axp.isPEKShortPressIRQ()) { + DEBUG_MSG("PEK short button press\n"); + } + isCharging = axp.isChargeing() ? 1 : 0; isUSBPowered = axp.isVBUSPlug() ? 1 : 0; - axp.clearIRQ(); } diff --git a/src/sleep.cpp b/src/sleep.cpp index f69ab5ce8..71fc3c4dc 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -155,17 +155,11 @@ void doDeepSleep(uint64_t msecToWake) static const uint8_t rtcGpios[] = {/* 0, */ 2, /* 4, */ #ifndef USE_JTAG - 12, - 13, - /* 14, */ /* 15, */ + 12, 13, + /* 14, */ /* 15, */ #endif /* 25, */ 26, /* 27, */ - 32, - 33, - 34, - 35, - 36, - 37, + 32, 33, 34, 35, 36, 37, /* 38, */ 39}; for (int i = 0; i < sizeof(rtcGpios); i++) @@ -222,7 +216,8 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r gpio_wakeup_enable((gpio_num_t)DIO0_GPIO, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high #ifdef PMU_IRQ // FIXME, disable wake due to PMU because it seems to fire all the time? - // gpio_wakeup_enable((gpio_num_t)PMU_IRQ, GPIO_INTR_HIGH_LEVEL); // pmu irq + if (axp192_found) + gpio_wakeup_enable((gpio_num_t)PMU_IRQ, GPIO_INTR_LOW_LEVEL); // pmu irq #endif assert(esp_sleep_enable_gpio_wakeup() == ESP_OK); assert(esp_sleep_enable_timer_wakeup(sleepUsec) == ESP_OK); From a0c97825e8e7ca53eef0e2d25bfead3a8bc40437 Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 27 Mar 2020 12:32:18 -0700 Subject: [PATCH 3/8] always use gps.isConnected to check for GPS, it is the only thing guaranteed to be fresh and accurate --- src/MeshService.cpp | 4 ++-- src/screen.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MeshService.cpp b/src/MeshService.cpp index 02ce6a090..bf1702389 100644 --- a/src/MeshService.cpp +++ b/src/MeshService.cpp @@ -151,7 +151,7 @@ void MeshService::handleFromRadio(MeshPacket *mp) mp->rx_time = gps.getValidTime(); // store the arrival timestamp for the phone // If it is a position packet, perhaps set our clock (if we don't have a GPS of our own, otherwise wait for that to work) - if (!myNodeInfo.has_gps) + if (!gps.isConnected) handleIncomingPosition(mp); else { DEBUG_MSG("Ignoring incoming time, because we have a GPS\n"); @@ -263,7 +263,7 @@ void MeshService::sendToMesh(MeshPacket *p) // nodes shouldn't trust it anyways) Note: for now, we allow a device with a local GPS to include the time, so that gpsless // devices can get time. if (p->has_payload && p->payload.which_variant == SubPacket_position_tag) { - if (!myNodeInfo.has_gps) { + if (!gps.isConnected) { DEBUG_MSG("Stripping time %u from position send\n", p->payload.variant.position.time); p->payload.variant.position.time = 0; } else diff --git a/src/screen.cpp b/src/screen.cpp index 6d06b0207..4c66f982f 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -393,7 +393,7 @@ static void drawDebugInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16 snprintf(batStr, sizeof(batStr), "Batt %x%%", (isCharging << 1) + isUSBPowered); static char gpsStr[20]; - if (myNodeInfo.has_gps) + if (gps.isConnected) snprintf(gpsStr, sizeof(gpsStr), "GPS %d%%", 75); // FIXME, use something based on hdop else From 5c4ae6c042df58ae5f4263a8a13b66bbadb3f52f Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 27 Mar 2020 12:37:47 -0700 Subject: [PATCH 4/8] now that axp192 interrups work, no need to poll over i2c. #48 --- src/main.cpp | 58 ++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 18b094f71..3dc0fa2ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -342,46 +342,38 @@ void loop() // for debug printing // service.radio.rf95.canSleep(); -#ifdef T_BEAM_V10 - if (axp192_found) { #ifdef PMU_IRQ - if (pmu_irq) { - pmu_irq = false; - axp.readIRQ(); + if (pmu_irq) { + pmu_irq = false; + axp.readIRQ(); - DEBUG_MSG("pmu irq!\n"); + DEBUG_MSG("pmu irq!\n"); - if (axp.isChargingIRQ()) { - DEBUG_MSG("Battery start charging\n"); - } - if (axp.isChargingDoneIRQ()) { - DEBUG_MSG("Battery fully charged\n"); - } - if (axp.isVbusRemoveIRQ()) { - DEBUG_MSG("USB unplugged\n"); - } - if (axp.isVbusPlugInIRQ()) { - DEBUG_MSG("USB plugged In\n"); - } - if (axp.isBattPlugInIRQ()) { - DEBUG_MSG("Battery inserted\n"); - } - if (axp.isBattRemoveIRQ()) { - DEBUG_MSG("Battery removed\n"); - } - if (axp.isPEKShortPressIRQ()) { - DEBUG_MSG("PEK short button press\n"); - } - - isCharging = axp.isChargeing() ? 1 : 0; - isUSBPowered = axp.isVBUSPlug() ? 1 : 0; - axp.clearIRQ(); + if (axp.isChargingIRQ()) { + DEBUG_MSG("Battery start charging\n"); + } + if (axp.isChargingDoneIRQ()) { + DEBUG_MSG("Battery fully charged\n"); + } + if (axp.isVbusRemoveIRQ()) { + DEBUG_MSG("USB unplugged\n"); + } + if (axp.isVbusPlugInIRQ()) { + DEBUG_MSG("USB plugged In\n"); + } + if (axp.isBattPlugInIRQ()) { + DEBUG_MSG("Battery inserted\n"); + } + if (axp.isBattRemoveIRQ()) { + DEBUG_MSG("Battery removed\n"); + } + if (axp.isPEKShortPressIRQ()) { + DEBUG_MSG("PEK short button press\n"); } - // FIXME AXP192 interrupt is not firing, remove this temporary polling of battery state isCharging = axp.isChargeing() ? 1 : 0; isUSBPowered = axp.isVBUSPlug() ? 1 : 0; -#endif + axp.clearIRQ(); } #endif From d831beab3d82f9f0161e4135b72210b8eadb55c4 Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 27 Mar 2020 13:20:52 -0700 Subject: [PATCH 5/8] moving build selection into platformio.ini rather than nasty #defines. thanks to @sensorslot for the pointer to https://github.com/arendst/Tasmota - where I just borrowed heavily ;-) --- .vscode/launch.json | 4 ++-- bin/build-all.sh | 33 ++++++++++++++--------------- docs/software/build-instructions.md | 10 +++++---- platformio.ini | 25 +++++++++++++--------- src/configuration.h | 13 ++++++------ src/main.cpp | 6 +++--- src/sleep.cpp | 8 +++---- 7 files changed, 53 insertions(+), 46 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 2e1ab296a..914831d68 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,7 +12,7 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug", - "executable": "/home/kevinh/development/meshtastic/meshtastic-esp32/.pio/build/esp32/firmware.elf", + "executable": "/home/kevinh/development/meshtastic/meshtastic-esp32/.pio/build/tbeam/firmware.elf", "toolchainBinDir": "/home/kevinh/.platformio/packages/toolchain-xtensa32/bin", "preLaunchTask": { "type": "PlatformIO", @@ -24,7 +24,7 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug (skip Pre-Debug)", - "executable": "/home/kevinh/development/meshtastic/meshtastic-esp32/.pio/build/esp32/firmware.elf", + "executable": "/home/kevinh/development/meshtastic/meshtastic-esp32/.pio/build/tbeam/firmware.elf", "toolchainBinDir": "/home/kevinh/.platformio/packages/toolchain-xtensa32/bin", "internalConsoleOptions": "openOnSessionStart" } diff --git a/bin/build-all.sh b/bin/build-all.sh index 9dbc2fb48..a398be246 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -7,9 +7,7 @@ source bin/version.sh COUNTRIES="US EU433 EU865 CN JP" #COUNTRIES=US -SRCMAP=.pio/build/esp32/output.map -SRCBIN=.pio/build/esp32/firmware.bin -SRCELF=.pio/build/esp32/firmware.elf + OUTDIR=release/latest # We keep all old builds (and their map files in the archive dir) @@ -17,25 +15,26 @@ ARCHIVEDIR=release/archive rm -f $OUTDIR/firmware* +function do_build { + ENV_NAME=$1 + echo "Building for $ENV_NAME with $PLATFORMIO_BUILD_FLAGS" + SRCBIN=.pio/build/$ENV_NAME/firmware.bin + SRCELF=.pio/build/$ENV_NAME/firmware.elf + rm -f $SRCBIN $SRCMAP + pio run --environment $ENV_NAME # -v + cp $SRCBIN $OUTDIR/firmware-$ENV_NAME-$COUNTRY-$VERSION.bin + cp $SRCELF $OUTDIR/firmware-$ENV_NAME-$COUNTRY-$VERSION.elf +} + for COUNTRY in $COUNTRIES; do HWVERSTR="1.0-$COUNTRY" - COMMONOPTS="-DAPP_VERSION=$VERSION -DHW_VERSION_$COUNTRY -DHW_VERSION=$HWVERSTR -Wall -Wextra -Wno-missing-field-initializers -Isrc -Os -Wl,-Map,.pio/build/esp32/output.map -DAXP_DEBUG_PORT=Serial" + COMMONOPTS="-DAPP_VERSION=$VERSION -DHW_VERSION_$COUNTRY -DHW_VERSION=$HWVERSTR -Wall -Wextra -Wno-missing-field-initializers -Isrc -Os -DAXP_DEBUG_PORT=Serial" - export PLATFORMIO_BUILD_FLAGS="-DT_BEAM_V10 $COMMONOPTS" - echo "Building with $PLATFORMIO_BUILD_FLAGS" - rm -f $SRCBIN $SRCMAP - pio run # -v - cp $SRCBIN $OUTDIR/firmware-TBEAM-$COUNTRY-$VERSION.bin - cp $SRCELF $OUTDIR/firmware-TBEAM-$COUNTRY-$VERSION.elf - #cp $SRCMAP $ARCHIVEDIR/firmware-TBEAM-$COUNTRY-$VERSION.map + export PLATFORMIO_BUILD_FLAGS="$COMMONOPTS" - export PLATFORMIO_BUILD_FLAGS="-DHELTEC_LORA32 $COMMONOPTS" - rm -f $SRCBIN $SRCMAP - pio run # -v - cp $SRCBIN $OUTDIR/firmware-HELTEC-$COUNTRY-$VERSION.bin - cp $SRCELF $OUTDIR/firmware-HELTEC-$COUNTRY-$VERSION.elf - #cp $SRCMAP $ARCHIVEDIR/firmware-HELTEC-$COUNTRY-$VERSION.map + do_build "tbeam" + do_build "heltec" done # keep the bins in archive also diff --git a/docs/software/build-instructions.md b/docs/software/build-instructions.md index 624becd17..d8bac64f4 100644 --- a/docs/software/build-instructions.md +++ b/docs/software/build-instructions.md @@ -6,19 +6,21 @@ in these instructions I describe use of their command line tool. 1. Purchase a suitable radio (see above) 2. Install [PlatformIO](https://platformio.org/platformio-ide) 3. Download this git repo and cd into it -4. Edit configuration.h and comment out *one* of the following two lines (depending on which board you are using): +4. Edit configuration.h and comment out _one_ of the following two lines (depending on which board you are using): + ``` -// #define T_BEAM_V10 -#define HELTEC_LORA32 +// #define ARDUINO_T_Beam +#define ARDUINO_HELTEC_WIFI_LORA_32_V2 ``` + 5. Plug the radio into your USB port 6. Type "pio run -t upload" (This command will fetch dependencies, build the project and install it on the board via USB) 7. Platform IO also installs a very nice VisualStudio Code based IDE, see their [tutorial](https://docs.platformio.org/en/latest/tutorials/espressif32/arduino_debugging_unit_testing.html) if you'd like to use it - ## Decoding stack traces If you get a crash, you can decode the addresses from the `Backtrace:` line: + 1. Save the `Backtrace: 0x....` line to a file, e.g., `backtrace.txt`. 2. Run `bin/exception_decoder.py backtrace.txt` (this uses symbols from the last `firmware.elf`, so you must be running the same binary that's still in diff --git a/platformio.ini b/platformio.ini index 2ab626f1f..7a1c73b13 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,10 +9,15 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] +default_envs = tbeam -[env:esp32] +[common] +; default to a US frequency range, change it as needed for your region and hardware (CN, JP, EU433, EU865) +hw_version = US + +[env] platform = espressif32 -board = ttgo-t-beam +; board = ttgo-t-beam ; board = heltec_wifi_lora_32_V2 framework = arduino @@ -22,14 +27,13 @@ board_build.partitions = partition-table.csv ; note: we add src to our include search path so that lmic_project_config can override ; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc -build_flags = -Wall -Wextra -Wno-missing-field-initializers -Isrc -Os -Wl,-Map,.pio/build/esp32/output.map -DAXP_DEBUG_PORT=Serial +build_flags = -Wall -Wextra -Wno-missing-field-initializers -Isrc -Os -Wl,-Map,.pio/build/output.map -DAXP_DEBUG_PORT=Serial -DHW_VERSION_${common.hw_version} ; not needed included in ttgo-t-beam board file ; also to use PSRAM https://docs.platformio.org/en/latest/platforms/espressif32.html#external-ram-psram ; -DBOARD_HAS_PSRAM ; -mfix-esp32-psram-cache-issue - ; -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG upload_speed = 921600 @@ -55,8 +59,6 @@ debug_tool = jlink debug_init_break = tbreak setup -; Note: some libraries are specified by #ID where there are conflicting library -; names. lib_deps = https://github.com/meshtastic/RadioHead.git https://github.com/meshtastic/esp8266-oled-ssd1306.git ; ESP8266_SSD1306 @@ -68,9 +70,12 @@ lib_deps = https://github.com/meshtastic/arduino-fsm.git https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git -;[env:tbeam] -;board = ttgo-t-beam +[env:tbeam] +board = ttgo-t-beam +lib_deps = + ${env.lib_deps} + AXP202X_Library -;[env:heltec] +[env:heltec] ;build_type = debug ; to make it possible to step through our jtag debugger -;board = heltec_wifi_lora_32_V2 +board = heltec_wifi_lora_32_V2 diff --git a/src/configuration.h b/src/configuration.h index 00b04fcf5..9ce1c69d3 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -40,9 +40,10 @@ along with this program. If not, see . // ----------------------------------------------------------------------------- // Select which board is being used. If the outside build environment has sent a choice, just use that -#if !defined(T_BEAM_V10) && !defined(HELTEC_LORA32) -#define T_BEAM_V10 // AKA Rev1 (second board released) -// #define HELTEC_LORA32 +#if !defined(ARDUINO_T_Beam) && !defined(ARDUINO_HELTEC_WIFI_LORA_32_V2) +// The platformio build environment should set this now +// #define ARDUINO_T_Beam // AKA Rev1 (second board released) +// #define ARDUINO_HELTEC_WIFI_LORA_32_V2 #define HW_VERSION_US // We encode the hardware freq range in the hw version string, so sw update can eventually install the // correct build @@ -50,7 +51,7 @@ along with this program. If not, see . // If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled) // we don't support jtag on the ttgo - access to gpio 12 is a PITA -#ifdef HELTEC_LORA32 +#ifdef ARDUINO_HELTEC_WIFI_LORA_32_V2 //#define USE_JTAG #endif @@ -105,7 +106,7 @@ along with this program. If not, see . #define MOSI_GPIO 27 #define NSS_GPIO 18 -#if defined(T_BEAM_V10) +#if defined(ARDUINO_T_Beam) // This string must exactly match the case used in release file names or the android updater won't work #define HW_VENDOR "TBEAM" @@ -126,7 +127,7 @@ along with this program. If not, see . // Leave undefined to disable our PMU IRQ handler #define PMU_IRQ 35 -#elif defined(HELTEC_LORA32) +#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2) // This string must exactly match the case used in release file names or the android updater won't work #define HW_VENDOR "HELTEC" diff --git a/src/main.cpp b/src/main.cpp index 3dc0fa2ec..c4b522e2f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,7 +38,7 @@ #include #include -#ifdef T_BEAM_V10 +#ifdef ARDUINO_T_Beam #include "axp20x.h" AXP20X_Class axp; bool pmu_irq = false; @@ -81,7 +81,7 @@ void scanI2Cdevice(void) ssd1306_found = true; DEBUG_MSG("ssd1306 display found\n"); } -#ifdef T_BEAM_V10 +#ifdef ARDUINO_T_Beam if (addr == AXP192_SLAVE_ADDRESS) { axp192_found = true; DEBUG_MSG("axp192 PMU found\n"); @@ -108,7 +108,7 @@ void scanI2Cdevice(void) */ void axp192Init() { -#ifdef T_BEAM_V10 +#ifdef ARDUINO_T_Beam if (axp192_found) { if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) { DEBUG_MSG("AXP192 Begin PASS\n"); diff --git a/src/sleep.cpp b/src/sleep.cpp index 71fc3c4dc..9894e6299 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -14,7 +14,7 @@ #include #include -#ifdef T_BEAM_V10 +#ifdef ARDUINO_T_Beam #include "axp20x.h" extern AXP20X_Class axp; #endif @@ -48,7 +48,7 @@ void setLed(bool ledOn) digitalWrite(LED_PIN, ledOn); #endif -#ifdef T_BEAM_V10 +#ifdef ARDUINO_T_Beam if (axp192_found) { // blink the axp led axp.setChgLEDMode(ledOn ? AXP20X_LED_LOW_LEVEL : AXP20X_LED_OFF); @@ -60,7 +60,7 @@ void setGPSPower(bool on) { DEBUG_MSG("Setting GPS power=%d\n", on); -#ifdef T_BEAM_V10 +#ifdef ARDUINO_T_Beam if (axp192_found) axp.setPowerOutPut(AXP192_LDO3, on ? AXP202_ON : AXP202_OFF); // GPS main power #endif @@ -124,7 +124,7 @@ void doDeepSleep(uint64_t msecToWake) setLed(false); -#ifdef T_BEAM_V10 +#ifdef ARDUINO_T_Beam if (axp192_found) { // No need to turn this off if the power draw in sleep mode really is just 0.2uA and turning it off would // leave floating input for the IRQ line From cf2aa37635975c1efd74235bd7f41bcfa178b6d5 Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 27 Mar 2020 16:55:19 -0700 Subject: [PATCH 6/8] clean up configuration.h and add support for ttgo-lora-v1 boards --- bin/build-all.sh | 2 ++ platformio.ini | 9 +++++-- src/configuration.h | 64 +++++++++++++++++++++++++++++++-------------- 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/bin/build-all.sh b/bin/build-all.sh index a398be246..ada9a4fc9 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -15,6 +15,7 @@ ARCHIVEDIR=release/archive rm -f $OUTDIR/firmware* +# build the named environment and copy the bins to the release directory function do_build { ENV_NAME=$1 echo "Building for $ENV_NAME with $PLATFORMIO_BUILD_FLAGS" @@ -33,6 +34,7 @@ for COUNTRY in $COUNTRIES; do export PLATFORMIO_BUILD_FLAGS="$COMMONOPTS" + do_build "ttgo-lora32-v1" do_build "tbeam" do_build "heltec" done diff --git a/platformio.ini b/platformio.ini index 7a1c73b13..f8de66947 100644 --- a/platformio.ini +++ b/platformio.ini @@ -17,8 +17,6 @@ hw_version = US [env] platform = espressif32 -; board = ttgo-t-beam -; board = heltec_wifi_lora_32_V2 framework = arduino ; customize the partition table @@ -79,3 +77,10 @@ lib_deps = [env:heltec] ;build_type = debug ; to make it possible to step through our jtag debugger board = heltec_wifi_lora_32_V2 + +[env:ttgo-lora32-v1] +board = ttgo-lora32-v1 + +; note: the platformio definition for lora32-v2 seems stale, it is missing a pins_arduino.h file, therefore I don't think it works +; [env:ttgo-lora32-v2] +; board = ttgo-lora32-v2 \ No newline at end of file diff --git a/src/configuration.h b/src/configuration.h index 9ce1c69d3..a0bbdbe97 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -39,16 +39,6 @@ along with this program. If not, see . // Configuration // ----------------------------------------------------------------------------- -// Select which board is being used. If the outside build environment has sent a choice, just use that -#if !defined(ARDUINO_T_Beam) && !defined(ARDUINO_HELTEC_WIFI_LORA_32_V2) -// The platformio build environment should set this now -// #define ARDUINO_T_Beam // AKA Rev1 (second board released) -// #define ARDUINO_HELTEC_WIFI_LORA_32_V2 - -#define HW_VERSION_US // We encode the hardware freq range in the hw version string, so sw update can eventually install the - // correct build -#endif - // If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled) // we don't support jtag on the ttgo - access to gpio 12 is a PITA #ifdef ARDUINO_HELTEC_WIFI_LORA_32_V2 @@ -108,7 +98,7 @@ along with this program. If not, see . #if defined(ARDUINO_T_Beam) // This string must exactly match the case used in release file names or the android updater won't work -#define HW_VENDOR "TBEAM" +#define HW_VENDOR "tbeam" // #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep @@ -129,25 +119,59 @@ along with this program. If not, see . #elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2) // This string must exactly match the case used in release file names or the android updater won't work -#define HW_VENDOR "HELTEC" +#define HW_VENDOR "heltec" -#ifndef USE_JTAG // gpio15 is TDO for JTAG, so no I2C on this board while doing jtag -#define I2C_SDA 4 +#ifndef USE_JTAG // gpio15 is TDO for JTAG, so no I2C on this board while doing jtag +#define I2C_SDA 4 // I2C pins for this board #define I2C_SCL 15 #endif -#define RESET_OLED 16 +#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost -#define LED_PIN 25 -#define BUTTON_PIN 0 +#define LED_PIN 25 // If defined we will blink this LED +#define BUTTON_PIN 0 // If defined, this will be used for user button presses #ifndef USE_JTAG -#define RESET_GPIO 14 +#define RESET_GPIO 14 // If defined, this pin will be used to reset the LORA radio #endif #define DIO0_GPIO 26 -#define DIO1_GPIO 35 -#define DIO2_GPIO 34 +#define DIO1_GPIO 35 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number +#define DIO2_GPIO 34 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number +#elif defined(ARDUINO_TTGO_LoRa32_V1) +// This string must exactly match the case used in release file names or the android updater won't work +#define HW_VENDOR "ttgo-lora32-v1" + +#define I2C_SDA 4 // I2C pins for this board +#define I2C_SCL 15 + +#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller + +// #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost +#define LED_PIN 2 // If defined we will blink this LED +#define BUTTON_PIN 0 // If defined, this will be used for user button presses + +#define RESET_GPIO 23 // If defined, this pin will be used to reset the LORA radio +#define DIO0_GPIO 26 // IRQ line for the LORA radio +#define DIO1_GPIO 35 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number +#define DIO2_GPIO 34 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number +#elif defined(ARDUINO_TTGO_LoRa32_V2) +// This string must exactly match the case used in release file names or the android updater won't work +#define HW_VENDOR "ttgo-lora32-v2" + +#define I2C_SDA 21 // I2C pins for this board +#define I2C_SCL 22 + +#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller + +#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost +#define LED_PIN 2 // If defined we will blink this LED +#define BUTTON_PIN 0 // If defined, this will be used for user button presses + +#define RESET_GPIO 23 // If defined, this pin will be used to reset the LORA radio +#define DIO0_GPIO 26 // IRQ line for the LORA radio +#define DIO1_GPIO 35 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number +#define DIO2_GPIO 34 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number #endif // ----------------------------------------------------------------------------- From a350b3795b64a21735e3be70f9656d2ac492b479 Mon Sep 17 00:00:00 2001 From: geeksville Date: Sat, 28 Mar 2020 13:16:54 -0700 Subject: [PATCH 7/8] remove unused file --- bin/build-all.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/build-all.sh b/bin/build-all.sh index ada9a4fc9..b7eccd59e 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -7,7 +7,6 @@ source bin/version.sh COUNTRIES="US EU433 EU865 CN JP" #COUNTRIES=US - OUTDIR=release/latest # We keep all old builds (and their map files in the archive dir) @@ -21,7 +20,7 @@ function do_build { echo "Building for $ENV_NAME with $PLATFORMIO_BUILD_FLAGS" SRCBIN=.pio/build/$ENV_NAME/firmware.bin SRCELF=.pio/build/$ENV_NAME/firmware.elf - rm -f $SRCBIN $SRCMAP + rm -f $SRCBIN pio run --environment $ENV_NAME # -v cp $SRCBIN $OUTDIR/firmware-$ENV_NAME-$COUNTRY-$VERSION.bin cp $SRCELF $OUTDIR/firmware-$ENV_NAME-$COUNTRY-$VERSION.elf From 5386a5b224e8d6c3ddcac5e26c858396309152a4 Mon Sep 17 00:00:00 2001 From: geeksville Date: Sat, 28 Mar 2020 13:17:07 -0700 Subject: [PATCH 8/8] update build instructions --- docs/software/build-instructions.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/docs/software/build-instructions.md b/docs/software/build-instructions.md index d8bac64f4..073ce4e8e 100644 --- a/docs/software/build-instructions.md +++ b/docs/software/build-instructions.md @@ -6,16 +6,10 @@ in these instructions I describe use of their command line tool. 1. Purchase a suitable radio (see above) 2. Install [PlatformIO](https://platformio.org/platformio-ide) 3. Download this git repo and cd into it -4. Edit configuration.h and comment out _one_ of the following two lines (depending on which board you are using): - -``` -// #define ARDUINO_T_Beam -#define ARDUINO_HELTEC_WIFI_LORA_32_V2 -``` - +4. If you are outside the USA, edit [platformio.ini](/platformio.ini) to set the correct frequency range for your country. The line you need to change starts with "hw_version" and instructions are provided above that line. Options are provided for EU433, EU835, CN, JP and US. Pull-requests eagerly accepted for other countries. 5. Plug the radio into your USB port -6. Type "pio run -t upload" (This command will fetch dependencies, build the project and install it on the board via USB) -7. Platform IO also installs a very nice VisualStudio Code based IDE, see their [tutorial](https://docs.platformio.org/en/latest/tutorials/espressif32/arduino_debugging_unit_testing.html) if you'd like to use it +6. Type "pio run --environment XXX -t upload" (This command will fetch dependencies, build the project and install it on the board via USB). For XXX, use the board type you have (either tbeam, heltec, ttgo-lora32-v1, ttgo-lora32-v2). +7. Platform IO also installs a very nice VisualStudio Code based IDE, see their [tutorial](https://docs.platformio.org/en/latest/tutorials/espressif32/arduino_debugging_unit_testing.html) if you'd like to use it. ## Decoding stack traces