Enum tockloader_proto::Command
[−]
[src]
pub enum Command<'a> {
Ping,
Info,
Id,
Reset,
ErasePage {
address: u32,
},
WritePage {
address: u32,
data: &'a [u8],
},
EraseExBlock {
address: u32,
},
WriteExPage {
address: u32,
data: &'a [u8],
},
CrcRxBuffer,
ReadRange {
address: u32,
length: u16,
},
ExReadRange {
address: u32,
length: u16,
},
SetAttr {
index: u8,
key: &'a [u8],
value: &'a [u8],
},
GetAttr {
index: u8,
},
CrcIntFlash {
address: u32,
length: u32,
},
CrcExtFlash {
address: u32,
length: u32,
},
EraseExPage {
address: u32,
},
ExtFlashInit,
ClockOut,
WriteFlashUserPages {
page1: u32,
page2: u32,
},
ChangeBaud {
mode: BaudMode,
baud: u32,
},
}Commands supported by the protocol. A bootloader will decode these and a flash tool will encode them.
Variants
PingSend a PING to the bootloader. It will drop its hp buffer and send back a PONG.
InfoGet info about the bootloader. The result is one byte of length, plus length bytes of string, followed by 192-length zeroes.
IdGet the Unique ID. Result is 8 bytes of unique ID (but I'm not sure what the result code should be).
ResetReset all TX and RX buffers.
ErasePageErase a page. The RX buffer should contain the address of the start of the 512 byte page. Any non-page-aligned addresses will result in RES_BADADDR. This command is not required before writing a page, it is just an optimisation. It is particularly quick for already empty pages.
Fields of ErasePage
address: u32 |
WritePageWrite a page in internal flash. The RX buffer should contain the 4 byte address of the start of the page, followed by 512 bytes of page.
Fields of WritePage
address: u32 | |
data: &'a [u8] |
EraseExBlockErase a block of pages in ex flash. The RX buffer should contain the address of the start of the block. Each block is 8 pages, so 2048 bytes.
Fields of EraseExBlock
address: u32 |
WriteExPageWrite a page to ex flash. The RX buffer should contain the address of the start of the 256 byte page, followed by 256 bytes of page.
Fields of WriteExPage
address: u32 | |
data: &'a [u8] |
CrcRxBufferGet the length and CRC of the RX buffer. The response is two bytes of little endian length, followed by 4 bytes of crc32.
ReadRangeRead a range from internal flash. The RX buffer should contain a 4 byte address followed by 2 bytes of length. The response will be length bytes long.
Fields of ReadRange
address: u32 | |
length: u16 |
ExReadRangeRead a range from external flash. The RX buffer should contain a 4 byte address followed by 2 bytes of length. The response will be length bytes long.
Fields of ExReadRange
address: u32 | |
length: u16 |
SetAttrWrite a payload attribute. The RX buffer should contain a one byte index, 8 bytes of key (null padded), one byte of value length, and valuelength value bytes. valuelength must be less than or equal to 55. The value may contain nulls.
The attribute index must be less than 16.
Fields of SetAttr
index: u8 | |
key: &'a [u8] | |
value: &'a [u8] |
GetAttrGet a payload attribute. The RX buffer should contain a 1 byte index. The result is 8 bytes of key, 1 byte of value length, and 55 bytes of potential value. You must discard 55-valuelength bytes from the end yourself.
Fields of GetAttr
index: u8 |
CrcIntFlashGet the CRC of a range of internal flash. The RX buffer should contain a four byte address and a four byte range. The result will be a four byte crc32.
Fields of CrcIntFlash
address: u32 | |
length: u32 |
CrcExtFlashGet the CRC of a range of external flash. The RX buffer should contain a four byte address and a four byte range. The result will be a four byte crc32.
Fields of CrcExtFlash
address: u32 | |
length: u32 |
EraseExPageErase a page in external flash. The RX buffer should contain a 4 byte address pointing to the start of the 256 byte page.
Fields of EraseExPage
address: u32 |
ExtFlashInitInitialise the external flash chip. This sets the page size to 256b.
ClockOutGo into an infinite loop with the 32khz clock present on pin PA19 (GP6) this is used for clock calibration.
WriteFlashUserPagesWrite the flash user pages (first 4 bytes is first page, second 4 bytes is second page, little endian).
Fields of WriteFlashUserPages
page1: u32 | |
page2: u32 |
ChangeBaudChange the baud rate of the bootloader. The first byte is 0x01 to set a new baud rate. The next 4 bytes are the new baud rate. To allow the bootloader to verify that the new baud rate works, the host must call this command again with the first byte of 0x02 and the next 4 bytes of the new baud rate. If the next command does not match this, the bootloader will revert to the old baud rate.
Fields of ChangeBaud
mode: BaudMode | |
baud: u32 |