scripts: runners: esp32: add erase option
Adds option for erasing esp32 SoC. Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
This commit is contained in:
parent
e12d06690e
commit
60417bad79
1 changed files with 14 additions and 11 deletions
|
@ -16,12 +16,13 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
|
||||||
'''Runner front-end for espidf.'''
|
'''Runner front-end for espidf.'''
|
||||||
|
|
||||||
def __init__(self, cfg, device, boot_address, part_table_address,
|
def __init__(self, cfg, device, boot_address, part_table_address,
|
||||||
app_address, baud=921600, flash_size='detect',
|
app_address, erase=False, baud=921600, flash_size='detect',
|
||||||
flash_freq='40m', flash_mode='dio', espidf='espidf',
|
flash_freq='40m', flash_mode='dio', espidf='espidf',
|
||||||
bootloader_bin=None, partition_table_bin=None):
|
bootloader_bin=None, partition_table_bin=None):
|
||||||
super().__init__(cfg)
|
super().__init__(cfg)
|
||||||
self.elf = cfg.elf_file
|
self.elf = cfg.elf_file
|
||||||
self.app_bin = cfg.bin_file
|
self.app_bin = cfg.bin_file
|
||||||
|
self.erase = bool(erase)
|
||||||
self.device = device
|
self.device = device
|
||||||
self.boot_address = boot_address
|
self.boot_address = boot_address
|
||||||
self.part_table_address = part_table_address
|
self.part_table_address = part_table_address
|
||||||
|
@ -40,7 +41,7 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def capabilities(cls):
|
def capabilities(cls):
|
||||||
return RunnerCaps(commands={'flash'})
|
return RunnerCaps(commands={'flash'}, erase=True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def do_add_parser(cls, parser):
|
def do_add_parser(cls, parser):
|
||||||
|
@ -84,16 +85,22 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
|
||||||
return Esp32BinaryRunner(
|
return Esp32BinaryRunner(
|
||||||
cfg, args.esp_device, boot_address=args.esp_boot_address,
|
cfg, args.esp_device, boot_address=args.esp_boot_address,
|
||||||
part_table_address=args.esp_partition_table_address,
|
part_table_address=args.esp_partition_table_address,
|
||||||
app_address=args.esp_app_address, baud=args.esp_baud_rate,
|
app_address=args.esp_app_address, erase=args.erase,
|
||||||
flash_size=args.esp_flash_size, flash_freq=args.esp_flash_freq,
|
baud=args.esp_baud_rate, flash_size=args.esp_flash_size,
|
||||||
flash_mode=args.esp_flash_mode, espidf=espidf,
|
flash_freq=args.esp_flash_freq, flash_mode=args.esp_flash_mode,
|
||||||
bootloader_bin=args.esp_flash_bootloader,
|
espidf=espidf, bootloader_bin=args.esp_flash_bootloader,
|
||||||
partition_table_bin=args.esp_flash_partition_table)
|
partition_table_bin=args.esp_flash_partition_table)
|
||||||
|
|
||||||
def do_run(self, command, **kwargs):
|
def do_run(self, command, **kwargs):
|
||||||
self.require(self.espidf)
|
self.require(self.espidf)
|
||||||
|
|
||||||
cmd_flash = [self.espidf, '--chip', 'auto']
|
# Add Python interpreter
|
||||||
|
cmd_flash = [sys.executable, self.espidf, '--chip', 'auto']
|
||||||
|
|
||||||
|
if self.erase is True:
|
||||||
|
cmd_erase = cmd_flash + ['erase_flash']
|
||||||
|
self.check_call(cmd_erase)
|
||||||
|
|
||||||
if self.device is not None:
|
if self.device is not None:
|
||||||
cmd_flash.extend(['--port', self.device])
|
cmd_flash.extend(['--port', self.device])
|
||||||
cmd_flash.extend(['--baud', self.baud])
|
cmd_flash.extend(['--baud', self.baud])
|
||||||
|
@ -103,10 +110,6 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
|
||||||
cmd_flash.extend(['--flash_freq', self.flash_freq])
|
cmd_flash.extend(['--flash_freq', self.flash_freq])
|
||||||
cmd_flash.extend(['--flash_size', self.flash_size])
|
cmd_flash.extend(['--flash_size', self.flash_size])
|
||||||
|
|
||||||
# Execute Python interpreter if calling a Python script
|
|
||||||
if self.espidf.lower().endswith(".py") and sys.executable:
|
|
||||||
cmd_flash.insert(0, sys.executable)
|
|
||||||
|
|
||||||
if self.bootloader_bin:
|
if self.bootloader_bin:
|
||||||
cmd_flash.extend([self.boot_address, self.bootloader_bin])
|
cmd_flash.extend([self.boot_address, self.bootloader_bin])
|
||||||
cmd_flash.extend([self.part_table_address, self.partition_table_bin])
|
cmd_flash.extend([self.part_table_address, self.partition_table_bin])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue