Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "soft reboot" command from rshell #187

Open
vvladic opened this issue May 18, 2022 · 6 comments
Open

add "soft reboot" command from rshell #187

vvladic opened this issue May 18, 2022 · 6 comments

Comments

@vvladic
Copy link

vvladic commented May 18, 2022

It would be great if there was a machine.soft_reset() / "Ctrl-D in REPL" command available in rshell... ideally with some shortcut... Ctrl-<some_key>

@vvladic vvladic changed the title "soft reboot" command from rshell required. add "soft reboot" command from rshell May 18, 2022
@dhylands
Copy link
Owner

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.

@vvladic
Copy link
Author

vvladic commented May 18, 2022

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.

@vvladic
Copy link
Author

vvladic commented May 19, 2022

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.

@dhylands
Copy link
Owner

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.

@krytie75
Copy link

krytie75 commented Oct 23, 2022

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~

@dhylands
Copy link
Owner

dhylands commented Oct 26, 2022

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 ~'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants