iap

package
v0.0.0-...-9377b47 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT Copyright (c) 2020 Brian Starkey <stark3y@gmail.com>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsVersionErased

func IsVersionErased(e error) bool

Types

type Context

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

func NewContext

func NewContext(vid, pid uint16) (*Context, error)

func (*Context) APGetVersion

func (c *Context) APGetVersion() (update.FWVersion, error)

func (*Context) CRCCheck

func (c *Context) CRCCheck(start, length uint32, crc uint16) (uint16, error)

CRCCheck() WILL ERASE THE FIRMWARE IF THE PASSED-IN 'crc' VALUE IS INCORRECT

The correct 'crc' value is derived from data received and a secret string stored in the IAP code. In the case of a firmware update, if the following sequence is followed, then the correct 'crc' value is returned by (*update.Update).GetCRCValue():

  • Erase version string
  • Erase firmware region
  • Write encoded firmware data from (*update.Update).GetFWBlob(...).RawData() in 52-byte chunks, via WriteData()
  • Call CRCCheck() with 'crc' = (*update.Update).GetCRCValue(...)

As well as performing the CRC check on the written data, CRCCheck() calculates (and returns) the XMODEM CRC of 'length' bytes starting at 'start'. This is returned in the same GET_REPORT response as used for GetStatus(). As a result, this function drains the status buffer in order to retrieve the calculated CRC value.

func (*Context) CheckStatus

func (c *Context) CheckStatus(expected int) error

func (*Context) Close

func (c *Context) Close()

func (*Context) ErasePage

func (c *Context) ErasePage(start uint32, length int) error

func (*Context) EraseVersion

func (c *Context) EraseVersion(i IAPInfo, force bool) error

func (*Context) GetInformation

func (c *Context) GetInformation() (IAPInfo, error)

func (*Context) GetStatus

func (c *Context) GetStatus() ([]Status, error)

func (*Context) GetVersion

func (c *Context) GetVersion(i IAPInfo) (update.FWVersion, error)

func (*Context) Ping

func (c *Context) Ping(val byte) (bool, error)

func (*Context) RawControl

func (c *Context) RawControl() ([]byte, error)

func (*Context) ReadData

func (c *Context) ReadData(start uint32, data []byte) (int, error)

func (*Context) Reset

func (c *Context) Reset(toIAP bool) error

'toIAP' is ignored when in AP mode. It always resets to IAP

func (*Context) SetExtraCRCData

func (c *Context) SetExtraCRCData(data []byte)

func (*Context) VerifyData

func (c *Context) VerifyData(start uint32, data []byte) error

TODO: I have no idea what this does (if anything) and how to detect if it fails.

func (*Context) WriteData

func (c *Context) WriteData(start uint32, data []byte) error

func (*Context) WriteVersion

func (c *Context) WriteVersion(i IAPInfo, v update.FWVersion) error

type IAPInfo

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

func (IAPInfo) ChipName

func (i IAPInfo) ChipName() string

func (IAPInfo) FlashSize

func (i IAPInfo) FlashSize() uint32

func (IAPInfo) IAPVersion

func (i IAPInfo) IAPVersion() string

func (IAPInfo) OB_PPBits

func (i IAPInfo) OB_PPBits() uint16

func (IAPInfo) OptionSize

func (i IAPInfo) OptionSize() uint16

func (IAPInfo) StartAddr

func (i IAPInfo) StartAddr() uint32

func (IAPInfo) String

func (i IAPInfo) String() string

func (IAPInfo) VersionAddr

func (i IAPInfo) VersionAddr() uint32

type Status

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

func (Status) IsFail

func (s Status) IsFail() bool

func (Status) IsOK

func (s Status) IsOK() bool

func (Status) String

func (s Status) String() string

type StatusCode

type StatusCode int
const (
	StatusOK StatusCode = iota
	StatusFail
	StatusUnknown
)

Jump to

Keyboard shortcuts

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