MAIN.PY Runs With CTL-D but Not Power Off/On #10884
-
I am testing the passing of a GLOBAL variable between BOOT and MAIN. The programs are:
and
When I issue a CTL-D I get
TEST.TXT shows BOOT.PY When I disconnect and reconnect the USB power, all I see in TEST.TXT is BOOT.PY What am I doing wrong? I want MAIN.PY to run all the time |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Try the same two tests with nothing in boot.py and only a `print('success') in main.py The other thing to be aware of different things happen doing a CTRL-C, machine.reset() or a poweron reset (enable or boot buttons). I am not familiar with the Pico. Are you using an IDE? |
Beta Was this translation helpful? Give feedback.
-
As per @davefes suggestion I simplified my BOOT and MAIN and did some additional testing. I discovered the issues were:
Here's what I found:
The RESET & SOFT_RESET machine calls were issued from the Micropython Interpreter shell in Thonny for the test. According to HELP(MACHINE) 1 is PWRON_RESET; 3 is WDT_RESET. Not sure why 3 is the reason for both REST and SOFT_RESET on the PICO. Still confused why RESET and SOFT_RESET return the same reset cause and one runs main and the other doesn't. May be when Thonny takes/relinquishes control. Still confusing to me. |
Beta Was this translation helpful? Give feedback.
-
I vaguely recall some recent threads on Thonny and Pico. Have you checked issues on the Thonny website? |
Beta Was this translation helpful? Give feedback.
-
@karfas put me onto trying to isolate the problem, so I took Thonny out of the equation. I set BOOT and MAIN to run autonomously, from a power cycle, through reset and soft_reset by passing the next reset type in a file. {I had to replace indent spaces with '.' for readability}
and
The resulting 'test.txt shows that the PICO W running Micropython standalone, without a connection to Thonny runs properly.
I have a post open in the Thonny Forum I will link to this. Thanks all for the guidance. |
Beta Was this translation helpful? Give feedback.
@karfas put me onto trying to isolate the problem, so I took Thonny out of the equation. I set BOOT and MAIN to run autonomously, from a power cycle, through reset and soft_reset by passing the next reset type in a file.
{I had to replace indent spaces with '.' for readability}
and