diff --git a/boards/_boards_json/lord-board.json b/boards/_boards_json/lord-board.json new file mode 100644 index 000000000..b9a663d30 --- /dev/null +++ b/boards/_boards_json/lord-board.json @@ -0,0 +1,49 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default_16MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DSMOOCHIEE_BOARD", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DARDUINO_USB_CDC_ON_BOOT", + "-DARDUINO_USB_MODE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "pinouts" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Smoochiee Board", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://docs.m5stack.com/en/core/StampS3", + "vendor": "Smoochiee" + } diff --git a/boards/lord-board/circuit_image.png b/boards/lord-board/circuit_image.png new file mode 100644 index 000000000..c4ff9759f Binary files /dev/null and b/boards/lord-board/circuit_image.png differ diff --git a/boards/lord-board/interface.cpp b/boards/lord-board/interface.cpp new file mode 100644 index 000000000..0d28c8cf0 --- /dev/null +++ b/boards/lord-board/interface.cpp @@ -0,0 +1,162 @@ +#include "core/powerSave.h" +#include "core/utils.h" +#include + +/*************************************************************************************** +** Function name: _setup_gpio() +** Location: main.cpp +** Description: initial setup for the device +***************************************************************************************/ +void _setup_gpio() { + + pinMode(TFT_CS, OUTPUT); + digitalWrite(TFT_CS, HIGH); + pinMode(TFT_MOSI, OUTPUT); + digitalWrite(TFT_MOSI, HIGH); + pinMode(TFT_SCLK, OUTPUT); + + pinMode(TFT_BL, OUTPUT); + digitalWrite(TFT_BL, HIGH); + pinMode(TFT_RST, OUTPUT); + pinMode(TFT_DC, OUTPUT); + digitalWrite(TFT_DC, HIGH); + + pinMode(NRF24_SS_PIN, OUTPUT); + pinMode(CC1101_SS_PIN, OUTPUT); + pinMode(SDCARD_CS, OUTPUT); + pinMode(TFT_CS, OUTPUT); + + digitalWrite(NRF24_SS_PIN, HIGH); + digitalWrite(CC1101_SS_PIN, HIGH); + digitalWrite(SDCARD_CS, HIGH); + digitalWrite(TFT_CS, HIGH); + + bruceConfig.colorInverted = 0; +} +/*************************************************************************************** +** Function name: _post_setup_gpio() +** Location: main.cpp +** Description: second stage gpio setup to make a few functions work +***************************************************************************************/ +void _post_setup_gpio() { + pinMode(TOUCH_CS, OUTPUT); + uint16_t calData[5]; + File caldata = LittleFS.open("/calData", "r"); + + if (!caldata) { + tft.setRotation(ROTATION); + tft.calibrateTouch(calData, TFT_WHITE, TFT_BLACK, 10); + + caldata = LittleFS.open("/calData", "w"); + if (caldata) { + caldata.printf( + "%d\n%d\n%d\n%d\n%d\n", calData[0], calData[1], calData[2], calData[3], calData[4] + ); + caldata.close(); + } + } else { + Serial.print("\ntft Calibration data: "); + for (int i = 0; i < 5; i++) { + String line = caldata.readStringUntil('\n'); + calData[i] = line.toInt(); + Serial.printf("%d, ", calData[i]); + } + Serial.println(); + caldata.close(); + } + tft.setTouch(calData); +} + +/*************************************************************************************** +** Function name: getBattery() +** location: display.cpp +** Description: Delivers the battery value from 1-100 +***************************************************************************************/ +int getBattery() { return 0; } + +/*************************************************************************************** +** Function name: isCharging() +** Description: Default implementation that returns false +***************************************************************************************/ +bool isCharging() { return false; } + +/********************************************************************* +** Function: setBrightness +** location: settings.cpp +** set brightness value +**********************************************************************/ +void _setBrightness(uint8_t brightval) { + if (brightval == 0) { + analogWrite(TFT_BL, brightval); + } else { + int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval / 100)); + analogWrite(TFT_BL, bl); + } +} + +/********************************************************************* +** Function: InputHandler +** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress +**********************************************************************/ +void InputHandler(void) { + static unsigned long tm = 0; + if (millis() - tm < 200 && !LongPress) return; + + TouchPoint t; + checkPowerSaveTime(); + bool _IH_touched = tft.getTouch(&t.x, &t.y); + if (_IH_touched) { + NextPress = false; + PrevPress = false; + UpPress = false; + DownPress = false; + SelPress = false; + EscPress = false; + AnyKeyPress = false; + NextPagePress = false; + PrevPagePress = false; + touchPoint.pressed = false; + _IH_touched = false; + Serial.printf("\nRAW: Touch Pressed on x=%d, y=%d", t.x, t.y); + if (bruceConfig.rotation == 3) { + t.y = (tftHeight + 20) - t.y; + t.x = tftWidth - t.x; + } + if (bruceConfig.rotation == 0) { + uint16_t tmp = t.x; + t.x = map((tftHeight + 20) - t.y, 0, 320, 0, 240); + t.y = map(tmp, 0, 240, 0, 320); + } + if (bruceConfig.rotation == 2) { + uint16_t tmp = t.x; + t.x = map(t.y, 0, 320, 0, 240); + t.y = map(tftWidth - tmp, 0, 240, 0, 320); + } + + Serial.printf("\nROT: Touch Pressed on x=%d, y=%d, rot=%d\n", t.x, t.y, bruceConfig.rotation); + + if (!wakeUpScreen()) AnyKeyPress = true; + else return; + + // Touch point global variable + touchPoint.x = t.x; + touchPoint.y = t.y; + touchPoint.pressed = true; + touchHeatMap(touchPoint); + tm = millis(); + } +} + +/********************************************************************* +** Function: powerOff +** location: mykeyboard.cpp +** Turns off the device (or try to) +**********************************************************************/ +void powerOff() {} + +/********************************************************************* +** Function: checkReboot +** location: mykeyboard.cpp +** Btn logic to turnoff the device (name is odd btw) +**********************************************************************/ +void checkReboot() {} diff --git a/boards/lord-board/lord-board.ini b/boards/lord-board/lord-board.ini new file mode 100644 index 000000000..d1323982b --- /dev/null +++ b/boards/lord-board/lord-board.ini @@ -0,0 +1,32 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + + + +;Little Offensive Reconnaissance Device Board +[env:lord-board] +board = lord-board +build_src_filter =${env.build_src_filter} +<../boards/lord-board> +board_build.arduino.memory_type = qio_opi +board_build.partitions = custom_16Mb.csv +build_flags = + ${env.build_flags} + -Iboards/lord-board + -Os + -DCORE_DEBUG_LEVEL=5 + -DARDUINO_USB_CDC_ON_BOOT=1 ; Used only in ESP32-S3 to make Serial Comands work + -DDEVICE_NAME='"Lord Board"' + + + +lib_deps = + ${env.lib_deps} + lewisxhe/XPowersLib @0.2.6 + ; fastled/FastLED @3.9.4 diff --git a/boards/lord-board/pins_arduino.h b/boards/lord-board/pins_arduino.h new file mode 100644 index 000000000..f1a3447ad --- /dev/null +++ b/boards/lord-board/pins_arduino.h @@ -0,0 +1,133 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "soc/soc_caps.h" +#include + +// ---------------- CONFIG -------------------- +#define USB_VID 0x303a +#define USB_PID 0x1001 +#define USER_SETUP_LOADED 1 +#define USE_HSPI_PORT 1 +#define HAS_SCREEN 1 +#define HAS_TOUCH 1 +#define HAS_SD 0 +#define FP 1 +#define FM 2 +#define FG 3 + +// ---------------- UART -------------------- +// UART0: Programming via CH343 USB-Serial (default) +static const uint8_t TX = 43; // CH343 USB-Serial TX +static const uint8_t RX = 44; // CH343 USB-Serial + +// UART1: GPS NEO‑6M +static const uint8_t GPS_TX = 41; // ESP32 TX1 -> GPS RX +static const uint8_t GPS_RX = 40; // ESP32 RX1 <- GPS TX + +//------------------BAD USB ---------------- +#define SERIAL_RX 44 // CH343 USB-serial RX +#define SERIAL_TX 43 // CH343 USB-serial TX +#define BAD_RX SERIAL_RX +#define BAD_TX SERIAL_TX +#define USB_as_HID 1 + +// ---------------- I2C ------------------------- +// PN532 NFC (I2C) +static const uint8_t SDA = 45; +static const uint8_t SCL = 42; // Safe choice, avoids SPI/Touch conflicts + +// ---------------- Shared VSPI Bus --------------- +// VSPI for TFT (ILI9341), Touch (XPT2046), SD card +static const uint8_t SS = 14; +static const uint8_t SCK = 13; +static const uint8_t MOSI = 12; +static const uint8_t MISO = 11; +#define SPI_FREQUENCY 16000000 +#define SPI_READ_FREQUENCY 16000000 +#define SPI_TOUCH_FREQUENCY 2000000 + +// ---------------- ILI9341 TFT --------------- +#define ILI9341_DRIVER 1 +#define TFT_RGB_ORDER 0 +#define TFT_WIDTH 240 +#define TFT_HEIGHT 320 +#define TFT_BACKLIGHT_ON 1 +#define TFT_BL 10 +#define TFT_RST 9 +#define TFT_DC 3 +#define TFT_MISO MISO +#define TFT_MOSI MOSI +#define TFT_SCLK SCK +#define TFT_CS 8 +#define SMOOTH_FONT 1 +#define ROTATION 1 +#define MINBRIGHT (uint8_t)1 + +// ---------------- XPT2046 Touch --------------- + +#define USE_TFT_eSPI_TOUCH 1 // touchscreen uses same tft spi bus +#define HAS_TOUCH 1 +#define TOUCH_INT 39 +#define TOUCH_CS 38 +#define BTN_ACT LOW +#define DEEPSLEEP_WAKEUP_PIN 0 + +// ---------------- SD CARD -------------------- +#define SDCARD_CS -1 +#define SDCARD_SCK SCK +#define SDCARD_MISO MISO +#define SDCARD_MOSI MOSI + +// ----------------Onboard RGB LED -------------------- +#define LED_BUILTIN 48 // WS2812 data pin +#define HAS_RGB_LED 1 +#define RGB_LED 48 +#define LED_TYPE WS2812B +#define LED_ORDER GRB +#define LED_TYPE_IS_RGBW 0 +#define LED_COUNT 1 +#define LED_COLOR_STEP 15 + +// ----------------Button -------------------- +#define HAS_BTN 0 +#define BTN_ALIAS "\"Ok\"" +#define BTN_PIN -1 + +// ---------------- Shared HSPI Bus --------------- +// HSPI for CC1101 , NRF24+ +static const uint8_t SPI_SCK_PIN = 18; +static const uint8_t SPI_MOSI_PIN = 17; +static const uint8_t SPI_MISO_PIN = 16; + +// ---------------- CC1101 Radio ---------------- +#define USE_CC1101_VIA_SPI +#define CC1101_SS_PIN 15 +#define CC1101_GDO0_PIN 7 // No longer conflict with TFT_BL +#define CC1101_GDO2_PIN 6 // Moved from GPIO4 β†’ avoids backlight & reserved pins +#define CC1101_SCK_PIN SPI_SCK_PIN +#define CC1101_MOSI_PIN SPI_MOSI_PIN +#define CC1101_MISO_PIN SPI_MISO_PIN + +// ---------------- nRF24L01+ Radio -------------- +#define USE_NRF24_VIA_SPI +#define NRF24_SS_PIN 5 +#define NRF24_CE_PIN 4 +#define NRF24_SCK_PIN SPI_SCK_PIN +#define NRF24_MOSI_PIN SPI_MOSI_PIN +#define NRF24_MISO_PIN SPI_MISO_PIN + +// ---------------- IR Transmitter/Receiver ----- +#define GROVE_SDA 45 +#define GROVE_SCL 42 +#define IR_RX_PIN 1 // digital input (connect IR receiver OUT here) +#define IR_TX_PIN 2 // digital output (PWM capable, for IR LED) +#define RXLED 1 +#define LED 2 // Renamed from LED to avoid conflicts +#define LED_ON HIGH +#define LED_OFF LOW + +// ---------------- ALIAS ----- +#define SPI_SS_PIN TFT_CS + +#endif /* Pins_Arduino_h */ diff --git a/boards/lord-board/readme.md b/boards/lord-board/readme.md new file mode 100644 index 000000000..a524bd75b --- /dev/null +++ b/boards/lord-board/readme.md @@ -0,0 +1,144 @@ +# LORD Board +## Little Offensive Reconnaissance Device + +
+ LORD Board + LORD Board + LORD Board + LORD Board + +
+ +### 🎯 Project Overview + +The **LORD Board** (Little Offensive Reconnaissance Device) is a powerful BRuce ESP32-S3 based multi-tool platform designed for security research. Built on the ESP32-S3-N16R8 (16MB Flash, 8MB PSRAM). + +--- + +## πŸ“¦ Required Components + +### Core Components +- **ESP32-S3-WROOM-1-N16R8** +- **ILI9341 2.8" Touch TFT Display** +### RF Modules +- **CC1101 transceiver** +- **nRF24L01+** +- **Antennas for CC1101 and nRF24L01 frequency** + +### Sensors & Peripherals +- **PN532 NFC module** +- **NEO-6M GPS module** +- **IR LED** +- **IR Receiver** + + +## πŸ”Œ Pin Configuration + +### (Display, Touch, SD Card) Connections +| Function | GPIO | Description | +|----------|------|-------------| +| TFT/SD_CARD/Touch_MISO | 11 | TFT/Touch/Sd Card Master In Slave Out | +| TFT/SD_CARD/Touch_MOSI | 12 | TFT/Touch/Sd Card Master Out Slave In | +| TFT/SD_CARD/Touch_SCK | 13 | TFT/Touch/Sd Card Clock | +| TFT_CS | 8 | Display Chip Select | +| TFT_DC | 3 | Display Data/Command | +| TFT_RST | 9 | Display Reset | +| TFT_BL | 10 | Backlight (PWM) | +| TOUCH_CS | 38 | Touch Chip Select | +| TOUCH_IRQ | 39 | Touch Interrupt | +| SD_CS | 21 | SD Card Chip Select | + +### (RF Modules) Connections +| Function | GPIO | Description | +|----------|------|-------------| +| CC1101/nrf_MISO | 16 | CC1101/nrf Master In Slave Out | +| CC1101/nrf_MOSI | 17 | CC1101/nrf Master Out Slave In | +| CC1101/nrf_SCK | 18 | CC1101/nrf Clock | +| CC1101_CS | 15 | CC1101 Chip Select | +| CC1101_GDO0 | 7 | CC1101 Data Output 0 | +| CC1101_GDO2 | 6 | CC1101 Data Output 2 | +| NRF24_CS | 5 | nRF24 Chip Select | +| NRF24_CE | 4 | nRF24 Chip Enable | + +### (NFC) Connections +| Function | GPIO | Description | +|----------|------|-------------| +| SDA | 45 | I2C Data | +| SCL | 42 | I2C Clock | + +### (GPS) Connections +| Function | GPIO | Description | +|----------|------|-------------| +| GPS_TX (UART1) | 41 | GPS Module TX | +| GPS_RX (UART1) | 40 | GPS Module RX | + +### Other Peripherals Connections +| Function | GPIO | Description | +|----------|------|-------------| +| IR_TX | 2 | Infrared Transmitter | +| IR_RX | 1 | Infrared Receiver | + +### VCC and GND Connections + +Connect all VCC pins to 3.3V and all GND pins to GND. + + +--- + + + +# +## πŸ”Œ Connection Diagram + +> **πŸ“Ž See attached circuit diagram:** `circuit_image.png` + + +--- + + +## πŸ“‹ Hardware Specifications + +### Main Controller +| Component | Specification | +|-----------|---------------| +| MCU | ESP32-S3-WROOM-1-N16R8 | +| Flash | 16 MB | +| PSRAM | 8 MB (Octal SPI) | +| Clock | 240 MHz (Dual Core) | +| WiFi | 2.4 GHz 802.11 b/g/n | +| Bluetooth | BLE 5.0 | +| USB | Native USB (CDC + HID) | + +### Display & Touch +| Component | Specification | +|-----------|---------------| +| Display | ILI9341 2.8" TFT | +| Resolution | 320x240 pixels | +| Touch | XPT2046 Resistive | +| Interface | SPI (Shared VSPI) | +| Backlight | PWM controlled (GPIO 10) | + +### RF Modules +| Module | Frequency | Interface | Use Case | +|--------|-----------|-----------|----------| +| CC1101 | 300-928 MHz | SPI (HSPI) | Sub-GHz analysis, garage doors, weather stations | +| nRF24L01+ | 2.4 GHz | SPI (HSPI) | Wireless keyboards/mice, IoT devices | + +### Additional Modules +| Module | Interface | GPIO | Purpose | +|--------|-----------|------|---------| +| PN532 NFC | I2C | SDA:45, SCL:42 | NFC/RFID read/write | +| GPS NEO-6M | UART | TX:41, RX:40 | Location tracking | +| IR TX/RX | GPIO | TX:2, RX:1 | Infrared remote control | + + +--- + + +## πŸ“ž Support & Contact + +- **Issues**: [GitHub Issues](https://github.com/BruceDevices/firmware/issues) +- **Contritubed**: [Sivabala](https://github.com/sivabala21) + +--- + diff --git a/boards/pinouts/pins_arduino.h b/boards/pinouts/pins_arduino.h index 8cc716273..cb88e3dee 100644 --- a/boards/pinouts/pins_arduino.h +++ b/boards/pinouts/pins_arduino.h @@ -46,4 +46,6 @@ #include "../ESP32-C5-tft/pins_arduino.h" #elif ESP32C5_DEVKITC_1 #include "../ESP32-C5/pins_arduino.h" +#elif LORD_BOARD +#include "../lord-board/pins_arduino.h" #endif diff --git a/platformio.ini b/platformio.ini index 160a118ee..c00e9dfd0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -65,6 +65,7 @@ default_envs = ;WaveSentry-R1 ;esp32-c5-tft ;esp32-c5 + ;lord-board ;uncomment to not use global dirs to avoid possible conflicts ;platforms_dir = .pio/platforms