ESP32 Build - EIO File System Error

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

ESP32 Build - EIO File System Error

Post by devnull » Sun Jun 11, 2017 3:30 am

Have spent all of Saturday and Sunday morning and I am unable to solve this problem.

on OSX, after compiling the ESP32 code, first stage is to erase the flash, second is to flash the firmware, both stages complete without errors.

I have tried several different branches, and also re-cloned xtensa, esp-idf and micropython-esp32 several times the result is always the same.

The esp-idf hash is correct and there are no warnings or errors during the build, the pre-compiled file is identical in size to my compiled file 995792 bytes:

The pre-compiled file ( esp32-20170610-v1.8.7-964-g62d40e8b.bin ) does not have this boot error.

Code: Select all

ls -all
-rwxrwxrwx@ 1 xxx  staff  995792 10 чер 11:54 esp32-20170610-v1.8.7-964-g62d40e8b.bin
-rwxrwxrwx  1 xxx  staff  995792 11 чер 11:07 firmware.bin
After flashing (erase and flash) and resetting the device I get the following errors, and the file system is inaccessible.

Code: Select all

Traceback (most recent call last):
Traceback (most recent call last):
  File "_boot.py", line 10, in <module>
  File "inisetup.py", line 28, in setup
  File "inisetup.py", line 6, in check_bootsec
  File "flashbdev.py", line 13, in readblocks
OSError: [Errno 5] EIO
OSError: [Errno 1] EPERM
OSError: [Errno 1] EPERM
MicroPython v1.8.7-964-g62d40e8b on 2017-06-11; ESP32 module with ESP32
Type "help()" for more information.
>>> import os
>>> os.listdir()
[]
>>> import flashbdev
>>> os.VfsFat.mkfs(flashbdev.bdev)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "flashbdev.py", line 18, in writeblocks
OSError: [Errno 5] EIO
>>> 
I have rebuild the entire build folders probably 4 or 5 times and run several different commits, the result is always the same.

As you can see from the listdir() there are no files or folders, attempting to format the file system results in EIO error.

Any suggestions on what the problem may be as I am at a loss now and run out of ideas :-(

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

Re: ESP32 Build - EIO File System Error

Post by Roberthh » Sun Jun 11, 2017 7:53 am

Which kind of board are you using? At the first boot, a file system is created with a fixed size of 2 MByte. Maybe that does not meet your board's memory size, although I think the minimum available flash size is 4 MByte, which should be fine then.
or something else does not meet the assumptions of the build, like flash programming mode, etc..

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: ESP32 Build - EIO File System Error

Post by devnull » Sun Jun 11, 2017 8:25 am

Hi Robert;

I am using both ESP32-Thing and ESP-WROOM Boards.

The pre-compiled binary load just fine, there's no error when loading that during boot, it is only with the firmware I compiled.

I use the exact same settings for flashing the pre-compiled and my builds, it is very strange as the file sizes of the 2 files is identical, yest it appears that something related to the file system is wrong, I am using the standard makefile.

No problem whatsoever with the esp8266 compile / build / flash, it is only the ESP-32 !

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

Re: ESP32 Build - EIO File System Error

Post by Roberthh » Sun Jun 11, 2017 12:03 pm

I just tried to rebuild a firmware myself, with the matching has code version, and ran into compile errors.- I then recalled that after checking out a certain version, you have to issue "git submodule update --init".
I'm also using a version of flashbdev.py similar to the esp8266 version. It goes as:

Code: Select all

import esp
_HEADROOM = const(0) # not clear whether that is needed

class FlashBdev:

    SEC_SIZE = 4096
    START_SEC = esp.flash_user_start() // SEC_SIZE

    def __init__(self, blocks = 256):
        self.blocks = blocks

    def readblocks(self, n, buf):
        #print("readblocks(%s, %x(%d))" % (n, id(buf), len(buf)))
        esp.flash_read((n + self.START_SEC) * self.SEC_SIZE, buf)

    def writeblocks(self, n, buf):
        #print("writeblocks(%s, %x(%d))" % (n, id(buf), len(buf)))
        #assert len(buf) <= self.SEC_SIZE, len(buf)
        esp.flash_erase(n + self.START_SEC)
        esp.flash_write((n + self.START_SEC) * self.SEC_SIZE, buf)

    def ioctl(self, op, arg):
        #print("ioctl(%d, %r)" % (op, arg))
        if op == 4:  # BP_IOCTL_SEC_COUNT
            return self.blocks
        if op == 5:  # BP_IOCTL_SEC_SIZE
            return self.SEC_SIZE

size = esp.flash_size() 
if size < 1024*1024:
    # flash too small for a filesystem
    bdev = None
else:
    # Use the available space for the filesystem
    bdev = FlashBdev((size - _HEADROOM) // FlashBdev.SEC_SIZE - FlashBdev.START_SEC)
But I have my doubts if that makes a difference.

Post Reply