Skip to content

Commit 6245d9d

Browse files
committed
Add program ('prg') command to reboot the Pi Pico into programming mode without physical access.
1 parent aea505b commit 6245d9d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ These commands must be run when the running status is `STOPPED`.
8181

8282
* `clk <src (0: internal, 1: external)> <freq (in decimal Hz)>` - 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.
8383
* `frq` - Measure and print system frequencies.
84+
* `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.
8485

8586
The basis of the functionality for this serial interface was developed by Carter Turnbaugh.
8687

prawn_do/prawn_do.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <string.h>
44
#include <math.h>
55
#include <stdint.h>
6+
#include "pico/bootrom.h"
67
#include "pico/stdio.h"
78
#include "pico/stdlib.h"
89
#include "pico/multicore.h"
@@ -13,7 +14,6 @@
1314
#include "hardware/structs/clocks.h"
1415

1516

16-
1717
#include "prawn_do.pio.h"
1818
#include "fast_serial.h"
1919

@@ -699,6 +699,10 @@ int main(){
699699
else if(strncmp(serial_buf, "frq", 3) == 0) {
700700
measure_freqs();
701701
}
702+
// Reboot into programming mode
703+
else if(strncmp(serial_buf, "prg", 3) == 0) {
704+
reset_usb_boot(0, 0);
705+
}
702706
else{
703707
fast_serial_printf("Invalid command: %s\r\n", serial_buf);
704708
}

0 commit comments

Comments
 (0)