Build, flash and recover C124
On this page
This example uses the reusable library in lib/GrokGadgets. It is standalone Arduino firmware, not an ESPHome integration.
Use M5Stack AtomS3 Lite SKU C124, with ESP32-S3FN8 and 8 MB flash. ATOM Lite and AtomS3 with a display are different boards.
Clean setup
You need Python 3.11 or later, CMake 3.16 or later, Git and a C++14 compiler. The recorded local build used Python 3.14.7 on macOS. Linux USB operation remains unverified.
From the repository root, run:
python3 -m venv .venv
.venv/bin/pip install -r requirements.lock
.venv/bin/pio pkg install
sh tools/check.sh
.venv/bin/python tools/check_contract.py
.venv/bin/pio run -e atoms3-lite-usb
The pinned tools and libraries are:
| Dependency | Version |
|---|---|
| PlatformIO | 6.1.18 |
| espressif32 | 6.10.0 |
| Arduino-ESP32 | 2.0.17 |
| Xtensa compiler | 8.4.0+2021r2-patch5 |
| ArduinoJson | 6.21.5 |
| NeoPixel | 1.12.3 |
Verification records contain the full resolved package list and hashes. Downloads need internet access and local disk space. Mac host tests do not verify Linux USB permissions or physical pins.
Inspect build output
The build writes these files in .pio/build/atoms3-lite-usb/:
firmware.binfirmware.elfbootloader.binpartitions.bin
Git ignores build output. tools/package_build.py copies these files into artifacts/c124-usb and writes checksums. A successful compile means build verified, hardware pending.
To create a package with source records:
- Commit the tested source.
- From a clean checkout, run
.venv/bin/python tools/package_build.py. - Update
docs/build-checksums.jsonfrom the resulting manifest. - Record that update in a separate evidence commit.
Packaging rebuilds the exact commit. It records clean source state, UTC build time, toolchain versions and SHA-256 hashes. It rejects uncommitted source changes.
Flash when hardware is available
These hardware steps remain unverified. They are separate from the software quickstart. Select and authorize the intended physical board first.
- Connect C124 with a USB-C data cable.
- Run
.venv/bin/pio device list. - Identify the board's port. Do not guess another device's port.
- Close any serial monitor or bridge.
- Replace the port placeholder and upload:
.venv/bin/pio run -e atoms3-lite-usb -t upload --upload-port /dev/cu.usbmodemYOUR_BOARD
On Linux, the port is often /dev/ttyACM0. Inspect the actual port before use. Linux can require membership in a serial-device group, often dialout. You can need to reconnect or log in again after that change. Do not run the entire gateway as root.
The example sends no debug logs on the protocol CDC channel.
Connect the USB bridge
The device ID is c124-<MAC hex>. Each boot creates a random boot ID. Credentials remain on the host.
- Open a serial monitor at 115200 briefly to inspect hello.
- Record the device ID for the gateway credential.
- Close the monitor.
- Set
GROK_GADGETS_DEVICE_TOKENin your private shell environment. - Follow the gateway USB bridge guide.
The bridge command is .venv/bin/python -m grok_gadgets_gateway.usb_bridge PORT. The bridge supplies the token to the loopback connection. Only one process can use the serial connection at a time.
Recover the board
If the board does not appear as a USB device, follow M5Stack's C124 download-mode procedure:
- Hold the reset button for about two seconds, until the green indicator appears.
- Release the button.
- Identify the new port.
- Upload to that port.
The reset/boot control is different from the front user button. If the board still does not appear, use a direct USB port and a known data cable.
For an unreliable upload connection, reduce upload speed in platformio.ini. Record this build change.
Restore a previous version
- Open a clean checkout of a previously tested commit.
- Repeat that commit's pinned build.
- Upload with
pio run -t upload.
This command supplies the bootloader, partition and firmware offsets. Do not write only firmware.bin to a guessed address.
For factory restoration, use the manufacturer's M5Burner or Easyloader route. Preserve its source and license. Verify the exact C124 target. No firmware was flashed during the recorded local phase.
First physical acceptance
Record SDK and gateway commits, firmware checksums, operating system, port, timestamps and observations.
- Discover C124.
- Request green, another colour and off. Observe each result.
- Press and release the user button. Check the order of reported events.
- Unplug the board during a command. Check offline and unconfirmed status.
- Reconnect and check fresh state.
- Reboot the board and gateway. Check boot and cursor resets.
- Repeat through Grok only after its account and transport route is verified.
A compiled binary or firmware acknowledgement cannot replace these observations.