summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTormod Volden <debian.tormod@gmail.com>2024-04-19 20:13:07 +0200
committerTormod Volden <debian.tormod@gmail.com>2025-05-25 10:55:05 +0200
commitd4ac31c0d782f9630bc9bb292dc59a81a2c18b1e (patch)
treec573e5e4db367c1a12f6797924df50e9e37ce329
parent0c1d759b1662611625d820051b2041430b055828 (diff)
stm32: Remove duplicate version field
It was only used locally so make it a local. In any case, this version, reported by the GVR command, should be the same as the bootloader version reported by the GET command. Print a warning if they ever happen to not be the same. Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
-rw-r--r--stm32.c8
-rw-r--r--stm32.h1
2 files changed, 6 insertions, 3 deletions
diff --git a/stm32.c b/stm32.c
index bceb3d8..de98417 100644
--- a/stm32.c
+++ b/stm32.c
@@ -418,6 +418,7 @@ stm32_t *stm32_init(struct port_interface *port, const char init)
uint8_t len, val, buf[257];
stm32_t *stm;
int i, new_cmds;
+ uint8_t version;
stm = calloc(sizeof(stm32_t), 1);
stm->cmd = malloc(sizeof(stm32_cmd_t));
@@ -446,7 +447,7 @@ stm32_t *stm32_init(struct port_interface *port, const char init)
port->read(port, &buf[2], 1);
}
- stm->version = buf[0];
+ version = buf[0]; /* same as bl_version retrieved later */
stm->option1 = (port->flags & PORT_GVR_ETX) ? buf[1] : 0;
stm->option2 = (port->flags & PORT_GVR_ETX) ? buf[2] : 0;
if (stm32_get_ack(stm) != STM32_ERR_OK) {
@@ -458,7 +459,7 @@ stm32_t *stm32_init(struct port_interface *port, const char init)
len = STM32_CMD_GET_LENGTH;
if (port->cmd_get_reply)
for (i = 0; port->cmd_get_reply[i].length; i++)
- if (stm->version == port->cmd_get_reply[i].version) {
+ if (version == port->cmd_get_reply[i].version) {
len = port->cmd_get_reply[i].length;
break;
}
@@ -519,6 +520,9 @@ stm32_t *stm32_init(struct port_interface *port, const char init)
}
if (new_cmds)
fprintf(stderr, ")\n");
+ if (stm->bl_version != version) {
+ fprintf(stderr, "Warning: Bootloader version mismatch: %02x vs %02x\n", stm->bl_version, version);
+ }
if (stm32_get_ack(stm) != STM32_ERR_OK) {
stm32_close(stm);
return NULL;
diff --git a/stm32.h b/stm32.h
index eb9e79e..587044e 100644
--- a/stm32.h
+++ b/stm32.h
@@ -51,7 +51,6 @@ struct stm32 {
const serial_t *serial;
struct port_interface *port;
uint8_t bl_version;
- uint8_t version;
uint8_t option1, option2;
uint16_t pid;
stm32_cmd_t *cmd;