Library firmware

To use this library in your code:

import system.firmware
User-space side of the RPC API for updating the firmware.

Classes

The FirmwareWriter supports incrementally building up a new firmware in a separate partition.

Globals

The configuration of the current firmware.

Functions

Returns whether another firmware is installed and can be rolled back to.

Returns whether the currently executing firmware is pending validation.
Firmware that is not validated automatically rolls back to the previous firmware on reboot, so if validation is pending, you must validate the firmware if you want to reboot into the current firmware.

map --from/int=0 --to/int=null [block] -> none
Map the current firmware into memory, so the content bytes of it can be accessed.
The mapping is only valid while executing the given block.
Examples

map: | mapping/FirmwareMapping |
  print "Size of firmware: $mapping.size"
  print "First byte of firmware: $mapping[0]"
  bytes := ByteArray 128
  mapping.copy 0 128 --into=bytes
  print "First 128 bytes of firmware: $bytes"

rollback -> none
Rolls back the firmware to a previously installed firmware and reboots.
Throws an exception if the previous firmware is invalid or not present.

upgrade -> none
Reboots into the firmware installed through the latest committed firmware writing. See FirmwareWriter.commit.
Throws an exception if the upgraded firmware is invalid or not present.

The identifier for the current firmware.
A non-null uri can be passed to storage.Region.open to get access to the region containing the current firmware.

Validates the current firmware and tells the bootloader to boot from it in the future.
Returns true if the validation was successful and false if the validation was unsuccessful or just not needed (is-validation-pending is false).