runners: esp32.py: Support flashing for MCUboot and IDF bootloader
IDF bootloader requires partition table which is not a requirement for MCUboot. Hence, esp32.py is updated to flash partition table only if it exists. Current implementation only allows flashing zephyr.bin. This commit adds capability to flash binaries with other names as well (e.g. - zephyr.signed.bin) Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
This commit is contained in:
parent
d008f1c63a
commit
5f11ac7c2a
1 changed files with 12 additions and 4 deletions
|
@ -18,7 +18,7 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
|
||||||
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, 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, app_bin=None):
|
||||||
super().__init__(cfg)
|
super().__init__(cfg)
|
||||||
self.elf = cfg.elf_file
|
self.elf = cfg.elf_file
|
||||||
self.device = device
|
self.device = device
|
||||||
|
@ -32,6 +32,7 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
|
||||||
self.espidf = espidf
|
self.espidf = espidf
|
||||||
self.bootloader_bin = bootloader_bin
|
self.bootloader_bin = bootloader_bin
|
||||||
self.partition_table_bin = partition_table_bin
|
self.partition_table_bin = partition_table_bin
|
||||||
|
self.app_bin = app_bin
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def name(cls):
|
def name(cls):
|
||||||
|
@ -71,6 +72,8 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
|
||||||
help='Bootloader image to flash')
|
help='Bootloader image to flash')
|
||||||
parser.add_argument('--esp-flash-partition_table',
|
parser.add_argument('--esp-flash-partition_table',
|
||||||
help='Partition table to flash')
|
help='Partition table to flash')
|
||||||
|
parser.add_argument('--esp-flash-app',
|
||||||
|
help='App to flash')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def do_create(cls, cfg, args):
|
def do_create(cls, cfg, args):
|
||||||
|
@ -87,11 +90,15 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
|
||||||
flash_size=args.esp_flash_size, flash_freq=args.esp_flash_freq,
|
flash_size=args.esp_flash_size, flash_freq=args.esp_flash_freq,
|
||||||
flash_mode=args.esp_flash_mode, espidf=espidf,
|
flash_mode=args.esp_flash_mode, espidf=espidf,
|
||||||
bootloader_bin=args.esp_flash_bootloader,
|
bootloader_bin=args.esp_flash_bootloader,
|
||||||
partition_table_bin=args.esp_flash_partition_table)
|
partition_table_bin=args.esp_flash_partition_table,
|
||||||
|
app_bin=args.esp_flash_app)
|
||||||
|
|
||||||
def do_run(self, command, **kwargs):
|
def do_run(self, command, **kwargs):
|
||||||
self.require(self.espidf)
|
self.require(self.espidf)
|
||||||
bin_name = path.splitext(self.elf)[0] + path.extsep + 'bin'
|
if self.app_bin:
|
||||||
|
bin_name = self.app_bin
|
||||||
|
else:
|
||||||
|
bin_name = path.splitext(self.elf)[0] + path.extsep + 'bin'
|
||||||
|
|
||||||
cmd_flash = [self.espidf, '--chip', 'auto']
|
cmd_flash = [self.espidf, '--chip', 'auto']
|
||||||
if self.device is not None:
|
if self.device is not None:
|
||||||
|
@ -109,7 +116,8 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
|
||||||
|
|
||||||
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])
|
if self.partition_table_bin:
|
||||||
|
cmd_flash.extend([self.part_table_address, self.partition_table_bin])
|
||||||
cmd_flash.extend([self.app_address, bin_name])
|
cmd_flash.extend([self.app_address, bin_name])
|
||||||
else:
|
else:
|
||||||
cmd_flash.extend([self.boot_address, bin_name])
|
cmd_flash.extend([self.boot_address, bin_name])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue