Lolin32 lite crash FAT filesystem

reynum
Posts: 2
Joined: Wed May 30, 2018 6:58 pm

Lolin32 lite crash FAT filesystem

Postby reynum » Wed May 30, 2018 7:30 pm

Hello,

I have a mistake with my lolin32 lite with micropython.
My esp32 is :
esptool chip_id
esptool.py v2.1
Connecting....
Detecting chip type... ESP32
Chip is ESP32D0WDQ6 (revision 1)
Enabling default SPI flash mode...
Chip ID: 0xd630aea43915
With rshell I load a little python program to control a stepper motor.

Code: Select all

import machine
import utime

MICROSTEP_RESOLUTION = {
    'FULL': (1, (0, 0, 0)),
    'HALF': (2, (1, 0, 0)),
    'QUARTER': (4, (0, 1, 0)),
    'EIGHTH': (8, (1, 1, 0)),
    'SIXTEENTH': (16, (1, 1, 1)),
}

def one_step(val):
    step.value(0)
    utime.sleep_us(1)
    step.value(1)

def set_resolution(msx):
    ms1.value(msx[0])
    ms2.value(msx[1])
    ms3.value(msx[2])

def change_way(val):
    print("value ", val.value())
    if val.value() == 0:
        direction.value(not direction.value())

step = machine.Pin(19, machine.Pin.OUT, machine.Pin.PULL_UP)
ms3 = machine.Pin(5, machine.Pin.OUT, machine.Pin.PULL_UP)
ms2 = machine.Pin(17, machine.Pin.OUT, machine.Pin.PULL_UP)
ms1 = machine.Pin(16, machine.Pin.OUT, machine.Pin.PULL_UP)
enable = machine.Pin(4, machine.Pin.OUT, machine.Pin.PULL_UP)
com = machine.Pin(2, machine.Pin.OUT, machine.Pin.PULL_UP)
direction = machine.Pin(22, machine.Pin.OUT, machine.Pin.PULL_UP)
fermeture = machine.Pin(15, machine.Pin.IN, machine.Pin.PULL_UP)

resolution = "SIXTEENTH"
set_resolution(MICROSTEP_RESOLUTION[resolution][1])
tick_number = 200 * MICROSTEP_RESOLUTION[resolution][0]
enable.value(0)
time = 5
sleep_time = time * 1000000 / tick_number
print(sleep_time)

fermeture.value(0)
fermeture.irq(handler=change_way, trigger=machine.Pin.IRQ_FALLING)
direction.value(1)
timer = machine.Timer(4)
timer.init(
    period=int(sleep_time / 1000),
    mode=machine.Timer.PERIODIC,
    callback=one_step)

while True:
    pass
It works a few time and stop !
Since I can't connect with rshell, it stay like :
rshell --buffer-size=30 -p /dev/ttyUSB0
Connecting to /dev/ttyUSB0 ...
And nothing next.
I try to erase the flash with a file contains 4MB of 0xFF and then load the last stable micropython firmware :
esptool --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-20180511-v1.9.4.bin
esptool.py v2.1
Connecting.....
Chip is ESP32D0WDQ6 (revision 1)
Enabling default SPI flash mode...
Configuring flash size...
Auto-detected Flash size: 4MB
Erasing flash...
Compressed 982832 bytes to 609724...
Took 2.43s to erase flash block
Wrote 982832 bytes (609724 compressed) at 0x00001000 in 62.0 seconds (effective 126.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...
The flashing works be still impossible to connect to the board
I try to observe what happen on the USB and there is a message which coming periodicaly
minicom -D /dev/ttyUSB0
FAT filesystem appears to be corrupted. If you had important data there, you
may want to make a flash snapshot to try to recover it. Otherwise, perform
factory reprogramming of MicroPython firmware (completely erase flash, followed
by firmware programming).
But I already do that and it doesn't work.
Do you have any idea :?:

reynum
Posts: 2
Joined: Wed May 30, 2018 6:58 pm

Re: Lolin32 lite crash FAT filesystem

Postby reynum » Thu May 31, 2018 4:54 pm

I find the mistake, the file I create to erase the flash was 4KB and Not 4MB
So now my question is more a tutorial to erase the flash :lol:

So to finish here is the command to create the 4MB file:
dd if=/dev/zero ibs=1M count=4 | tr "\000" "\377" > paddedFile.bin
And the command to erase the flash:
esptool --chip esp32 --port /dev/ttyUSB0 write_flash 0x0 paddedFile.bin

Who is online

Users browsing this forum: No registered users and 121 guests