From c056e56492db04a8b578ecb34241663927c82cb0 Mon Sep 17 00:00:00 2001 From: slurdge Date: Fri, 19 Jul 2019 18:08:59 +0200 Subject: [PATCH] Add a version command to the bootloader (not activated yet) --- bootrom/bootrom.c | 7 +++++++ include/pm3_cmd.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/bootrom/bootrom.c b/bootrom/bootrom.c index 0726f332d..491cafec7 100644 --- a/bootrom/bootrom.c +++ b/bootrom/bootrom.c @@ -126,6 +126,7 @@ void UsbPacketReceived(uint8_t *packet, int len) { DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM | DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH | DEVICE_INFO_FLAG_UNDERSTANDS_CHIP_INFO; + //to add later: DEVICE_INFO_FLAG_UNDERSTANDS_VERSION if (common_area.flags.osimage_present) arg0 |= DEVICE_INFO_FLAG_OSIMAGE_PRESENT; @@ -140,6 +141,12 @@ void UsbPacketReceived(uint8_t *packet, int len) { } break; + case CMD_BL_VERSION: { + dont_ack = 1; + arg0 = VERSION_1_0_0; + reply_old(CMD_BL_VERSION, arg0, 0, 0, 0, 0); + } + case CMD_SETUP_WRITE: { /* The temporary write buffer of the embedded flash controller is mapped to the * whole memory region, only the last 8 bits are decoded. diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index d271d3099..55204e1a4 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -208,6 +208,7 @@ typedef struct { #define CMD_HARDWARE_RESET 0x0004 #define CMD_START_FLASH 0x0005 #define CMD_CHIP_INFO 0x0006 +#define CMD_BL_VERSION 0x0007 #define CMD_NACK 0x00fe #define CMD_ACK 0x00ff @@ -536,6 +537,12 @@ typedef struct { /* Set if this device understands the chip info command */ #define DEVICE_INFO_FLAG_UNDERSTANDS_CHIP_INFO (1<<5) +/* Set if this device understands the version command */ +#define DEVICE_INFO_FLAG_UNDERSTANDS_VERSION (1<<6) + +// Different versions here. Each version should increse the number +#define VERSION_1_0_0 1 + /* CMD_START_FLASH may have three arguments: start of area to flash, end of area to flash, optional magic. The bootrom will not allow to overwrite itself unless this magic