Skip to content

Commit 8bac2d7

Browse files
committed
[SD] Add some overhead for pico2, generate json checksum data script
1 parent cd720e5 commit 8bac2d7

File tree

7 files changed

+47
-4
lines changed

7 files changed

+47
-4
lines changed

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"exportVersion": "1.0.0", "exportedBy": "tester", "exportedAt": "2024-10-28T18:58:23.976Z", "exportedFromDevice": {"board": "metroesp32s3", "firmwareVersion": "1.0.0-beta.93", "referenceVoltage": 2.6, "totalGPIOPins": 11, "totalAnalogPins": 6, "rtc": "DS3231", "statusLEDBrightness": 0.1}, "components": [{"componentAPI": "analogio", "name": "Analog Pin", "pinName": "A0", "type": "analog_pin", "mode": "ANALOG", "direction": "INPUT", "sampleMode": "TIMER", "analogReadMode": "PIN_VALUE", "period": 30}, {"componentAPI": "ds18x20", "name": "DS18B20: Temperature Sensor (\u00b0F)", "sensorTypeCount": 2, "sensorType1": "object-temp-fahrenheit", "sensorType2": "object-temp", "pinName": "D4", "sensorResolution": 12, "period": 30}], "checksum": 236}

generate_json_checksum.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# generates the 8-bit checksum from a JSON file, provided its path is given as an argument
2+
import sys
3+
import json
4+
5+
# load json file from provided path
6+
with open(sys.argv[1], 'r') as f:
7+
json_data = json.load(f)
8+
if not json_data:
9+
print("Error: JSON file did not contain any data or path didn't match exactly, exiting...")
10+
exit(1)
11+
12+
# convert json dict->string and sum
13+
str_json_data = json.dumps(json_data)
14+
sum_json_data = sum(bytearray(str_json_data.encode()))
15+
print('Sum (hex): ', hex(sum_json_data))
16+
17+
# calculate checksum
18+
calculated_checksum = sum(bytearray(str_json_data.encode())) & 0xFF
19+
print('Checksum: ', calculated_checksum)
20+
print('Checksum (hex): ', hex(calculated_checksum))
21+
22+
# store and write checksum to new file
23+
json_data['checksum'] = calculated_checksum
24+
with open(sys.argv[1], 'w') as f:
25+
json.dump(json_data, f)
26+
print('SUCCESS: Checksum written to JSON file!')

platformio.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,15 @@ build_flags = -DUSE_TINYUSB=1
409409
-DADAFRUIT_METRO_M4_AIRLIFT_LITE
410410
upload_port = /dev/cu.usbmodem1201
411411

412+
[env:raspberrypi_pico_2]
413+
platform = https://github.com/maxgerhardt/platform-raspberrypi.git#develop
414+
board = rpipico2
415+
platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
416+
board_build.filesystem_size = 0.5m
417+
build_flags = -DUSE_TINYUSB
418+
; Once https://github.com/platformio/platformio-core > 6.1.11 these can be removed
419+
lib_ignore = WiFiNINA, WiFi101, Adafruit Zero DMA Library
420+
lib_compat_mode = soft ; can be strict once pio detects SleepyDog on RP2350
412421

413422
[env:raspberypi_picow]
414423
extends = common:rp2040

src/Wippersnapper_Boards.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@
206206
#define USE_STATUS_LED
207207
#define STATUS_LED_PIN 32
208208
#define SD_CS_PIN 17
209+
#elif defined(ARDUINO_RASPBERRY_PI_PICO_2)
210+
#define BOARD_ID "rpi-pico-2"
211+
#define USE_TINYUSB
212+
#define USE_STATUS_LED
213+
#define STATUS_LED_PIN LED_BUILTIN
214+
#define SD_CS_PIN 17
209215
#else
210216
#warning "Board type not identified within Wippersnapper_Boards.h!"
211217
#endif

src/Wippersnapper_V2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,8 @@ void Wippersnapper_V2::pingBrokerV2() {
10971097
void Wippersnapper_V2::feedWDTV2() {
10981098
#ifndef OFFLINE_MODE_WOKWI
10991099
// TODO: This is a temporary fix for watchdog.reset() not firing
1100-
// Watchdog.reset();
1101-
esp_task_wdt_reset();
1100+
Watchdog.reset();
1101+
//esp_task_wdt_reset(); // TODO: Putback for ESP32 WDT
11021102
#endif
11031103
}
11041104

src/components/analogIO/hardware.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,6 @@ float AnalogIOHardware::GetPinVoltage(uint8_t pin) {
140140
#ifdef ARDUINO_ARCH_ESP32
141141
return analogReadMilliVolts(pin) / 1000.0;
142142
#else
143-
return (getPinValue(pin) * _ref_voltage) / 65536;
143+
return (GetPinValue(pin) * _ref_voltage) / 65536;
144144
#endif // ARDUINO_ARCH_ESP32
145145
}

src/provisioning/tinyusb/Wippersnapper_FS_V2.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
defined(ARDUINO_RASPBERRY_PI_PICO_W) || \
2727
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3_REVTFT) || \
2828
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2_REVTFT) || \
29-
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_N4R2)
29+
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_N4R2) || \
30+
defined(ARDUINO_RASPBERRY_PI_PICO_2)
3031
#include "Wippersnapper_FS_V2.h"
3132
// On-board external flash (QSPI or SPI) macros should already
3233
// defined in your board variant if supported

0 commit comments

Comments
 (0)