mirror of
https://github.com/andreili/katapult.git
synced 2025-08-23 19:34:06 +02:00
canboot_main: Add mcu type to connect response message
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
466a9de594
commit
a00c4c78c5
@ -38,7 +38,7 @@ Responds with [acknowledged](#acknowledged-0xa0) containing a 16 byte payload
|
||||
in the following format:
|
||||
|
||||
```
|
||||
<4 byte orig_command><4 byte protocol_version><4 byte start_address><4 byte block_size>
|
||||
<4 byte orig_command><4 byte protocol_version><4 byte start_address><4 byte block_size><n byte mcu_type_string>
|
||||
```
|
||||
|
||||
- `orig_command` - must be `0x11`
|
||||
@ -50,6 +50,7 @@ in the following format:
|
||||
address.
|
||||
- `block_size` - the size of a block (in bytes) expected in the `send block` and
|
||||
`request block` commands. Typically this should be 64 bytes.
|
||||
- `mcu_type_string` - The type of micro-controller (eg, "stm32f103xe").
|
||||
|
||||
|
||||
#### Send Block: `0x12`
|
||||
|
@ -86,15 +86,21 @@ class CanFlasher:
|
||||
async def connect_btl(self):
|
||||
output_line("Attempting to connect to bootloader")
|
||||
ret = await self.send_command('CONNECT')
|
||||
ver_bytes, start_addr, self.block_size = struct.unpack("<4sII", ret)
|
||||
pinfo = ret[:12]
|
||||
mcu_type = ret[12:]
|
||||
ver_bytes, start_addr, self.block_size = struct.unpack("<4sII", pinfo)
|
||||
self.app_start_addr = start_addr
|
||||
proto_version = ".".join([str(v) for v in reversed(ver_bytes[:3])])
|
||||
if self.block_size not in [64, 128, 256, 512]:
|
||||
raise FlashCanError("Invalid Block Size: %d" % (self.block_size,))
|
||||
while mcu_type and mcu_type[-1] == 0x00:
|
||||
mcu_type = mcu_type[:-1]
|
||||
mcu_type = mcu_type.decode()
|
||||
output_line(
|
||||
f"CanBoot Connected\nProtocol Version: {proto_version}\n"
|
||||
f"Block Size: {self.block_size} bytes\n"
|
||||
f"Application Start: 0x{self.app_start_addr:4X}"
|
||||
f"Application Start: 0x{self.app_start_addr:4X}\n"
|
||||
f"MCU type: {mcu_type}"
|
||||
)
|
||||
|
||||
async def send_command(
|
||||
|
@ -126,12 +126,15 @@ process_complete(void)
|
||||
static void
|
||||
process_connnect(void)
|
||||
{
|
||||
uint32_t out[6];
|
||||
uint32_t mcuwords = DIV_ROUND_UP(strlen(CONFIG_MCU), 4);
|
||||
uint32_t out[6 + mcuwords];
|
||||
memset(out, 0, (6 + mcuwords) * 4);
|
||||
out[1] = cpu_to_le32(CMD_CONNECT);
|
||||
out[2] = cpu_to_le32(PROTO_VERSION);
|
||||
out[3] = cpu_to_le32(CONFIG_APPLICATION_START);
|
||||
out[4] = cpu_to_le32(CONFIG_BLOCK_SIZE);
|
||||
send_ack(out, 4);
|
||||
memcpy(&out[5], CONFIG_MCU, strlen(CONFIG_MCU));
|
||||
send_ack(out, 4 + mcuwords);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
Loading…
x
Reference in New Issue
Block a user