Differences

This shows you the differences between two versions of the page.

Link to this comparison view

iothings:hackathon [2026/04/02 12:36]
dan.tudose [4.1 Create a tiny application directory]
iothings:hackathon [2026/04/02 13:31] (current)
dan.tudose [4.4 Flash Hacktor over USB]
Line 111: Line 111:
  
  
-===== 3. Pick a Zephyr “board target” for Sparrow ​=====+===== 3. Pick a Zephyr “board target” for Hacktor ​=====
  
 Hacktor is **not** (yet) an upstream Zephyr board (maybe you could help with that?), so we need a compatible Zephyr board definition to build/flash a first image. Hacktor is **not** (yet) an upstream Zephyr board (maybe you could help with that?), so we need a compatible Zephyr board definition to build/flash a first image.
Line 214: Line 214:
 (See Zephyr issue #60825 about using ''​usb_serial''​ for console on ESP32-class devices.) (See Zephyr issue #60825 about using ''​usb_serial''​ for console on ESP32-class devices.)
  
-Create ​the overlay directory:+In the root of the project folder, create:
  
-<code bash> +**app.overlay**
-mkdir -p boards +
-</​code>​ +
- +
-Because the board target includes qualifiers, Zephyr looks for overlay filenames like: +
- +
-  ​''​boards/​xiao_esp32c6_esp32c6_hpcore.overlay''​ +
- +
-Create: +
- +
-**boards/​xiao_esp32c6_esp32c6_hpcore.overlay**+
 <code dts> <code dts>
 / { / {
-    ​chosen { + chosen { 
-        zephyr,​console = &​usb_serial;​ + zephyr,​console = &​usb_serial;​ 
-        ​zephyr,​shell-uart = &​usb_serial;​ + };
-        zephyr,​uart-mcumgr = &​usb_serial;​ +
-    ​};+
 }; };
  
 &​usb_serial { &​usb_serial {
-    ​status = "​okay";​+ status = "​okay";​
 }; };
 </​code>​ </​code>​
  
-Why this matters for Sparrow:+Why this matters for Hacktor:
   * DevKit‑style ESP32 boards often default the console to **UART0** (meant for an external USB‑UART bridge).   * DevKit‑style ESP32 boards often default the console to **UART0** (meant for an external USB‑UART bridge).
-  * Sparrow ​uses **USB Serial/JTAG over the USB connector**,​ so the console needs to be routed there.+  * Hacktor ​uses **USB Serial/JTAG over the USB connector**,​ so the console needs to be routed there.
  
-ESP32‑C6’s USB Serial/JTAG is implemented entirely in hardware (fixed‑function serial+JTAG).  ​ 
-(Espressif docs: USB Serial/JTAG controller for ESP32‑C6.) 
  
  
-==== 4.3 Build the application ​(HP core) ====+==== 4.3 Build the application ====
  
 Activate your Python venv first if it isn’t active: Activate your Python venv first if it isn’t active:
  
-<code bash>+<code bash build.sh>
 cd ~/​zephyrproject cd ~/​zephyrproject
 source .venv/​bin/​activate source .venv/​bin/​activate
 </​code>​ </​code>​
  
-Then go to your ''​sparrow_hello''​ folder and build:+Then go to your ''​hacktor_hello''​ folder and create this build script, name it ''​build.sh''​:
  
 <code bash> <code bash>
-Build into a local build folder: +#!/usr/bin/env bash
-west build -b xiao_esp32c6/esp32c6/hpcore -d build_sparrow . +
-</code>+
  
-If you get an error about “Board qualifiers not found”, ensure you used the full target name including ''/​esp32c6/​hpcore''​. ​  +set -euo pipefail
-(See the Zephyr issue listing valid xiao_esp32c6 targets.)+
  
 +SCRIPT_DIR="​$(cd "​$(dirname "​${BASH_SOURCE[0]}"​)"​ && pwd)"
 +PROJECT_ROOT="​$SCRIPT_DIR"​
 +DEFAULT_BOARD="​esp32s3_devkitc/​esp32s3/​procpu"​
  
-==== 4.4 Flash Sparrow over USB ====+if [ -d "​$PROJECT_ROOT/​../​.venv/​bin"​ ]; then 
 +    export PATH="​$PROJECT_ROOT/​../​.venv/​bin:​$PATH"​ 
 +fi
  
-Connect Sparrow over USB‑C.+if [ -z "​${ZEPHYR_BASE:​-}"​ ]; then 
 +    if [ -d "​$PROJECT_ROOT/​../​zephyr"​ ]; then 
 +        export ZEPHYR_BASE="​$PROJECT_ROOT/​../​zephyr"​ 
 +    else 
 +        echo "​ZEPHYR_BASE is not set and ../zephyr was not found."​ >&​2 
 +        exit 1 
 +    fi 
 +fi
  
-Then flash:+BOARD="​${BOARD:-$DEFAULT_BOARD}"​ 
 +BUILD_DIR="​${BUILD_DIR:​-$PROJECT_ROOT/​build}"​ 
 +FLASH_PORT="​${FLASH_PORT:​-${ESPTOOL_PORT:​-}}"​ 
 +FLASH_BAUD="​${FLASH_BAUD:​-}"​
  
-<code bash> +PRISTINE=0 
-west flash -d build_sparrow --runner esp32 +RUN_FLASH=0 
-</​code>​+ERASE_FLASH=0
  
-If ''​west ​flash''​ doesn’t pick the correct port automatically,​ the ESP32 west runner supports options including ''​--esp-device''​ (serial ​port), ''​--esp-baud-rate'',​ and ''​--esp-flash-size''​A Zephyr ESP32 runner option list (mirrored documentationshows:+while [ $# -gt 0 ]; do 
 +    case "​$1"​ in 
 +        -p|--pristine) 
 +            PRISTINE=1 
 +            ;; 
 +        -f|--flash|--upload) 
 +            RUN_FLASH=1 
 +            ;; 
 +        --erase) 
 +            ERASE_FLASH=1 
 +            ;; 
 +        --port) 
 +            shift 
 +            if [ $# -eq 0 ]; then 
 +                echo "--port requires a value."​ >&​2 
 +                exit 1 
 +            fi 
 +            FLASH_PORT="​$1"​ 
 +            ;; 
 +        ​--baud) 
 +            shift 
 +            if [ $# -eq 0 ]; then 
 +                echo "--baud requires a value." >&​2 
 +                exit 1 
 +            fi 
 +            FLASH_BAUD="​$1"​ 
 +            ;; 
 +        -h|--help) 
 +            cat <<​EOF 
 +Usage./build.sh [--pristine] [--flash] [--port <​device>​] [--baud <​rate>​] [--erase]
  
