bootloader

package
v0.0.0-...-fa7f932 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Overview

Package bootloader contains the API to the physical device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashFirmware

func HashFirmware(firmwareVersion uint32, unsignedFirmware []byte) []byte

HashFirmware returns the hash of `<firmware version><firmware>`, as computed by the bootloader to check the firmware signature.

func ParseSignedFirmware

func ParseSignedFirmware(firmware []byte) (common.Product, []byte, []byte, error)

ParseSignedFirmware parses a signed firmware file and returns (sigdata, firmware). Errors if the format is invalid, or the firmware magic is not recognized.

Types

type Communication

type Communication interface {
	SendFrame(string) error
	Query([]byte) ([]byte, error)
	Close()
}

Communication contains functions needed to communicate with the device.

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device provides the API to communicate with the BitBox02 bootloader.

func NewDevice

func NewDevice(
	version *semver.SemVer,
	product common.Product,
	communication Communication,
	onStatusChanged func(*Status),
) *Device

NewDevice creates a new instance of Device.

func (*Device) Close

func (device *Device) Close()

Close closes the communication.

func (*Device) Erased

func (device *Device) Erased() (bool, error)

Erased returns true if the device contains no firmware.

func (*Device) GetHashes

func (device *Device) GetHashes(displayFirmwareHash, displaySigningKeydataHash bool) (
	[]byte, []byte, error)

GetHashes queries the device for the firmware and signing keydata hashes. If the display flags are true, the hashes are also shown on the device screen.

func (*Device) Product

func (device *Device) Product() common.Product

Product returns the bootloader product.

func (*Device) Reboot

func (device *Device) Reboot() error

Reboot reboots the device.

func (*Device) ScreenRotate

func (device *Device) ScreenRotate() error

ScreenRotate rotates the device screen.

func (*Device) SetShowFirmwareHashEnabled

func (device *Device) SetShowFirmwareHashEnabled(enabled bool) error

SetShowFirmwareHashEnabled returns whether the bootloader will automatically show the firmware hash on boot.

func (*Device) ShowFirmwareHashEnabled

func (device *Device) ShowFirmwareHashEnabled() (bool, error)

ShowFirmwareHashEnabled returns whether the bootloader will automatically show the firmware hash on boot.

func (*Device) SignedFirmwareVersion

func (device *Device) SignedFirmwareVersion(firmware []byte) (uint32, error)

SignedFirmwareVersion returns the monotonic firmware version contained in the signed firmware format.

func (*Device) Status

func (device *Device) Status() *Status

Status returns the progress of a firmware upgrade.

func (*Device) UpgradeFirmware

func (device *Device) UpgradeFirmware(firmware []byte) error

UpgradeFirmware uploads a signed bitbox02 firmware release to the device.

func (*Device) Versions

func (device *Device) Versions() (uint32, uint32, error)

Versions queries the device for the firmware and signing pubkeys version.

type Status

type Status struct {
	Upgrading         bool    `json:"upgrading"`
	Progress          float64 `json:"progress"`
	UpgradeSuccessful bool    `json:"upgradeSuccessful"`
	ErrMsg            string  `json:"errMsg"`
}

Status has all the info to handle the bootloader mode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL