2026 sim: drive the Unity simulation with the real remote over the radio
Dongle (app):
- bridge mode: stands in for the robot's radio (ch 96 / 250k / HXPD1,
auto-ack, dynamic payloads, ack payloads). Received packets go to the PC
as A5-framed 'R' frames; the PC's 'A' frames become the ack payload of
the next packet, like robot/Comms.cpp; dropped after ~0.5 s without a
refresh. 'S' status once a second.
- USART RX through circular DMA into a ring buffer, overrun stall
disabled, error flags cleared: a burst (e.g. SignalRGB probing the port)
used to deafen the app until a replug.
- RX test mode ('x') accepts protocol v4's dynamic-length packets.
- safeboot_flash.py --knock: keeps knocking across a replug to catch
safeboot's cold-boot window when the app doesn't answer.
Unity:
- SimRemote sources: Keyboard, or the real remote via the dongle
(DongleLink.cs: kernel32 serial, auto-finds the CH340, all port I/O on
one background thread). Packets go into the firmware byte for byte, the
robot's telemetry goes back on the ack, so the remote's display shows
the sim. Tested end to end with the real remote.
- Dropped the USB joystick and robot-serial-harness inputs and the old
Serial/Serial2/Serial3/HandleHoystick scripts (and their components in
Main.unity): no USB links to remote or robot any more.
- Test panel: dongle status; no sideways scroll bar.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6b3b2629cd
commit
2b4750f8f4
24 files changed
+682
-710
No files matched your search
@@ -155,7 +155,9 @@ python tools/safeboot_flash.py firmware/build/app.bin
|
||||
```
|
||||
|
||||
This resets the running app into safeboot and rewrites only the app region. If
|
||||
the app is dead, replug the stick and re-run — it will catch the knock window.
|
||||
the app is dead or doesn't answer, start it with `--knock` and then replug the
|
||||
stick: it keeps knocking (reopening the port as it comes back) until it lands in
|
||||
safeboot's 1.5 s cold-boot window.
|
||||
|
||||
## Air settings
|
||||
|
||||
@@ -168,6 +170,36 @@ the Si24R1 over SPI (same register layout as the nRF24L01+).
|
||||
- [x] identify the hardware, map the radio + serial pins
|
||||
- [x] permanent two-stage firmware, wire-free USB flashing
|
||||
- [ ] identify the LED and AT2401C TX/RX-enable pins (app toggles the 5 free pins)
|
||||
- [ ] radio hub app: carry `CmdPacket` both ways, per-node addressing, telemetry
|
||||
- [ ] Unity serial bridge (PC as hub when online, robot as hub when not) — see
|
||||
`../README.md` "Planned"
|
||||
- [x] bridge mode: the dongle stands in for the robot's radio, Unity runs the
|
||||
robot firmware (sim) behind it — see "Bridge mode" below
|
||||
- [ ] the other direction: Unity as the remote, driving the real robot
|
||||
- [ ] AT2401C pins: at desk range and even a few rooms away with the remote at
|
||||
minimum power, every on/off combination of PA1/PB1/PF0/PF1 received
|
||||
every packet, so they couldn't be told apart; the link works without
|
||||
driving them
|
||||
|
||||
## Bridge mode (Unity ↔ real remote)
|
||||
|
||||
The app listens on the hexapod's air settings as if it were the robot
|
||||
(ch 96, 250 kbps, `HXPD1`, auto-ack, dynamic payload lengths, ack payloads)
|
||||
and passes everything to the PC. Framing both ways over the USB serial
|
||||
(115200 8N1):
|
||||
|
||||
```
|
||||
A5 type len payload[len] sum sum = type + len + payload bytes (mod 256)
|
||||
```
|
||||
|
||||
| Direction | Type | Payload |
|
||||
|-----------|------|---------|
|
||||
| PC → dongle | `L` | — : start bridging (LED on) |
|
||||
| PC → dongle | `X` | — : stop |
|
||||
| PC → dongle | `A` | ≤ 32 bytes: the robot's `Telemetry`, sent back on the auto-ack of the remote's next packet (reloaded after every packet, like `robot/Comms.cpp`). Dropped if not refreshed for ~0.5 s, so the remote never shows stale telemetry as live |
|
||||
| dongle → PC | `R` | a packet the remote sent (its `CmdPacket`, any length; the firmware checks it) |
|
||||
| dongle → PC | `S` | once a "second": packets received (u16 LE), ack payloads loaded (u16 LE). Its second runs ~30% long (blocking UART sends miss SysTick ticks); it's only for display |
|
||||
|
||||
Plain text never contains `A5`, so the PC skips anything between frames;
|
||||
while bridging the app prints no text and only takes frames (and `b` for a
|
||||
reflash). USB serial input goes through DMA into a ring buffer (no
|
||||
interrupts in this app), and the USART's overrun stall is disabled, so a
|
||||
burst can't deafen it. Unity's side is
|
||||
`Hexapod_Simulation_Unity/Assets/HexapodSim/DongleLink.cs`.
|
||||
@@ -52,11 +52,14 @@ static void nrf_write_buf(uint8_t reg, const uint8_t *d, int n)
|
||||
}
|
||||
static void nrf_cmd(uint8_t c) { CSN_LO(); spi_xfer(c); CSN_HI(); }
|
||||
|
||||
/* Receive on the hexapod protocol (ch 96, 250 kbps, addr HXPD1, 22-byte). Lets
|
||||
* us find the AT2401C RX-enable pin: packets only arrive when the LNA/antenna
|
||||
* path is on. */
|
||||
/* Receive on the hexapod protocol (ch 96, 250 kbps, addr HXPD1). Protocol v4
|
||||
* uses dynamic payload lengths (the remote's CmdPacket is 26 bytes, with ack
|
||||
* payloads), so this does too and accepts any length. Auto-ack is on, so the
|
||||
* remote's link % also shows whether our acks get back out (TX path). Lets us
|
||||
* find the AT2401C enable pins: packets only arrive when the LNA path is on. */
|
||||
static uint8_t rxmode;
|
||||
static uint16_t rx_count;
|
||||
static uint8_t rx_len;
|
||||
static void rx_setup(void)
|
||||
{
|
||||
static const uint8_t addr[5] = { 0x48, 0x58, 0x50, 0x44, 0x31 }; /* "HXPD1" */
|
||||
@@ -68,18 +71,22 @@ static void rx_setup(void)
|
||||
nrf_write(0x05, 96); /* RF_CH */
|
||||
nrf_write(0x06, 0x26); /* RF_SETUP: 250 kbps, max power */
|
||||
nrf_write_buf(0x0A, addr, 5); /* RX_ADDR_P0 */
|
||||
nrf_write(0x11, 22); /* RX_PW_P0 */
|
||||
nrf_write(0x1D, 0x04); /* FEATURE: EN_DPL */
|
||||
nrf_write(0x1C, 0x01); /* DYNPD: pipe0 */
|
||||
nrf_write(0x07, 0x70); /* clear status flags */
|
||||
nrf_cmd(0xE2); /* FLUSH_RX */
|
||||
rx_count = 0;
|
||||
rx_len = 0;
|
||||
CE_HI();
|
||||
}
|
||||
static void rx_poll(void)
|
||||
{
|
||||
if (nrf_read(0x07) & 0x40) { /* RX_DR */
|
||||
uint8_t buf[22];
|
||||
CSN_LO(); spi_xfer(0x61); for (int i = 0; i < 22; i++) buf[i] = spi_xfer(0xFF); CSN_HI();
|
||||
while (nrf_read(0x07) & 0x40) { /* RX_DR */
|
||||
CSN_LO(); spi_xfer(0x60); uint8_t n = spi_xfer(0xFF); CSN_HI(); /* R_RX_PL_WID */
|
||||
if (n > 32) { nrf_cmd(0xE2); nrf_write(0x07, 0x40); break; } /* corrupt: flush */
|
||||
CSN_LO(); spi_xfer(0x61); for (int i = 0; i < n; i++) spi_xfer(0xFF); CSN_HI();
|
||||
nrf_write(0x07, 0x40); /* clear RX_DR */
|
||||
rx_len = n;
|
||||
rx_count++;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +139,7 @@ static void banner(void)
|
||||
uart_puts("\r\nhexapod dongle app v0 (@0x08001000)\r\n");
|
||||
uart_puts("nRF CONFIG=0x"); hex2(nrf_read(0)); uart_puts(" STATUS=0x"); hex2(nrf_read(7));
|
||||
uart_puts(" RF_CH=0x"); hex2(nrf_read(5)); uart_puts(" RF_SETUP=0x"); hex2(nrf_read(6));
|
||||
uart_puts("\r\ncmds: v r 0-4(PA0/PA1/PB1/PF0/PF1) b=reflash\r\n");
|
||||
uart_puts("\r\ncmds: v r 0-4(PA0/PA1/PB1/PF0/PF1) x=rx test b=reflash; bridge: frame A5 'L'\r\n");
|
||||
}
|
||||
static void regdump(void)
|
||||
{
|
||||
@@ -156,6 +163,134 @@ static void finder_rx(void)
|
||||
delay_ms(2);
|
||||
}
|
||||
|
||||
/* ---- USART1 RX through circular DMA ------------------------------------
|
||||
* The bridge moves ~100 frames/s each way at 115200 baud. Polled single-byte
|
||||
* RX loses bytes while we block on a TX frame or an SPI read, and this M0 app
|
||||
* runs without interrupts (no vector relocation), so DMA channel 3 (USART1_RX)
|
||||
* writes every byte into a ring we drain at leisure. */
|
||||
#define DMA_CCR3 REG(0x40020030)
|
||||
#define DMA_CNDTR3 REG(0x40020034)
|
||||
#define DMA_CPAR3 REG(0x40020038)
|
||||
#define DMA_CMAR3 REG(0x4002003C)
|
||||
#define USART1_CR3 REG(0x40013808)
|
||||
#define RXRING 256u
|
||||
static volatile uint8_t rxring[RXRING];
|
||||
static uint16_t rxtail;
|
||||
static void uart_dma_init(void)
|
||||
{
|
||||
RCC_AHBENR |= 1u; /* DMA1 */
|
||||
while (!(USART1_ISR & (1u << 6))) {} /* let any TX finish */
|
||||
USART1_CR1 &= ~1u; /* UE off: CR3 OVRDIS needs it */
|
||||
USART1_CR3 = (1u << 6) | (1u << 12); /* DMAR, OVRDIS (never stall on overrun) */
|
||||
USART1_CR1 |= 1u;
|
||||
DMA_CCR3 = 0;
|
||||
DMA_CPAR3 = 0x40013824u; /* USART1_RDR */
|
||||
DMA_CMAR3 = (uint32_t)rxring;
|
||||
DMA_CNDTR3 = RXRING;
|
||||
DMA_CCR3 = (1u << 7) | (1u << 5) | 1u; /* MINC, CIRC, EN; 8-bit, periph -> mem */
|
||||
}
|
||||
static int rx_getc(void)
|
||||
{
|
||||
uint16_t head = (uint16_t)(RXRING - DMA_CNDTR3) % RXRING;
|
||||
if (head == rxtail) return -1;
|
||||
uint8_t c = rxring[rxtail];
|
||||
rxtail = (uint16_t)((rxtail + 1) % RXRING);
|
||||
return c;
|
||||
}
|
||||
|
||||
/* ---- Bridge: the dongle stands in for the robot's radio ------------------
|
||||
* Framing both ways: A5 type len payload[len] sum, sum = type+len+payload (mod 256).
|
||||
* host -> dongle 'L' listen (enter bridge) 'X' leave
|
||||
* 'A' ack payload (<= 32 B): goes back on the auto-ack of the
|
||||
* next packet, like the robot's Comms::loadAckPayload.
|
||||
* Dropped if the host stops refreshing it for 500 ms, so
|
||||
* the remote doesn't see stale telemetry as live.
|
||||
* dongle -> host 'R' a received packet (the remote's CmdPacket)
|
||||
* 'S' once a second: packets received (u16 LE), acks loaded (u16 LE)
|
||||
* Plain text never contains A5, so the host can skip anything between frames. */
|
||||
static uint8_t bridge;
|
||||
static uint8_t ack_buf[32], ack_len;
|
||||
static uint32_t ack_ms;
|
||||
static uint16_t br_rx, br_acks;
|
||||
static void frame_send(uint8_t type, const uint8_t *d, uint8_t n)
|
||||
{
|
||||
uint8_t sum = (uint8_t)(type + n);
|
||||
uart_putc((char)0xA5); uart_putc((char)type); uart_putc((char)n);
|
||||
for (uint8_t i = 0; i < n; i++) { uart_putc((char)d[i]); sum = (uint8_t)(sum + d[i]); }
|
||||
uart_putc((char)sum);
|
||||
}
|
||||
static void ack_load(void)
|
||||
{
|
||||
nrf_cmd(0xE1); /* FLUSH_TX: only the newest one */
|
||||
if (!ack_len) return;
|
||||
CSN_LO(); spi_xfer(0xA8); for (uint8_t i = 0; i < ack_len; i++) spi_xfer(ack_buf[i]); CSN_HI(); /* W_ACK_PAYLOAD pipe 0 */
|
||||
br_acks++;
|
||||
}
|
||||
static void bridge_start(void)
|
||||
{
|
||||
rx_setup(); /* ch96 / 250k / HXPD1 / auto-ack / dynamic length */
|
||||
CE_LO();
|
||||
nrf_write(0x1D, 0x06); /* FEATURE: EN_DPL | EN_ACK_PAY */
|
||||
nrf_write(0x1C, 0x01); /* DYNPD pipe 0 */
|
||||
nrf_cmd(0xE1);
|
||||
ack_len = 0; br_rx = br_acks = 0;
|
||||
rxmode = 0; finder = 0; bridge = 1;
|
||||
BSRR(GPIOA) = 1u; /* LED on while bridging */
|
||||
CE_HI();
|
||||
}
|
||||
static void bridge_stop(void)
|
||||
{
|
||||
bridge = 0; ack_len = 0;
|
||||
CE_LO(); nrf_write(0, 0x0E); nrf_cmd(0xE1);
|
||||
BSRR(GPIOA) = 1u << 16;
|
||||
}
|
||||
static void bridge_poll(uint32_t now)
|
||||
{
|
||||
if (ack_len && now - ack_ms > 500) { ack_len = 0; nrf_cmd(0xE1); } /* host went quiet */
|
||||
while (nrf_read(0x07) & 0x40) { /* RX_DR */
|
||||
uint8_t buf[32];
|
||||
CSN_LO(); spi_xfer(0x60); uint8_t n = spi_xfer(0xFF); CSN_HI(); /* R_RX_PL_WID */
|
||||
if (n > 32) { nrf_cmd(0xE2); nrf_write(0x07, 0x40); break; }
|
||||
CSN_LO(); spi_xfer(0x61); for (uint8_t i = 0; i < n; i++) buf[i] = spi_xfer(0xFF); CSN_HI();
|
||||
nrf_write(0x07, 0x40);
|
||||
ack_load(); /* the ack for the NEXT packet */
|
||||
frame_send('R', buf, n);
|
||||
br_rx++;
|
||||
if ((br_rx & 31) == 0) BSRR(GPIOA) = (IDR(GPIOA) & 1u) ? (1u << 16) : 1u; /* LED flicker */
|
||||
}
|
||||
}
|
||||
/* Host frame parser; returns 1 while inside a frame (so its bytes aren't
|
||||
* taken as single-letter commands). */
|
||||
static uint8_t fr_state, fr_type, fr_len, fr_got, fr_sum, fr_buf[32];
|
||||
static int frame_rx(int c, uint32_t now)
|
||||
{
|
||||
/* if-chain, not switch: a switch becomes a jump table needing libgcc */
|
||||
if (fr_state == 0) {
|
||||
if (c != 0xA5) return 0;
|
||||
fr_state = 1;
|
||||
} else if (fr_state == 1) {
|
||||
fr_type = (uint8_t)c;
|
||||
fr_state = 2;
|
||||
} else if (fr_state == 2) {
|
||||
fr_len = (uint8_t)c; fr_got = 0; fr_sum = (uint8_t)(fr_type + fr_len);
|
||||
fr_state = (fr_len > 32) ? 0 : (fr_len ? 3 : 4);
|
||||
} else if (fr_state == 3) {
|
||||
fr_buf[fr_got++] = (uint8_t)c; fr_sum = (uint8_t)(fr_sum + c);
|
||||
if (fr_got == fr_len) fr_state = 4;
|
||||
} else {
|
||||
fr_state = 0;
|
||||
if ((uint8_t)c != fr_sum) return 1; /* corrupt: drop */
|
||||
if (fr_type == 'L') bridge_start();
|
||||
else if (fr_type == 'X') bridge_stop();
|
||||
else if (fr_type == 'A' && bridge) {
|
||||
for (uint8_t i = 0; i < fr_len; i++) ack_buf[i] = fr_buf[i];
|
||||
ack_len = fr_len; ack_ms = now;
|
||||
ack_load();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void reflash(void) /* ask safeboot to take over, no wire needed */
|
||||
{
|
||||
uart_puts("resetting into safeboot flash mode...\r\n");
|
||||
@@ -168,16 +303,25 @@ static void reflash(void) /* ask safeboot to take over, no wire needed */
|
||||
int main(void)
|
||||
{
|
||||
uart_init8n1();
|
||||
uart_dma_init();
|
||||
spi_init();
|
||||
free_init();
|
||||
nrf_write(0, 0x0E);
|
||||
delay_ms(5);
|
||||
banner();
|
||||
|
||||
uint32_t t = 0;
|
||||
uint32_t now = 0, t = 0;
|
||||
systick_setup();
|
||||
for (;;) {
|
||||
int c = uart_getc();
|
||||
if (c == 'v' || c == 'V') banner();
|
||||
uint32_t ctrl = STK_CTRL; /* one read: reading clears COUNTFLAG */
|
||||
if (ctrl == 0) systick_setup(); /* delay_ms() (sweep, finder) stops it */
|
||||
else if (ctrl & 0x10000) { now++; t++; } /* 1 ms ticks, polled */
|
||||
if (bridge) bridge_poll(now);
|
||||
int c = rx_getc();
|
||||
if (c >= 0 && frame_rx(c, now)) c = -1; /* consumed by a host frame */
|
||||
if (c < 0) {}
|
||||
else if (bridge && c != 'b' && c != 'B') {} /* bridging: only frames (and reflash) */
|
||||
else if (c == 'v' || c == 'V') banner();
|
||||
else if (c == 'r' || c == 'R') regdump();
|
||||
else if (c == 'b' || c == 'B') reflash();
|
||||
else if (c == 'x' || c == 'X') { rxmode = !rxmode; finder = 0; if (rxmode) rx_setup(); else { CE_LO(); nrf_write(0, 0x0E); } uart_puts(rxmode ? "RX mode on (ch96/250k/HXPD1)\r\n" : "RX off\r\n"); }
|
||||
@@ -193,10 +337,15 @@ int main(void)
|
||||
uart_puts("\r\n");
|
||||
}
|
||||
if (rxmode) rx_poll();
|
||||
delay_ms(1);
|
||||
if (++t >= 1000) {
|
||||
if (t >= 1000) {
|
||||
t = 0;
|
||||
if (rxmode) { uart_puts("RX pkts="); hex2(rx_count >> 8); hex2(rx_count & 0xFF);
|
||||
if (bridge) {
|
||||
uint8_t s[4] = { (uint8_t)br_rx, (uint8_t)(br_rx >> 8), (uint8_t)br_acks, (uint8_t)(br_acks >> 8) };
|
||||
frame_send('S', s, 4);
|
||||
br_rx = br_acks = 0;
|
||||
}
|
||||
else if (rxmode) { uart_puts("RX pkts="); hex2(rx_count >> 8); hex2(rx_count & 0xFF);
|
||||
uart_puts(" len="); hex2(rx_len);
|
||||
uart_puts(" pins="); for (int i = 0; i < NFREE; i++) uart_putc(fst[i] ? '1' : '0');
|
||||
uart_puts(" (0=PA0LED,1=PA1,2=PB1,3=PF0,4=PF1)\r\n"); rx_count = 0; }
|
||||
else if (finder) { uart_puts("finder ch=0x"); hex2(finder_ch); uart_puts(" RPD="); hex2(nrf_read(9));
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#define USART1_CR1 REG(0x40013800)
|
||||
#define USART1_BRR REG(0x4001380C)
|
||||
#define USART1_ISR REG(0x4001381C)
|
||||
#define USART1_ICR REG(0x40013820)
|
||||
#define USART1_RDR REG(0x40013824)
|
||||
#define USART1_TDR REG(0x40013828)
|
||||
/* SysTick */
|
||||
@@ -65,14 +66,22 @@ static inline void uart_putc(char c)
|
||||
USART1_TDR = (uint8_t)c;
|
||||
}
|
||||
static inline void uart_puts(const char *s) { while (*s) uart_putc(*s++); }
|
||||
/* Clear overrun / noise / framing / parity errors. While ORE is set the USART
|
||||
* stops moving new bytes into RDR, so one burst the app didn't read in time
|
||||
* (e.g. SignalRGB probing the COM port) used to deafen it until a replug. */
|
||||
static inline void uart_clear_errors(void)
|
||||
{
|
||||
if (USART1_ISR & 0x0Fu) USART1_ICR = 0x0Fu; /* ORECF NCF FECF PECF */
|
||||
}
|
||||
static inline int uart_getc(void) /* non-blocking, -1 if none */
|
||||
{
|
||||
uart_clear_errors();
|
||||
if (USART1_ISR & (1u << 5)) return (uint8_t)USART1_RDR;
|
||||
return -1;
|
||||
}
|
||||
static inline uint8_t uart_getc_block(void)
|
||||
{
|
||||
while (!(USART1_ISR & (1u << 5))) {}
|
||||
while (!(USART1_ISR & (1u << 5))) uart_clear_errors();
|
||||
return (uint8_t)USART1_RDR;
|
||||
}
|
||||
static inline void systick_setup(void) { STK_LOAD = 8000 - 1; STK_VAL = 0; STK_CTRL = 5; }
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
No BOOT0 wire, no ST-Link, no ROM bootloader. Writes only the app region
|
||||
(pages 4-15); safeboot itself is never touched.
|
||||
|
||||
usage: safeboot_flash.py app.bin [--port COM16]
|
||||
usage: safeboot_flash.py app.bin [--port COM16] [--knock]
|
||||
|
||||
How it enters flash mode:
|
||||
1) if the app is running, 'b' makes it soft-reset into safeboot flash mode;
|
||||
2) otherwise (dead/absent app) replug the dongle and this spams 'S' to catch
|
||||
safeboot's cold-boot knock window.
|
||||
--knock skips 1) and keeps knocking for 2 minutes, reopening the port as it
|
||||
comes and goes: start it, then replug. Use it when the app doesn't answer.
|
||||
"""
|
||||
import sys, time, serial
|
||||
|
||||
@@ -54,6 +56,36 @@ def enter_flash(s):
|
||||
return False
|
||||
|
||||
|
||||
def knock_until_caught(port, timeout=120.0):
|
||||
"""--knock: for an app that doesn't answer 'b' (dead or deaf). Keeps the
|
||||
port open and spams 'S' for up to `timeout` s, reopening whenever the port
|
||||
vanishes, so replugging the dongle at any moment lands in safeboot's 1.5 s
|
||||
cold-boot knock window. Returns the open port in flash mode, or None."""
|
||||
t = time.time()
|
||||
s = None
|
||||
while time.time() - t < timeout:
|
||||
try:
|
||||
if s is None:
|
||||
s = serial.Serial(port, 115200, timeout=0.02)
|
||||
s.write(b"S")
|
||||
r = s.read(16)
|
||||
if b"K" in r or b"SB1" in r or b"SBR" in r:
|
||||
time.sleep(0.1); s.reset_input_buffer(); s.timeout = 0.3
|
||||
s.write(b"V"); time.sleep(0.1)
|
||||
if b"SBV" in s.read(16):
|
||||
return s
|
||||
s.timeout = 0.02
|
||||
except (serial.SerialException, OSError):
|
||||
try:
|
||||
if s is not None:
|
||||
s.close()
|
||||
except Exception:
|
||||
pass
|
||||
s = None
|
||||
time.sleep(0.02)
|
||||
return None
|
||||
|
||||
|
||||
def expect(s, ch, what):
|
||||
r = s.read(1)
|
||||
if r != ch:
|
||||
@@ -68,11 +100,18 @@ def main():
|
||||
data += b"\xFF"
|
||||
print("app %s: %d bytes -> 0x%08X" % (args[0], len(data), APP_BASE))
|
||||
|
||||
s = open_port(port)
|
||||
print("entering safeboot flash mode...")
|
||||
if not enter_flash(s):
|
||||
print("could not enter flash mode (app not running? replug and retry)")
|
||||
return 1
|
||||
if "--knock" in sys.argv:
|
||||
print("knock mode: replug the dongle now (waiting up to 2 min)...")
|
||||
s = knock_until_caught(port)
|
||||
if s is None:
|
||||
print("no knock window caught")
|
||||
return 1
|
||||
else:
|
||||
s = open_port(port)
|
||||
print("entering safeboot flash mode...")
|
||||
if not enter_flash(s):
|
||||
print("could not enter flash mode (app not running? replug and retry with --knock)")
|
||||
return 1
|
||||
s.reset_input_buffer()
|
||||
s.write(b"V"); time.sleep(0.1)
|
||||
print("safeboot:", s.read(16).decode("ascii", "replace").strip())
|
||||
|
||||
Reference in new issue
Block a user