Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
FROM node:22-alpine AS base
FROM ubuntu:22.04 AS base

ENV ARDUINO_CLI_VERSION=1.1.0
ENV SENSEBOXCORE_VERSION=2.0.0
ENV ARDUINO_SAMD_VERSION=1.8.13
ENV ARDUINO_AVR_VERSION=1.8.5
ENV ESP32_VERSION=2.0.17
ENV ESP32_VERSION=3.3.0
ENV SENSEBOXCORE_URL=https://raw.githubusercontent.com/mariopesch/senseBoxMCU-core/master/package_sensebox_index.json
ENV ESP32CORE_URL=https://espressif.github.io/arduino-esp32/package_esp32_index.json

RUN apk update
RUN apk add curl
RUN apk add libc6-compat
RUN apk add bash
RUN apk add python3
RUN apk add py3-pyserial
RUN apt-get update && apt-get install -y \
curl \
gnupg \
ca-certificates \
python3 \
python3-serial \
bash \
git \
build-essential

RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get install -y nodejs

RUN corepack enable && corepack prepare yarn@stable --activate

RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s ${ARDUINO_CLI_VERSION}

Expand All @@ -40,10 +48,14 @@ RUN arduino-cli --additional-urls ${ESP32CORE_URL} core install esp32:esp32@${ES
COPY ./OTAFiles/ /tmp/OTAFiles/

# Use these lines to use environment variable in docker
RUN mkdir -p /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/variants/sensebox_eye
RUN cp /tmp/OTAFiles/boards.txt /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/ && \
cp /tmp/OTAFiles/APOTA.ino /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/variants/sensebox_mcu_esp32s2/ && \
cp /tmp/OTAFiles/APOTA.bin /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/variants/sensebox_mcu_esp32s2/ && \
cp /tmp/OTAFiles/variant.cpp /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/variants/sensebox_mcu_esp32s2/
cp /tmp/OTAFiles/APOTA.ino /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/variants/sensebox_eye/ && \
cp /tmp/OTAFiles/APOTA.bin /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/variants/sensebox_eye/ && \
cp /tmp/OTAFiles/variant.cpp /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/variants/sensebox_eye/ && \
cp /tmp/OTAFiles/partitions-16MB-tinyuf2.csv /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/variants/sensebox_eye/ && \
cp /tmp/OTAFiles/pins_arduino.h /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/variants/sensebox_eye/ && \
cp /tmp/OTAFiles/tinyuf2.bin /root/.arduino15/packages/esp32/hardware/esp32/${ESP32_VERSION}/variants/sensebox_eye/

RUN rm -rf /tmp/OTAFiles

Expand Down Expand Up @@ -120,7 +132,7 @@ COPY yarn.lock /app
# test stage
FROM base AS test
ENV NODE_ENV=test
RUN yarn install --pure-lockfile
RUN yarn install
COPY src /app/src
COPY test /app/test
COPY mocha-reporters.json /app
Expand All @@ -132,7 +144,7 @@ CMD ["yarn","test"]
# production stage
FROM base AS production
ENV NODE_ENV=production
RUN yarn install --pure-lockfile --production
RUN yarn install
COPY src /app/src
COPY splash.h ../root/Arduino/libraries/Adafruit_SSD1306/splash.h

Expand Down
Binary file modified OTAFiles/APOTA.bin
Binary file not shown.
229 changes: 115 additions & 114 deletions OTAFiles/APOTA.ino

Large diffs are not rendered by default.

3,172 changes: 2,811 additions & 361 deletions OTAFiles/boards.txt

Large diffs are not rendered by default.

Binary file added OTAFiles/bootloader-tinyuf2.bin
Binary file not shown.
10 changes: 10 additions & 0 deletions OTAFiles/partitions-16MB-tinyuf2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
# bootloader.bin,, 0x1000, 32K
# partition table, 0x8000, 4K
nvs, data, nvs, 0x9000, 20K,
otadata, data, ota, 0xe000, 8K,
ota_0, 0, ota_0, 0x10000, 2048K,
ota_1, 0, ota_1, 0x210000, 2048K,
uf2, app, factory,0x410000, 256K,
ffat, data, fat, 0x450000, 11968K,
90 changes: 90 additions & 0 deletions OTAFiles/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>

#define USB_VID 0x303A
#define USB_PID 0x82D1
#define USB_MANUFACTURER "senseBox"
#define USB_PRODUCT "Eye ESP32S3"
#define USB_SERIAL "" // Empty string for MAC address

// Default USB FirmwareMSC Settings
#define USB_FW_MSC_VENDOR_ID "senseBox" // max 8 chars
#define USB_FW_MSC_PRODUCT_ID "Eye ESP32S3" // max 16 chars
#define USB_FW_MSC_PRODUCT_REVISION "1.00" // max 4 chars
#define USB_FW_MSC_VOLUME_NAME "senseBox" // max 11 chars
#define USB_FW_MSC_SERIAL_NUMBER 0x00000000

#define PIN_RGB_LED 45 // RGB LED
#define RGBLED_PIN 45 // RGB LED
#define PIN_LED 45
#define RGBLED_NUM 1 // number of RGB LEDs

// Default I2C QWIIC-Ports
static const uint8_t SDA = 2;
static const uint8_t SCL = 1;
#define PIN_QWIIC_SDA 2
#define PIN_QWIIC_SCL 1

// IO Pins
#define PIN_IO14 14
static const uint8_t A14 = PIN_IO14; // Analog
static const uint8_t D14 = PIN_IO14; // Digital
static const uint8_t T14 = PIN_IO14; // Touch
#define PIN_IO48 48
static const uint8_t A48 = PIN_IO48; // Analog
static const uint8_t D48 = PIN_IO48; // Digital
static const uint8_t T48 = PIN_IO48; // Touch

// Button
#define PIN_BUTTON 47

// UART Port
static const uint8_t TX = 43;
static const uint8_t RX = 44;
#define PIN_UART_TXD 43
#define PIN_UART_RXD 44
#define PIN_UART_ENABLE 26

// SD-Card
#define MISO 40
#define MOSI 38
#define SCK 39
#define SS 41
#define SD_ENABLE 3

#define PIN_SD_MISO 40
#define PIN_SD_MOSI 38
#define PIN_SD_SCLK 39
#define PIN_SD_CS 41
#define PIN_SD_ENABLE 3

// USB
#define PIN_USB_DM 19
#define PIN_USB_DP 20

// Camera
#define PWDN_GPIO_NUM 46
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 15
#define SIOD_GPIO_NUM 4
#define SIOC_GPIO_NUM 5

#define Y9_GPIO_NUM 16
#define Y8_GPIO_NUM 17
#define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 12
#define Y5_GPIO_NUM 10
#define Y4_GPIO_NUM 8
#define Y3_GPIO_NUM 9
#define Y2_GPIO_NUM 11
#define VSYNC_GPIO_NUM 6
#define HREF_GPIO_NUM 7
#define PCLK_GPIO_NUM 13

// LoRa
#define LORA_TX 43
#define LORA_RX 44

#endif /* Pins_Arduino_h */
Binary file added OTAFiles/tinyuf2.bin
Binary file not shown.
81 changes: 27 additions & 54 deletions OTAFiles/variant.cpp
Original file line number Diff line number Diff line change
@@ -1,66 +1,39 @@
#include "esp32-hal-gpio.h"
#include "pins_arduino.h"
#include "esp_log.h"
#include "esp_partition.h"
#include "esp_system.h"
#include "esp_ota_ops.h"
#include "esp_log.h"

// Globale Variable zur Kommunikation mit dem Hauptprogramm
bool buttonWasPressed = false;

extern "C" {

// Initialize variant/board, called before setup()
void initVariant(void) {
// Initialisiere Pins wie vorher
pinMode(IO_ENABLE, OUTPUT);
digitalWrite(IO_ENABLE, LOW);

pinMode(1, OUTPUT);
digitalWrite(1, LOW);

pinMode(PIN_XB1_ENABLE, OUTPUT);
digitalWrite(PIN_XB1_ENABLE, LOW);

pinMode(PD_ENABLE, OUTPUT);
digitalWrite(PD_ENABLE, HIGH);

// Neuen Button-Pin definieren (z.B. GPIO 0 als Beispiel)
const int PIN_BUTTON = 0;
pinMode(PIN_BUTTON, INPUT_PULLUP);

// Button gedrückt halten
unsigned long pressStartTime = 0;
bool buttonPressed = false;

// Warten auf Button-Eingabe für 5 Sekunden
unsigned long startTime = millis();

// Überprüfen, ob der Button gedrückt wird
while (millis() - startTime < 5000) {
if (digitalRead(PIN_BUTTON) == LOW) {
if (!buttonPressed) {
// Der Button wurde gerade gedrückt
buttonPressed = true;
}
} else if (buttonPressed) {
// Wenn der Button gedrückt und dann losgelassen wird, in OTA1-Partition booten
const esp_partition_t* ota1_partition = esp_partition_find_first(
ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, NULL);
void blinkLED(uint8_t r, uint8_t g, uint8_t b) {
rgbLedWrite(PIN_LED, r, g, b);
delay(20);
rgbLedWrite(PIN_LED, 0x00, 0x00, 0x00); // off
}

if (ota1_partition) {
esp_err_t err = esp_ota_set_boot_partition(ota1_partition);
if (err == ESP_OK) {
esp_restart(); // Neustarten, um die OTA1-Partition zu booten
} else {
// Fehler beim Setzen der Boot-Partition
ESP_LOGE("OTA", "Fehler beim Setzen der OTA1-Partition: %s", esp_err_to_name(err));
}
}
// Nach dem Loslassen des Buttons abbrechen
break;
}
void initVariant(void) {
// define button pin
pinMode(47, INPUT_PULLUP);

// Check if button is pressed
if (digitalRead(47) == LOW) {
// When the button is pressed and then released, boot into the OTA1 partition
const esp_partition_t *ota1_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, NULL);

if (ota1_partition) {
esp_err_t err = esp_ota_set_boot_partition(ota1_partition);
if (err == ESP_OK) {
blinkLED(0x00, 0x00, 0x10); // blue
esp_restart(); // restart, to boot OTA1 partition
} else {
blinkLED(0x10, 0x00, 0x00); // red
ESP_LOGE("OTA", "Error setting OTA1 partition: %s", esp_err_to_name(err));
}
}
} else {
blinkLED(0x00, 0x10, 0x00); // green
}
}

}
Binary file added bin/arduino-cli
Binary file not shown.
2 changes: 2 additions & 0 deletions src/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const boardFQBNs = {
"sensebox-mcu": "sensebox:samd:sb:power=on",
sensebox: "arduino:avr:uno",
"sensebox-esp32s2": "esp32:esp32:sensebox_mcu_esp32s2",
"sensebox-eye": "esp32:esp32:sensebox_eye",
};

const validBoards = Object.keys(boardFQBNs);
Expand All @@ -17,6 +18,7 @@ export const boardBinaryFileextensions = {
"sensebox-mcu": "bin",
sensebox: "hex",
"sensebox-esp32s2": "bin",
"sensebox-eye": "bin",
};

export const payloadValidator = function payloadValidator(req, res, next) {
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("Compiler", () => {
res.body.should.have
.property("message")
.eql(
"Invalid board parameter. Valid values are: sensebox-mcu,sensebox,sensebox-esp32s2"
"Invalid board parameter. Valid values are: sensebox-mcu,sensebox,sensebox-esp32s2,sensebox-eye"
);
done();
});
Expand Down
81 changes: 81 additions & 0 deletions test/mcu_eye.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import fs from "fs";
import server from "../src/index.js";
import request from "./setup.js";

describe("Compiler - Eye", () => {
let downloadId_eye = "";

it("should compile an empty sketch for senseBox Eye", (done) => {
const sketch = fs.readFileSync("test/sketches/empty.ino", "utf8");

request(server)
.post("/compile")
.send({ board: "sensebox-eye", sketch })
.end((err, res) => {
res.should.have.status(200);
res.body.data.should.have.property("id");
downloadId_eye = res.body.data.id;
done();
});
});

it("should compile a hello world sketch for senseBox Eye", (done) => {
const sketch = fs.readFileSync("test/sketches/hello-world.ino", "utf8");

request(server)
.post("/compile")
.send({ board: "sensebox-eye", sketch })
.end((err, res) => {
res.should.have.status(200);
res.body.data.should.have.property("id");
downloadId_eye = res.body.data.id;
done();
});
});

it("should compile the tof-distance-display sketch for senseBox Eye", (done) => {
const sketch = fs.readFileSync(
"test/sketches/mcu_s2/tof-distance-display.ino",
"utf8"
);
request(server)
.post("/compile")
.send({ board: "sensebox-eye", sketch })
.end((err, res) => {
res.should.have.status(200);
res.body.data.should.have.property("id");
downloadId_eye = res.body.data.id;
done();
});
});

it("should compile the robo-eyes sketch for senseBox Eye", (done) => {
const sketch = fs.readFileSync(
"test/sketches/mcu_s2/robo-eyes.ino",
"utf8"
);
request(server)
.post("/compile")
.send({ board: "sensebox-eye", sketch })
.end((err, res) => {
res.should.have.status(200);
res.body.data.should.have.property("id");
downloadId_eye = res.body.data.id;
done();
});
});


it("should download sketch for senseBox Eye", (done) => {
request(server)
.get("/download")
.query({ board: "sensebox-eye", id: downloadId_eye })
.end((err, res) => {
res.should.have.status(200);
res.header.should.have
.property("content-disposition")
.eql("attachment; filename=sketch.bin");
done();
});
});
});
Loading