main.py does not appear to working after boot

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

Re: main.py does not appear to working after boot

Post by smith.randallscott » Sun Jul 14, 2019 8:59 pm

I created the main.py on the raspberryPI, then transferred it to the esp32 by being already logged into the ESP32, then using the command "cp main.py /pyboard/" each time that I modify main.py I use the same procedure. I edit the file on the Pi and then transfer it to the ESP32 using the cp command.

I am using rshell for the repl.

Thanks for all your help

smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

Re: main.py does not appear to working after boot

Post by smith.randallscott » Tue Jul 16, 2019 1:10 pm

Any thoughts?

kevinkk525
Posts: 469
Joined: Sat Feb 03, 2018 7:02 pm

Re: main.py does not appear to working after boot

Post by kevinkk525 » Tue Jul 16, 2019 1:23 pm

You didn't ask any question so what should we say about it? It's a valid method to update your main.py...

Edit: Ah right, the question is in your title only. Please show the main.py, has it ever worked?

smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

Re: main.py does not appear to working after boot

Post by smith.randallscott » Tue Jul 16, 2019 2:22 pm

Main only executes when I am already logged into the REPL and issue machine.reset() or cmd+D or soft reset. When I do that all works fine. If I power cycle the unit main.py does not execute. I don't know how to further troubleshoot this. Any help would be appreciated.

User avatar
Roberthh
Posts: 1650
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: main.py does not appear to working after boot

Post by Roberthh » Tue Jul 16, 2019 2:33 pm

What happens if you power the device with a simple USB Micro power supply, like a smart phone charger? I expect it to work, because that's what I do sometimes.

User avatar
Roberthh
Posts: 1650
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: main.py does not appear to working after boot

Post by Roberthh » Tue Jul 16, 2019 2:36 pm

It is a little bit strange because that is the code in question:

Code: Select all

    // run boot-up scripts
    pyexec_frozen_module("_boot.py");
    pyexec_file_if_exists("boot.py");
    if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
        pyexec_file_if_exists("main.py");
    }
So there a two reasons why main.py is not executed:
1. It does not exist
2. The device is not in the mode PYEXEC_MODE_FRIENDLY_REPL. That may be cause by a Ctrl-A character sent to the device by the RPi during startup, for whatever reason.

smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

Re: main.py does not appear to working after boot

Post by smith.randallscott » Tue Jul 16, 2019 3:15 pm

How do I get similar with what that code actually means, especially the frozen part? Also main.py is in the root of the file system has far as I can tell.
>>> os.listdir('')
['boot.py', 'main.py']
>>>

User avatar
Roberthh
Posts: 1650
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: main.py does not appear to working after boot

Post by Roberthh » Tue Jul 16, 2019 3:47 pm

The file _boot.py is embedded in the firmware. That's why it is called frozen. If you build your own firmware, you can also embed python scripts into the firmware, at the benefit of faster loading and lower RAM usage.
Did you make the test with a simple USB power supply?

smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

Re: main.py does not appear to working after boot

Post by smith.randallscott » Tue Jul 16, 2019 4:03 pm

No it will be several hours before I can make this test. Thank you for all your help.

smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

Re: main.py does not appear to working after boot

Post by smith.randallscott » Wed Jul 17, 2019 12:30 am

Using a standard power supply (not powering from the Raspberrry Pi) produces the same results, main.py is not executing. Is there another way of troubleshooting this problem? Is there any chance there's something wrong with the ESP32? Beyond setting variables, energizing leds, and print statements, I'm at a loss as the how to trouble shoot it further. Any and all help will be appreciated

Post Reply