mc683xx-bdm

Host-pod protocol

How a host talks to the pod: over USB, or over a stream socket to anything that answers as the pod does (bdm-stand-in). It is the complete specification: a stand-in written from it alone answers as the pod does. The pod’s implementation is crates/proto/src/usb.rs; where the two disagree, that is a bug in one of them.

Protocol version: 11 (PROTOCOL_VERSION), raised on any change to a request or reply.

Transport

USB:

Stream (Unix or TCP socket):

Either way:

Hello

Request Reply
0x0E (the whole packet) 0x00, then u32 protocol version

A one-byte packet other than 0x0E is a tag with no request: BadRequest.

Requests

Byte 0 is the tag, byte 1 the code; the body follows. Every body length is exact, as the table gives it; any other length, a packet with no code or an unknown code is answered BadRequest. “FREEZE” means refused with NoFreeze unless the target is in background mode, since a command’s clocks would otherwise be BKPT pulses that halt it.

Code Request Body Reply body (status Ok) FREEZE
0x01 Transfer 1-15 words, u16 each (2-30 bytes, even) one u32 per word: the 17 bits shifted in, bit 16 the status bit, bits 31-17 zero no
0x02 Pins none u8 levels, u16 VDD in mV, ATEMP field no
0x03 ResetHalt none ATEMP field no
0x04 Halt none ATEMP field no
0x05 Go none none yes
0x06 SetClock u32 DSCLK Hz u32 DSCLK Hz set no
0x07 ReadRegister u8 register code u32 value yes
0x08 WriteRegister u8 register code, u32 value none yes
0x09 ReadSystemRegister u8 select code u32 value yes
0x0A WriteSystemRegister u8 select code, u32 value none yes
0x0B ReadMemory u32 address, u8 size, u8 length exactly length bytes yes
0x0C WriteMemory u32 address, u8 size, 1-56 data bytes (7-63 bytes with tag and code) none yes
0x0D Call u32 address none yes
0x0F ResetRun none none no
0x10 Resync none ATEMP field, kind 2 yes
0x11 Version none the firmware’s version, ASCII: crate version and git commit (0.1.0 1a2b3c4, -dirty if built with uncommitted changes) no
0x12 Hold none none no
0x13 BerrPulse none u32: 1 if a hung access ended, else 0 yes
0x14 GetClock none u32 DSCLK Hz in effect no

Fields:

Semantics:

Replies

Byte 0 is the request’s tag, byte 1 FREEZE’s edge count, byte 2 the status. The reply body follows only for Ok, exactly as the request table gives it; every other status is a three-byte reply.

Status Name Meaning
0 Ok Done; the body is the result
1 BadRequest Not a request the pod parses: unknown code, wrong length, field out of range
2 NoTarget Target VDD below 4.5 V
3 NoFreeze FREEZE did not assert, or is not asserted for a request that needs it
4 BusError The access ended in a bus or address error
5 Illegal The target refused the command
6 NotReady Still not ready after the retries
7 Unexpected A response the command’s sequence does not allow, or the pod could not read VDD
8 BdmDisabled Halt or Hold under the halt guard: the pod’s last reset was ResetRun
9 ResetHeld RESET still low 100 ms after the pod’s reset pulse: the target holds it

Checking

cargo test -p mc683xx-bdm-proto round-trips every request and reply; a change here goes with a change to usb.rs and its tests, and a raised PROTOCOL_VERSION if the wire changes.