diff --git a/.vscode/launch.json b/.vscode/launch.json
index 2e1ab296..914831d6 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 9dbc2fb4..a398be24 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 624becd1..d8bac64f 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 2ab626f1..7a1c73b1 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 00b04fcf..9ce1c69d 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 3dc0fa2e..c4b522e2 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 71fc3c4d..9894e629 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