From 197e2d0e8066fd8c2fd068c23ea310fa86536cdd Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 30 Jun 2019 17:48:24 +0200 Subject: [PATCH] new hal file selection concept --- build.py | 16 +++++- platformio.ini | 109 +++++++++----------------------------- src/hal/ebox.h | 2 + src/hal/eboxtube.h | 3 ++ src/hal/ecopower.h | 2 + src/hal/fipy.h | 2 + src/hal/generic.h | 2 + src/hal/heltec.h | 3 +- src/hal/heltecv2.h | 2 + src/hal/lolin32lite.h | 2 + src/hal/lolin32litelora.h | 2 + src/hal/lolin32lora.h | 2 + src/hal/lopy.h | 2 + src/hal/lopy4.h | 2 + src/hal/octopus32.h | 2 + src/hal/ttgobeam.h | 2 + src/hal/ttgofox.h | 2 + src/hal/ttgov1.h | 2 + src/hal/ttgov2.h | 2 + src/hal/ttgov21new.h | 2 + src/hal/ttgov21old.h | 2 + src/hal/wemos32oled.h | 2 + 22 files changed, 81 insertions(+), 86 deletions(-) diff --git a/build.py b/build.py index cbe14c37..4235c8d7 100644 --- a/build.py +++ b/build.py @@ -1,5 +1,5 @@ # build.py -# pre-build script, setting up build environment +# pre-build script, setting up build environment and fetch hal file for user's board import sys import os @@ -55,8 +55,20 @@ if os.path.isfile(otakeyfile) and os.access(otakeyfile, os.R_OK): else: sys.exit("Missing file " + otakeyfile + ", please create it! Aborting.") -# parse ota key file +# parse hal file mykeys = {} +with open(halconfigfile) as myfile: + for line in myfile: + line2 = line.strip("// ") + key, value = line2.partition(" ")[::2] + mykeys[key.strip()] = str(value).strip() +myboard = mykeys["board"] +myuploadspeed = mykeys["upload_speed"] +env.Replace(BOARD=myboard) +env.Replace(UPLOAD_SPEED=myuploadspeed) +print '\033[94m' + "TARGET BOARD: " + myboard + " @ " + myuploadspeed + "bps" + '\033[0m' + +# parse ota key file with open(otakeyfile) as myfile: for line in myfile: key, value = line.partition("=")[::2] diff --git a/platformio.ini b/platformio.ini index 30c7cf3f..cddea030 100644 --- a/platformio.ini +++ b/platformio.ini @@ -5,88 +5,28 @@ ; http://docs.platformio.org/page/projectconf.html -; ---> SELECT TARGET PLATFORM HERE! <--- +; ---> SELECT THE TARGET PLATFORM HERE! <--- [board] -;halfile = ebox.h -;board = esp32dev -;upload_speed = 115200 - -;halfile = eboxtube.h -;board = esp32dev -;upload_speed = 115200 - -;halfile = ecopower.h -;board = esp32dev -;upload_speed = 921600 - -;halfile = heltec.h -;board = heltec_wifi_lora_32 -;upload_speed = 921600 - -;halfile = heltecv2.h -;board = heltec_wifi_lora_32_V2 -;upload_speed = 921600 - -;halfile = ttgov1.h -;board = ttgo-lora32-v1 -;upload_speed = 115200 - -;halfile = ttgov2.h -;board = ttgo-lora32-v1 -;upload_speed = 921600 - -;halfile = ttgov21old.h -;board = esp32dev -;upload_speed = 921600 - -;halfile = ttgov21new.h -;board = esp32dev -;upload_speed = 921600 - -;halfile = ttgofox.h -;board = esp32dev -;upload_speed = 921600 - -halfile = ttgobeam.h -board = ttgo-t-beam -upload_speed = 921600 - -;halfile = fipy.h -;board = esp32dev -;upload_speed = 921600 - -;halfile = lopy.h -;board = lopy -;upload_speed = 921600 - -;halfile = lopy4.h -;board = lopy4 -;upload_speed = 921600 - -;halfile = lolin32litelora.h -;board = lolin32 -;upload_speed = 921600 - -;halfile = lolin32lora.h -;board = lolin32 -;upload_speed = 921600 - -;halfile = lolin32lite.h -;board = lolin32 -;upload_speed = 921600 - -;halfile = wemos32oled.h -;board = lolin32 -;upload_speed = 921600 - -;halfile = octopus32.h -;board = featheresp32 -;upload_speed = 921600 - ;halfile = generic.h -;board = esp32dev -;upload_speed = 115200 - +;halfile = ebox.h +;halfile = eboxtube.h +;halfile = ecopower.h +;halfile = heltec.h +;halfile = heltecv2.h +;halfile = ttgov1.h +;halfile = ttgov2.h +;halfile = ttgov21old.h +;halfile = ttgov21new.h +;halfile = ttgofox.h +halfile = ttgobeam.h +;halfile = fipy.h +;halfile = lopy.h +;halfile = lopy4.h +;halfile = lolin32litelora.h +;halfile = lolin32lora.h +;halfile = lolin32lite.h +;halfile = wemos32oled.h +;halfile = octopus32.h [platformio] ; upload firmware to board with usb cable @@ -97,7 +37,7 @@ default_envs = usb ;default_envs = dev build_cache_dir = /tmp/platformio-shared-cache -description = Paxcounter is a proof-of-concept ESP32 device for metering passenger flows in realtime. It counts how many mobile devices are around. +description = Paxcounter is a device for metering passenger flows in realtime. It counts how many mobile devices are around. [common] ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" @@ -111,7 +51,9 @@ lorakeyfile = loraconf.h lmicconfigfile = lmic_config.h platform_espressif32 = espressif32@1.9.0 board_build.partitions = min_spiffs.csv +board = esp32dev monitor_speed = 115200 +upload_speed = 115200 lib_deps_lora = ;MCCI LoRaWAN LMIC library@2.3.2 https://github.com/mcci-catena/arduino-lmic.git @@ -154,8 +96,8 @@ build_flags_all = -mfix-esp32-psram-cache-issue [env] -board = ${board.board} -upload_speed = ${board.upload_speed} +board = ${common.board} +upload_speed = ${common.upload_speed} platform = ${common.platform_espressif32} framework = arduino board_build.partitions = ${common.board_build.partitions} @@ -173,6 +115,7 @@ upload_protocol = esptool [env:dev] upload_protocol = esptool +build_type = debug platform = https://github.com/platformio/platform-espressif32.git#develop platform_packages = ; use upstream Git version diff --git a/src/hal/ebox.h b/src/hal/ebox.h index 6ebb93fc..ebd70136 100644 --- a/src/hal/ebox.h +++ b/src/hal/ebox.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 115200 +// board esp32dev #ifndef _EBOX_H #define _EBOX_H diff --git a/src/hal/eboxtube.h b/src/hal/eboxtube.h index 628e1a94..9278f0a6 100644 --- a/src/hal/eboxtube.h +++ b/src/hal/eboxtube.h @@ -1,4 +1,7 @@ // clang-format off +// upload_speed 115200 +// board esp32dev + #ifndef _EBOXTUBE_H #define _EBOXTUBE_H diff --git a/src/hal/ecopower.h b/src/hal/ecopower.h index 0a9d30af..4f4b303a 100644 --- a/src/hal/ecopower.h +++ b/src/hal/ecopower.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board esp32dev #ifndef _GENERIC_H #define _GENERIC_H diff --git a/src/hal/fipy.h b/src/hal/fipy.h index 03ce818b..c59dff59 100644 --- a/src/hal/fipy.h +++ b/src/hal/fipy.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board esp32dev #ifndef _FIPY_H #define _FIPY_H diff --git a/src/hal/generic.h b/src/hal/generic.h index ae0c90bf..280a68ad 100644 --- a/src/hal/generic.h +++ b/src/hal/generic.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 115200 +// board esp32dev #ifndef _GENERIC_H #define _GENERIC_H diff --git a/src/hal/heltec.h b/src/hal/heltec.h index 6ec1a068..465793a1 100644 --- a/src/hal/heltec.h +++ b/src/hal/heltec.h @@ -1,5 +1,6 @@ - // clang-format off +// upload_speed 921600 +// board heltec_wifi_lora_32 #ifndef _HELTEC_H #define _HELTEC_H diff --git a/src/hal/heltecv2.h b/src/hal/heltecv2.h index 6a8dd36e..3f6bf743 100644 --- a/src/hal/heltecv2.h +++ b/src/hal/heltecv2.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board heltec_wifi_lora_32_V2 #ifndef _HELTECV2_H #define _HELTECV2_H diff --git a/src/hal/lolin32lite.h b/src/hal/lolin32lite.h index 3c3942e8..320372d8 100644 --- a/src/hal/lolin32lite.h +++ b/src/hal/lolin32lite.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board lolin32 #ifndef _LOLINLITE_H #define _LOLINLITE_H diff --git a/src/hal/lolin32litelora.h b/src/hal/lolin32litelora.h index 8a13aa9c..79f9bb6b 100644 --- a/src/hal/lolin32litelora.h +++ b/src/hal/lolin32litelora.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board lolin32 #ifndef _LOLINLITELORA_H #define _LOLINLITELORA_H diff --git a/src/hal/lolin32lora.h b/src/hal/lolin32lora.h index 4fb279e9..a6fa2f37 100644 --- a/src/hal/lolin32lora.h +++ b/src/hal/lolin32lora.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board lolin32 #ifndef _LOLINLORA_H #define _LOLINLORA_H diff --git a/src/hal/lopy.h b/src/hal/lopy.h index 2cb99261..4bf50781 100644 --- a/src/hal/lopy.h +++ b/src/hal/lopy.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board lopy #ifndef _LOPY_H #define _LOPY_H diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index a2be705c..321244e4 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board lopy4 #ifndef _LOPY4_H #define _LOPY4_H diff --git a/src/hal/octopus32.h b/src/hal/octopus32.h index ad4fbb07..c2bf3735 100644 --- a/src/hal/octopus32.h +++ b/src/hal/octopus32.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board featheresp32 #ifndef _OCTOPUS_H #define _OCTOPUS_H diff --git a/src/hal/ttgobeam.h b/src/hal/ttgobeam.h index 4fc218e1..d67a1db4 100644 --- a/src/hal/ttgobeam.h +++ b/src/hal/ttgobeam.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board ttgo-t-beam #ifndef _TTGOBEAM_H #define _TTGOBEAM_H diff --git a/src/hal/ttgofox.h b/src/hal/ttgofox.h index 133c5d04..94b2b60f 100644 --- a/src/hal/ttgofox.h +++ b/src/hal/ttgofox.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board esp32dev #ifndef _TTGOFOX_H #define _TTGOFOX_H diff --git a/src/hal/ttgov1.h b/src/hal/ttgov1.h index 176d0b19..fddc3ef5 100644 --- a/src/hal/ttgov1.h +++ b/src/hal/ttgov1.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 115200 +// board ttgo-lora32-v1 #ifndef _TTGOV1_H #define _TTGOV1_H diff --git a/src/hal/ttgov2.h b/src/hal/ttgov2.h index 35c98485..54f1657a 100644 --- a/src/hal/ttgov2.h +++ b/src/hal/ttgov2.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board ttgo-lora32-v1 #ifndef _TTGOV2_H #define _TTGOV2_H diff --git a/src/hal/ttgov21new.h b/src/hal/ttgov21new.h index 97967187..c50869b2 100644 --- a/src/hal/ttgov21new.h +++ b/src/hal/ttgov21new.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board esp32dev #ifndef _TTGOV21NEW_H #define _TTGOV21NEW_H diff --git a/src/hal/ttgov21old.h b/src/hal/ttgov21old.h index 3541dc76..0a7c386c 100644 --- a/src/hal/ttgov21old.h +++ b/src/hal/ttgov21old.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board esp32dev #ifndef _TTGOV21OLD_H #define _TTGOV21OLD_H diff --git a/src/hal/wemos32oled.h b/src/hal/wemos32oled.h index 3917dfea..49911a37 100644 --- a/src/hal/wemos32oled.h +++ b/src/hal/wemos32oled.h @@ -1,4 +1,6 @@ // clang-format off +// upload_speed 921600 +// board lolin32 #ifndef _WEMOS32OLED_H #define _WEMOS32OLED_H