You've already forked uiflow-micropython
mirror of
https://github.com/m5stack/uiflow-micropython.git
synced 2026-05-20 10:39:27 -07:00
4b8dbf65b9
Signed-off-by: lbuque <1102390310@qq.com>
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
# Combine bootloader, partition table and application into a final binary.
|
|
|
|
import cmd
|
|
import os, sys
|
|
|
|
sys.path.append(os.getenv("IDF_PATH") + "/components/partition_table")
|
|
|
|
import gen_esp32part
|
|
|
|
|
|
def load_partition_table(filename):
|
|
with open(filename, "rb") as f:
|
|
return gen_esp32part.PartitionTable.from_binary(f.read())
|
|
|
|
|
|
# Extract command-line arguments.
|
|
arg_littlefs2_exec = sys.argv[1]
|
|
arg_board_type_in = sys.argv[2]
|
|
arg_filesystem_in = sys.argv[3]
|
|
arg_filesystem_out = sys.argv[4]
|
|
arg_partitions_bin = sys.argv[5]
|
|
|
|
# Load the partition table.
|
|
partition_table = load_partition_table(arg_partitions_bin)
|
|
|
|
max_size_filesystem = None
|
|
|
|
# Inspect the partition table to find offsets and maximum sizes.
|
|
for part in partition_table:
|
|
if (
|
|
part.type == gen_esp32part.DATA_TYPE
|
|
and part.name == "sys"
|
|
and "system" in arg_filesystem_out
|
|
):
|
|
max_size_filesystem = part.size
|
|
elif (
|
|
part.type == gen_esp32part.DATA_TYPE
|
|
and part.name == "vfs"
|
|
and "user" in arg_filesystem_out
|
|
):
|
|
max_size_filesystem = part.size
|
|
|
|
# print("fs partition size: 0x%x bytes" % max_size_filesystem)
|
|
|
|
if max_size_filesystem is not None:
|
|
cmd_line = "{} -c -b {} -i {} -o {} -s {}".format(
|
|
arg_littlefs2_exec,
|
|
arg_board_type_in,
|
|
arg_filesystem_in,
|
|
arg_filesystem_out,
|
|
hex(max_size_filesystem),
|
|
)
|
|
|
|
os.system(cmd_line)
|