Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

esp32: auto-detect the SPI flash size and automatically size the filesystem#17337

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dpgeorge wants to merge2 commits intomicropython:master
base:master
Choose a base branch
Loading
fromdpgeorge:esp32-detect-flash-size
Open
Show file tree
Hide file tree
Changes fromall 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
3 changes: 1 addition & 2 deletionsports/esp32/boards/ESP32_GENERIC_S3/board.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,6 @@
"url": "https://www.espressif.com/en/products/modules",
"vendor": "Espressif",
"variants": {
"SPIRAM_OCT": "Support for Octal-SPIRAM",
"FLASH_4M": "4MiB flash"
"SPIRAM_OCT": "Support for Octal-SPIRAM"
}
}
View file
Open in desktop

This file was deleted.

6 changes: 0 additions & 6 deletionsports/esp32/boards/ESP32_GENERIC_S3/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"
4 changes: 0 additions & 4 deletionsports/esp32/boards/ESP32_GENERIC_S3/sdkconfig.flash_4m
View file
Open in desktop

This file was deleted.

5 changes: 0 additions & 5 deletionsports/esp32/boards/UM_FEATHERS2/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,11 +3,6 @@ CONFIG_ESPTOOLPY_FLASHFREQ_80M=y

CONFIG_SPIRAM_MEMTEST=

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16MiB.csv"

# LWIP
CONFIG_LWIP_LOCAL_HOSTNAME="UMFeatherS2"
# end of LWIP
5 changes: 0 additions & 5 deletionsports/esp32/boards/UM_FEATHERS3/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_SPIRAM_MEMTEST=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16MiB.csv"

CONFIG_LWIP_LOCAL_HOSTNAME="UMFeatherS3"

Expand Down
5 changes: 0 additions & 5 deletionsports/esp32/boards/UM_FEATHERS3NEO/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,11 +3,6 @@ CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_AFTER_NORESET=y

CONFIG_SPIRAM_MEMTEST=
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"

CONFIG_LWIP_LOCAL_HOSTNAME="UMFeatherS3Neo"

Expand Down
5 changes: 0 additions & 5 deletionsports/esp32/boards/UM_NANOS3/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=
CONFIG_SPIRAM_MEMTEST=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"

CONFIG_LWIP_LOCAL_HOSTNAME="UMNanoS3"

Expand Down
5 changes: 0 additions & 5 deletionsports/esp32/boards/UM_OMGS3/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,7 @@ CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_AFTER_NORESET=y

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=
CONFIG_SPIRAM_MEMTEST=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"

CONFIG_LWIP_LOCAL_HOSTNAME="UMOMGS3"

Expand Down
5 changes: 0 additions & 5 deletionsports/esp32/boards/UM_PROS3/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_SPIRAM_MEMTEST=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16MiB.csv"

CONFIG_LWIP_LOCAL_HOSTNAME="UMProS3"

Expand Down
5 changes: 0 additions & 5 deletionsports/esp32/boards/UM_RGBTOUCH_MINI/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,7 @@ CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_AFTER_NORESET=y

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=
CONFIG_SPIRAM_MEMTEST=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"

CONFIG_LWIP_LOCAL_HOSTNAME="UMRGBTouchMini"

Expand Down
5 changes: 0 additions & 5 deletionsports/esp32/boards/UM_TINYC6/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,4 @@ CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_AFTER_NORESET=y

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=
CONFIG_SPIRAM_MEMTEST=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"
5 changes: 0 additions & 5 deletionsports/esp32/boards/UM_TINYS3/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=
CONFIG_SPIRAM_MEMTEST=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"

CONFIG_LWIP_LOCAL_HOSTNAME="UMTinyS3"

Expand Down
5 changes: 0 additions & 5 deletionsports/esp32/boards/UM_TINYWATCHS3/sdkconfig.board
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=
CONFIG_SPIRAM_MEMTEST=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"

CONFIG_LWIP_LOCAL_HOSTNAME="UMTinyWATCHS3"

Expand Down
2 changes: 1 addition & 1 deletionports/esp32/boards/sdkconfig.base
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,7 +97,7 @@ CONFIG_ULP_COPROC_RESERVE_MEM=2040
# For cmake build
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MiB.csv"
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MiBplus.csv"

# To reduce iRAM usage
CONFIG_ESP32_WIFI_IRAM_OPT=n
Expand Down
23 changes: 23 additions & 0 deletionsports/esp32/esp32_partition.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,7 @@
#include "py/mphal.h"
#include "extmod/vfs.h"
#include "modesp32.h"
#include "esp_flash.h"
#include "esp_ota_ops.h"

// esp_partition_read and esp_partition_write can operate on arbitrary bytes
Expand All@@ -44,6 +45,7 @@
enum {
ESP32_PARTITION_BOOT,
ESP32_PARTITION_RUNNING,
ESP32_PARTITION_AUTOFS,
};

