mirror of
https://github.com/andreili/katapult.git
synced 2025-08-23 19:34:06 +02:00
flashcmd: add support for reporting software version
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
3f28ae2641
commit
4a1532ef24
@ -34,11 +34,11 @@ Initiates communication with the bootloader. This command has no payload:
|
|||||||
<0x01><0x88><0x11><0x00><CRC><0x99><0x03>
|
<0x01><0x88><0x11><0x00><CRC><0x99><0x03>
|
||||||
```
|
```
|
||||||
|
|
||||||
Responds with [acknowledged](#acknowledged-0xa0) containing a 16 byte payload
|
Responds with [acknowledged](#acknowledged-0xa0) containing a variable length payload
|
||||||
in the following format:
|
in the following format:
|
||||||
|
|
||||||
```
|
```
|
||||||
<4 byte orig_command><4 byte protocol_version><4 byte start_address><4 byte block_size><n byte mcu_type_string>
|
<4 byte orig_command><4 byte protocol_version><4 byte start_address><4 byte block_size><n byte mcu_type_string><1 null byte><n byte software_version_string>
|
||||||
```
|
```
|
||||||
|
|
||||||
- `orig_command` - must be `0x11`
|
- `orig_command` - must be `0x11`
|
||||||
@ -51,6 +51,8 @@ in the following format:
|
|||||||
- `block_size` - the size of a block (in bytes) expected in the `send block` and
|
- `block_size` - the size of a block (in bytes) expected in the `send block` and
|
||||||
`request block` commands. Typically this should be 64 bytes.
|
`request block` commands. Typically this should be 64 bytes.
|
||||||
- `mcu_type_string` - The type of micro-controller (eg, "stm32f103xe").
|
- `mcu_type_string` - The type of micro-controller (eg, "stm32f103xe").
|
||||||
|
- `software_version_string` - The software version as reported by
|
||||||
|
`git describe --tags --always --long --dirty`.
|
||||||
|
|
||||||
|
|
||||||
#### Send Block: `0x12`
|
#### Send Block: `0x12`
|
||||||
|
@ -89,17 +89,26 @@ class CanFlasher:
|
|||||||
output_line("Attempting to connect to bootloader")
|
output_line("Attempting to connect to bootloader")
|
||||||
ret = await self.send_command('CONNECT')
|
ret = await self.send_command('CONNECT')
|
||||||
pinfo = ret[:12]
|
pinfo = ret[:12]
|
||||||
mcu_type = ret[12:]
|
mcu_info = ret[12:]
|
||||||
|
ver_bytes: bytes
|
||||||
ver_bytes, start_addr, self.block_size = struct.unpack("<4sII", pinfo)
|
ver_bytes, start_addr, self.block_size = struct.unpack("<4sII", pinfo)
|
||||||
self.app_start_addr = start_addr
|
self.app_start_addr = start_addr
|
||||||
proto_version = ".".join([str(v) for v in reversed(ver_bytes[:3])])
|
self.software_version = "?"
|
||||||
|
self.proto_version = tuple([v for v in reversed(ver_bytes[:3])])
|
||||||
|
proto_version_str = ".".join([str(v) for v in self.proto_version])
|
||||||
if self.block_size not in [64, 128, 256, 512]:
|
if self.block_size not in [64, 128, 256, 512]:
|
||||||
raise FlashError("Invalid Block Size: %d" % (self.block_size,))
|
raise FlashError("Invalid Block Size: %d" % (self.block_size,))
|
||||||
while mcu_type and mcu_type[-1] == 0x00:
|
mcu_info.rstrip(b"\x00")
|
||||||
mcu_type = mcu_type[:-1]
|
if self.proto_version >= (1, 1, 0):
|
||||||
mcu_type = mcu_type.decode()
|
mcu_bytes, sv_bytes = mcu_info.split(b"\x00", maxsplit=1)
|
||||||
|
mcu_type = mcu_bytes.decode()
|
||||||
|
self.software_version = sv_bytes.decode()
|
||||||
|
else:
|
||||||
|
mcu_type = mcu_info.decode()
|
||||||
output_line(
|
output_line(
|
||||||
f"Katapult Connected\nProtocol Version: {proto_version}\n"
|
f"Katapult Connected\n"
|
||||||
|
f"Software Version: {self.software_version}\n"
|
||||||
|
f"Protocol Version: {proto_version_str}\n"
|
||||||
f"Block Size: {self.block_size} bytes\n"
|
f"Block Size: {self.block_size} bytes\n"
|
||||||
f"Application Start: 0x{self.app_start_addr:4X}\n"
|
f"Application Start: 0x{self.app_start_addr:4X}\n"
|
||||||
f"MCU type: {mcu_type}"
|
f"MCU type: {mcu_type}"
|
||||||
|
12
scripts/make-version.sh
Executable file
12
scripts/make-version.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Detect the version of Katapult
|
||||||
|
|
||||||
|
a="/$0"; a="${a%/*}"; a="${a:-.}"; a="${a##/}/"; SRCDIR=$(cd "$a/.."; pwd)
|
||||||
|
|
||||||
|
if [ -e "${SRCDIR}/.git" ]; then
|
||||||
|
git describe --tags --long --always --dirty
|
||||||
|
elif [ -f "${SRCDIR}/.version" ]; then
|
||||||
|
cat "${SRCDIR}/.version"
|
||||||
|
else
|
||||||
|
echo "?"
|
||||||
|
fi
|
@ -1,6 +1,6 @@
|
|||||||
# Main Kconfig settings
|
# Main Kconfig settings
|
||||||
|
|
||||||
VERSION := $(shell, git describe --tags --long --always --dirty 2> /dev/null)
|
VERSION := $(shell, ./scripts/make-version.sh 2> /dev/null)
|
||||||
|
|
||||||
mainmenu "Katapult Configuration $(VERSION)"
|
mainmenu "Katapult Configuration $(VERSION)"
|
||||||
|
|
||||||
@ -120,3 +120,7 @@ config BUILD_DEPLOYER
|
|||||||
config HAVE_CHIPID
|
config HAVE_CHIPID
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
config KATAPULT_VERSION
|
||||||
|
string
|
||||||
|
default "$(VERSION)"
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#define shutdown(msg) do { } while (1)
|
#define shutdown(msg) do { } while (1)
|
||||||
#define try_shutdown(msg) do { } while (0)
|
#define try_shutdown(msg) do { } while (0)
|
||||||
|
|
||||||
#define PROTO_VERSION 0x00010000 // Version 1.0.0
|
#define PROTO_VERSION 0x00010100 // Version 1.1.0
|
||||||
#define CMD_CONNECT 0x11
|
#define CMD_CONNECT 0x11
|
||||||
#define CMD_RX_BLOCK 0x12
|
#define CMD_RX_BLOCK 0x12
|
||||||
#define CMD_RX_EOF 0x13
|
#define CMD_RX_EOF 0x13
|
||||||
|
@ -19,12 +19,17 @@ void
|
|||||||
command_connect(uint32_t *data)
|
command_connect(uint32_t *data)
|
||||||
{
|
{
|
||||||
uint32_t mcuwords = DIV_ROUND_UP(strlen(CONFIG_MCU), 4);
|
uint32_t mcuwords = DIV_ROUND_UP(strlen(CONFIG_MCU), 4);
|
||||||
uint32_t out[6 + mcuwords];
|
uint32_t version_words = DIV_ROUND_UP(strlen(CONFIG_KATAPULT_VERSION), 4);
|
||||||
memset(out, 0, (6 + mcuwords) * 4);
|
uint32_t out[7 + mcuwords + version_words];
|
||||||
|
memset(out, 0, (7 + mcuwords + version_words) * 4);
|
||||||
out[2] = cpu_to_le32(PROTO_VERSION);
|
out[2] = cpu_to_le32(PROTO_VERSION);
|
||||||
out[3] = cpu_to_le32(CONFIG_LAUNCH_APP_ADDRESS);
|
out[3] = cpu_to_le32(CONFIG_LAUNCH_APP_ADDRESS);
|
||||||
out[4] = cpu_to_le32(CONFIG_BLOCK_SIZE);
|
out[4] = cpu_to_le32(CONFIG_BLOCK_SIZE);
|
||||||
memcpy(&out[5], CONFIG_MCU, strlen(CONFIG_MCU));
|
memcpy(&out[5], CONFIG_MCU, strlen(CONFIG_MCU));
|
||||||
|
memcpy(
|
||||||
|
&out[6 + mcuwords], CONFIG_KATAPULT_VERSION,
|
||||||
|
strlen(CONFIG_KATAPULT_VERSION)
|
||||||
|
);
|
||||||
command_respond_ack(CMD_CONNECT, out, ARRAY_SIZE(out));
|
command_respond_ack(CMD_CONNECT, out, ARRAY_SIZE(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user