This shows you the differences between two versions of the page.
|
iothings:hackathon [2026/04/02 12:40] dan.tudose [4.3 Build the application (HP core)] |
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 235: | Line 235: | ||
| - | ==== 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 build.sh bash> | + | <code bash build.sh> |
| cd ~/zephyrproject | cd ~/zephyrproject | ||
| source .venv/bin/activate | source .venv/bin/activate | ||
| </code> | </code> | ||
| - | Then go to your ''hacktor_hello'' folder and create this build script: | + | Then go to your ''hacktor_hello'' folder and create this build script, name it ''build.sh'': |
| <code bash> | <code bash> | ||
| Line 372: | Line 372: | ||
| - | ==== 4.4 Flash Sparrow over USB ==== | + | ==== 4.4 Flash Hacktor over USB ==== |
| - | Connect Sparrow over USB‑C. | + | Connect Hacktor Watch over USB‑C. |
| - | Then flash: | + | Then build and flash by running: |
| <code bash> | <code bash> | ||
| - | west flash -d build_sparrow --runner esp32 | + | ./build.sh --upload --port [your_usb_port] |
| </code> | </code> | ||
| - | 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 documentation) shows: | + | You will see the app being built, uploaded and then a serial terminal will print out the Hello World message. |
| - | * ''--esp-device ESP_DEVICE'' (serial port to flash; default uses ''$ESPTOOL_PORT'' or auto‑scan) | + | ===== 5. A more complex project ===== |
| - | * ''--esp-baud-rate'' | + | |
| - | * ''--esp-flash-size'' (default “detect”) | + | |
| - | Example (Linux): | + | Clone https://github.com/dantudose/Hacktor_Basic |
| - | <code bash> | + | This is a more advanced example and the starting point of your tutorial. It initializes the watch's display and touchscreen, imports the LVGL graphic library and builds a simple interactive app. Also, it initializes the shell, so you have a basic command line interface over the serial port. |
| - | west flash -d build_sparrow --runner esp32 -- --esp-device /dev/ttyACM0 | + | |
| - | </code> | + | |
| - | Example (Windows): | + | The project currently does four things: |
| - | <code powershell> | + | * routes the Zephyr console and shell to the ESP32-S3 native USB serial/JTAG port |
| - | west flash -d build_sparrow --runner esp32 -- --esp-device COM7 | + | * initializes a GC9A01 240x240 round LCD over SPI3 |
| - | </code> | + | * initializes a CST816T-style touch controller on I2C |
| - | + | * runs a minimal LVGL UI that shows Hello!, touch coordinates, and a touch indicator dot | |
| - | **Port naming tip (Sparrow’s USB vs DevKitC USB‑UART):** | + | |
| - | * Native USB Serial/JTAG devices commonly appear as **/dev/ttyACM* ** on Linux. | + | |
| - | * Boards using a USB‑UART bridge chip often appear as **/dev/ttyUSB* ** on Linux. | + | |
| - | + | ||
| - | Sparrow uses the native USB mapping (per your note), so **expect ttyACM** rather than ttyUSB on Linux. | + | |
| - | + | ||
| - | If flashing fails with “could not connect”, try: | + | |
| - | * a different USB cable/port | + | |
| - | * pressing BOOT while resetting (if your Sparrow hardware revision requires it) | + | |
| - | * lowering baud rate: ''--esp-baud-rate 115200'' | + | |
| - | + | ||
| - | + | ||
| - | ==== 4.5 View “Hello World” output ==== | + | |
| - | + | ||
| - | You have two common options: | + | |
| - | + | ||
| - | * **Use Zephyr’s Espressif monitor extension:** many Espressif board docs recommend ''west espressif monitor''. | + | |
| - | * **Use a normal serial terminal:** ''screen'', ''minicom'', PuTTY, etc. | + | |
| - | + | ||
| - | Example with west: | + | |
| + | Build the project and upload it with: | ||
| <code bash> | <code bash> | ||
| - | west espressif monitor -d build_sparrow | + | ./build.sh --upload --port /dev/xxx |
| </code> | </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. | + | 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. |
| - | Fallback example (Linux): | + | ===== 6. Hackathon projects ===== |
| - | <code bash> | + | The goal of the hackathon is simple: |
| - | screen /dev/ttyACM0 115200 | + | |
| - | </code> | + | |
| - | If everything is wired correctly, you should see: | + | * build a useful, fun, or 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 | ||
| - | <code> | + | 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. |
| - | Hello World from Sparrow (ESP32-C6)! | + | |
| - | </code> | + | |
| - | ===== 5. Ensuring the 4 MB flash layout is correct ===== | + | ==== Suggested Projects ==== |
| - | + | ||
| - | If you used ''xiao_esp32c6'', you’re already matching a documented **4MB** ESP32‑C6 board. | + | |
| - | (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**. | + | |
| - | + | ||
| - | Zephyr’s snippet system is applied with ''west build -S <snippet>''. | + | |
| - | Docs: https://docs.zephyrproject.org/latest/build/snippets/using.html | + | |
| - | + | ||
| - | Example (conceptual): | + | |
| - | + | ||
| - | <code bash> | + | |
| - | west build -b esp32c6_devkitc/esp32c6/hpcore -S flash-4M samples/hello_world | + | |
| - | </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. | + | |
| - | (Zephyr XIAO ESP32C6 board doc.) | + | |
| - | + | ||
| - | + | ||
| - | ===== 6. “Proper” Sparrow support (out-of-tree board) ===== | + | |
| - | + | ||
| - | Once you move beyond hello_world (I2C sensors, neopixel, display, external SPI flash, etc.), you should create a **Sparrow Zephyr board definition**. | + | |
| - | + | ||
| - | High-level steps: | + | |
| - | + | ||
| - | 1. Create an out‑of‑tree board folder, e.g.: | + | |
| - | * ''<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 purposes, you can choose to implement them or you can propose a totally different project. |
| + | === 1. Fitness Tracker === | ||
| - | ===== 7. Troubleshooting 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” ==== | + | === 2. Watchface 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 app. Upload 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 weather, editable 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/ttyUSB* 2>/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''. | + | === 6. Voice 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: | + | === 8. Sleep / 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. | + | === 9. TinyML Activity or Keyword Detector === |
| - | ===== 8. References (primary docs) ===== | + | |
| - | * Zephyr Getting Started Guide: https://docs.zephyrproject.org/latest/develop/getting_started/index.html | + | * **Difficulty:** Hard |
| - | * Installing west: https://docs.zephyrproject.org/latest/develop/west/install.html | + | * **Main hardware:** IMU or microphone, PSRAM, flash, display |
| - | * Zephyr SDK: https://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 doc: https://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 repo: https://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. | ||