Boot problem ? on ESP32 MicroPython

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
ixbo
Posts: 36
Joined: Wed May 04, 2022 11:12 am
Location: France

Boot problem ? on ESP32 MicroPython

Post by ixbo » Fri May 06, 2022 9:43 am

Hello
I use "MakePython ESP32 Development Kit" with Thonny IDE ,I have very much problem... I often must reintroduce the firmware to use it again......

Now my problem...impossible to run a program after a power off. I had not this problem at the beginning , I have done a mistake and I don't know how to repair it

I download a projet in my kit connected to the PC with Thonny , the program run very well ...
I cut the power (disconnect USB) and reconnect the board to the USB (to power the board) ,the programm do not run .....!!
(the program seems not to be registred in the board ? or not reboot ?)

I must sometime for downloading again disconnect all components on the board !!!

Thank you for your help
Best regards

Message I received .....

WARNING:root:Unexpected echo. Expected b'%Run -c $EDITOR_CONTENT\r\n', got b'ets Jun 8 2016 00:22:57\r'

tepalia02
Posts: 99
Joined: Mon Mar 21, 2022 5:13 am

Re: Boot problem ? on ESP32 MicroPython

Post by tepalia02 » Sat May 07, 2022 10:53 am

Hi, have you tested the ESP32 board with any other code? Kindly check if you can upload any other simple code to the ESP-32.

ixbo
Posts: 36
Joined: Wed May 04, 2022 11:12 am
Location: France

Re: Boot problem ? on ESP32 MicroPython

Post by ixbo » Sat May 07, 2022 11:11 am

Thanks very much
Yes if my board is connected i can download my program and run it , if i disconnect the board and reconnect it , the program do not run ....i must redownload it and sometime it' s impossible when components are connected

Why can i not run my program simply without the IDE Thonny , just the board connected to the power ?

Thanks very much

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Boot problem ? on ESP32 MicroPython

Post by davef » Sat May 07, 2022 7:19 pm

Tell us which GPIO ports you have things connected to. Also, which ESP32 board and ESP32 variant.

ixbo
Posts: 36
Joined: Wed May 04, 2022 11:12 am
Location: France

Re: Boot problem ? on ESP32 MicroPython

Post by ixbo » Sun May 08, 2022 9:01 am

Thanks for your help....

I use this board:
https://www.makerfabs.com/makepython-es ... r-kit.html

The main problem is that my program seems not to bee flashed in the board or there is a boot problem
A simple program like this one:

from machine import Pin,Timer

led2 = Pin(2,Pin.OUT)
tim = Timer(0)
led_state =False
def FlashLed(timer):
global led_state
led_state=not led_state
led2.value(led_state)
tim.init(period=1000,mode=Timer.PERIODIC,callback=FlashLed)

This program run well , when downloaded with Thonny....the Led is flasching....
But if i disconnect the board and reconnect to power it , the program do not run , the Led do not flash
I must download again with Thonny to run it again and the Led flash....
I try with uPyVraft but it's the same

What can i do ??
A great thanks for your help
Best regards

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Boot problem ? on ESP32 MicroPython

Post by davef » Sun May 08, 2022 9:54 am

Just posted this on another thread, so maybe try this:
- leave the boot file as is
- in main.py just call your program like:

Code: Select all

import my_program
and
- have the all the code you want to run in my_program.py

As an aid for debugging in main place at the top (first thing that gets executed) :

Code: Select all

print ('Hit CTRL-C to edit')
utime.sleep(5)
so that you can break into my_program.py and make changes.

ixbo
Posts: 36
Joined: Wed May 04, 2022 11:12 am
Location: France

Re: Boot problem ? on ESP32 MicroPython

Post by ixbo » Mon May 09, 2022 7:48 am

Thanks for your help.....
But I don't anderstand what you have discribed ....
The only file on my board is "Boot.py" ,no directory

and as you can see there is no code in Boot.py:
Boot.py content this code
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl
#webrepl.start()

Always very happy for your precious help
best regards

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Boot problem ? on ESP32 MicroPython

Post by davef » Mon May 09, 2022 8:39 am

Where are you placing your "blinking LED" program? Or what do you call the file that has the blinking LED code in it?
Last edited by davef on Mon May 09, 2022 8:51 am, edited 1 time in total.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Boot problem ? on ESP32 MicroPython

Post by davef » Mon May 09, 2022 8:50 am

I have not used Thonny. Are you sure that the program has actually been downloaded to the flash on the ESP32?

Do you run Linux or Windows?

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Boot problem ? on ESP32 MicroPython

Post by davef » Mon May 09, 2022 8:59 am

1) leave boot.py as it is
2) in main.py place:

Code: Select all

import my_Led
3) in a file called my_Led.py place:

Code: Select all

import machine
from machine import Pin

pin2 = Pin(2, Pin.OUT)

while True:

 #  heartbeat
    pin2.on()
    utime.sleep_ms(150)
    pin2.off()
    utime.sleep_ms(150)
    pin2.on()
    utime.sleep_ms(150)
    pin2.off()

    print ('another loop')
4) download main.py and my_Led.py to the ESP32
Unplug the USB and hit the EN (reset)button.

Be aware some ESP32 boards use GPIO2 to turn on a on-board LED. You might want to use another pin like 33.

Post Reply