ampy not working after main.py is uploaded

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
MicroNinja
Posts: 16
Joined: Sun Dec 29, 2019 8:38 am

ampy not working after main.py is uploaded

Post by MicroNinja » Thu Apr 09, 2020 6:33 pm

I have uploaded a main.py file. Whenever I press the reset button the the code is run again. But I cannot make any changes since the unit is busy
ampy <any commands>

Code: Select all

serial.serialutil.SerialException: GetOverlappedResult failed (PermissionError(13, 'Access is denied.', None, 5))
So far I have to flash the unit to reset it to be able to upload a new main.py file. Is this expected or how can I work with micropython more seamless with the board?

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: ampy not working after main.py is uploaded

Post by bitninja » Fri Apr 10, 2020 12:33 am

Obviously it is something in your main.py that is keeping the microcontroller busy.

Can you post your main.py?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: ampy not working after main.py is uploaded

Post by dhylands » Fri Apr 10, 2020 1:43 am

The error that you're showing means that the HOST serial port couldn't be opened.

So you need to either ensure that your permissions or correct, and/or exit from the terminal emulator that has the serial port open.

As far as I can tell, that particular error has absolutely nothing to do with main.py or anything else on the micropython board.

supersquirel500
Posts: 2
Joined: Fri Apr 10, 2020 3:05 am

Re: ampy not working after main.py is uploaded

Post by supersquirel500 » Fri Apr 10, 2020 3:12 am

dhylands seems to be correct. Might wanna check your user/group permissions for serial connections.

Another tip to try in case it is a problem with the board and not the PC: My ESP32-PICOKITd4 does the same thing when connected to IO (ie UART/SPI). To fix this, I disconnect all pins to the board, hit EN (button to reboot) and run ampy command again. It's always been much more responsive after this.

MicroNinja
Posts: 16
Joined: Sun Dec 29, 2019 8:38 am

Re: ampy not working after main.py is uploaded

Post by MicroNinja » Fri Apr 10, 2020 6:06 am

Thank you guys for the suggestions. I am on a steep learning curve with microcontroller and micropython it seems.
I finally found the error!
I had connected the wire wrong to wake up the unit again so instead everything crashed. Once the wiring was resolved I was able to communicate with ampy again. Is there a way to stop a running script in the repl? If I connect to the unit with putty I cannot do anything. Ctrl + D, Ctrl + C or quit() is not registered at all. The sleep mode is sending it into an infinite loop I cannot stop

Post Reply