Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
theMusicMan
Posts: 23
Joined: Mon Feb 11, 2019 12:16 am

Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

Post by theMusicMan » Wed Feb 13, 2019 12:14 am

Hi All

Ok, so I am messing around having fun with the RPi using it to flash my ESP8266 and ESP32 with MicroPython and have ensured I downloaded and flashed the correct versions for each ESP board. So far I have downloaded esptool and the MicroPython.bin, have successfully erased the default flash file on the ESP8266, and successfully installed [maybe not though!!] the MicroPython .bin file.

I have also successfully installed rshell as per the instructional video I am following.

However, I seem to now be in an infinite wait loop after I type the following commands to launch the rshell

Code: Select all

rshell --buffer-size=30 -p /dev/ttyUSB0
... the terminal is showing

Code: Select all

Testing if ubinascii.unhexlify exists ... 
And is just sat there doing absolutely nothing...!! I have read a fair amount of docs on this, and I have the latest MicroPython version, and latest esptool and rshell commands. I see a command in main.py that has a path for Y and a path for N - but it goes to neither and appears to fail at this statement in main.py.

Code: Select all

unhexlify_exists = self.remote.eval(test_unhexlify)
... as it doesn't print Y or N as per the next line of code after this.

I am at a loss at the moment. Any pointers from any experts please?
Many thanks,
John

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

Re: Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

Post by dhylands » Wed Feb 13, 2019 3:11 am

If you run add -d to rshell it will print out some additional information.

Do you have a main.py that runs somethng? Or does it go right into the REPL?

If you go into the REPL manually (using picocom or similar), and run the following:

Code: Select all

import ubinascii
_ = ubinascii.unhexlify
what do you see?

theMusicMan
Posts: 23
Joined: Mon Feb 11, 2019 12:16 am

Re: Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

Post by theMusicMan » Wed Feb 13, 2019 3:28 am

Thanks for the response Dave.
dhylands wrote:
Wed Feb 13, 2019 3:11 am
If you run add -d to rshell it will print out some additional information.
Here you go for the 1st question... this is what was returned when adding -d

Code: Select all

pi@raspberrypi:~ $ rshell --buffer-size=30 -d -p /dev/ttyUSB0
Debug = True
Port = /dev/ttyUSB0
Baud = 115200
User = micro
Password = python
Wait = 0
List = 0
nocolor = 0
ascii = 0
Timing = 0
Quiet = 0
BUFFER_SIZE = 30
Cmd = []
Using buffer-size of 30
connecting to serial /dev/ttyUSB0
Connecting to /dev/ttyUSB0 (buffer-size 30)...
Testing if ubinascii.unhexlify exists ... ----- About to send 304 bytes of code to the pyboard -----
def test_unhexlify():
    """Checks the micropython firmware to see if ubinascii.unhexlify exists."""
    import ubinascii
    try:
        _ = ubinascii.unhexlify
        return True
    except:
        return False
output = test_unhexlify()
if output is None:
    print("None")
else:
    print(output)

-----
dhylands wrote:
Wed Feb 13, 2019 3:11 am
Do you have a main.py that runs somethng? Or does it go right into the REPL?
The main.py is I believe, part of the rshell code. I only took a look at the contents of this file after seeing the error returned that specifically identifies it.
dhylands wrote:
Wed Feb 13, 2019 3:11 am
If you go into the REPL manually (using picocom or similar), and run the following:

Code: Select all

import ubinascii
_ = ubinascii.unhexlify
what do you see?
This is what I get when I tried to access using picocom. It runs, but then I get scrolling garbage as seen below.

Code: Select all

pi@raspberrypi:~ $ picocom /dev/ttyUSB0
picocom v1.7

port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 9600
parity is      : none
databits are   : 8
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,

Terminal ready
??B?ACМ@???B!h??????%?
                      A y??L??!@6"?H?0ゃ???A??	($F@?A??H?
                                                          N?		?" ?pN??G??H?o H??AG?.??????Hr??$`̸?,2H
