Skip to content

Commit

Permalink
Implement get_board_f_image (#1308)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Feb 15, 2024
1 parent ecb0953 commit 8fe5e12
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,24 @@ def _get_board_memory_type(env):
)


def _get_board_f_flash(env):
frequency = env.subst("$BOARD_F_FLASH")
def _normalize_frequency(frequency):
frequency = str(frequency).replace("L", "")
return str(int(int(frequency) / 1000000)) + "m"


def _get_board_f_flash(env):
frequency = env.subst("$BOARD_F_FLASH")
return _normalize_frequency(frequency)


def _get_board_f_image(env):
board_config = env.BoardConfig()
if "build.f_image" in board_config:
return _normalize_frequency(board_config.get("build.f_image"))

return _get_board_f_flash(env)


def _get_board_flash_mode(env):
if ["arduino"] == env.get("PIOFRAMEWORK") and _get_board_memory_type(env) in (
"opi_opi",
Expand Down Expand Up @@ -225,6 +237,7 @@ def __fetch_fs_size(target, source, env):
env.Replace(
__get_board_boot_mode=_get_board_boot_mode,
__get_board_f_flash=_get_board_f_flash,
__get_board_f_image=_get_board_f_image,
__get_board_flash_mode=_get_board_flash_mode,
__get_board_memory_type=_get_board_memory_type,

Expand Down Expand Up @@ -296,7 +309,7 @@ def __fetch_fs_size(target, source, env):
'"$PYTHONEXE" "$OBJCOPY"',
"--chip", mcu, "elf2image",
"--flash_mode", "${__get_board_flash_mode(__env__)}",
"--flash_freq", "${__get_board_f_flash(__env__)}",
"--flash_freq", "${__get_board_f_image(__env__)}",
"--flash_size", board.get("upload.flash_size", "4MB"),
"-o", "$TARGET", "$SOURCES"
]), "Building $TARGET"),
Expand Down Expand Up @@ -432,7 +445,7 @@ def __fetch_fs_size(target, source, env):
"--after", board.get("upload.after_reset", "hard_reset"),
"write_flash", "-z",
"--flash_mode", "${__get_board_flash_mode(__env__)}",
"--flash_freq", "${__get_board_f_flash(__env__)}",
"--flash_freq", "${__get_board_f_image(__env__)}",
"--flash_size", board.get("upload.flash_size", "detect")
],
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS $ESP32_APP_OFFSET $SOURCE'
Expand All @@ -450,7 +463,7 @@ def __fetch_fs_size(target, source, env):
"--after", board.get("upload.after_reset", "hard_reset"),
"write_flash", "-z",
"--flash_mode", "${__get_board_flash_mode(__env__)}",
"--flash_freq", "${__get_board_f_flash(__env__)}",
"--flash_freq", "${__get_board_f_image(__env__)}",
"--flash_size", board.get("upload.flash_size", "detect"),
"$FS_START"
],
Expand Down

0 comments on commit 8fe5e12

Please sign in to comment.