8000 Add MSC support for ESP32 S3 by M-D-777 · Pull Request #8699 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Add MSC support for ESP32 S3 #8699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ports/esp32/boards/GENERIC_S2/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include("$(PORT_DIR)/boards/manifest.py")
freeze("modules")
13 changes: 13 additions & 0 deletions ports/esp32/boards/GENERIC_S2/modules/_boot_fat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import gc
import uos
from flashbdev import bdev

try:
if bdev:
uos.mount(bdev, "/")
except OSError:
import inisetup_fat

vfs = inisetup_fat.setup()

gc.collect()
49 changes: 49 additions & 0 deletions ports/esp32/boards/GENERIC_S2/modules/inisetup_fat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import uos
from flashbdev import bdev


def check_bootsec():
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
empty = False
< 67ED span class='blob-code-inner blob-code-marker ' data-code-marker="+"> break
if empty:
return True
fs_corrupted()


def fs_corrupted():
import time

while 1:
print(
"""\
The 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).
"""
)
time.sleep(3)


def setup():
check_bootsec()
print("Performing initial setup")
uos.VfsFat.mkfs(bdev)
vfs = uos.VfsFat(bdev)
uos.mount(vfs, "/")
with open("boot.py", "w") as f:
f.write(
"""\
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl
#webrepl.start()
"""
)
return vfs
3 changes: 3 additions & 0 deletions ports/esp32/boards/GENERIC_S2/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ set(IDF_TARGET esp32s2)
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.usb
#boards/sdkconfig.usb_msc
)

set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
2 changes: 2 additions & 0 deletions ports/esp32/boards/GENERIC_S3/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include("$(PORT_DIR)/boards/manifest.py")
freeze("modules")
13 changes: 13 additions & 0 deletions ports/esp32/boards/GENERIC_S3/modules/_boot_fat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import gc
import uos
from flashbdev import bdev

try:
if bdev:
uos.mount(bdev, "/")
except OSError:
impor F438 t inisetup_fat

vfs = inisetup_fat.setup()

gc.collect()
49 changes: 49 additions & 0 deletions ports/esp32/boards/GENERIC_S3/modules/inisetup_fat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import uos
from flashbdev import bdev


def check_bootsec():
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
empty = False
break
if empty:
return True
fs_corrupted()


def fs_corrupted():
import time

while 1:
print(
"""\
The 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).
"""
)
time.sleep(3)


def setup():
check_bootsec()
print("Performing initial setup")
uos.VfsFat.mkfs(bdev)
vfs = uos.VfsFat(bdev)
uos.mount(vfs, "/")
with open("boot.py", "w") as f:
f.write(
"""\
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl
#webrepl.start()
"""
)
return vfs
3 changes: 3 additions & 0 deletions ports/esp32/boards/GENERIC_S3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ set(IDF_TARGET esp32s3)
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.usb
#boards/sdkconfig.usb_msc
boards/sdkconfig.ble
boards/GENERIC_S3/sdkconfig.board
)

set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
2 changes: 2 additions & 0 deletions ports/esp32/boards/GENERIC_S3_SPIRAM/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include("$(PORT_DIR)/boards/manifest.py")
freeze("modules")
13 changes: 13 additions & 0 deletions ports/esp32/boards/GENERIC_S3_SPIRAM/modules/_boot_fat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import gc
import uos
from flashbdev import bdev

try:
if bdev:
uos.mount(bdev, "/")
except OSError:
import inisetup_fat

vfs = inisetup_fat.setup()

gc.collect()
49 changes: 49 additions & 0 deletions ports/esp32/boards/GENERIC_S3_SPIRAM/modules/inisetup_fat.py
F42D
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import uos
from flashbdev import bdev


def check_bootsec():
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
empty = False
break
if empty:
return True
fs_corrupted()


def fs_corrupted():
import time

while 1:
print(
"""\
The 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).
"""
)
time.sleep(3)


def setup():
check_bootsec()
print("Performing initial setup")
uos.VfsFat.mkfs(bdev)
vfs = uos.VfsFat(bdev)
uos.mount(vfs, "/")
with open("boot.py", "w") as f:
f.write(
"""\
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl
#webrepl.start()
"""
)
return vfs
3 changes: 3 additions & 0 deletions ports/esp32/boards/GENERIC_S3_SPIRAM/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ set(IDF_TARGET esp32s3)
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.usb
#boards/sdkconfig.usb_msc
boards/sdkconfig.ble
boards/sdkconfig.spiram_sx
boards/GENERIC_S3_SPIRAM/sdkconfig.board
)

set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
13 changes: 13 additions & 0 deletions ports/esp32/boards/LOLIN_S2_MINI/modules/_boot_fat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import gc
import uos
from flashbdev import bdev

try:
if bdev:
uos.mount(bdev, "/")
except OSError:
import inisetup_fat

vfs = inisetup_fat.setup()

gc.collect()
49 changes: 49 additions & 0 deletions ports/esp32/boards/LOLIN_S2_MINI/modules/inisetup_fat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import uos
from flashbdev import bdev


def check_bootsec():
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
empty = False
break
if empty:
return True
fs_corrupted()


def fs_corrupted():
import time

while 1:
print(
"""\
The 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).
"""
)
time.sleep(3)


def setup():
check_bootsec()
print("Performing initial setup")
uos.VfsFat.mkfs(bdev)
vfs = uos.VfsFat(bdev)
uos.mount(vfs, "/")
with open("boot.py", "w") as f:
f.write(
"""\
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl
#webrepl.start()
"""
)
return vfs
1 change: 1 addition & 0 deletions ports/esp32/boards/LOLIN_S2_MINI/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.spiram_sx
boards/sdkconfig.usb
#boards/sdkconfig.usb_msc
)

set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
13 changes: 13 additions & 0 deletions ports/esp32/boards/LOLIN_S2_PICO/modules/_boot_fat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import gc
import uos
from flashbdev import bdev

try:
if bdev:
uos.mount(bdev, "/")
except OSError:
import inisetup_fat

vfs = inisetup_fat.setup()

gc.collect()
49 changes: 49 additions & 0 deletions ports/esp32/boards/LOLIN_S2_PICO/modules/inisetup_fat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import uos
from flashbdev import bdev


def check_bootsec():
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
empty = False
break
if empty:
return True
fs_corrupted()


def fs_corrupted():
import time

while 1:
print(
"""\
The 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).
"""
)
time.sleep(3)


def setup():
check_bootsec()
print("Performing initial setup")
uos.VfsFat.mkfs(bdev)
vfs = uos.VfsFat(bdev)
uos.mount(vfs, "/")
with open("boot.py", "w") as f:
f.write(
"""\
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl
#webrepl.start()
"""
)
return vfs
1 change: 1 addition & 0 deletions ports/esp32/boards/LOLIN_S2_PICO/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.spiram_sx
boards/sdkconfig.usb
#boards/sdkconfig.usb_msc
)

set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
13 changes: 13 additions & 0 deletions ports/esp32/boards/UM_FEATHERS2/modules/_boot_fat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import gc
import uos
from flashbdev import bdev

try:
if bdev:
uos.mount(bdev, "/")
except OSError:
import inisetup_fat

vfs = inisetup_fat.setup()

gc.collect()
Loading
0