Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

add s3 devkit support

Geoc2a4701acb81
diff --git a/platformio.ini b/platformio.ini
index 18d7c0a1..f634f0b5 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -36,6 +36,7 @@ build_flags =
; --- Builtin LED ---
-DLED_PIN=21
+ -DLED_TYPE_RGB=true
; --- OneWire ---
-DONEWIRE_PIN=1
@@ -74,9 +75,9 @@ build_flags =
-DLED_CLOCK_PIN=2
; --- I2S ---
- -DI2S_BCLK_PIN=41
+ -DI2S_BCLK_PIN=43
-DI2S_LRCK_PIN=43
- -DI2S_DATA_PIN=42
+ -DI2S_DATA_PIN=46
-DI2S_SAMPLE_RATE=44100
-DI2S_BITS=16
@@ -108,6 +109,8 @@ build_flags =
; --- Builtin LED ---
-DLED_PIN=19
+ -DLED_TYPE_RGB=false
+
; --- OneWire ---
-DONEWIRE_PIN=0
@@ -156,6 +159,82 @@ build_flags =
-DJTAG_SCAN_PINS="\"0, 25, 26, 33\""
+[env:s3-devkit]
+platform = espressif32
+board = esp32-s3-devkitc-1
+framework = arduino
+monitor_speed = 115200
+lib_deps =
+ fastled/FastLED@^3.3.3
+ bblanchon/ArduinoJson@^7.3.0
+ paulstoffregen/OneWire@^2.3.8
+ esp32ping
+ hideakitai/ESP32SPISlave@^0.6.8
+ gilman88/XModem@^1.0.3
+ ewpa/LibSSH-ESP32@^5.6.0
+build_flags =
+ -D CONFIG_TINYUSB_ENABLED=1
+ -D CONFIG_TINYUSB_CDC_ENABLED=1
+ -D CONFIG_TINYUSB_HID_ENABLED=1
+ -D ARDUINO_USB_MODE=1
+ -D ARDUINO_USB_CDC_ON_BOOT=1
+
+ -DDEVICE_S3DEVKIT
+
+ ; --- Pin in use ---
+ -DPROTECTED_PINS="\"3, 19, 20, 45, 46\""
+
+ ; --- Builtin LED ---
+ -DLED_PIN=21
+ -DLED_TYPE_RGB=true
+
+ ; --- OneWire ---
+ -DONEWIRE_PIN=8
+
+ ; --- UART ---
+ -DUART_BAUD=9600
+ -DUART_RX_PIN=17
+ -DUART_TX_PIN=18
+
+ ; --- HDUART ---
+ -DHDUART_BAUD=9600
+ -DHDUART_PIN=17
+
+ ; --- I2C ---
+ -DI2C_SCL_PIN=8
+ -DI2C_SDA_PIN=9
+ -DI2C_FREQ=100000
+
+ ; --- SPI ---
+ -DSPI_CS_PIN=34
+ -DSPI_CLK_PIN=36
+ -DSPI_MISO_PIN=37
+ -DSPI_MOSI_PIN=35
+
+ ; --- Infrared ---
+ -DIR_TX_PIN=40
+ -DIR_RX_PIN=41
+
+ ; --- LED ---
+ -DLED_DATA_PIN=38
+ -DLED_CLOCK_PIN=39
+
+ ; --- TwoWire ---
+ -DTWOWIRE_CLK_PIN=13
+ -DTWOWIRE_IO_PIN=14
+ -DTWOWIRE_RST_PIN=15
+
+ ; --- I2S ---
+ -DI2S_BCLK_PIN=42
+ -DI2S_LRCK_PIN=41
+ -DI2S_DATA_PIN=2
+ -DI2S_SAMPLE_RATE=16000
+ -DI2S_BITS=16
+
+ ; --- JTAG ---
+ -DJTAG_SCAN_PINS="\"6, 7, 10, 11\""
+
+
[env:m5stack-stamps3]
platform = espressif32
board = m5stack-stamps3
@@ -184,6 +263,8 @@ build_flags =
; --- Builtin LED ---
-DLED_PIN=21
+ -DLED_TYPE_RGB=true
+
; --- OneWire ---
-DONEWIRE_PIN=1
@@ -260,6 +341,7 @@ build_flags =
; --- Builtin LED ---
-DLED_PIN=35
+ -DLED_TYPE_RGB=true
; --- OneWire ---
-DONEWIRE_PIN=5
@@ -339,6 +421,7 @@ build_flags =
; --- Builtin LED ---
-DLED_PIN=42
+ -DLED_TYPE_RGB=true
; --- OneWire ---
-DONEWIRE_PIN=16
@@ -418,6 +501,7 @@ build_flags =
; --- Builtin LED ---
-DLED_PIN=14
+ -DLED_TYPE_RGB=true
; --- OneWire ---
-DONEWIRE_PIN=18
@@ -456,9 +540,9 @@ build_flags =
-DTWOWIRE_RST_PIN=43
; --- I2S ---
- -DI2S_BCLK_PIN=44
+ -DI2S_BCLK_PIN=39
-DI2S_LRCK_PIN=43
- -DI2S_DATA_PIN=18
+ -DI2S_DATA_PIN=42
-DI2S_SAMPLE_RATE=16000
-DI2S_BITS=16
diff --git a/src/Config/TerminalTypeConfigurator.cpp b/src/Config/TerminalTypeConfigurator.cpp
index 65d53d56..48a753ee 100644
--- a/src/Config/TerminalTypeConfigurator.cpp
+++ b/src/Config/TerminalTypeConfigurator.cpp
@@ -11,7 +11,7 @@ TerminalTypeEnum TerminalTypeConfigurator::configure() {
int selected = 1; // Serial
- #ifdef DEVICE_M5STAMPS3
+ #if defined(DEVICE_M5STAMPS3) || defined(DEVICE_S3DEVKIT)
selected = selector.selectHeadless();
#else
selected = selector.select(
diff --git a/src/Config/WifiTypeConfigurator.cpp b/src/Config/WifiTypeConfigurator.cpp
index db748806..499260af 100644
--- a/src/Config/WifiTypeConfigurator.cpp
+++ b/src/Config/WifiTypeConfigurator.cpp
@@ -5,23 +5,18 @@ std::string WifiTypeConfigurator::configure(TerminalTypeEnum& terminalType) {
switch (terminalType)
{
case TerminalTypeEnum::WiFiClient:
- #ifdef DEVICE_CARDPUTER
+ #if defined(DEVICE_CARDPUTER)
// Use this standalone setup for now
- setupCardputerWifi(); // endless loop untill a valid WiFi is selected and connected
- #endif
-
- #ifdef DEVICE_M5STICK
+ setupCardputerWifi(); // endless loop until a valid WiFi is selected and connected
+ #elif defined(DEVICE_M5STICK)
// Use this standalone setup for now
setupStickWifi(); // check stored creds
- #endif
-
- #ifdef DEVICE_M5STAMPS3
+ #elif defined(DEVICE_M5STAMPS3)
// Use this standalone setup for now
- setupS3Wifi(); // check stored creds
- #endif
-
- #if defined(DEVICE_TEMBEDS3) || defined(DEVICE_TEMBEDS3CC1101)
+ #elif defined(DEVICE_TEMBEDS3) || defined(DEVICE_TEMBEDS3CC1101)
setupTembedWifi(); // check stored creds
+ #else
+ setupS3Wifi(); // check stored creds
#endif
return std::string(WiFi.localIP().toString().c_str());
diff --git a/src/Inputs/S3DevKitInput.cpp b/src/Inputs/S3DevKitInput.cpp
new file mode 100644
index 00000000..f6d625fc
--- /dev/null
+++ b/src/Inputs/S3DevKitInput.cpp
@@ -0,0 +1,37 @@
+#ifdef DEVICE_S3DEVKIT
+
+#include "S3DevKitInput.h"
+#include "InputKeys.h"
+
+#define BOOT_BUTTON_PIN 0
+
+S3DevKitInput::S3DevKitInput() {
+ pinMode(BOOT_BUTTON_PIN, INPUT_PULLUP);
+}
+
+char S3DevKitInput::mapButton() {
+ if (digitalRead(BOOT_BUTTON_PIN) == LOW) {
+ return KEY_OK;
+ }
+ return KEY_NONE;
+}
+
+char S3DevKitInput::readChar() {
+ return mapButton();
+}
+
+char S3DevKitInput::handler() {
+ char c = KEY_NONE;
+ while ((c = mapButton()) == KEY_NONE) {
+ delay(5);
+ }
+ return c;
+}
+
+void S3DevKitInput::waitPress() {
+ while (mapButton() == KEY_NONE) {
+ delay(5);
+ }
+}
+
+#endif
diff --git a/src/Inputs/S3DevKitInput.h b/src/Inputs/S3DevKitInput.h
new file mode 100644
index 00000000..8210d861
--- /dev/null
+++ b/src/Inputs/S3DevKitInput.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "Interfaces/IInput.h"
+#include "Arduino.h"
+
+class S3DevKitInput : public IInput {
+public:
+ S3DevKitInput();
+
+ char mapButton();
+ char readChar();
+ char handler();
+ void waitPress();
+};
diff --git a/src/Vendors/S3WifiSetup.cpp b/src/Vendors/S3WifiSetup.cpp
index c498b3a0..07920bfc 100644
--- a/src/Vendors/S3WifiSetup.cpp
+++ b/src/Vendors/S3WifiSetup.cpp
@@ -1,5 +1,3 @@
-#ifdef DEVICE_M5STAMPS3
-
#include "S3WifiSetup.h"
#include <Preferences.h>
#include <WiFi.h>
@@ -60,6 +58,4 @@ bool setupS3Wifi() {
FastLED.clear(true);
return false;
-}
-
-#endif
+}
\ No newline at end of file
diff --git a/src/Vendors/S3WifiSetup.h b/src/Vendors/S3WifiSetup.h
index 7dd37729..d433ef38 100644
--- a/src/Vendors/S3WifiSetup.h
+++ b/src/Vendors/S3WifiSetup.h
@@ -1,7 +1,3 @@
#pragma once
-#ifdef DEVICE_M5STAMPS3
-
-bool setupS3Wifi();
-
-#endif
\ No newline at end of file
+bool setupS3Wifi();
\ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index db3c1715..39806555 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -10,6 +10,7 @@
#include <Inputs/StickInput.h>
#include <Inputs/StampS3Input.h>
#include <Inputs/TembedInput.h>
+#include <Inputs/S3DevKitInput.h>
#include <Providers/DependencyProvider.h>
#include <Dispatchers/ActionDispatcher.h>
#include <Servers/HttpServer.h>
@@ -44,7 +45,7 @@ void setup() {
deviceView.setRotation(1);
CardputerInput deviceInput;
#elif DEVICE_M5STAMPS3
- // Setup the StampS3
+ // Setup the StampS3/AtomS3
#include <M5Unified.h>
auto cfg = M5.config();
M5.begin(cfg);
@@ -54,6 +55,10 @@ void setup() {
// Setup the T-embed
TembedDeviceView deviceView;
TembedInput deviceInput;
+ #else
+ // Fallback to S3 dev kit
+ NoScreenDeviceView deviceView;
+ S3DevKitInput deviceInput;
#endif
deviceView.logo();