diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 9d09ce3edfe..a3e2e93df0c 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -561,7 +561,6 @@ config BOOTLOADER_ESP_IDF config BOOTLOADER_BOSSA bool "BOSSA bootloader support" select USE_DT_CODE_PARTITION - depends on SOC_FAMILY_SAM0 help Signifies that the target uses a BOSSA compatible bootloader. If CDC @@ -579,6 +578,13 @@ choice prompt "BOSSA bootloader variant" 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 bool "Arduino" help diff --git a/doc/guides/flash_debug/host-tools.rst b/doc/guides/flash_debug/host-tools.rst index 05f2363dd0f..8b2ee167a00 100644 --- a/doc/guides/flash_debug/host-tools.rst +++ b/doc/guides/flash_debug/host-tools.rst @@ -65,12 +65,18 @@ For these devices, the user should: automatically select the :option:`CONFIG_USE_DT_CODE_PARTITION` Kconfig option which instruct the build system to use these partitions for code relocation. The board :file:`.defconfig` file should have - :option:`CONFIG_BOOTLOADER_BOSSA_ARDUINO` or the - :option:`CONFIG_BOOTLOADER_BOSSA_ADAFRUIT_UF2` Kconfig option set to ``y`` + :option:`CONFIG_BOOTLOADER_BOSSA_ARDUINO` , + :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. 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. +.. 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 -------------------------------------- @@ -176,6 +182,7 @@ As a quick reference, see these three board documentation pages: - :ref:`sam4e_xpro` (ROM bootloader) - :ref:`adafruit_feather_m0_basic_proto` (Adafruit UF2 bootloader) - :ref:`arduino_nano_33_iot` (Arduino bootloader) + - :ref:`arduino_nano_33_ble` (Arduino legacy bootloader) .. _jlink-debug-host-tools: diff --git a/scripts/west_commands/runners/bossac.py b/scripts/west_commands/runners/bossac.py index 40b9cf4325a..325d6723063 100644 --- a/scripts/west_commands/runners/bossac.py +++ b/scripts/west_commands/runners/bossac.py @@ -121,6 +121,9 @@ class BossacBinaryRunner(ZephyrBinaryRunner): return self.build_conf['CONFIG_BOARD'] 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'): return self.build_conf['CONFIG_FLASH_LOAD_OFFSET'] diff --git a/scripts/west_commands/tests/test_bossac.py b/scripts/west_commands/tests/test_bossac.py index 30bbbab3e78..08051fa823a 100644 --- a/scripts/west_commands/tests/test_bossac.py +++ b/scripts/west_commands/tests/test_bossac.py @@ -1,6 +1,6 @@ # Copyright (c) 2018 Foundries.io # Copyright (c) 2019 Nordic Semiconductor ASA. -# Copyright (c) 2020 Gerson Fernando Budke +# Copyright (c) 2020-2021 Gerson Fernando Budke # # SPDX-License-Identifier: Apache-2.0 @@ -121,6 +121,15 @@ CONFIG_HAS_FLASH_LOAD_OFFSET=y 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): # Adjust a RunnerConfig object, 'runner_config', by # 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] +@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', return_value=False) @patch('runners.bossac.BossacBinaryRunner.get_chosen_code_partition_node',