Bootloader¶
Overview¶
The ARDEP bootloader uses MCUboot and supports different firmware update mechanisms depending on the board version:
Default boot logic: UDS Firmware Loader
V2 boards come with an On-Board Debugger (OBD) and use UDS (Unified Diagnostic Services) over CAN as the default firmware update mechanism via the UDS Firmware Loader.
The BOOT jumper (PE4) triggers entry into the UDS firmware loader for UDS updates.
Default boot logic: USB DFU
V1 boards use USB DFU (Device Firmware Update) as the default firmware update mechanism.
The BOOT jumper (PE4) triggers entry into USB DFU mode for firmware updates via the dfu-util tool.
Note
V1 boards can optionally be configured to use the UDS firmware loader by explicitly enabling it in sysbuild configuration.
Building the bootloader¶
The bootloader can be built using sysbuild together with a sample for flashing. To reset the board to a delivery state, use
west build -b ardep samples/led -p --sysbuild
to build the LED Sample and bootloader
If you want to build for a specific board version, change the -b argument accordingly:
west build -b ardep@1.0.0 samples/led -p --sysbuild
Flashing the bootloader¶
The bootloader is flashed via the on-board debugger using the west flash command.
Just run:
west flash
This will flash the bootloader to the board.
The bootloader is flashed with an external debug probe (e.g. J-Link) using the west flash command.
For this connect the SWD Pins of the ARDEP board to the debug probe an run:
west flash -r {runner}
The Pinout of the SWD connector is printed on the boards backside.
See the board.cmake file under boards/arm/ardep for more info about supported debuggers/runners.
USB DFU Bootloader Mode (ARDEP v1)¶
Note
This section applies primarily to ARDEP v1 boards, which use USB DFU as the default firmware update mechanism.
ARDEP v2 and later boards use the UDS Firmware Loader by default and have an On-Board Debugger (OBD), allowing standard flashing via west flash.
In USB DFU mode, the ARDEP board does not load any firmware and waits for a firmware upgrade via the dfu-util tool.
This is handy if your firmware is broken and you can’t update it from there.
It is helpful to see the Bootloader console output on UART-A for this.
Entering USB DFU Bootloader Mode¶
To enter the USB DFU bootloader mode, pull the PE4 pin (labeled BOOT) to a LOW state (by setting the jumper) while power-cycling or pushing the Reset button.
When the red LED lights up permanently, the board is in USB DFU bootloader mode.
On UART-A you will see the following output:
*** Booting Zephyr OS build zephyr-vx.y.z ***
I: Starting bootloader
I: Waiting for USB DFU
Note
UART-A is the output that is forwarded by the on-board debugger.
Note
If you flashed the UDS firmware loader on the ARDEP v1 board, the bootloader will enter the UDS firmware loader instead of USB DFU mode when the BOOT jumper is set. This means, that flashing via USB DFU is only possible when not using the UDS firmware loader and according bootloader.
Upgrading the Firmware via USB DFU¶
Build the firmware you want to flash (assuming it is in the build directory)
Perform the upgrade with
west flashWait for the upgrade to complete
UDS Firmware Loader¶
Note
ARDEP v2.0.0 and later: The UDS firmware loader is the default boot logic. You can build any application with sysbuild and it will automatically include the UDS firmware loader.
ARDEP v1.0.0: USB DFU is the default. To use the UDS firmware loader, you must explicitly enable it in the sysbuild configuration and flash the application, bootloader and firmware loader via an external debug probe, see Flashing the bootloader.
For applications that require firmware updates over UDS (Unified Diagnostic Services), a UDS Firmware Loader is provided which can be built using sysbuild.
It is not recommended to build the firmware loader independently as the bootloader needs configuration options to handle the firmware loader correctly.
For demonstration purposes, build the UDS Sample using sysbuild (which contains a sysbuild.conf), which automatically builds the firmware loader:
west build -b ardep samples/uds -p --sysbuild
Note
On ARDEP v1 boards, the default dfu-util flasher will not work to flash the bootloader, see Flashing the bootloader
If you wish to build your own application using the UDS Firmware loader, enable the sysbuild boot logic configuration like this:
west build -b ardep <path-to-your-app> -p --sysbuild -- -DSB_CONFIG_BOOT_LOGIC_UDS_FIRMWARE_LOADER=y
Or more permanently by creating a sysbuild.conf file in your application folder and adding the following content:
SB_CONFIG_BOOT_LOGIC_UDS_FIRMWARE_LOADER=y
Important
When using the default UDS instance (CONFIG_UDS_DEFAULT_INSTANCE=y, enabled by default on ARDEP boards), the firmware loader switch is handled automatically on programming session requests unless disabled with CONFIG_UDS_DEFAULT_INSTANCE_DISABLE_SWITCH_TO_FIRMWARE_LOADER=y.
If you create a custom UDS instance or disable the automatic switch, you must call uds_switch_to_firmware_loader_with_programming_session() in your diagnostic session control action handler when a programming session is requested.
Sysbuild¶
With sysbuild, multiple applications (i.e. bootloader, main application and sometimes firmware loader) are built together using just one build command.
More information is available in the official Zephyr Sysbuild documentation.
Sysbuild basics¶
There are multiple things that differ from a normal west build:
First, there are multiple targets for using menuconfig, one for each “domain”:
# Main application menuconfig
west build -t menuconfig
# Bootloader menuconfig
west build -t mcuboot_menuconfig
# (If enabled) Firmware loader menuconfig
west build -t firmware_loader_menuconfig
# Sysbuild menuconfig (also contains the config option for enabling the firmware loader)
west build -t sysbuild_menuconfig
Second, you can switch between domains when debugging by specifying the domain:
# Debug main application
west debug
# Debug bootloader
west debug --domain mcuboot
# (If enabled) Debug firmware loader
west debug --domain firmware_loader
Finally, when flashing, you can either specify no domain, which flashes all domains in series or you can specify a domain to flash only that domain:
# Flash all domains (bootloader, firmware loader (if enabled) and main application)
west flash
# Flash only bootloader
west flash --domain mcuboot
# (If enabled) Flash only firmware loader
west flash --domain firmware_loader
# Flash only main application (when building sample/uds the sample-name would be uds)
west flash --domain <sample-name>
Important
Note that on ARDEP v1 boards, only the main application can be flashed using the ardep runner. This also means that the bootloader and (if needed) firmware loader must be flashed using an external debug probe, see Flashing the bootloader.