-  * ''​--esp-device ​ESP_DEVICE''​ (serial ​port to flash; default uses ''​$ESPTOOL_PORT''​ or auto‑scan) +Environment overrides:​ 
-  ​* ''​--esp-baud-rate''​ +  BOARD=<​board target> ​      ​Default:​ $DEFAULT_BOARD 
-  ''​--esp-flash-size''​ (default “detect”)+  BUILD_DIR=<​build dir> ​     Default: $PROJECT_ROOT/​build 
 +  ZEPHYR_BASE=<​zephyr path> ​ Auto-detected from ../zephyr if unset 
 +  FLASH_PORT=<​device>        Serial ​port for flashing 
 +  ​FLASH_BAUD=<​rate> ​         Serial ​baud rate for flashing 
 +EOF 
 +            exit 0 
 +            ;; 
 +        ​*) 
 +            echo "​Unknown argument: $1" >&​2 
 +            exit 1 
 +            ;; 
 +    esac 
 +    shift 
 +done
  
-Example (Linux):+if [ "​$PRISTINE"​ -eq 1 ]; then 
 +    rm -rf "​$BUILD_DIR"​ 
 +fi
  
-<code bash> +cmake -GNinja ​-B "​$BUILD_DIR" ​-S "​$PROJECT_ROOT" ​-DBOARD="​$BOARD"​ 
-west flash -d build_sparrow ​--runner esp32 -- --esp-device /​dev/​ttyACM0 +cmake --build "​$BUILD_DIR"​
-</​code>​+
  
