why os.listdir return ENODEV

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: why os.listdir return ENODEV

Post by deshipu » Thu Jul 28, 2016 8:59 pm

Those instructions exist at http://docs.micropython.org/en/latest/e ... e-firmware

Perhaps it would be good to link to them from the firmware download page, though.

User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Re: why os.listdir return ENODEV

Post by mcauser » Mon Aug 08, 2016 1:57 am

One part I found a little confusing. In the Makefile there is an esptool.py attribute --flash_size=8m.
If I have a board with 4MB flash, should I change this to --flash_size=32m?

I am still seeing the error when trying to build and upload the latest version to a WeMos D1 Mini on OSX 10.10.5:
If I flash a precompiled binary, downloaded from the website, it works fine.

Code: Select all

make clean
make axtls
make PORT=/dev/tty.wchusbserial1420 deploy
It uploads successfully and verifies with OK, but when I run the following, I see the error 19.

Code: Select all

could not find module '_boot.py'
could not open file 'boot.py' for reading
could not open file 'main.py' for reading
MicroPython v1.8.2-118-g3e5534c on 2016-08-08; ESP module with ESP8266
>>> import uos
>>> uos.listdir()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 19] ENODEV
Tried pfalcon's firmware check, returned true.

Code: Select all

>>> import esp
>>> esp.check_fw()
size: 544412
md5: 5e00d49b9bb220e5f89c9c51f4dc6cb7
True

User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Re: why os.listdir return ENODEV

Post by mcauser » Mon Aug 08, 2016 2:58 am

Compiled vs precompiled v1.8.2-118-g3e5534c

Compiled is not working for me. :(

Code: Select all

esptool.py -p /dev/tty.wchusbserial1420 erase_flash
make clean && make axtls
make PORT=/dev/tty.wchusbserial1420 deploy
screen /dev/tty.wchusbserial1420 115200

Code: Select all

oom 16
tail 4
chksum 0x8e
load 0x3ffe8000, len 1060, room 4
PYB: soft reboot
#5 ets_task(40100390, 3, 3fff6300, 4)
could not find module '_boot.py'
could not open file 'boot.py' for reading
could not open file 'main.py' for reading
MicroPython v1.8.2-118-g3e5534c on 2016-08-08; ESP module with ESP8266
Type "help()" for more information.
>>> import uos
>>> uos.listdir()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 19] ENODEV
Precompiled binaries downloaded from micropython.org are working for me :D

Code: Select all

wget http://micropython.org/resources/firmware/esp8266-20160808-v1.8.2-118-g3e5534c.bin
esptool.py -p /dev/tty.wchusbserial1420 erase_flash
esptool.py -p /dev/tty.wchusbserial1420 write_flash -fm dio -fs 32m 0 esp8266-20160808-v1.8.2-118-g3e5534c.bin
screen /dev/tty.wchusbserial1420 115200

Code: Select all

oom 16
tail 4
chksum 0x43
load 0x3ffe8000, len 1060, room 4
PYB: soft reboot
#6 ets_task(40100390, 3, 3fff6300, 4)
could not open file 'main.py' for reading
MicroPython v1.8.2-118-g3e5534c on 2016-08-08; ESP module with ESP8266
Type "help()" for more information.
>>> import uos
>>> uos.listdir()
['boot.py']
Here is the output of my make clean, make axtls and make deploy:
https://gist.github.com/mcauser/b837dae ... c51a28f666

jms
Posts: 108
Joined: Thu May 05, 2016 8:29 pm
Contact:

Re: why os.listdir return ENODEV

Post by jms » Mon Aug 08, 2016 1:20 pm

It would be great, no I mean it is absolutely necessary that people and software use correct letters and terminology.

m for milli
M for mega
b for bits
B for bytes

esptool should also complain loudly when given a file that is larger than the size of the device it thinks it is programming then we wouldn't keep having these unnecessary problems.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: why os.listdir return ENODEV

Post by deshipu » Mon Aug 08, 2016 1:48 pm

