Merge branch 'bugfix/otadata_operations_do_not_use_esptool_configs' into 'master'

Fix Make otadata operations do not use esptool configs

Closes IDFGH-686

See merge request espressif/esp-idf!4636
pull/3783/head
Angus Gratton 2019-07-08 15:19:30 +08:00
commit f6ad7f564d
4 zmienionych plików z 74 dodań i 15 usunięć

Wyświetl plik

@ -38,14 +38,16 @@ if(NOT BOOTLOADER_BUILD)
set(otatool_py ${python} ${COMPONENT_DIR}/otatool.py)
set(esptool_args --esptool-args before=${CONFIG_ESPTOOLPY_BEFORE} after=${CONFIG_ESPTOOLPY_AFTER})
add_custom_target(read_otadata DEPENDS "${PARTITION_CSV_PATH}"
COMMAND ${otatool_py}
COMMAND ${otatool_py} ${esptool_args}
--partition-table-file ${PARTITION_CSV_PATH}
--partition-table-offset ${PARTITION_TABLE_OFFSET}
read_otadata)
add_custom_target(erase_otadata DEPENDS "${PARTITION_CSV_PATH}"
COMMAND ${otatool_py}
COMMAND ${otatool_py} ${esptool_args}
--partition-table-file ${PARTITION_CSV_PATH}
--partition-table-offset ${PARTITION_TABLE_OFFSET}
erase_otadata)

Wyświetl plik

@ -28,13 +28,15 @@ blank_ota_data: $(BLANK_OTA_DATA_FILE)
# expand to empty values.
ESPTOOL_ALL_FLASH_ARGS += $(OTA_DATA_OFFSET) $(BLANK_OTA_DATA_FILE)
ESPTOOL_ARGS := --esptool-args port=$(CONFIG_ESPTOOLPY_PORT) baud=$(CONFIG_ESPTOOLPY_BAUD) before=$(CONFIG_ESPTOOLPY_BEFORE) after=$(CONFIG_ESPTOOLPY_AFTER)
erase_otadata: $(PARTITION_TABLE_CSV_PATH) partition_table_get_info | check_python_dependencies
$(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_CSV_PATH) \
$(OTATOOL_PY) $(ESPTOOL_ARGS) --partition-table-file $(PARTITION_TABLE_CSV_PATH) \
--partition-table-offset $(PARTITION_TABLE_OFFSET) \
erase_otadata
read_otadata: $(PARTITION_TABLE_CSV_PATH) partition_table_get_info | check_python_dependencies
$(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_CSV_PATH) \
$(OTATOOL_PY) $(ESPTOOL_ARGS) --partition-table-file $(PARTITION_TABLE_CSV_PATH) \
--partition-table-offset $(partition_table_offset) \
read_otadata

Wyświetl plik

@ -50,8 +50,11 @@ class OtatoolTarget():
OTADATA_PARTITION = PartitionType("data", "ota")
def __init__(self, port=None, partition_table_offset=PARTITION_TABLE_OFFSET, partition_table_file=None, spi_flash_sec_size=SPI_FLASH_SEC_SIZE):
self.target = ParttoolTarget(port, partition_table_offset, partition_table_file)
def __init__(self, port=None, partition_table_offset=PARTITION_TABLE_OFFSET, partition_table_file=None,
spi_flash_sec_size=SPI_FLASH_SEC_SIZE, esptool_args=[], esptool_write_args=[],
esptool_read_args=[], esptool_erase_args=[]):
self.target = ParttoolTarget(port, partition_table_offset, partition_table_file, esptool_args,
esptool_write_args, esptool_read_args, esptool_erase_args)
self.spi_flash_sec_size = spi_flash_sec_size
temp_file = tempfile.NamedTemporaryFile(delete=False)
@ -214,11 +217,11 @@ class OtatoolTarget():
def _read_otadata(target):
target._check_otadata_partition()
otadata_info = target._get_otadata_info(target.otadata)
otadata_info = target._get_otadata_info()
print("\t\t{:11}\t{:8s}|\t{:8s}\t{:8s}".format("OTA_SEQ", "CRC", "OTA_SEQ", "CRC"))
print("Firmware: 0x{:8x} \t 0x{:8x} |\t0x{:8x} \t 0x{:8x}".format(otadata_info[0].seq, otadata_info[0].crc,
otadata_info[1].seq, otadata_info[1].crc))
print(" {:8s} \t {:8s} | \t {:8s} \t {:8s}".format("OTA_SEQ", "CRC", "OTA_SEQ", "CRC"))
print("Firmware: 0x{:8x} \t0x{:8x} | \t0x{:8x} \t 0x{:8x}".format(otadata_info[0].seq, otadata_info[0].crc,
otadata_info[1].seq, otadata_info[1].crc))
def _erase_otadata(target):
@ -251,6 +254,10 @@ def main():
parser = argparse.ArgumentParser("ESP-IDF OTA Partitions Tool")
parser.add_argument("--quiet", "-q", help="suppress stderr messages", action="store_true")
parser.add_argument("--esptool-args", help="additional main arguments for esptool", nargs="+")
parser.add_argument("--esptool-write-args", help="additional subcommand arguments for esptool write_flash", nargs="+")
parser.add_argument("--esptool-read-args", help="additional subcommand arguments for esptool read_flash", nargs="+")
parser.add_argument("--esptool-erase-args", help="additional subcommand arguments for esptool erase_region", nargs="+")
# There are two possible sources for the partition table: a device attached to the host
# or a partition table CSV/binary file. These sources are mutually exclusive.
@ -312,6 +319,18 @@ def main():
except AttributeError:
pass
if args.esptool_args:
target_args["esptool_args"] = args.esptool_args
if args.esptool_write_args:
target_args["esptool_write_args"] = args.esptool_write_args
if args.esptool_read_args:
target_args["esptool_read_args"] = args.esptool_read_args
if args.esptool_erase_args:
target_args["esptool_erase_args"] = args.esptool_erase_args
target = OtatoolTarget(**target_args)
# Create the operation table and execute the operation

