SyntaxError at boot with esp8266-20160809-v1.8.3.bin

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
humungus
Posts: 2
Joined: Sun Aug 28, 2016 8:13 pm

SyntaxError at boot with esp8266-20160809-v1.8.3.bin

Post by humungus » Sun Aug 28, 2016 8:37 pm

Hi,

I flashed esp8266-20160809-v1.8.3.bin to my esp8266-01.
When I boot the esp8266 now I get an error (full output below):
Traceback (most recent call last):
File "boot.py", line 5, in <module>
File "webrepl.py", line 6, in <module>
File "websocket_helper.py", line 1
SyntaxError: invalid syntax

Can somebody please tell me what the problem is? A syntax-error in boot.py?
I just flashed the .bin-file. I used the --verify-option and got an OK.
It seems I cannot use machine.xxx objects. Webrepl seems not to be working too.

I executed
>>> esp.check_fw()
size: 558748
md5: 66cd5e59c4f2236a5bc3b7c97789adc3
False

That function unfortunately is not documented in https://docs.micropython.org/en/latest/ ... y/esp.html but 'False' is probably bad?

Thank you!

Output at boot:
�������������������������������������������������������������
�������������������������������������������������������������
�������������������������������������������������������������
�������������������������������������������������������������
�������������������������������������������������������������
�������������������������������������������������������������
�������������������������������������������������������������
�������������������������������������������������������������
�������������������������������������������������������������
�������������������������������������������������������������
������������������������������������������l)
h, v = [x.strip() for x in l.split(b":", 1)]
if DEBUG:
print((h, v))
if h == b'Sec-WebSocket-Key':
webkey = v

if not webkey:
raise OSError("Not a websocket request")

if DEBUG:
print("Sec-WebSocket-Key:", webkey, len(webkey))

d = hashlib.sha1(webkey)
d.update(b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11")
respkey = d.digest()
respkey = binascii.b2a_base64(respkey)[:-1]
if DEBUG:
print("respkey:", respkey)

sock.send(b"""\
HTTP/1.1 101 Switching Protocols\r
Upgrade: websocket\r
Connection: Upgrade\r
Sec-WebSocket-Accept: """)
sock.send(respkey)
sock.send("\r\n\r\n")


# Very simplified client handshake, works for MicroPython's
# websocket server implementation, but probably not for other
# servers.
def client_handshake(sock):
cl = sock.makefile("rwb", 0)
cl.write(b"""\
GET / HTTP/1.1\r
Host: echo.websocket.org\r
Connection: Upgrade\r
Upgrade: websocket\r
Sec-WebSocket-Key: foo\r
\r
""")
l = cl.readline()
# print(l)
while 1:
l = cl.readline()
if l == b"\r\n":
break
# sys.stdout.write(l)
Traceback (most recent call last):
File "boot.py", line 5, in <module>
File "webrepl.py", line 6, in <module>
File "websocket_helper.py", line 1
SyntaxError: invalid syntax
could not open file 'main.py' for reading

MicroPython v1.8.3-10-g2401581 on 2016-08-09; ESP module with ESP8266
Type "help()" for more information.
>>>

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: SyntaxError at boot with esp8266-20160809-v1.8.3.bin

Post by pythoncoder » Mon Aug 29, 2016 9:01 am

False is indeed bad and indicates that the firmware image is invalid. Does your device have sufficient flash to accommodate it?
Peter Hinch
Index to my micropython libraries.

Beta_Ravener
Posts: 35
Joined: Tue Aug 09, 2016 6:56 pm

Re: SyntaxError at boot with esp8266-20160809-v1.8.3.bin

Post by Beta_Ravener » Mon Aug 29, 2016 10:28 am

I had the same error when I switched from some older version of 1.8.2 to 1.8.3. I was also using something different at that time, not esptool. Cleaning flash and flashing the image with esptool solved the problem for me, so try running these 2 commands first (and replace the name of the image if needed):

Code: Select all

esptool.py --port COM3 erase_flash
esptool.py --port COM3 --baud 460800 write_flash --flash_size=8m 0 esp8266-20160809-v1.8.3-release.bin

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: SyntaxError at boot with esp8266-20160809-v1.8.3.bin

Post by pfalcon » Mon Aug 29, 2016 11:21 am

That function unfortunately is not documented in https://docs.micropython.org/en/latest/ ... y/esp.html but 'False' is probably bad?
Fortunately, everything is documented in troubleshooting section: http://docs.micropython.org/en/latest/e ... n-problems
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

humungus
Posts: 2
Joined: Sun Aug 28, 2016 8:13 pm

Re: SyntaxError at boot with esp8266-20160809-v1.8.3.bin

Post by humungus » Mon Aug 29, 2016 6:55 pm

My ESP8266 should have 512KB. The 1.8.3.bin-file has 558,8KB, so maybe it is to large.
I now flashed 1.8.2.bin which is 507,6KB. It seems to be working so far... :)

Post Reply