DocsReferenceAPI reference

Updates and boot

Write signed firmware over Wi-Fi, confirm or roll back a new kernel, switch the boot partition, fetch the crash dump. Boot rules: docs/interfaces.md section 1

POST /v1/ota#

Write a signed firmware image (used by stick deploy)

Signature required Restarts

The body is the built .bin as is (signed with the signing key; Content-Length required). The device writes it to the target partition as it arrives, then checks the image and its signature; only then is it set to boot. slot=kernel writes the other kernel slot, and after the restart the new kernel is pending: POST /v1/ota/confirm within 60 s or it rolls back. slot=rescue works only in the kernel and goes through the other kernel slot, wiping the fallback version there. The web app cannot call this; use stick deploy / stick deploy rescue

Parameters#

ParameterTypeRequiredValuesRangeDescription
slotstringkernel rescue; default kernelkernel (default) or rescue (rescue firmware)
rebootinteger0 11 = restart after replying; defaults to 1 for kernel, 0 for rescue

Request body#

application/octet-stream

Signed firmware image, no larger than the target partition

Examples#

Start of an image (illustration)#

Only the image header (magic e9) and the app description (magic 0xABCD5432, version 0.1.0, project_name stick_kernel, build ID); a real device answers bad_image. Push real images with stick deploy

HEX
e907024ffc5d3740ee00000009000000 00630000000000012000143cc84b0700 3254cdab000000000000000000000000 302e312e300000000000000000000000 00000000000000000000000000000000 737469636b5f6b65726e656c00000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 1a2b3c4d5e6f7a8b0000000000000000 00000000000000000000000000000000

Reply#

Written

The image is written and its signature verified

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true
slotstringYeskernel_a kernel_b rescuePartition written
versionstringYesVersion of the image
buildstringYespattern ^[0-9a-f]{16}$Build ID: first 16 hex digits of the ELF's SHA-256
rebootbooleanYestrue = restarts into the new image about 0.5 s after replying

Error codes#

StatusCodeDescription
400bad_slotslot is not kernel / rescue, or rescue was given in the rescue firmware
409pendingThe running kernel is pending: POST /v1/ota/confirm or /v1/ota/rollback first
409busyAnother image is being written
400wrong_projectWrong project_name: kernel needs stick_kernel, rescue needs stick_rescue
400bad_imageNot an app image, incomplete, or the check or signature failed. Nothing was installed
400wrong_keyThe image is signed with a different key: the device only accepts the signing key of the firmware it is running (ota.sign_key in info). Nothing was installed; changing keys requires reflashing over USB (stick usb-flash, or the web installer for official firmware)
413too_largeLarger than the target partition
500no_slotTarget partition not found (wrong partition table)
500ota_beginStarting the partition write failed. Check stick logs
500set_bootSetting the boot partition failed. Check stick logs

For errors any endpoint can return, see Common errors.

POST /v1/ota/confirm#

Confirm the pending kernel

Signature required

Call within 60 s after a new kernel boots to mark it valid so it no longer rolls back; on timeout or a crash while pending it rolls back to the previous version. stick deploy calls it after its health check

Reply#

Confirmed

The running kernel is marked valid

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true
buildstringYespattern ^[0-9a-f]{16}$Build ID: first 16 hex digits of the ELF's SHA-256

Error codes#

StatusCodeDescription
409not_pendingThe running kernel is not pending (already confirmed, or in the rescue firmware)
500confirmMarking failed. Check stick logs

For errors any endpoint can return, see Common errors.

POST /v1/ota/rollback#

Switch to the other kernel slot and restart

Signature required Restarts

Boots the version in the other kernel slot, restarting about 0.5 s after replying; while a new kernel is pending this abandons it at once. Not available in the rescue firmware

Reply#

Restarting

The boot partition is set; restarts about 0.5 s after replying

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true
targetstringYesrescue kernel_a kernel_bPartition booted after the restart

Error codes#

StatusCodeDescription
409no_fallbackThe other kernel slot has no usable version, or this is the rescue firmware
500set_bootSetting the boot partition failed. Check stick logs

For errors any endpoint can return, see Common errors.

POST /v1/boot#

Switch the boot partition and restart

Signature required Restarts

Sets the firmware to boot next and restarts about 0.5 s after replying. From the rescue firmware, use kernel to go back. Host: stick boot rescue|kernel

Request body#

application/json

Firmware to boot

FieldTypeRequiredValuesRangeDescription
targetstringYesrescue kernel kernel_a kernel_brescue = rescue firmware; kernel = the last confirmed kernel slot (else whichever is valid); kernel_a / kernel_b = that slot

Examples#

Boot the rescue firmware#

JSON
{"target": "rescue"}

Back to the kernel#

JSON
{"target": "kernel"}

Reply#

Restarting

The boot partition is set; restarts about 0.5 s after replying

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true
targetstringYesrescue kernel_a kernel_bPartition booted after the restart

Error codes#

StatusCodeDescription
400bad_targettarget must be rescue / kernel / kernel_a / kernel_b. See the example “Boot the rescue firmware” for the correct form
409no_imageThe target partition has no usable firmware
500set_bootSetting the boot partition failed. Check stick logs

For errors any endpoint can return, see Common errors.

GET /v1/crash#

Raw crash dump (decode with stick crash --decode)

Signature required

The crash dump partition as is (ESP-IDF raw format); decode with stick crash --decode (finds the archived ELF by build ID) or esp-coredump --core-format raw. A summary (task, PC, backtrace) is in crash of GET /v1/info

Reply#

Raw dump

The reply is binary.

application/octet-stream

Error codes#

StatusCodeDescription
404no_crashNo crash dump

For errors any endpoint can return, see Common errors.

DELETE /v1/crash#

Clear the crash dump

Signature required Changes data

Erases the crash dump partition; succeeds even when there is none

Reply#

Cleared

Successful reply; endpoints add their own fields

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true

Error codes#

StatusCodeDescription
500eraseErasing failed. Check stick logs

For errors any endpoint can return, see Common errors.

View the source of this page on GitHub