Wyświetl plik

@ -22,6 +22,7 @@ import os
import sys
import subprocess
import tempfile
import re
import gen_esp32part as gen
@ -66,11 +67,30 @@ PARTITION_BOOT_DEFAULT = _PartitionId()
class ParttoolTarget():
def __init__(self, port=None, partition_table_offset=PARTITION_TABLE_OFFSET, partition_table_file=None):
def __init__(self, port=None, partition_table_offset=PARTITION_TABLE_OFFSET, partition_table_file=None,
esptool_args=[], esptool_write_args=[], esptool_read_args=[], esptool_erase_args=[]):
self.port = port
gen.offset_part_table = partition_table_offset
def parse_esptool_args(esptool_args):
results = list()
for arg in esptool_args:
pattern = re.compile(r"(.+)=(.+)")
result = pattern.match(arg)
try:
key = result.group(1)
value = result.group(2)
results.extend(["--" + key, value])
except AttributeError:
results.extend(["--" + arg])
return results
self.esptool_args = parse_esptool_args(esptool_args)
self.esptool_write_args = parse_esptool_args(esptool_write_args)
self.esptool_read_args = parse_esptool_args(esptool_read_args)
self.esptool_erase_args = parse_esptool_args(esptool_erase_args)
if partition_table_file:
try:
with open(partition_table_file, "rb") as f:
@ -93,7 +113,7 @@ class ParttoolTarget():
self.partition_table = partition_table
def _call_esptool(self, args, out=None):
esptool_args = [sys.executable, ESPTOOL_PY]
esptool_args = [sys.executable, ESPTOOL_PY] + self.esptool_args
if self.port:
esptool_args += ["--port", self.port]
@ -124,11 +144,11 @@ class ParttoolTarget():
def erase_partition(self, partition_id):
partition = self.get_partition_info(partition_id)
self._call_esptool(["erase_region", str(partition.offset), str(partition.size)])
self._call_esptool(["erase_region", str(partition.offset), str(partition.size)] + self.esptool_erase_args)
def read_partition(self, partition_id, output):
partition = self.get_partition_info(partition_id)
self._call_esptool(["read_flash", str(partition.offset), str(partition.size), output])
self._call_esptool(["read_flash", str(partition.offset), str(partition.size), output] + self.esptool_read_args)
def write_partition(self, partition_id, input):
self.erase_partition(partition_id)
@ -141,7 +161,7 @@ class ParttoolTarget():
if content_len > partition.size:
raise Exception("Input file size exceeds partition size")
self._call_esptool(["write_flash", str(partition.offset), input])
self._call_esptool(["write_flash", str(partition.offset), input] + self.esptool_write_args)
def _write_partition(target, partition_id, input):
@ -191,6 +211,10 @@ def main():
parser = argparse.ArgumentParser("ESP-IDF Partitions Tool")
parser.add_argument("--quiet", "-q", help="suppress stderr messages", action="store_true")
parser.add_argument("--esptool-args", help="additional main arguments for esptool", nargs="+")
parser.add_argument("--esptool-write-args", help="additional subcommand arguments when writing to flash", nargs="+")
parser.add_argument("--esptool-read-args", help="additional subcommand arguments when reading flash", nargs="+")
parser.add_argument("--esptool-erase-args", help="additional subcommand arguments when erasing regions of flash", nargs="+")
# By default the device attached to the specified port is queried for the partition table. If a partition table file
# is specified, that is used instead.
@ -264,6 +288,18 @@ def main():
if args.partition_table_offset:
target_args["partition_table_offset"] = int(args.partition_table_offset, 0)
if args.esptool_args:
target_args["esptool_args"] = args.esptool_args
if args.esptool_write_args:
target_args["esptool_write_args"] = args.esptool_write_args
if args.esptool_read_args:
target_args["esptool_read_args"] = args.esptool_read_args
if args.esptool_erase_args:
target_args["esptool_erase_args"] = args.esptool_erase_args
target = ParttoolTarget(**target_args)
# Create the operation table and execute the operation