Documentation ¶
Overview ¶
SPDX-License-Identifier: MIT Copyright (c) 2020 Brian Starkey <stark3y@gmail.com>
Index ¶
- func IsVersionErased(e error) bool
- type Context
- func (c *Context) APGetVersion() (update.FWVersion, error)
- func (c *Context) CRCCheck(start, length uint32, crc uint16) (uint16, error)
- func (c *Context) CheckStatus(expected int) error
- func (c *Context) Close()
- func (c *Context) ErasePage(start uint32, length int) error
- func (c *Context) EraseVersion(i IAPInfo, force bool) error
- func (c *Context) GetInformation() (IAPInfo, error)
- func (c *Context) GetStatus() ([]Status, error)
- func (c *Context) GetVersion(i IAPInfo) (update.FWVersion, error)
- func (c *Context) Ping(val byte) (bool, error)
- func (c *Context) RawControl() ([]byte, error)
- func (c *Context) ReadData(start uint32, data []byte) (int, error)
- func (c *Context) Reset(toIAP bool) error
- func (c *Context) SetExtraCRCData(data []byte)
- func (c *Context) VerifyData(start uint32, data []byte) error
- func (c *Context) WriteData(start uint32, data []byte) error
- func (c *Context) WriteVersion(i IAPInfo, v update.FWVersion) error
- type IAPInfo
- type Status
- type StatusCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsVersionErased ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func (*Context) CRCCheck ¶
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 (*Context) GetInformation ¶
func (*Context) RawControl ¶
func (*Context) SetExtraCRCData ¶
func (*Context) VerifyData ¶
TODO: I have no idea what this does (if anything) and how to detect if it fails.
type IAPInfo ¶
type IAPInfo struct {
// contains filtered or unexported fields
}