scripts: runners: bossac: Add legacy mode
Add compatibility mode with old sam-ba flash bootloaders that don't have offset capabilities. These bootloaders flash to a pre-defined flash region. At end, bossac will suppress --offset parameter. Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
parent
0e26836c8a
commit
f3a7f041bf
4 changed files with 64 additions and 4 deletions
|
@ -561,7 +561,6 @@ config BOOTLOADER_ESP_IDF
|
||||||
config BOOTLOADER_BOSSA
|
config BOOTLOADER_BOSSA
|
||||||
bool "BOSSA bootloader support"
|
bool "BOSSA bootloader support"
|
||||||
select USE_DT_CODE_PARTITION
|
select USE_DT_CODE_PARTITION
|
||||||
depends on SOC_FAMILY_SAM0
|
|
||||||
|
|
||||||
help
|
help
|
||||||
Signifies that the target uses a BOSSA compatible bootloader. If CDC
|
Signifies that the target uses a BOSSA compatible bootloader. If CDC
|
||||||
|
@ -579,6 +578,13 @@ choice
|
||||||
prompt "BOSSA bootloader variant"
|
prompt "BOSSA bootloader variant"
|
||||||
depends on BOOTLOADER_BOSSA
|
depends on BOOTLOADER_BOSSA
|
||||||
|
|
||||||
|
config BOOTLOADER_BOSSA_LEGACY
|
||||||
|
bool "Legacy"
|
||||||
|
help
|
||||||
|
Select the Legacy variant of the BOSSA bootloader. This is defined
|
||||||
|
for compatibility mode only. The recommendation is use newer
|
||||||
|
versions like Arduino or Adafruit UF2.
|
||||||
|
|
||||||
config BOOTLOADER_BOSSA_ARDUINO
|
config BOOTLOADER_BOSSA_ARDUINO
|
||||||
bool "Arduino"
|
bool "Arduino"
|
||||||
help
|
help
|
||||||
|
|
|
@ -65,12 +65,18 @@ For these devices, the user should:
|
||||||
automatically select the :option:`CONFIG_USE_DT_CODE_PARTITION` Kconfig
|
automatically select the :option:`CONFIG_USE_DT_CODE_PARTITION` Kconfig
|
||||||
option which instruct the build system to use these partitions for code
|
option which instruct the build system to use these partitions for code
|
||||||
relocation. The board :file:`.defconfig` file should have
|
relocation. The board :file:`.defconfig` file should have
|
||||||
:option:`CONFIG_BOOTLOADER_BOSSA_ARDUINO` or the
|
:option:`CONFIG_BOOTLOADER_BOSSA_ARDUINO` ,
|
||||||
:option:`CONFIG_BOOTLOADER_BOSSA_ADAFRUIT_UF2` Kconfig option set to ``y``
|
:option:`CONFIG_BOOTLOADER_BOSSA_ADAFRUIT_UF2` or the
|
||||||
|
:option:`CONFIG_BOOTLOADER_BOSSA_LEGACY` Kconfig option set to ``y``
|
||||||
to select the right compatible SAM-BA bootloader mode.
|
to select the right compatible SAM-BA bootloader mode.
|
||||||
These options can also be set in ``prj.conf`` or any other Kconfig fragment.
|
These options can also be set in ``prj.conf`` or any other Kconfig fragment.
|
||||||
3. Build and flash the SAM-BA bootloader on the device.
|
3. Build and flash the SAM-BA bootloader on the device.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
The :option:`CONFIG_BOOTLOADER_BOSSA_LEGACY` Kconfig option should be used
|
||||||
|
as last resource. Try configure first with Devices without ROM bootloader.
|
||||||
|
|
||||||
|
|
||||||
Typical flash layout and configuration
|
Typical flash layout and configuration
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
|
@ -176,6 +182,7 @@ As a quick reference, see these three board documentation pages:
|
||||||
- :ref:`sam4e_xpro` (ROM bootloader)
|
- :ref:`sam4e_xpro` (ROM bootloader)
|
||||||
- :ref:`adafruit_feather_m0_basic_proto` (Adafruit UF2 bootloader)
|
- :ref:`adafruit_feather_m0_basic_proto` (Adafruit UF2 bootloader)
|
||||||
- :ref:`arduino_nano_33_iot` (Arduino bootloader)
|
- :ref:`arduino_nano_33_iot` (Arduino bootloader)
|
||||||
|
- :ref:`arduino_nano_33_ble` (Arduino legacy bootloader)
|
||||||
|
|
||||||
.. _jlink-debug-host-tools:
|
.. _jlink-debug-host-tools:
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,9 @@ class BossacBinaryRunner(ZephyrBinaryRunner):
|
||||||
return self.build_conf['CONFIG_BOARD']
|
return self.build_conf['CONFIG_BOARD']
|
||||||
|
|
||||||
def get_dts_img_offset(self):
|
def get_dts_img_offset(self):
|
||||||
|
if self.build_conf.getboolean('CONFIG_BOOTLOADER_BOSSA_LEGACY'):
|
||||||
|
return 0
|
||||||
|
|
||||||
if self.build_conf.getboolean('CONFIG_HAS_FLASH_LOAD_OFFSET'):
|
if self.build_conf.getboolean('CONFIG_HAS_FLASH_LOAD_OFFSET'):
|
||||||
return self.build_conf['CONFIG_FLASH_LOAD_OFFSET']
|
return self.build_conf['CONFIG_FLASH_LOAD_OFFSET']
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright (c) 2018 Foundries.io
|
# Copyright (c) 2018 Foundries.io
|
||||||
# Copyright (c) 2019 Nordic Semiconductor ASA.
|
# Copyright (c) 2019 Nordic Semiconductor ASA.
|
||||||
# Copyright (c) 2020 Gerson Fernando Budke <nandojve@gmail.com>
|
# Copyright (c) 2020-2021 Gerson Fernando Budke <nandojve@gmail.com>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
@ -121,6 +121,15 @@ CONFIG_HAS_FLASH_LOAD_OFFSET=y
|
||||||
CONFIG_FLASH_LOAD_OFFSET=0x0
|
CONFIG_FLASH_LOAD_OFFSET=0x0
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
# SAM-BA Legacy Mode
|
||||||
|
DOTCONFIG_COND6 = f'''
|
||||||
|
CONFIG_BOARD="{TEST_BOARD_NAME}"
|
||||||
|
CONFIG_USE_DT_CODE_PARTITION=y
|
||||||
|
CONFIG_BOOTLOADER_BOSSA_LEGACY=y
|
||||||
|
CONFIG_HAS_FLASH_LOAD_OFFSET=y
|
||||||
|
CONFIG_FLASH_LOAD_OFFSET=0x162e
|
||||||
|
'''
|
||||||
|
|
||||||
def adjust_runner_config(runner_config, tmpdir, dotconfig):
|
def adjust_runner_config(runner_config, tmpdir, dotconfig):
|
||||||
# Adjust a RunnerConfig object, 'runner_config', by
|
# Adjust a RunnerConfig object, 'runner_config', by
|
||||||
# replacing its build directory with 'tmpdir' after writing
|
# replacing its build directory with 'tmpdir' after writing
|
||||||
|
@ -396,6 +405,41 @@ def test_bossac_create_with_adafruit(cc, req, get_cod_par, sup,
|
||||||
assert cc.call_args_list == [call(x) for x in EXPECTED_COMMANDS_WITH_EXTENDED]
|
assert cc.call_args_list == [call(x) for x in EXPECTED_COMMANDS_WITH_EXTENDED]
|
||||||
|
|
||||||
|
|
||||||
|
@patch('runners.bossac.BossacBinaryRunner.supports',
|
||||||
|
return_value=True)
|
||||||
|
@patch('runners.bossac.BossacBinaryRunner.get_chosen_code_partition_node',
|
||||||
|
return_value=True)
|
||||||
|
@patch('runners.core.ZephyrBinaryRunner.require',
|
||||||
|
side_effect=require_patch)
|
||||||
|
@patch('runners.core.ZephyrBinaryRunner.check_call')
|
||||||
|
def test_bossac_create_with_legacy(cc, req, get_cod_par, sup,
|
||||||
|
runner_config, tmpdir):
|
||||||
|
"""
|
||||||
|
Test SAM-BA legacy protocol
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
Any SDK
|
||||||
|
|
||||||
|
Configuration:
|
||||||
|
Extended bootloader
|
||||||
|
CONFIG_USE_DT_CODE_PARTITION=y
|
||||||
|
CONFIG_BOOTLOADER_BOSSA_LEGACY=y
|
||||||
|
with zephyr,code-partition
|
||||||
|
|
||||||
|
Input:
|
||||||
|
--bossac-port
|
||||||
|
|
||||||
|
Output:
|
||||||
|
no --offset
|
||||||
|
"""
|
||||||
|
runner_config = adjust_runner_config(runner_config, tmpdir,
|
||||||
|
DOTCONFIG_COND6)
|
||||||
|
runner = BossacBinaryRunner(runner_config, port=TEST_BOSSAC_PORT)
|
||||||
|
with patch('os.path.isfile', side_effect=os_path_isfile_patch):
|
||||||
|
runner.run('flash')
|
||||||
|
assert cc.call_args_list == [call(x) for x in EXPECTED_COMMANDS]
|
||||||
|
|
||||||
|
|
||||||
@patch('runners.bossac.BossacBinaryRunner.supports',
|
@patch('runners.bossac.BossacBinaryRunner.supports',
|
||||||
return_value=False)
|
return_value=False)
|
||||||
@patch('runners.bossac.BossacBinaryRunner.get_chosen_code_partition_node',
|
@patch('runners.bossac.BossacBinaryRunner.get_chosen_code_partition_node',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue