Open vvladic opened 2 years ago
You can do this by using the repl
command to enter the REPL and then typing Control-D. This is why the REPL uses Control-X (rather than Control-D) to exit the repl and go back to the regular command mode.
Thank you for your quick answer. I know, I just thought it would be very convenient to be able to do this without entering REPL. On my ESP32, I can also press reset button, or do what you said, and it works. On RP2 Pico, there is no reset button, and if I try to enter REPL while Pico is printing something to it, everything just freezes, and I have to power cycle the board to reset the serial port. This is on Win10... I can try it on Linux later, maybe there it will work better.
Same thing on Ubuntu. If the current thread on Pico is "blocking" REPL, you can only interrupt it if your first character is Ctrl-C, every other key or key combination just causes it to freeze, after which even Ctrl-C does not work any more. This is not the case on ESP32.
Anytime that rshell sends a command to the microcontroller, the microcontroller goes through a soft-reboot process.
So even a simple ls
command cause the microcontroller to go through at least one soft-reboot cycle.
If Control-C doesn't work, then a soft reboot won't work either.
The way rshell works is that for every command that needs to get information to/from the microcontroller it goes through a process of entering and exiting the raw repl, which involves sending a Control-C then a Control-A to enter the raw repl, then a Control-D to do a soft-reset, then it sends the command it wants to execute and finally a Control-B to exit the raw repl.
The act of starting rshell requires sending at least 6 different commands to establish communications with the board, so by the time you get to the rshell prompt, the board will have gone through 6 soft-reboots.
You can do this by using the
repl
command to enter the REPL and then typing Control-D
I'm trying to update the code on a Pico via rshell in a bash script (the Pico and host are remote), so I can't send Control-D. I've tried sending dummy ls commands, as well as entering and immediately exiting the repl but the Pico is not resetting. Have I misunderstood?
Example:
rshell cp main.py /pyboard/main.py rshell repl~
Hmm. I think the problem is that when rshell does a soft-reboot it's doing it with the raw-repl, and when that happens micropython doesn't run main.py
If you create a file called reset.py with the following contents:
import machine
machine.reset()
Then you could do: rshell 'cp main.py reset.py /pyboard/; repl ~ import reset ~'
It would be great if there was a machine.soft_reset() / "Ctrl-D in REPL" command available in rshell... ideally with some shortcut... Ctrl-