C?C??? ?|?B!hR??? !b???Dp?B??8??B8?     ?LUAW?F@?qN??0                                                        ?J??
                                                      ???F?0?IE??,B?Hq?@?B!?
                                                                            d@ ?????H†???
                                                                                         ?@8??B?Hq?D?F@8,$`?<`????DŽ\?A?????? ?DE??? H??"@?f$Y??N\AL0?"?9??B!h?r!W"?qL???8?rA??& œ??????"??B??8p.?? q$	??I?Հ??I?`?
                    ,

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

Re: Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

Post by dhylands » Wed Feb 13, 2019 3:31 am

If you can't get to a regular REPL prompt (i.e. >>>) using a serial program, then rshell definitely won't work, since rshell is basically just acting like a person typing things at the REPL.

You need to resolve getting to REPL before rshell will do anything useful for you.

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

Re: Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

Post by Roberthh » Wed Feb 13, 2019 6:45 am

In the last post the picocom settings again showed a baud rate of 9600 baud. Whatever else is happening, with 9600 baud it will not work. You have to use 115200 baud. Additionally, the firmware is most likely not properly loaded.
The first boot messages of an ESP8266 are sent with 74880 Baud. On a linux device, you cannot set that baud rate. Therefore you wil see garbage at any speed you can set. You may use a Windows computer with Putty, which can be set to 74880 baud.
So, what to do:
- please check again, that you flashed the firmware properly.
- run picocom at 115200 baud.

theMusicMan
Posts: 23
Joined: Mon Feb 11, 2019 12:16 am

Re: Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

Post by theMusicMan » Wed Feb 13, 2019 9:17 am

dhylands wrote:
Wed Feb 13, 2019 3:31 am
If you can't get to a regular REPL prompt (i.e. >>>) using a serial program, then rshell definitely won't work, since rshell is basically just acting like a person typing things at the REPL.

You need to resolve getting to REPL before rshell will do anything useful for you.
Roberthh wrote:
Wed Feb 13, 2019 6:45 am
In the last post the picocom settings again showed a baud rate of 9600 baud. Whatever else is happening, with 9600 baud it will not work. You have to use 115200 baud. Additionally, the firmware is most likely not properly loaded.
The first boot messages of an ESP8266 are sent with 74880 Baud. On a linux device, you cannot set that baud rate. Therefore you wil see garbage at any speed you can set. You may use a Windows computer with Putty, which can be set to 74880 baud.
So, what to do:
- please check again, that you flashed the firmware properly.
- run picocom at 115200 baud.
Many thanks Dave and Robert.

Here's an update, "it works, however there's a... but...."

I managed to get rshell up and running by adding 0x1000 to its launch path, and thus can access the MicroPython REPL. This seems to have half fixed the issue temporarily.

However, ... I can only access rshell and thus REPL on the first instance only after rebooting the RPi3B+. If I exit from REPL, or out of rshell and then relaunch it, I can no longer access it and sadly am faced once again with the "Testing if unbinascii.unhexlify exists..." error.

Really appreciate your help thus far. Hopefully we can continue and get this resolved.

John

theMusicMan
Posts: 23
Joined: Mon Feb 11, 2019 12:16 am

Re: Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

Post by theMusicMan » Wed Feb 13, 2019 10:02 am

UPDATE:

When I press the EN button on the ESP32 board after exiting, it seems to once again allow me to lacuna repl and run python scripts. I thought the serial driver was supposed to handle those type of items...?

Any advice on this?

scruss
Posts: 1
Joined: Sat Aug 12, 2017 2:27 pm

Re: Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

Post by scruss » Wed Feb 13, 2019 5:57 pm

FYI, OP has asked same question here: [url=https://www.raspberrypi.org/forums/view ... 9&t=233367]Flashing MicroPython to ESP8266 using rPi - Testing if ubinascii.unhexlify exists ... - Raspberry Pi Forums[/url]

From what they're posting there it seems that they haven't flashed the MicroPython image correctly.

theMusicMan
Posts: 23
Joined: Mon Feb 11, 2019 12:16 am

Re: Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

Post by theMusicMan » Thu Feb 14, 2019 12:22 pm

scruss wrote:
Wed Feb 13, 2019 5:57 pm
FYI, OP has asked same question here: Flashing MicroPython to ESP8266 using rPi - Testing if ubinascii.unhexlify exists ... - Raspberry Pi Forums

From what they're posting there it seems that they haven't flashed the MicroPython image correctly.
Hs scruss

Yes, asked over there too. The issue with forums is sometimes one asks a question using multiple systems and one never knows where the best place to ask that question is. I have been bitten in the past with such questions, especially when no-one is able to answer as they then blame the other systems etc.

Hasn't happened in this instance, and I have answered your latest question over there. Thanks for the help by the way, really appreciated.

A benefit of course, of asking on multiple associated forums, is that as and when the issue is resolved, many more people benefit from seeing the resolution and its path. :D

theMusicMan
Posts: 23
Joined: Mon Feb 11, 2019 12:16 am

Re: Error when flashing ESP32 - Testing if ubinascii.unhexlify exists ...

Post by theMusicMan » Thu Feb 14, 2019 1:41 pm

Latest update by the way... is that I have managed to successfully flash MicroPython on my new ESP32 board, but both of my ESP8266 boards fail to flash. I have a Wemos D1 Pro board and a ModeMCU board - both of which fail with the above error.

So, this issue remains unresolved for me, so any help / pointers would be most welcome.

Post Reply