Merge branch 'bugfix/idfpy_erase_otadata_v4.3' into 'release/v4.3'

tools: set baudrate and port with otatool. (v4.3)

See merge request espressif/esp-idf!17468
This commit is contained in:
Roland Dobai
2022-03-14 17:37:54 +08:00
2 changed files with 27 additions and 15 deletions

View File

@ -380,16 +380,6 @@ def action_extensions(base_actions, project_path):
'order_dependencies': ['reconfigure'], 'order_dependencies': ['reconfigure'],
'options': global_options, 'options': global_options,
}, },
'erase_otadata': {
'callback': build_target,
'help': 'Erase otadata partition.',
'options': global_options,
},
'read_otadata': {
'callback': build_target,
'help': 'Read otadata partition.',
'options': global_options,
},
'build-system-targets': { 'build-system-targets': {
'callback': list_build_system_targets, 'callback': list_build_system_targets,
'help': 'Print list of build system targets.', 'help': 'Print list of build system targets.',

View File

@ -138,6 +138,17 @@ def action_extensions(base_actions, project_path):
task.action_args['encrypted'] = True task.action_args['encrypted'] = True
break break
def ota_targets(target_name, ctx, args):
"""
Execute the target build system to build target 'target_name'.
Additionally set global variables for baud and port.
Calls ensure_build_directory() which will run cmake to generate a build
directory (with the specified generator) as needed.
"""
args.port = args.port or _get_default_serial_port(args)
ensure_build_directory(args, ctx.info_name)
run_target(target_name, args, {'ESPBAUD': str(args.baud), 'ESPPORT': args.port})
baud_rate = { baud_rate = {
'names': ['-b', '--baud'], 'names': ['-b', '--baud'],
'help': 'Baud rate for flashing.', 'help': 'Baud rate for flashing.',
@ -154,19 +165,20 @@ def action_extensions(base_actions, project_path):
'default': None, 'default': None,
} }
BAUD_AND_PORT = [baud_rate, port]
serial_actions = { serial_actions = {
'global_action_callbacks': [global_callback], 'global_action_callbacks': [global_callback],
'actions': { 'actions': {
'flash': { 'flash': {
'callback': flash, 'callback': flash,
'help': 'Flash the project.', 'help': 'Flash the project.',
'options': global_options + [baud_rate, port], 'options': global_options + BAUD_AND_PORT,
'order_dependencies': ['all', 'erase_flash'], 'order_dependencies': ['all', 'erase_flash'],
}, },
'erase_flash': { 'erase_flash': {
'callback': erase_flash, 'callback': erase_flash,
'help': 'Erase entire flash chip.', 'help': 'Erase entire flash chip.',
'options': [baud_rate, port], 'options': BAUD_AND_PORT,
}, },
'monitor': { 'monitor': {
'callback': 'callback':
@ -218,19 +230,19 @@ def action_extensions(base_actions, project_path):
'partition_table-flash': { 'partition_table-flash': {
'callback': flash, 'callback': flash,
'help': 'Flash partition table only.', 'help': 'Flash partition table only.',
'options': [baud_rate, port], 'options': BAUD_AND_PORT,
'order_dependencies': ['partition_table', 'erase_flash'], 'order_dependencies': ['partition_table', 'erase_flash'],
}, },
'bootloader-flash': { 'bootloader-flash': {
'callback': flash, 'callback': flash,
'help': 'Flash bootloader only.', 'help': 'Flash bootloader only.',
'options': [baud_rate, port], 'options': BAUD_AND_PORT,
'order_dependencies': ['bootloader', 'erase_flash'], 'order_dependencies': ['bootloader', 'erase_flash'],
}, },
'app-flash': { 'app-flash': {
'callback': flash, 'callback': flash,
'help': 'Flash the app only.', 'help': 'Flash the app only.',
'options': [baud_rate, port], 'options': BAUD_AND_PORT,
'order_dependencies': ['app', 'erase_flash'], 'order_dependencies': ['app', 'erase_flash'],
}, },
'encrypted-app-flash': { 'encrypted-app-flash': {
@ -243,6 +255,16 @@ def action_extensions(base_actions, project_path):
'help': 'Flash the encrypted project.', 'help': 'Flash the encrypted project.',
'order_dependencies': ['all', 'erase_flash'], 'order_dependencies': ['all', 'erase_flash'],
}, },
'erase_otadata': {
'callback': ota_targets,
'help': 'Erase otadata partition.',
'options': global_options + BAUD_AND_PORT,
},
'read_otadata': {
'callback': ota_targets,
'help': 'Read otadata partition.',
'options': global_options + BAUD_AND_PORT,
},
}, },
} }