jms wrote:esptool should also complain loudly when given a file that is larger than the size of the device it thinks it is programming
The problem is that it has no idea at the time it starts programming about the size of the flash on the device.

jms
Posts: 108
Joined: Thu May 05, 2016 8:29 pm
Contact:

Re: why os.listdir return ENODEV

Post by jms » Mon Aug 08, 2016 1:56 pm

deshipu wrote:
jms wrote:esptool should also complain loudly when given a file that is larger than the size of the device it thinks it is programming
The problem is that it has no idea at the time it starts programming about the size of the flash on the device.
yet the explanation given several times all over this forum is that people should have given the size option. The exact size doesn't matter does it ? As long as it is large enough.

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

Re: why os.listdir return ENODEV

Post by pfalcon » Tue Aug 09, 2016 6:46 pm

mcauser wrote:One part I found a little confusing. In the Makefile there is an esptool.py attribute --flash_size=8m.
If I have a board with 4MB flash, should I change this to --flash_size=32m?
No, you don't have to. MicroPython has flash auto-detection code which will "resize" to the actual size. The only requirement is that Espressif SDK didn't corrupt MicroPython firmware. For this, you need to use (at least) --flash_size=8m.

Also, read updated flashing instructions: http://docs.micropython.org/en/latest/e ... html#intro
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/

flegarrec
Posts: 2
Joined: Mon Oct 09, 2017 9:34 am

Re: why os.listdir return ENODEV

Post by flegarrec » Mon Oct 09, 2017 10:01 am

Hello, i am quite new to ESP8266 and i face the os.listdir() problem generating pages of \x00 on my ESP12F

[code]
>>> import os
>>> os.listdir()
['\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00', '\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00', '\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00', '\x00\x00\x00\x00\x00\x00\x00\x00.\x00\]
[/code]

I understand it comes from filesystem being corrupted.

I get this despite doing all combinations of those this week-end:
- I always erase flash first. I even tried to do it with --baud 115200 instead of default (i.e. no speed provided in command line)
- After erase, i always remove power and put it back to ensure clean start.
- I tried flashing several non-OTA versions. I did it also at a speed of 115200 and 460800.
- I used flash size of 'detect', '4MB' and even '32m', even if i understand that latest esptool should be fine with 'detect'.
- I used the '--verify' flag when flashing, concluding ok
- I tried with and without '-fm dio' (i understood that i should have to use it on ESP12F)
- After flashing, i always remove power and put it back to ensure clean start.
- Once flashing is over, i use the esp.check_fw() and it returns ok

And i did all those first with Python 3 and latest esptool, and with Python 2.7 and esptool 1.0.1. Just in case. BTW, the erase flash time with esptool 1.0.1 is suspiciously super fast. So i will return to Python 3 later on.

I even tried flashing the binary image with the nodeMCU flasher.

But, i get the \x00 always. Right now, i am pulling my hair frenetically... :cry:

I power from USB port of my lenovo laptop (same i use to power my arduino and raspberry pi). I use a LD1117 voltage regulator to generate the 3.3V from USB. I also tried from an external powerbank, but does not change anything. And the ESP works fine when flashing the Arduino IDE example of the basic webserver, attaching to my wifi router. So i consider it is not defective.

My last hope next week-end is to try this (i.e. formatting it after flashing) that i found this morning:
viewtopic.php?f=16&t=3102&p=18335&hilit=listdir#p18335

Anybody has a clue?

Thx.

flegarrec
Posts: 2
Joined: Mon Oct 09, 2017 9:34 am

Re: why os.listdir return ENODEV

Post by flegarrec » Sat Oct 14, 2017 2:36 pm

So, the filesystem format i found in the post mentionned above did not work:

[code]
import os
import flashbdev
os.VfsFat.mkfs(flashbdev.bdev)
[/code]

But, this one found via googeling on VfsFat worked!

[code]
import uos
import flashbdev
uos.VfsFat.mkfs(flashbdev.bdev)
[/code]

i don't know why.
But, now i have something clean:
[code]
>>> os.listdir()
[]
>>>
[/code]

houra :P

Post Reply