typedef struct _esp32_partition_obj_t {
Expand All@@ -53,6 +55,8 @@ typedef struct _esp32_partition_obj_t {
uint16_t block_size;
} esp32_partition_obj_t;

static esp_partition_t auto_partition;

#if MICROPY_VFS_ROM_IOCTL

static esp32_partition_obj_t esp32_partition_romfs_obj = {
Expand DownExpand Up@@ -106,6 +110,24 @@ static mp_obj_t esp32_partition_make_new(const mp_obj_type_t *type, size_t n_arg
case ESP32_PARTITION_RUNNING:
part = esp_ota_get_running_partition();
break;
case ESP32_PARTITION_AUTOFS:
if (auto_partition.flash_chip == NULL) {
auto_partition.flash_chip = esp_flash_default_chip;
auto_partition.type = ESP_PARTITION_TYPE_DATA;
auto_partition.subtype = 0x8f;
auto_partition.address = 0x200000;
if (esp_flash_default_chip->size < auto_partition.address) {
auto_partition.size = 0;
} else {
auto_partition.size = esp_flash_default_chip->size - auto_partition.address;
}
auto_partition.erase_size = NATIVE_BLOCK_SIZE_BYTES;
strcpy(auto_partition.label, "autofs");
auto_partition.encrypted = false;
auto_partition.readonly = false;
}
part = &auto_partition;
break;
default:
mp_raise_ValueError(NULL);
}
Expand DownExpand Up@@ -311,6 +333,7 @@ static const mp_rom_map_elem_t esp32_partition_locals_dict_table[] = {

{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_INT(ESP32_PARTITION_BOOT) },
{ MP_ROM_QSTR(MP_QSTR_RUNNING), MP_ROM_INT(ESP32_PARTITION_RUNNING) },
{ MP_ROM_QSTR(MP_QSTR_AUTOFS), MP_ROM_INT(ESP32_PARTITION_AUTOFS) },
{ MP_ROM_QSTR(MP_QSTR_TYPE_APP), MP_ROM_INT(ESP_PARTITION_TYPE_APP) },
{ MP_ROM_QSTR(MP_QSTR_TYPE_DATA), MP_ROM_INT(ESP_PARTITION_TYPE_DATA) },
};
Expand Down
7 changes: 6 additions & 1 deletionports/esp32/main.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,7 @@
#include "nvs_flash.h"
#include "esp_task.h"
#include "esp_event.h"
#include "esp_flash.h"
#include "esp_log.h"
#include "esp_memory_utils.h"
#include "esp_psram.h"
Expand DownExpand Up@@ -214,11 +215,15 @@ void boardctrl_startup(void) {
nvs_flash_erase();
nvs_flash_init();
}

// Query the physical size of the SPI flash and store it in the size
// variable of the global, default SPI flash handle.
esp_flash_get_physical_size(NULL, &esp_flash_default_chip->size);
}

void MICROPY_ESP_IDF_ENTRY(void) {
// Hook for a board to run code at start up.
// This defaults to initialising NVS.
// This defaults to initialising NVS and detecting the flash size.
MICROPY_BOARD_STARTUP();

// Create and transfer control to the MicroPython task.
Expand Down
7 changes: 7 additions & 0 deletionsports/esp32/modules/flashbdev.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,3 +5,10 @@
if not bdev:
bdev = Partition.find(Partition.TYPE_DATA, label="ffat", block_size=512)
bdev = bdev[0] if bdev else None

# If there are no explicit partitions, try to use the AUTOFS one.
if bdev is None:
bdev = Partition(Partition.AUTOFS)
if bdev.info()[3] == 0:
# Empty partition, don't use it.
bdev = None
7 changes: 0 additions & 7 deletionsports/esp32/partitions-16MiB.csv
View file
Open in desktop

This file was deleted.

7 changes: 0 additions & 7 deletionsports/esp32/partitions-32MiB.csv
View file
Open in desktop

This file was deleted.

1 change: 0 additions & 1 deletionports/esp32/partitions-4MiB-romfs.csv
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,4 +5,3 @@ nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 0x1D0000,
romfs, data, 0x8f, 0x1E0000, 0x20000,
vfs, data, fat, 0x200000, 0x200000,
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
# This partition table is for devices with 4MiB or more of flash.
# The first 2MiB is used for bootloader, nvs, phy_init and firmware.
# The remaining flash is for the user filesystem(s).

# Notes: the offset of the partition table itself is set in
# $IDF_PATH/components/partition_table/Kconfig.projbuild.
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 0x1F0000,
vfs, data, fat, 0x200000, 0x200000,
7 changes: 0 additions & 7 deletionsports/esp32/partitions-8MiB.csv
View file
Open in desktop

This file was deleted.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp