Repository navigation
Zephyr port: open the serial port at 1200 baud to enter the bootloader - #11570
mikeysklar wants to merge 5 commits into
Conversation
The README said the touch worked, but nothing handled it: the TinyUSB handler is not built for this port. Watch line coding and DTR on the first CDC. At 1200 baud with DTR low, recheck 100 ms later, detach USB and call reset_to_bootloader(), which now asks for UF2 mode so the Adafruit nRF52 bootloader shows its drive. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
On the RP2 boards the touch and on_next_reset(UF2) only rebooted into CircuitPython, so every reflash needed BOOTSEL. Add Zephyr's boot-mode retention region to the five RP2 overlays and enable the retained-memory chain. Zephyr's rom_bootloader.c then enters the ROM bootloader. A "CP" prefix and CRC8 keep cold-boot SRAM from being read as a request. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Checked on a Feather nRF52840: |
tannewt
left a comment
There was a problem hiding this comment.
Thanks for fixing this. I think some of it should be moved to adaboot.
RP2 boards have no MCUboot, so adaboot_request_update_mode() had nothing to signal on them. Wire Zephyr's boot-mode retention into the five RP2 layout dtsis (4-byte region with an "AB" prefix and CRC8, so cold-boot SRAM is not read as a request) and add a module Kconfig that enables RETAINED_MEM, RETENTION and RETENTION_BOOT_MODE on RP2 when the region is chosen. Zephyr's RPI_PICO_ROM_BOOTLOADER then follows and enters the ROM UF2 bootloader on the next boot. This moves the settings out of CircuitPython (adafruit/circuitpython#11570) so any application using adaboot gets the same behavior. Signed-off-by: Mikey Sklar <mikeysklar@gmail.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The RP2 boot-mode retention region and its Kconfig defaults now live in adaboot, next to the RP2 flash layouts, so Zephyr Arduino can share them. Drop the CP copies and bump adaboot. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
| msg->type == USBD_MSG_CDC_ACM_CONTROL_LINE_STATE) && | ||
| msg->dev == touch_cdc) { | ||
| if (touch_requested()) { | ||
| k_work_schedule(&touch_work, K_MSEC(100)); |
There was a problem hiding this comment.
Why do you need a delay? TinyUSB doesn't:
circuitpython/supervisor/shared/usb/usb_device.c
Lines 81 to 89 in 8253c03
There was a problem hiding this comment.
It isn't needed. I took it from ArduinoCore-samd, which waits 250 ms and cancels if DTR comes back. CircuitPython's TinyUSB path resets right away, so I removed it in 8cd3687.
| Pico W, no delay | Result |
|---|---|
| 1200 touch, then UF2 copy | 10/10, ROM drive 0.5-0.7 s after close |
| open at 115200, or held at 1200 | 5/5, no reset |
| power off | 3/3, back in CircuitPython |
There was a problem hiding this comment.
Same on Pico 2 W:
| Pico 2 W, no delay | Result |
|---|---|
| 1200 touch, then UF2 copy | 10/10, ROM drive 0.5-0.9 s after close |
| open at 115200, or held at 1200 | 5/5, no reset |
| power off | 3/3, back in CircuitPython |
There was a problem hiding this comment.
Same on Feather nRF52840:
| Feather nRF52840, no delay | Result |
|---|---|
| 1200 touch, then UF2 copy | 10/10, FTHR840BOOT drive 0.5-0.7 s after close |
| open at 115200, or held at 1200 | 5/5, no reset |
| power off | 3/3, back in CircuitPython |
Drop the 100 ms recheck. The TinyUSB ports reset as soon as DTR drops at 1200 baud, and this now does the same. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
What
Opening the USB serial port at 1200 baud now resets the board into its bootloader.
Why
The README said this worked, but the Zephyr port never handled it.
Raspberry Pi boards no longer need BOOTSEL to reflash.
The RP2 settings live in adaboot (adafruit/adaboot#9), so Zephyr Arduino can share them.
on_next_reset(UF2 / BOOTLOADER), then UF2 copyNot tested: nRF54L15 DK (UART console). Pico, Pico 2 and Feather RP2040 are build-tested only.
Written with Claude. The "after move" tests were run on the farm by Claude; I reviewed them.
🤖 Generated with Claude Code