From 6245d9d46922893792b5d16ead680f1e88ccc168 Mon Sep 17 00:00:00 2001 From: Carter Turn Date: Sun, 28 Apr 2024 15:01:12 -0400 Subject: [PATCH] Add program ('prg') command to reboot the Pi Pico into programming mode without physical access. --- README.md | 1 + prawn_do/prawn_do.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9414e75..19d4ec7 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ These commands must be run when the running status is `STOPPED`. * `clk ` - Sets the system clock and frequency. Maximum frequency allowed is 133 MHz. Default is 100 MHz internal clock. External clock frequency input is GPIO pin 20. * `frq` - Measure and print system frequencies. +* `prg` - Equivalent to disconnecting the Pico, holding down the "bootsel" button, and reconnecting the Pico. Places the Pico into firmware flashing mode; the PrawnDO serial port should disappear and the Pico should mount as a mass storage device. The basis of the functionality for this serial interface was developed by Carter Turnbaugh. diff --git a/prawn_do/prawn_do.c b/prawn_do/prawn_do.c index ad55128..52c0c6f 100644 --- a/prawn_do/prawn_do.c +++ b/prawn_do/prawn_do.c @@ -3,6 +3,7 @@ #include #include #include +#include "pico/bootrom.h" #include "pico/stdio.h" #include "pico/stdlib.h" #include "pico/multicore.h" @@ -13,7 +14,6 @@ #include "hardware/structs/clocks.h" - #include "prawn_do.pio.h" #include "fast_serial.h" @@ -699,6 +699,10 @@ int main(){ else if(strncmp(serial_buf, "frq", 3) == 0) { measure_freqs(); } + // Reboot into programming mode + else if(strncmp(serial_buf, "prg", 3) == 0) { + reset_usb_boot(0, 0); + } else{ fast_serial_printf("Invalid command: %s\r\n", serial_buf); }