From 39dcbe16bca9c5e5925f63635c4e4b6f83439e3e Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 23 Sep 2023 14:08:44 +0000 Subject: [PATCH] add first board --- arch/esp32/esp32.ini | 55 +++++++++++++++++++++ platformio.ini | 85 ++++++++++++++++++++++++-------- suppressions.txt | 49 ++++++++++++++++++ variants/tlora_v2/platformio.ini | 7 +++ variants/tlora_v2/variant.h | 18 +++++++ 5 files changed, 194 insertions(+), 20 deletions(-) create mode 100644 arch/esp32/esp32.ini create mode 100644 suppressions.txt create mode 100644 variants/tlora_v2/platformio.ini create mode 100644 variants/tlora_v2/variant.h diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini new file mode 100644 index 0000000..d2311ca --- /dev/null +++ b/arch/esp32/esp32.ini @@ -0,0 +1,55 @@ +; Common settings for ESP targes, mixin with extends = esp32_base +[esp32_base] +extends = arduino_base +platform = platformio/espressif32 @ 6.3.2 + +build_src_filter = + ${arduino_base.build_src_filter} - - - - + +upload_speed = 921600 +debug_init_break = tbreak setup +monitor_filters = esp32_exception_decoder + +;board_build.filesystem = littlefs + +# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging. +# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h +# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h +build_flags = + ${arduino_base.build_flags} + -Wall +; -Wextra + -Isrc/platform/esp32 + -std=c++2a +; -std=c++11 + -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL + -DAXP_DEBUG_PORT=Serial + -DCONFIG_BT_NIMBLE_ENABLED + -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 + -DCONFIG_BT_NIMBLE_MAX_CCCDS=20 + -DCONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=5120 + -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING + -DSERIAL_BUFFER_SIZE=4096 + ;-DDEBUG_HEAP + +;lib_deps = +; ${arduino_base.lib_deps} +; ${networking_base.lib_deps} +; ${environmental_base.lib_deps} +; h2zero/NimBLE-Arduino@^1.4.1 +; jgromes/RadioLib@^6.1.0 +; https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 + +;lib_ignore = +; segger_rtt +; ESP32 BLE Arduino + +; leave this commented out to avoid breaking Windows +;upload_port = /dev/ttyUSB0 +;monitor_port = /dev/ttyUSB0 + +; customize the partition table +; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables +;board_build.partitions = partition-table.csv diff --git a/platformio.ini b/platformio.ini index f813a45..cbc6510 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,14 +9,49 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = lora_board +;default_envs = tbeam +;default_envs = tbeam-s3-core +;default_envs = heltec-v1 +;default_envs = heltec-v2_0 +;default_envs = heltec-v2_1 +;default_envs = tlora-v1 +;default_envs = tlora_v1_3 +default_envs = tlora-v2 +;default_envs = tlora-v2-1-1_6 + +extra_configs = + arch/*/*.ini + variants/*/platformio.ini [env] -platform = espressif32 @ 6.3.2 -framework = arduino -lib_ldf_mode = deep+ +;extra_scripts = bin/platformio-custom.py + +build_flags = -Wno-missing-field-initializers + -Wno-format +; -Isrc -Isrc/mesh -Isrc/mesh/generated -Isrc/gps -Isrc/buzz -Wl,-Map,.pio/build/output.map +; -DUSE_THREAD_NAMES +; -DTINYGPS_OPTION_NO_CUSTOM_FIELDS +; -DPB_ENABLE_MALLOC=1 + -DRADIOLIB_EXCLUDE_CC1101 + -DRADIOLIB_EXCLUDE_NRF24 + -DRADIOLIB_EXCLUDE_RF69 + -DRADIOLIB_EXCLUDE_SX1231 + -DRADIOLIB_EXCLUDE_SI443X + -DRADIOLIB_EXCLUDE_RFM2X + -DRADIOLIB_EXCLUDE_AFSK + -DRADIOLIB_EXCLUDE_HELLSCHREIBER + -DRADIOLIB_EXCLUDE_MORSE + -DRADIOLIB_EXCLUDE_RTTY + -DRADIOLIB_EXCLUDE_SSTV + -DRADIOLIB_EXCLUDE_AX25 + -DRADIOLIB_EXCLUDE_DIRECT_RECEIVE + -DRADIOLIB_EXCLUDE_BELL + -DRADIOLIB_EXCLUDE_PAGER + -DRADIOLIB_EXCLUDE_FSK4 + -DRADIOLIB_EXCLUDE_APRS + monitor_speed = 115200 -monitor_raw = yes + lib_deps = bblanchon/ArduinoJson @ 6.21.3 lewisxhe/AXP202X_Library @ 1.1.3 @@ -27,23 +62,33 @@ lib_deps = mikalhart/TinyGPSPlus @ 1.0.3 shaggydog/OneButton @ 1.5.0 jgromes/RadioLib @ 6.1.0 + check_tool = cppcheck -check_flags = cppcheck: --std=c++20 --suppress=*:*.pio\* --inline-suppr --suppress=unusedFunction -DCPPCHECK --force lib -ilib/TimeLib check_skip_packages = yes -test_build_src = yes -# activate for OTA Update, use the CALLSIGN from is-cfg.json as upload_port: -#upload_protocol = espota -#upload_port = .local +check_flags = + --suppressions-list=suppressions.txt + --inline-suppr -[env:lora_board] -board = esp32doit-devkit-v1 -build_flags = -Werror -Wall -DUNITY_INCLUDE_PRINT_FORMATTED +;check_flags = cppcheck: --std=c++20 --suppress=*:*.pio\* --inline-suppr --suppress=unusedFunction --suppress=shadowFunction:*TimeLib.cpp --suppress=unreadVariable:*TimeLib.cpp --suppress=badBitmaskCheck:*project_configuration.cpp +;test_build_src = yes -[env:lora_v3_board] -board = heltec_wifi_lora_32_V3 -build_flags = -Werror -Wall -DUNITY_INCLUDE_PRINT_FORMATTED +[arduino_base] +framework = arduino +lib_deps = + ${env.lib_deps} -[env:lora_board_debug] -board = esp32doit-devkit-v1 -build_flags = -Werror -Wall -DCORE_DEBUG_LEVEL=5 -DUNITY_INCLUDE_PRINT_FORMATTED -build_type = debug +build_flags = ${env.build_flags} -Os -DRADIOLIB_SPI_PARANOID=0 +build_src_filter = ${env.build_src_filter} - + +;[env:lora_board] +;board = esp32doit-devkit-v1 +;build_flags = -Werror -Wall -DUNITY_INCLUDE_PRINT_FORMATTED +; +;[env:lora_v3_board] +;board = heltec_wifi_lora_32_V3 +;build_flags = -Werror -Wall -DUNITY_INCLUDE_PRINT_FORMATTED +; +;[env:lora_board_debug] +;board = esp32doit-devkit-v1 +;build_flags = -Werror -Wall -DCORE_DEBUG_LEVEL=5 -DUNITY_INCLUDE_PRINT_FORMATTED +;build_type = debug diff --git a/suppressions.txt b/suppressions.txt new file mode 100644 index 0000000..4c5c794 --- /dev/null +++ b/suppressions.txt @@ -0,0 +1,49 @@ +// cppcheck suppressions +assertWithSideEffect + +// TODO: need to come back to these +//duplInheritedMember + +// TODO: +// "Using memset() on struct which contains a floating point number." +// tried: +// if (std::is_floating_point::value) { +// p = 0; +// in src/mesh/MemoryPool.h +//memsetClassFloat + +//knownConditionTrueFalse + +// no real downside/harm in these +//unusedFunction +//unusedPrivateFunction + +// most likely due to a cppcheck configuration issue (like missing an include) +//syntaxError + +// try to quiet a few +//useInitializationList:src/main.cpp +//useInitializationList + +// I don't want to go back and cast function pointers just to appease a tools insatiable thirst for immutability +//constParameterCallback + +//redundantInitialization + +//cstyleCast:src/mesh/MemoryPool.h:71 +//cstyleCast + +// ignore stuff that is not ours +*:.pio/* +*:*/libdeps/* +*:*/generated/* +//noExplicitConstructor:*/mqtt/* +//postfixOperator:*/mqtt/* + +// these two caused issues +//missingOverride +//virtualCallInConstructor + +//passedByValue:*/RedirectablePrint.h + +//internalAstError:*/CrossPlatformCryptoEngine.cpp diff --git a/variants/tlora_v2/platformio.ini b/variants/tlora_v2/platformio.ini new file mode 100644 index 0000000..208d98c --- /dev/null +++ b/variants/tlora_v2/platformio.ini @@ -0,0 +1,7 @@ + +[env:tlora-v2] +extends = esp32_base +board = ttgo-lora32-v1 +board_level = extra +build_flags = + ${esp32_base.build_flags} -D TLORA_V2 -I variants/tlora_v2 diff --git a/variants/tlora_v2/variant.h b/variants/tlora_v2/variant.h new file mode 100644 index 0000000..c52db5b --- /dev/null +++ b/variants/tlora_v2/variant.h @@ -0,0 +1,18 @@ +#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO35_CHANNEL + +#define I2C_SDA 21 // I2C pins for this board +#define I2C_SCL 22 + +#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost +#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, if your board doesn't have a physical switch, you can wire one + // between this pin and ground +#define BUTTON_NEED_PULLUP + +#define USE_RF95 +#define LORA_DIO0 26 // a No connect on the SX1262 module +#define LORA_RESET 14 +#define LORA_DIO1 33 // Must be manually wired: https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436 +#define LORA_DIO2 32 // Not really used