Skip to content

Commit 89d7ed2

Browse files
committed
Add optional MMU page size flag to elf2bin if it's configurable
1 parent bc5b51f commit 89d7ed2

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

builder/frameworks/espidf.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@
9797
PROJECT_SRC_DIR = env.subst("$PROJECT_SRC_DIR")
9898
CMAKE_API_REPLY_PATH = os.path.join(".cmake", "api", "v1", "reply")
9999
SDKCONFIG_PATH = os.path.expandvars(board.get(
100-
"build.esp-idf.sdkconfig_path",
101-
os.path.join(PROJECT_DIR, "sdkconfig.%s" % env.subst("$PIOENV")),
100+
"build.esp-idf.sdkconfig_path",
101+
os.path.join(PROJECT_DIR, "sdkconfig.%s" % env.subst("$PIOENV")),
102102
))
103103

104104

@@ -1212,7 +1212,7 @@ def _create_venv(venv_dir):
12121212
env.Execute(
12131213
env.VerboseAction(
12141214
'"$PYTHONEXE" -m venv --clear "%s"' % venv_dir,
1215-
"Creating a new virtual environment for IDF Python dependencies",
1215+
"Creating a new virtual environment for IDF Python dependencies",
12161216
)
12171217
)
12181218

@@ -1586,9 +1586,24 @@ def _skip_prj_source_files(node):
15861586
# To embed firmware checksum a special argument for esptool.py is required
15871587
#
15881588

1589+
extra_elf2bin_flags = "--elf-sha256-offset 0xb0"
1590+
# https://github.com/espressif/esp-idf/blob/master/components/esptool_py/project_include.cmake#L58
1591+
# For chips that support configurable MMU page size feature
1592+
# If page size is configured to values other than the default "64KB" in menuconfig,
1593+
mmu_page_size = "64KB"
1594+
if sdk_config.get("SOC_MMU_PAGE_SIZE_CONFIGURABLE", False):
1595+
if board_flash_size == "2MB":
1596+
mmu_page_size = "32KB"
1597+
elif board_flash_size == "1MB":
1598+
mmu_page_size = "16KB"
1599+
1600+
if mmu_page_size != "64KB":
1601+
extra_elf2bin_flags += " --flash-mmu-page-size %s" % mmu_page_size
1602+
15891603
action = copy.deepcopy(env["BUILDERS"]["ElfToBin"].action)
1604+
15901605
action.cmd_list = env["BUILDERS"]["ElfToBin"].action.cmd_list.replace(
1591-
"-o", "--elf-sha256-offset 0xb0 -o"
1606+
"-o", extra_elf2bin_flags + " -o"
15921607
)
15931608
env["BUILDERS"]["ElfToBin"].action = action
15941609

0 commit comments

Comments
 (0)