Documentation
¶
Index ¶
Constants ¶
const ( BlockSize = 512 MagicStart0 = 0x0A324655 // "UF2\n" MagicStart1 = 0x9E5D5157 // Randomly selected MagicEnd = 0x0AB16F30 // Also randomly selected. BlockMaxData = 476 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { Flags Flags TargetAddr uint32 // Address in flash where the data should be written. PayloadSize uint32 // Number of byttes used in data (often 256). BlockNum uint32 // Sequential block number; starts at 0. NumBlocks uint32 // Total number of blocks in file. SizeOrFamilyID uint32 // File size or board familyID or zero RawData [BlockMaxData]byte }
Block is the structure used for each UF2 code block sent to device. It is 512 bytes in size including magic words. Size of header is 32 bytes. This type does not include magic words as those are part of I/O validation in DecodeBlock.
func DecodeAppendBlocks ¶
func DecodeBlock ¶
DecodeBlock decodes a 512 byte block from the argument buffer. Buffer must be at least 512 bytes long.
func MustDecodeBlock ¶
MustDecodeBlock attempts to decode 512 byte block without bounds checking. Panics if buffer is shorter than 512 bytes.
func (Block) AppendTo ¶
AppendTo appends the blocks' binary representation to the argument buffer and returns the result, including magic start and end. It performs no error checking.
func (*Block) Data ¶
Data returns a pointer to this block's data field limited to the payload size it has.
func (Block) HeaderBytes ¶
HeaderBytes returns the block's first 32 bytes including magic numbers as an array.
type BlocksReaderAt ¶
type BlocksReaderAt struct {
// contains filtered or unexported fields
}
func NewBlocksReaderAt ¶
func NewBlocksReaderAt(blocks []Block) (*BlocksReaderAt, error)
NewBlocksReaderAt
func (*BlocksReaderAt) Addrs ¶
func (blks *BlocksReaderAt) Addrs() (start, end uint32)
type Formatter ¶
type Formatter struct { Flags Flags FamilyID uint32 ChunkSize uint32 // How to chunk payload (is payload size field). By default is chosen as 256. Maximum is 476. }
func (*Formatter) AppendTo ¶
func (f *Formatter) AppendTo(dst, data []byte, targetAddr uint32) (uftFormatted []byte, blocksWritten int, err error)
AppendTo appends data formatted as UF2 blocks to dst and returns the result and number of blocks written. To get total size appended one can do blocksWritten*512.