esp-idf/tools/idf_py_actions/dfu_ext.py
Roland Dobai 7b70154566 tools: Split up large binaries into smaller chunks in the DFU binary
ROM will erase the region a partition is in as soon as it receives the
first bit of the data that is in the partition. For large partitions it
takes more than 5 seconds to erase which is a hard-coded limit in
dfu-utils.

This splits large binaries and adds them by chunks which should avoid
timing-out during flashing.

Closes https://github.com/espressif/esp-idf/issues/6999
2021-06-01 15:11:12 +02:00

48 lines
1.8 KiB
Python

from idf_py_actions.tools import is_target_supported, ensure_build_directory, run_target
from idf_py_actions.errors import FatalError
def action_extensions(base_actions, project_path):
SUPPORTED_TARGETS = ['esp32s2']
def dfu_target(target_name, ctx, args, part_size):
ensure_build_directory(args, ctx.info_name)
run_target(target_name, args, {'ESP_DFU_PART_SIZE': part_size} if part_size else {})
def dfu_flash_target(target_name, ctx, args):
ensure_build_directory(args, ctx.info_name)
try:
run_target(target_name, args)
except FatalError:
# Cannot capture the error from dfu-util here so the best advise is:
print('Please have a look at the "Device Firmware Upgrade through USB" chapter in API Guides of the '
'ESP-IDF documentation for solving common dfu-util issues.')
raise
dfu_actions = {
'actions': {
'dfu': {
'callback': dfu_target,
'short_help': 'Build the DFU binary',
'dependencies': ['all'],
'options': [
{
'names': ['--part-size'],
'help': 'Large files are split up into smaller partitions in order to avoid timeout during '
'erasing flash. This option allows to overwrite the default partition size of '
'mkdfu.py.'
}
],
},
'dfu-flash': {
'callback': dfu_flash_target,
'short_help': 'Flash the DFU binary',
'order_dependencies': ['dfu'],
},
}
}
return dfu_actions if is_target_supported(project_path, SUPPORTED_TARGETS) else {}