-Example ​(Windows):+if [ "​$RUN_FLASH"​ -eq 1 ]; then 
 +    flash_cmd=(west flash --no-rebuild -d "​$BUILD_DIR"​ -r esp32) 
 +    runner_args=()
  
-<code powershell>​ +    if [ -n "​$FLASH_PORT"​ ]; then 
-west flash -d build_sparrow --runner esp32 -- --esp-device ​COM7 +        ​runner_args+=(--esp-device ​"​$FLASH_PORT"​) 
-</​code>​+    fi
  
-**Port naming tip (Sparrow’s USB vs DevKitC USB‑UART):** +    if [ -n "​$FLASH_BAUD"​ ]; then 
-  * Native USB Serial/JTAG devices commonly appear as **/​dev/​ttyACM* ** on Linux. +        runner_args+=(--esp-baud-rate "​$FLASH_BAUD"​
-  * Boards using a USB‑UART bridge chip often appear as **/​dev/​ttyUSB* ** on Linux.+    fi
  
-Sparrow uses the native USB mapping ​(per your note), so **expect ttyACM** rather than ttyUSB on Linux.+    if [ "​$ERASE_FLASH"​ -eq 1 ]; then 
 +        runner_args+=(--erase) 
 +    fi
  
-If flashing fails with “could not connect”, try: +    if [ ${#​runner_args[@]} -gt 0 ]; then 
-  * a different USB cable/​port +        ​flash_cmd+=(-- "​${runner_args[@]}"​
-  * pressing BOOT while resetting ​(if your Sparrow hardware revision requires it+    fi
-  * lowering baud rate: ''​--esp-baud-rate 115200''​+
  
 +    "​${flash_cmd[@]}"​
 +fi
  
-==== 4.5 View “Hello World” output ====+echo 
 +echo "Build complete:"​ 
 +echo " ​ Board: $BOARD"​ 
 +echo " ​ Build dir: $BUILD_DIR"​ 
 +echo " ​ ELF: $BUILD_DIR/​zephyr/​zephyr.elf"
  
-You have two common options:+if [ "​$RUN_FLASH"​ -eq 1 ]; then 
 +    echo " ​ Flashcompleted"​ 
 +    echo "​Opening serial terminal on ${FLASH_PORT} (115200)..."​ 
 +    exec screen "​${FLASH_PORT}"​ 115200 
 +fi
  
-  * **Use Zephyr’s Espressif monitor extension:​** many Espressif board docs recommend ''​west espressif monitor''​. +</​code>​
-  * **Use a normal serial terminal:** ''​screen'',​ ''​minicom'',​ PuTTY, etc.+
  
-Example with west: 
  
-<code bash> 
-west espressif monitor -d build_sparrow 
-</​code>​ 
  
-If you need to choose the port explicitly, note that older Zephyr tooling discussions show the monitor supports a ''​-p''​ (port) style option; if your environment doesn’t, use a standard serial terminal as a fallback. 
  
-Fallback example (Linux):+==== 4.4 Flash Hacktor over USB ==== 
 + 
 +Connect Hacktor Watch over USB‑C. 
 + 
 +Then build and flash by running:
  
 <code bash> <code bash>
-screen ​/dev/ttyACM0 115200+./build.sh --upload --port [your_usb_port]
 </​code>​ </​code>​
  
-If everything is wired correctly, you should ​see:+You will see the app being built, uploaded and then a serial terminal will print out the Hello World message.
  
-<​code>​ +===== 5. A more complex project =====
-Hello World from Sparrow (ESP32-C6)! +
-</​code>​+
  
-===== 5Ensuring the 4 MB flash layout is correct =====+Clone https://​github.com/​dantudose/​Hacktor_Basic
  
-If you used ''​xiao_esp32c6'​', ​you’re already matching ​documented **4MB** ESP32‑C6 board  +This is a more advanced example and the starting point of your tutorial. It initializes the watch's display and touchscreenimports the LVGL graphic library and builds ​simple interactive appAlso, it initializes the shell, so you have a basic command line interface over the serial port.
-(Zephyr XIAO ESP32C6 board doc.)+
  
-If you instead build with an ESP32‑C6 board definition that assumes **8 MB** (like DevKitC), use a **flash size snippet**.+The project currently does four things:
  
-Zephyr’s snippet system is applied with ''​west build -S <​snippet>''​. ​  +  * routes the Zephyr ​console and shell to the ESP32-S3 native USB serial/JTAG port 
-Docs: https://​docs.zephyrproject.org/​latest/​build/​snippets/​using.html +  * initializes a GC9A01 240x240 round LCD over SPI3 
- +  * initializes a CST816T-style touch controller on I2C 
-Example (conceptual):​+  * runs a minimal LVGL UI that shows Hello!, touch coordinates,​ and a touch indicator dot
  
 +Build the project and upload it with:
 <code bash> <code bash>
-west build -b esp32c6_devkitc/​esp32c6/​hpcore ​-S flash-4M samples/hello_world+./build.sh --upload ​--port /dev/xxx
 </​code>​ </​code>​
  
-The XIAO ESP32C6 board documentation lists snippet variants like ''​flash-4M'' ​''​flash-8M'' ​/ ''​flash-16M''​ / ''​flash-32M''​ / ''​flash-64M''​. Use the one that matches your module. ​  +You should see the screen display the hello message, the touch screen interaction and the ''​hacktor:~$'' ​shell prompt. Type ''​help'' ​for a list of commands.
-(Zephyr XIAO ESP32C6 board doc.)+
  
 +===== 6. Hackathon projects =====
  
-===== 6. “Proper” Sparrow support (out-of-tree board) =====+The goal of the hackathon is simple:
  
-Once you move beyond hello_world (I2C sensorsneopixeldisplay, external SPI flash, etc.), you should create a **Sparrow Zephyr board definition**.+  * build a usefulfunor technically impressive smartwatch app 
 +  ​use the above starter project as the base 
 +  ​demo the app running on real watch hardware at the end of the event
  
-High-level steps:+Participants should focus on binging up watch hardware, contributing to the Hacktor Zephyr port and building a single polished app, not a full smartwatch operating system.
  
-  1. Create an out‑of‑tree board folder, e.g.: +==== Suggested Projects ====
-     * ''<​your_workspace>/​modules/​your_sparrow_board/​boards/​espressif/​esp32c6_sparrow/''​ +
-  2. Start from a close upstream template: +
-     * ''​boards/​seeed/​xiao_esp32c6''​ (4MB, USB‑C) +
-     * or ''​boards/​espressif/​esp32c6_devkitc''​ (upstream Espressif board) +
-  3. Update the board devicetree:​ +
-     * set correct GPIOs for I2C (SDA/SCL), neopixel pin, SPI chip selects, etc. +
-     * include external SPI NOR flash on the pins listed in the Sparrow README (FLASH_CS GPIO23, MOSI GPIO7, MISO GPIO2, SCK GPIO6, etc.) +
-  4. Keep the console routed to USB Serial/JTAG (as shown in the overlay earlier) if Sparrow has no USB‑UART bridge. +
-  5. Add/adjust partitioning for **4 MB** internal flash (and optionally define external flash partitions for storage). +
- +
-Sparrow’s README lists the peripheral pin mapping (I2C on GPIO21/22, neopixel on GPIO3, shared SPI bus pins, etc.). ​  +
-Source: https://​github.com/​FarhadGUL06/​esp32-c6-sparrow +
- +
-When your out‑of‑tree board is ready, you can build with: +
- +
-<code bash> +
-west build -b esp32c6_sparrow . +
-</​code>​+
  
-(How you register out‑of‑tree boards depends on whether ​you keep them in your application tree, a module, or a separate repo; Zephyr’s “Modules” documentation explains module discovery and board discovery concepts.)+This is just a list of ideas to get you started. They are purely for orientation purposesyou can choose to implement them or you can propose ​totally different project.
  
 +=== 1. Fitness Tracker ===
  
-===== 7Troubleshooting checklist =====+  * **Difficulty:​** Medium 
 +  * **Main hardware:** IMU, display, touch, haptics, fuel gauge 
 +  * **Core idea:** Count steps, estimate activity level, and show progress toward a daily goal. 
 +  * **Minimum viable demo:** Step counter, distance estimate, calories estimate, daily goal ring. 
 +  * **Stretch goals:** Auto-walk detection, inactivity reminders, workout mode, local history, sync with a mobile app.
  
-==== 7.1 “esptool.py not found” ====+=== 2Watchface Studio ​===
  
-If ''​west flash''​ complains about missing ''​esptool.py''​it usually means your Espressif HAL/tools were not fully fetched or your environment is inconsistent.+  * **Difficulty:​** Hard 
 +  * **Main hardware:** display, touch, battery gauge, BLE optional 
 +  * **Core idea:** Build custom watchfaces with selectable themes and complications in a web appUpload these watchfaces to the watch. 
 +  * **Minimum viable demo:** At least three watchface styles with time, battery, and date. 
 +  * **Stretch goals:** Animated watchface, gesture wake, synced phone weathereditable layouts. 
 + 
  
-Double-check:​ +=== 3. BLE Phone Companion ===
-  * you ran ''​west update''​ +
-  * you ran ''​west blobs fetch hal_espressif''​ (and didn’t ignore errors) +
-  * your Python venv is activated and has Zephyr requirements installed (''​west packages pip --install''​)+
  
-There are Zephyr discussions where users hit “esptool.py not found” when their module/​tools were missing(Search for that message if you encounter it.)+  * **Difficulty:​** Medium to Hard 
 +  * **Main hardware:** BLE, display, touch, haptics, speaker optional 
 +  * **Core idea:** Connect to a phone app and exchange useful data. 
 +  * **Minimum viable demo:** Phone connects over BLE and sends notifications or simple text messages to the watch. 
 +  * **Stretch goals:** Music controls, find-my-phone,​ phone battery sync, quick replies.
  
 +=== 4. Gesture Remote ===
  
-==== 7.2 Wrong serial port ====+  * **Difficulty:​** Medium 
 +  * **Main hardware:** IMU, BLE or Wi-Fi, haptics 
 +  * **Core idea:** Use wrist gestures to control another device. 
 +  * **Minimum viable demo:** Recognize ​2-3 gestures and map them to actions such as next slide, previous slide, play/pause, or camera shutter. 
 +  * **Stretch goals:** Calibration mode, gesture training, context-aware control modes.
  
-Symptoms: +=== 5. Pomodoro / Focus Coach ===
-  * flashing fails (can’t connect) +
-  * monitor shows nothing +
-  * output only appears on a different port+
  
-Actions+  * **Difficulty:** Easy 
-  * On Linux, check which device was created when you plug Sparrow in+  * **Main hardware:** display, touch, haptics, speaker optional 
-    <​code bash> +  * **Core idea:** Help the user stay focused with work/break cycles. 
-    dmesg | tail -n 50 +  * **Minimum viable demo:** Configurable timer, session progress, vibration alert at timer end. 
-    ls -l /dev/ttyACM/dev/ttyUSB2>/dev/null +  * **Stretch goals:** Habit streaks, productivity stats, distraction tracking, BLE sync to a phone.
-    </​code>​+
  
-  * Try explicit flashing port: 
-    <code bash> 
-    west flash -d build_sparrow --runner esp32 -- --esp-device /​dev/​ttyACM0 
-    </​code>​ 
  
-  * Ensure your overlay routes the console to ''&​usb_serial''​.+=== 6Voice Memo Watch ===
  
 +  * **Difficulty:​** Hard
 +  * **Main hardware:** microphone, speaker, flash, PSRAM, touch
 +  * **Core idea:** Record and play short voice notes directly on the watch.
 +  * **Minimum viable demo:** Record, save, list, and replay short clips.
 +  * **Stretch goals:** Compression,​ timestamps, BLE export to phone, keyword tagging.
  
-==== 7.3 No console output after flashing ====+=== 7. Fall Detection / Safety Alert ===
  
-Common causes+  * **Difficulty:** Hard 
-  * console is still mapped to UART0 (overlay missing or wrong filename) +  * **Main hardware:** IMU, haptics, BLE 
-  * monitor is connected ​to the wrong port +  * **Core idea:** Detect a likely fall and trigger an alert flow. 
-  * you built for LP core instead of HP core+  * **Minimum viable demo:** Simulated fall detection with on-watch confirmation and BLE alert message ​to a phone app. 
 +  * **Stretch goals:** Motion confidence scoring, inactivity follow-up, emergency contact workflow.
  
-Fixes: +=== 8Sleep Restlessness Tracker ===
-  * verify the overlay filename matches your board target (slashes become underscores):​ +
-    * ''​xiao_esp32c6/​esp32c6/​hpcore''​ → ''​boards/​xiao_esp32c6_esp32c6_hpcore.overlay''​ +
-  * rebuild from scratch: +
-    <code bash> +
-    west build -p always -b xiao_esp32c6/​esp32c6/​hpcore -d build_sparrow ​. +
-    </code>+
  
-==== 7.4 Custom serial script for Sparrow ====+  * **Difficulty:​** Medium 
 +  * **Main hardware:** IMU, fuel gauge, display 
 +  * **Core idea:** Track overnight movement and estimate sleep quality. 
 +  * **Minimum viable demo:** Movement logging, simple sleep score, timeline of motion intensity. 
 +  * **Stretch goals:** Smart wake-up window, sleep trends, nap mode, phone sync.
  
-You can also try to run [[iothings:​laboratoare:​2025_code:​lab11_1|this python script]] instead of the built-in serial monitor, might help if the interface is stuck. +=== 9TinyML Activity or Keyword Detector ​===
-===== 8References (primary docs) =====+
  
-  * Zephyr Getting Started Guidehttps://​docs.zephyrproject.org/​latest/​develop/​getting_started/​index.html +  * **Difficulty:** Hard 
-  * Installing westhttps://​docs.zephyrproject.org/​latest/​develop/​west/​install.html +  * **Main hardware:** IMU or microphone, PSRAM, flash, display 
-  * Zephyr SDKhttps://​docs.zephyrproject.org/​latest/​develop/​toolchains/​zephyr_sdk.html +  * **Core idea:** Run a lightweight ML model on-device for activity classification or keyword detection
-  ​Zephyr Snippets (using ​-S): https://​docs.zephyrproject.org/​latest/​build/​snippets/​using.html +  * **Minimum viable demo:** Recognize a few gestures, motions, or spoken keywords and react in the UI
-  * Zephyr XIAO ESP32C6 board dochttps://​docs.zephyrproject.org/​latest/​boards/​seeed/​xiao_esp32c6/​doc/​index.html +  * **Stretch goals:** User training data collection, confidence metrics, low-power trigger mode.
-  ​Zephyr ESP32‑C6‑DevKitC board doc: https://​docs.zephyrproject.org/​latest/​boards/​espressif/​esp32c6_devkitc/​doc/​index.html +
-  * Sparrow hardware repohttps://​github.com/​FarhadGUL06/​esp32-c6-sparrow +
-  ​Espressif USB Serial/JTAG console (ESP32‑C6):​ https://​docs.espressif.com/​projects/​esp-idf/​en/​stable/​esp32c6/​api-guides/​usb-serial-jtag-console.html+
  
 +=== 10. IoT Dashboard / Smart Home Controller ===
  
 +  * **Difficulty:​** Medium
 +  * **Main hardware:** Wi-Fi or BLE, display, touch, haptics
 +  * **Core idea:** Turn the watch into a compact controller for sensors or smart-home devices.
 +  * **Minimum viable demo:** Show live values such as temperature,​ light, or room status, and toggle at least one remote action.
 +  * **Stretch goals:** Home Assistant integration,​ quick scenes, secure pairing, offline cache.
iothings/hackathon.1775122566.txt.gz · Last modified: 2026/04/02 12:36 by dan.tudose
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0