Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updatable firmware over I2C #3

Merged
merged 9 commits into from
Dec 9, 2023
Merged

Updatable firmware over I2C #3

merged 9 commits into from
Dec 9, 2023

Conversation

ardangelo
Copy link
Owner

Starting with Beepy firmware 3.0, firmware is loaded in two stages.

The first stage is a modified version of pico-flashloader.
It allows updates to be flashed to the second stage firmware while booted.

The second stage is the actual Beepy firmware.

Reading REG_UPDATE_DATA will return an update status code

  • UPDATE_OFF = 0
  • UPDATE_RECV = 1
  • UPDATE_FAILED = 2
  • UPDATE_FAILED_LINE_OVERFLOW = 3
  • UPDATE_FAILED_FLASH_EMPTY = 4
  • UPDATE_FAILED_FLASH_OVERFLOW = 5
  • UPDATE_FAILED_BAD_LINE = 6
  • UPDATE_FAILED_BAD_CHECKSUM = 7

Firmware updates are flashed by writing byte-by-byte to REG_UPDATE_DATA:

  • Header line beginning with + e.g. +Beepy
  • Followed by the contents of an image in Intel HEX format

By default, REG_UPDATE_DATA will be set to UPDATE_OFF.
After writing, REG_UPDATE_DATA will be set to UPDATE_RECV if more data is expected.

If the update completes successfully:

  • REG_UPDATE_DATA will be set to UPDATE_OFF
  • Shutdown signal will be sent to the Pi
  • Delay to allow the Pi to cleanly shut down before poweroff (configurable with REG_SHUTDOWN_GRACE)
  • Firmware is flashed and the system is reset

Please wait until the system reboots on its own before removing power.

If the update failed, REG_UPDATE_DATA will contain an error code and the firmware will not be modified.

The header line +... will reset the update process, so an interrupted or failed update can be retried by restarting the firmware write.


After building firmware:

  • build/app/i2c_puppet.uf2: flashable image with preloaded and Beepy firmware
  • build/app/firmware.hex: Intel HEX format Beepy firmware (add the header line +Beepy to the beginning of the file before writing)

@ardangelo ardangelo merged commit 864501e into main Dec 9, 2023
@ardangelo ardangelo deleted the fwupdate branch December 9, 2023 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant