software rest from python code vs CRTL-D

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

software rest from python code vs CRTL-D

Post by OutoftheBOTS_ » Sun Jan 23, 2022 1:26 am

so when I press CRTL-D in repl it software resets then runs boot.py then main.py but nicely maintains USB and network connections.

When I run machine.soft_reset() in my python code it resets then runs boot.py but doesn't run main.py. It also nicely maintains USB and network connections

boot.py has network connection and starts webrepl then main.py just has print("Shane makes his mark")

Here's my repl output on CTRL-D

Code: Select all

MPY: soft reboot
trying to connect to WiFi
('192.168.0.146', '255.255.255.0', '192.168.0.1', '192.168.0.1')
WebREPL daemon started on ws://192.168.0.146:8266
Started webrepl in normal mode
Shane makes his mark
MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32
Type "help()" for more information.
This is my output from machine.soft_reset()

Code: Select all

MPY: soft reboot
trying to connect to WiFi
('192.168.0.146', '255.255.255.0', '192.168.0.1', '192.168.0.1')
WebREPL daemon started on ws://192.168.0.146:8266
Started webrepl in normal mode

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: software rest from python code vs CRTL-D

Post by OutoftheBOTS_ » Sun Jan 23, 2022 1:33 am

OK a little more info here. It seems that if the machine.soft_reset is executed from main.py then when it resets it runs main.py but if it is executed from another script then it doesn't run main.py

marcidy
Posts: 133
Joined: Sat Dec 12, 2020 11:07 pm

Re: software rest from python code vs CRTL-D

Post by marcidy » Sun Jan 23, 2022 7:54 pm

this explanation may help:

viewtopic.php?f=18&t=10201&p=56672&hili ... set#p56672

Basically if you run anything that will call soft_reset, it should be from main.py. boot.py should be for initialization only.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: software rest from python code vs CRTL-D

Post by OutoftheBOTS_ » Sun Jan 23, 2022 8:52 pm

I wasn't calling machine.soft_reset() from boot.py but rather calling it from another script called line.py but the easy work around that I found was that main.py would just have the line from line import * then when line.py executed machine.soft_reset() it reset and run both boot.py and main.py

basically I wanted to be able to update line.py on my computer and send it to the board via webrepl then when line.py detected the boot button pressed it would call machine.soft_reset then rerun the new updated line.py

It would be nice if I could just hit CRTL-C then CRTL-D in the webrepl and it would reboot but at the moment I can't get webrepl to work it can only upload or download files but not use repl

Post Reply