Skip to content

Commit d3976e7

Browse files
authored
Merge pull request #8713 from meshtastic/develop
Develop to master
2 parents 0e3e8b7 + a4c92d9 commit d3976e7

File tree

14 files changed

+309
-4
lines changed

14 files changed

+309
-4
lines changed

arch/nrf52/nrf52.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extends = arduino_base
77
platform_packages =
88
; our custom Git version until they merge our PR
99
# TODO renovate
10-
platformio/framework-arduinoadafruitnrf52 @ https://github.com/meshtastic/Adafruit_nRF52_Arduino#e13f5820002a4fb2a5e6754b42ace185277e5adf
10+
platformio/framework-arduinoadafruitnrf52 @ https://github.com/meshtastic/Adafruit_nRF52_Arduino#c770c8a16a351b55b86e347a3d9d7b74ad0bbf39
1111
; Don't renovate toolchain-gccarmnoneeabi
1212
platformio/toolchain-gccarmnoneeabi@~1.90301.0
1313

boards/ThinkNode-M6.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "nrf52840_s140_v6.ld"
5+
},
6+
"core": "nRF5",
7+
"cpu": "cortex-m4",
8+
"extra_flags": "-DARDUINO_NRF52840_ELECROW_M6 -DNRF52840_XXAA",
9+
"f_cpu": "64000000L",
10+
"hwids": [
11+
["0x239A", "0x4405"],
12+
["0x239A", "0x0029"],
13+
["0x239A", "0x002A"]
14+
],
15+
"usb_product": "elecrow_thinknode_m6",
16+
"mcu": "nrf52840",
17+
"variant": "ELECROW-ThinkNode-M6",
18+
"variants_dir": "variants",
19+
"bsp": {
20+
"name": "adafruit"
21+
},
22+
"softdevice": {
23+
"sd_flags": "-DS140",
24+
"sd_name": "s140",
25+
"sd_version": "6.1.1",
26+
"sd_fwid": "0x00B6"
27+
},
28+
"bootloader": {
29+
"settings_addr": "0xFF000"
30+
}
31+
},
32+
"connectivity": ["bluetooth"],
33+
"debug": {
34+
"jlink_device": "nRF52840_xxAA",
35+
"onboard_tools": ["jlink"],
36+
"svd_path": "nrf52840.svd",
37+
"openocd_target": "nrf52840-mdk-rs"
38+
},
39+
"frameworks": ["arduino"],
40+
"name": "ELECROW ThinkNode M6",
41+
"upload": {
42+
"maximum_ram_size": 248832,
43+
"maximum_size": 815104,
44+
"speed": 115200,
45+
"protocol": "nrfutil",
46+
"protocols": ["jlink", "nrfjprog", "nrfutil", "stlink"],
47+
"use_1200bps_touch": true,
48+
"require_upload_port": true,
49+
"wait_for_upload_port": true
50+
},
51+
"url": "https://www.elecrow.com/thinknode-m6-outdoor-solar-power-for-lora-powered-by-nrf52840-supports-gps.html",
52+
"vendor": "ELECROW"
53+
}

src/graphics/draw/MenuHandler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void menuHandler::LoraRegionPicker(uint32_t duration)
119119
auto changes = SEGMENT_CONFIG;
120120

121121
// This is needed as we wait til picking the LoRa region to generate keys for the first time.
122+
#if !(MESHTASTIC_EXCLUDE_PKI_KEYGEN || MESHTASTIC_EXCLUDE_PKI)
122123
if (!owner.is_licensed) {
123124
bool keygenSuccess = false;
124125
if (config.security.private_key.size == 32) {
@@ -139,6 +140,7 @@ void menuHandler::LoraRegionPicker(uint32_t duration)
139140
memcpy(owner.public_key.bytes, config.security.public_key.bytes, 32);
140141
}
141142
}
143+
#endif
142144
config.lora.tx_enabled = true;
143145
initRegion();
144146
if (myRegion->dutyCycle < 100) {
@@ -1750,4 +1752,4 @@ void menuHandler::saveUIConfig()
17501752

17511753
} // namespace graphics
17521754

1753-
#endif
1755+
#endif

src/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ void setup()
963963
i2cScanner.reset();
964964
#endif
965965

966+
#if !defined(MESHTASTIC_EXCLUDE_PKI)
966967
// warn the user about a low entropy key
967968
if (nodeDB->keyIsLowEntropy && !nodeDB->hasWarned) {
968969
LOG_WARN(LOW_ENTROPY_WARNING);
@@ -973,6 +974,7 @@ void setup()
973974
service->sendClientNotification(cn);
974975
nodeDB->hasWarned = true;
975976
}
977+
#endif
976978

977979
// buttons are now inputBroker, so have to come after setupModules
978980
#if HAS_BUTTON

src/mesh/NodeDB.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,7 @@ UserLicenseStatus NodeDB::getLicenseStatus(uint32_t nodeNum)
20082008
return info->user.is_licensed ? UserLicenseStatus::Licensed : UserLicenseStatus::NotLicensed;
20092009
}
20102010

2011+
#if !defined(MESHTASTIC_EXCLUDE_PKI)
20112012
bool NodeDB::checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t &keyToTest)
20122013
{
20132014
if (keyToTest.size == 32) {
@@ -2022,6 +2023,7 @@ bool NodeDB::checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_pub
20222023
}
20232024
return false;
20242025
}
2026+
#endif
20252027

20262028
bool NodeDB::backupPreferences(meshtastic_AdminMessage_BackupLocation location)
20272029
{

src/mesh/NodeDB.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ class NodeDB
283283

284284
bool hasValidPosition(const meshtastic_NodeInfoLite *n);
285285

286+
#if !defined(MESHTASTIC_EXCLUDE_PKI)
286287
bool checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t &keyToTest);
288+
#endif
287289

288290
bool backupPreferences(meshtastic_AdminMessage_BackupLocation location);
289291
bool restorePreferences(meshtastic_AdminMessage_BackupLocation location,
@@ -373,4 +375,4 @@ extern uint32_t error_address;
373375
ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \
374376
ModuleConfig_TelemetryConfig_size + ModuleConfig_size)
375377

376-
// Please do not remove this comment, it makes trunk and compiler happy at the same time.
378+
// Please do not remove this comment, it makes trunk and compiler happy at the same time.

src/modules/AdminModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
773773
config.lora = validatedLora;
774774
// If we're setting region for the first time, init the region and regenerate the keys
775775
if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
776+
#if !(MESHTASTIC_EXCLUDE_PKI_KEYGEN || MESHTASTIC_EXCLUDE_PKI)
776777
if (!owner.is_licensed) {
777778
bool keygenSuccess = false;
778779
if (config.security.private_key.size == 32) {
@@ -791,6 +792,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
791792
memcpy(owner.public_key.bytes, config.security.public_key.bytes, 32);
792793
}
793794
}
795+
#endif
794796
config.lora.tx_enabled = true;
795797
initRegion();
796798
if (myRegion->dutyCycle < 100) {

src/modules/Telemetry/Sensor/DFRobotGravitySensor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ DFRobotGravitySensor::DFRobotGravitySensor() : TelemetrySensor(meshtastic_Teleme
1313
DFRobotGravitySensor::~DFRobotGravitySensor()
1414
{
1515
if (gravity) {
16+
#pragma GCC diagnostic push
17+
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
1618
delete gravity;
19+
#pragma GCC diagnostic pop
1720
gravity = nullptr;
1821
}
1922
}

src/platform/nrf52/architecture.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
#define HW_VENDOR meshtastic_HardwareModel_T_ECHO_LITE
6969
#elif defined(ELECROW_ThinkNode_M1)
7070
#define HW_VENDOR meshtastic_HardwareModel_THINKNODE_M1
71+
#elif defined(ELECROW_ThinkNode_M6)
72+
#define HW_VENDOR meshtastic_HardwareModel_THINKNODE_M6
7173
#elif defined(NANO_G2_ULTRA)
7274
#define HW_VENDOR meshtastic_HardwareModel_NANO_G2_ULTRA
7375
#elif defined(CANARYONE)

src/platform/nrf52/main-nrf52.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
#include <InternalFileSystem.h>
55
#include <SPI.h>
66
#include <Wire.h>
7+
8+
#define APP_WATCHDOG_SECS 90
9+
#define NRFX_WDT_ENABLED 1
10+
#define NRFX_WDT0_ENABLED 1
11+
#define NRFX_WDT_CONFIG_NO_IRQ 1
12+
#include <nrfx_wdt.c>
13+
#include <nrfx_wdt.h>
14+
715
#include <assert.h>
816
#include <ble_gap.h>
917
#include <memory.h>
@@ -22,6 +30,9 @@
2230
#include "BQ25713.h"
2331
#endif
2432

33+
static nrfx_wdt_t nrfx_wdt = NRFX_WDT_INSTANCE(0);
34+
static nrfx_wdt_channel_id nrfx_wdt_channel_id_nrf52_main;
35+
2536
static inline void debugger_break(void)
2637
{
2738
__asm volatile("bkpt #0x01\n\t"
@@ -205,6 +216,15 @@ void checkSDEvents()
205216

206217
void nrf52Loop()
207218
{
219+
{
220+
static bool watchdog_running = false;
221+
if (!watchdog_running) {
222+
nrfx_wdt_enable(&nrfx_wdt);
223+
watchdog_running = true;
224+
}
225+
}
226+
nrfx_wdt_channel_feed(&nrfx_wdt, nrfx_wdt_channel_id_nrf52_main);
227+
208228
checkSDEvents();
209229
reportLittleFSCorruptionOnce();
210230
}
@@ -272,6 +292,22 @@ void nrf52Setup()
272292
LOG_DEBUG("Set random seed %u", seed.seed32);
273293
randomSeed(seed.seed32);
274294
nRFCrypto.end();
295+
296+
// Set up nrfx watchdog. Do not enable the watchdog yet (we do that
297+
// the first time through the main loop), so that other threads can
298+
// allocate their own wdt channel to protect themselves from hangs.
299+
nrfx_wdt_config_t wdt0_config = {
300+
.behaviour = NRF_WDT_BEHAVIOUR_PAUSE_SLEEP_HALT, .reload_value = APP_WATCHDOG_SECS * 1000,
301+
// Note: Not using wdt interrupts.
302+
// .interrupt_priority = NRFX_WDT_DEFAULT_CONFIG_IRQ_PRIORITY
303+
};
304+
nrfx_err_t r = nrfx_wdt_init(&nrfx_wdt, &wdt0_config,
305+
nullptr // Watchdog event handler, not used, we just reset.
306+
);
307+
assert(r == NRFX_SUCCESS);
308+
309+
r = nrfx_wdt_channel_alloc(&nrfx_wdt, &nrfx_wdt_channel_id_nrf52_main);
310+
assert(r == NRFX_SUCCESS);
275311
}
276312

277313
void cpuDeepSleep(uint32_t msecToWake)

0 commit comments

Comments
 (0)