From 466a9de594d5f3362d427c3c2efc83eb7a4176bd Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 9 May 2022 14:15:00 -0400 Subject: [PATCH] canboot_main: Introduce a command_error response A nack indicates a transmission error while a command_error indicates a nonrecoverable error. Signed-off-by: Kevin O'Connor --- protocol.md | 13 +++++++++++-- src/canboot_main.c | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/protocol.md b/protocol.md index e37dce2..e5c3417 100644 --- a/protocol.md +++ b/protocol.md @@ -153,9 +153,18 @@ The payload depends on the command. #### NACK: `0xf1` -Indicates that the bootloader encountered an error when processing -a command. +Indicates that the bootloader failed to receive a well formed command. +The sender should retry. ``` <0x01><0x88><0xf1><0x00><0x68><0x95><0x99><0x03> ``` + +#### Command Error: `0xf2` + +Indicates that the bootloader encountered an error when processing +a command. + +``` +<0x01><0x88><0xf2><0x00><0x00><0xbf><0x99><0x03> +``` diff --git a/src/canboot_main.c b/src/canboot_main.c index a1d9741..90fb464 100644 --- a/src/canboot_main.c +++ b/src/canboot_main.c @@ -37,6 +37,7 @@ #define REQUEST_SIG 0x5984E3FA6CA1589B // Random request sig static uint8_t nack[8] = {0x01, 0x88, 0xF1, 0x00, 0x68, 0x95, 0x99, 0x03}; +static uint8_t cerr[8] = {0x01, 0x88, 0xF2, 0x00, 0x00, 0xbf, 0x99, 0x03}; static uint8_t page_buffer[CONFIG_MAX_FLASH_PAGE_SIZE]; // Input Tracking static uint8_t cmd_buf[CMD_BUF_SIZE]; @@ -81,7 +82,7 @@ process_read_block(uint32_t* data, uint8_t data_len) { static void process_write_block(uint32_t* data, uint8_t data_len) { if (data_len != (CONFIG_BLOCK_SIZE / 4) + 1) { - canboot_sendf(nack, 8); + canboot_sendf(cerr, 8); return; } uint32_t block_address = le32_to_cpu(data[0]); @@ -157,7 +158,7 @@ process_command(uint8_t cmd, uint32_t* data, uint8_t data_len) break; default: // Unknown command or gabage data, NACK it - canboot_sendf(nack, 8); + canboot_sendf(cerr, 8); } }