diff options
author | Tormod Volden <debian.tormod@gmail.com> | 2024-04-19 20:13:07 +0200 |
---|---|---|
committer | Tormod Volden <debian.tormod@gmail.com> | 2025-05-25 10:55:05 +0200 |
commit | d4ac31c0d782f9630bc9bb292dc59a81a2c18b1e (patch) | |
tree | c573e5e4db367c1a12f6797924df50e9e37ce329 | |
parent | 0c1d759b1662611625d820051b2041430b055828 (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.c | 8 | ||||
-rw-r--r-- | stm32.h | 1 |
2 files changed, 6 insertions, 3 deletions
@@ -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; @@ -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; |