mirror of
https://github.com/espressif/esptool.git
synced 2025-10-19 02:43:00 +08:00
fix(espefuse): Close serial port even when espefuse fails
Closes https://github.com/espressif/esptool/issues/803
This commit is contained in:

committed by
Radim Karniš

parent
14605173da
commit
26df171d24
@@ -249,27 +249,28 @@ def main(custom_commandline=None):
|
|||||||
if there_are_multiple_burn_commands_in_args:
|
if there_are_multiple_burn_commands_in_args:
|
||||||
efuses.batch_mode_cnt += 1
|
efuses.batch_mode_cnt += 1
|
||||||
|
|
||||||
for rem_args in grouped_remaining_args:
|
try:
|
||||||
args, unused_args = parser.parse_known_args(rem_args, namespace=common_args)
|
for rem_args in grouped_remaining_args:
|
||||||
if args.operation is None:
|
args, unused_args = parser.parse_known_args(rem_args, namespace=common_args)
|
||||||
parser.print_help()
|
if args.operation is None:
|
||||||
parser.exit(1)
|
parser.print_help()
|
||||||
assert len(unused_args) == 0, 'Not all commands were recognized "{}"'.format(
|
parser.exit(1)
|
||||||
unused_args
|
assert (
|
||||||
)
|
len(unused_args) == 0
|
||||||
|
), 'Not all commands were recognized "{}"'.format(unused_args)
|
||||||
|
|
||||||
operation_func = vars(efuse_operations)[args.operation]
|
operation_func = vars(efuse_operations)[args.operation]
|
||||||
# each 'operation' is a module-level function of the same name
|
# each 'operation' is a module-level function of the same name
|
||||||
print('\n=== Run "{}" command ==='.format(args.operation))
|
print('\n=== Run "{}" command ==='.format(args.operation))
|
||||||
operation_func(esp, efuses, args)
|
operation_func(esp, efuses, args)
|
||||||
|
|
||||||
if there_are_multiple_burn_commands_in_args:
|
if there_are_multiple_burn_commands_in_args:
|
||||||
efuses.batch_mode_cnt -= 1
|
efuses.batch_mode_cnt -= 1
|
||||||
if not efuses.burn_all(check_batch_mode=True):
|
if not efuses.burn_all(check_batch_mode=True):
|
||||||
raise esptool.FatalError("BURN was not done")
|
raise esptool.FatalError("BURN was not done")
|
||||||
|
finally:
|
||||||
if common_args.virt is False:
|
if not common_args.virt and esp._port:
|
||||||
esp._port.close()
|
esp._port.close()
|
||||||
|
|
||||||
|
|
||||||
def _main():
|
def _main():
|
||||||
|
Reference in New Issue
Block a user