Skip to content

Commit

Permalink
Add optional MMU page size flag to elf2bin if it's configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
valeros committed Dec 8, 2023
1 parent bc5b51f commit 89d7ed2
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
PROJECT_SRC_DIR = env.subst("$PROJECT_SRC_DIR")
CMAKE_API_REPLY_PATH = os.path.join(".cmake", "api", "v1", "reply")
SDKCONFIG_PATH = os.path.expandvars(board.get(
"build.esp-idf.sdkconfig_path",
os.path.join(PROJECT_DIR, "sdkconfig.%s" % env.subst("$PIOENV")),
"build.esp-idf.sdkconfig_path",
os.path.join(PROJECT_DIR, "sdkconfig.%s" % env.subst("$PIOENV")),
))


Expand Down Expand Up @@ -1212,7 +1212,7 @@ def _create_venv(venv_dir):
env.Execute(
env.VerboseAction(
'"$PYTHONEXE" -m venv --clear "%s"' % venv_dir,
"Creating a new virtual environment for IDF Python dependencies",
"Creating a new virtual environment for IDF Python dependencies",
)
)

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

extra_elf2bin_flags = "--elf-sha256-offset 0xb0"
# https://github.com/espressif/esp-idf/blob/master/components/esptool_py/project_include.cmake#L58
# For chips that support configurable MMU page size feature
# If page size is configured to values other than the default "64KB" in menuconfig,
mmu_page_size = "64KB"
if sdk_config.get("SOC_MMU_PAGE_SIZE_CONFIGURABLE", False):
if board_flash_size == "2MB":
mmu_page_size = "32KB"
elif board_flash_size == "1MB":
mmu_page_size = "16KB"

if mmu_page_size != "64KB":
extra_elf2bin_flags += " --flash-mmu-page-size %s" % mmu_page_size

action = copy.deepcopy(env["BUILDERS"]["ElfToBin"].action)

action.cmd_list = env["BUILDERS"]["ElfToBin"].action.cmd_list.replace(
"-o", "--elf-sha256-offset 0xb0 -o"
"-o", extra_elf2bin_flags + " -o"
)
env["BUILDERS"]["ElfToBin"].action = action

Expand Down

0 comments on commit 89d7ed2

Please sign in to comment.