8000 esp32: Enable VfsMap. · micropython/micropython@19b74d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 19b74d4

Browse files
committed
esp32: Enable VfsMap.
1 parent c183dc7 commit 19b74d4

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

ports/esp32/esp32_partition.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ STATIC mp_obj_t esp32_partition_mmap(mp_obj_t self_in) {
270270
esp32_partition_obj_t *self = MP_OBJ_TO_PTR(self_in);
271271
const void *ptr;
272272
spi_flash_mmap_handle_t handle;
273+
// TODO need to spi_flash_unmmap(handle) on soft reset
273274
check_esp_err(esp_partition_mmap(self->part, 0, self->part->size, SPI_FLASH_MMAP_DATA, &ptr, &handle));
274275
return mp_obj_new_memoryview('B', self->part->size, (void *)ptr);
275276
}

ports/esp32/modules/_boot.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import gc
22
import uos
3+
from esp32 import Partition
34
from flashbdev import bdev
45

6+
if mapfs := Partition.find(Partition.TYPE_DATA, label="mapfs"):
7+
uos.mount(uos.VfsMap(mapfs[0].mmap(), mapfs[0]), "/mapfs")
8+
del mapfs
9+
510
try:
611
if bdev:
712
uos.mount(bdev, "/")

ports/esp32/moduos.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "extmod/vfs.h"
4040
#include "extmod/vfs_fat.h"
4141
#include "extmod/vfs_lfs.h"
42+
#include "extmod/vfs_map.h"
4243
#include "genhdr/mpversion.h"
4344

4445
extern const mp_obj_type_t mp_fat_vfs_type;
@@ -130,6 +131,9 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
130131
#if MICROPY_VFS_LFS2
131132
{ MP_ROM_QSTR(MP_QSTR_VfsLfs2), MP_ROM_PTR(&mp_type_vfs_lfs2) },
132133
#endif
134+
#if MICROPY_VFS_MAP
135+
{ MP_ROM_QSTR(MP_QSTR_VfsMap), MP_ROM_PTR(&mp_type_vfs_map) },
136+
#endif
133137
#endif
134138
};
135139

ports/esp32/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#define MICROPY_USE_INTERNAL_PRINTF (0) // ESP32 SDK requires its own printf
5050
#define MICROPY_SCHEDULER_DEPTH (8)
5151
#define MICROPY_VFS (1)
52+
#define MICROPY_VFS_MAP (1)
5253

5354
// control over Python builtins
5455
#define MICROPY_PY_STR_BYTES_CMP_WARN (1)

0 commit comments

Comments
 (0)
0