ESP8266 Write Error

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
jdownie
Posts: 4
Joined: Thu Jul 30, 2020 9:37 pm

ESP8266 Write Error

Post by jdownie » Sun Aug 02, 2020 8:05 am

TLDR: I get an error when I try to write to the local filesystem in MicroPython. I get the error 'OSError: [Errno 19] ENODEV'

The long version...

I downloaded esp8266-20200421-v1.12-388-g388d419ba.bin from https://micropython.org/download/all/. I then connected my esp8266 using this adaptor...

https://photos.app.goo.gl/pdFszF9zVVxFwU957

I have the jumper connected underneath to switch the esp8266 into flashing mode...

https://photos.app.goo.gl/76kywAjra4gBDTBY7

I used esptool.py to first erase the flash...

Code: Select all

$ esptool.py --chip esp8266 erase_flash
Found 1 serial ports
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: ec:fa:bc:5e:50:2f
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 0.0s
Hard resetting via RTS pin...
I removed my esp8266 and reconnected it again (that seems to avoid errors on the subsequent operation)...

Code: Select all

$ esptool.py --chip esp8266 --port /dev/ttyUSB0 --baud 115200 write_flash --flash_size=detect 0 esp8266-20200421-v1.12-388-g388d419ba.bin
esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: ec:fa:bc:5e:50:2f
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Compressed 616424 bytes to 406806...
Wrote 616424 bytes (406806 compressed) at 0x00001000 in 44.3 seconds (effective 111.4 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Now that the bin file had presumably been flashed onto the esp8266 I unplugged it, removed the jumper and re-connected it again. I then opened a serial console to the esp8266 with...

Code: Select all

$ minicom -D /dev/ttyUSB0
From that ">>>" python prompt I attempt to open a file for writing, and get...

Code: Select all

>>> fout = open("/test", "wt")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 19] ENODEV
>>> 
For the flashing step i've also attempted adding the switch '-fm dio' (on advice from https://docs.micropython.org/en/latest/ ... intro.html).

Code: Select all

$ esptool.py --chip esp8266 --port /dev/ttyUSB0 --baud 115200 write_flash --flash_size=detect -fm dio 0 esp8266-20200421-v1.12-388-g388d419ba.bin
...with no change.

Am I doing something dumb?

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

Re: ESP8266 Write Error

Post by Roberthh » Sun Aug 02, 2020 8:25 am

All is fine. The error comes up because the file main.py does not exist. Once you create one, even empty, the error is gone.

jdownie
Posts: 4
Joined: Thu Jul 30, 2020 9:37 pm

Re: ESP8266 Write Error

Post by jdownie » Sun Aug 02, 2020 9:44 am

Really? I tried making that file too and got this...

Code: Select all

>>> fout = open("/main.py", "wt")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 19] ENODEV
>>> 
Is that what you mean?

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

Re: ESP8266 Write Error

Post by Roberthh » Sun Aug 02, 2020 9:56 am

Sorry. I did not look at the details of your log. You seem to use a 1M flash device. Then you have to use the images for that flash size. If the flash size is larger, try to specify that during flash.

Edit: The "main.py" file missing is also a common hiccup. Should be cleaned sometimes.

jdownie
Posts: 4
Joined: Thu Jul 30, 2020 9:37 pm

Re: ESP8266 Write Error

Post by jdownie » Sun Aug 02, 2020 10:07 am

Thanks for taking another look for me. you're right, my esp8266 only has 1m or flash.

The image that I have been using seems to be well below 1M...

Code: Select all

$ ls -lh esp8266-20200421-v1.12-388-g388d419ba.bin 
-rw-rw-r--. 1 jdownie jdownie 602K Jul 30 19:30 esp8266-20200421-v1.12-388-g388d419ba.bin
I'll look around for some other images that be more suitable.

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

Re: ESP8266 Write Error

Post by Roberthh » Sun Aug 02, 2020 10:08 am

This is the place to go for: http://micropython.org/download/esp8266/
You can safely use the recent daily builds. They are well tested and work fine.

jdownie
Posts: 4
Joined: Thu Jul 30, 2020 9:37 pm

Re: ESP8266 Write Error

Post by jdownie » Sun Aug 02, 2020 10:21 am

You're the best! That worked. I'm back on track. Thanks so much for taking the time to help me.

Post Reply