Skip to content

Adding support for ESP32-D2WD (2MiB) for issue #4986 #4987

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 2 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_D2WD/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define MICROPY_HW_BOARD_NAME "Generic ESP32-D2WD module"
#define MICROPY_HW_MCU_NAME "ESP32-D2WD"
7 changes: 7 additions & 0 deletions ports/esp32/boards/GENERIC_D2WD/mpconfigboard.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SDKCONFIG += boards/sdkconfig.base
PART_SRC = partitions-2MiB.csv
FLASH_SIZE = 2MB
FLASH_MODE = dio
FLASH_FREQ = 40m

$(info "Using $(PART_SRC)")
36 changes: 3 additions & 33 deletions ports/esp32/modules/flashbdev.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,4 @@
import esp
from esp32 import Partition

class FlashBdev:

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

def __init__(self, blocks):
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:
# for now we use a fixed size for the filesystem
bdev = FlashBdev(2048 * 1024 // FlashBdev.SEC_SIZE)
bdev = Partition.find(Partition.TYPE_DATA, label='vfs')
bdev = bdev[0] if bdev else None
6 changes: 6 additions & 0 deletions ports/esp32/partitions-2MiB.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 0x110000,
vfs, data, fat, 0x120000, 0xA0000,
1 change: 1 addition & 0 deletions ports/esp32/partitions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 0x180000,
vfs, data, fat, 0x200000, 0x200000,