system/fastboot: Add serial (UART) transport backend - #3760
Conversation
The read loop was passing the original buf pointer and full length on every iteration, causing subsequent reads to overwrite previous data and potentially request more bytes than the remaining buffer space. Update buf and len after each successful read to advance through the buffer correctly. Signed-off-by: fangpeina <fangpeina@xiaomi.com>
Add SYSTEM_FASTBOOTD_USB (default y) and SYSTEM_FASTBOOTD_TCP (default y) to allow disabling individual transports independently. Replace direct CONFIG_USBFASTBOOT / CONFIG_NET_TCP guards in the transport code with the new fastbootd-level Kconfig symbols. Signed-off-by: fangpeina <fangpeina@xiaomi.com>
Extract fastboot_framed_read() that handles TCP v1 wire framing: handshake detection (FB01 exchange) and 8-byte big-endian length prefix parsing. Simplify fastboot_tcp_read() to reuse this helper for both initial handshake and subsequent data frames. This prepares for adding a serial transport that shares the same framed protocol. Signed-off-by: fangpeina <fangpeina@xiaomi.com>
Add a serial transport alongside the existing USB and TCP backends. The serial backend reuses the TCP v1 wire framing (FB01 handshake plus an 8-byte big-endian length prefix) so the host side needs no new tool: socat bridges the UART to a TCP socket and the standard fastboot tool connects via tcp:. The serial port path is configured at build time through Kconfig SYSTEM_FASTBOOTD_SERIAL_PORT. Signed-off-by: fangpeina <fangpeina@xiaomi.com>
de44917 to
4ff8782
Compare
|
please create a new patch to fix the style issue: |
Add missing blank lines after variable declarations and fix alignment in preprocessor conditionals. These are pre-existing style issues exposed by the latest nxstyle version. Signed-off-by: fangpeina <fangpeina@xiaomi.com>
TestingVerified the multi-transport fastboot daemon end-to-end on real hardware for both USB and TCP transports. For each transport: Board: lckfb-szpi-esp32s3 (ESP32-S3, chip MAC
USB transportfastbootd is auto-started by init.rc (PID 5 in Board-side read-back (byte-exact): download -> flash -> erase -> re-flash cycle all pass; fastbootd (PID 5) stays alive throughout. TCP transportBoard joins a WiFi AP and gets Board-side read-back after flash matches the host
|
Summary
Add a serial (UART) transport backend to the fastboot daemon, alongside
the existing USB and TCP transports. This enables fastboot on devices
where neither USB nor network is available — only a UART port is needed.
The serial backend reuses the TCP v1 wire framing (FB01 handshake +
8-byte big-endian length prefix), so the host side needs no new tool:
socat bridges the UART to a TCP socket and the standard fastboot client
connects via
tcp:.Changes
Impact
Testing
All tests based on
sim:nsh.Configuration
Core
Flash Support (enabled on sim:nsh)
Transport Layer (Select one from USB, TCP, or Serial; multiple selections allowed)
Verification
1. Serial Transport
Setup:
Test output
2. TCP Transport
Setup:
Test output
3. USB Transport
Setup:
Test output