dfutool Command in Linux



The Linux dfutool command upgrades the DFU-capable device firmware. It is used to verify, archive, and upgrade the firmware files. The device manufacturer can include this tool to upgrade their device’s firmware. However, it is important to note that it may not be available on all Linux distributions. In such cases, an alternative tool dfu-util can be used.

The dfu-util is an open-source command line utility designed to upgrade DFU-capable USB devices. Since most modern devices use USB for data communication, dfu-util is highly useful for a wide range of devices, making it a practical alternative to the dfutool command.

Table of Contents

Here is a comprehensive guide to the options available with the dfutool command −

Syntax of dfutool Command

The syntax of the Linux dfutool command is as follows −

dfutool [options] [command] [dfu_file]

The [options] field is used to specify the options. The dfutool comes with various subcommands to manage the DFU files, they are specified in the [command] field. While the file to be modified will be mentioned in the [dfu_file] field.

dfutool Command Options

The options used with the dfutool command are listed below −

Options Description
-h It is used to display the help of the dfutool command
-d device It is used to specify the device to use

Subcommands of dfutool Command

The subcommands of dfutool are listed below −

Subcommand Description
verify <dfu-file> It prints the information about the specified firmware file
modify <dfu-file> It is used to modify the specific values of firmware file
upgrade <dfu-file> It is used to upgrade the firmware file
archive <dfu-file> It is used to archive the firmware of the device

Examples of dfutool Command in Linux

This section discusses the usage of the dfutool command in Linux with examples −

  • Verify the Firmware File
  • Archive the Firmware
  • Upgrade the Firmware

Verify the Firmware File

To verify whether the firmware file is valid, it can be verified using the verify subcommand −

dfutool verify testware.dfu

Archive the Firmware

To back up the firmware of a device, specify the device and use the archive subcommand −

dfutool -d /dev/sda1 archive testware.dfu

Upgrade the Firmware

To upgrade the firmware of the device, use the upgrade subcommand −

dfutool -d /dev/sda1 upgrade new_firmware.dfu

The dfutool command is no longer supported by many Linux distributions. Therefore, a robust alternative dfu-utils is available. It performs the same functionality in a much better way. The next section is dedicated to this tool.

Using dfu-util Command in Linux

The dfu-utils is an open-source command line utility for firmware updates of USB-connected DFU-capable devices. There are various DFU-capable devices such as Arduino boards, Raspberry Pi, switches, routers, and USB keyboards. The dfu-util can be used to manage their firmware.

The dfu-util may not be installed on Linux, to install it, use the instructions below.

To install dfu-util on Ubuntu, Debian, and its flavors, use −

sudo apt install dfu-util

To install it on Fedora, use −

sudo dnf install dfu-util

To get it on Arch Linux, use −

sudo pacman -S dfu-util

To verify the installation, use −

dfu-util --version
Using dfu-util Command 1

The syntax of using the dfu-util command is as follows −

dfu-util [options] [dfu_file]

The options used with dfu-util are listed in the following table −

Options Description
-l (--list) It lists the currently attached DFU-capable devices
-d (--device) VEN:PRO It is used to specify the DFU-capable device ID which includes vendor and product IDs (This option may not be needed only one device is attached)
-e (--detach) To remove the currently attached DFU device
-U (--upload) FILE It reads firmware from the device to the FILE
-D (--download) FILE It writes firmware from FILE to the device
-R (--reset) It issues a USB reset signal
-h (--help) It displays a brief help of the command
-v (--verbose) It is used to get verbose output

The usage of the dfu-util command is given in the following examples −

1. To display the list of connected DFU-capable devices, use the -l option −

dfu-util -l

This command also displays the vendor and product IDs.

2. To flash or update the firmware to a DFU-capable device, use the -D option. For example, to flash firmware to an Arduino Mega, use the following command −

dfu-util -D MEGA-dfu_and_usbserial_combined.hex

The firmware file can be a .bin or .hex file.

Note − To use dfu-util with Arduino, the device must be in DFU mode.

To specify the vendor and product name, use −

dfu-util -d 2342:0010 -D MEGA-dfu_and_usbserial_combined.hex

Here, 2342 is the vendor ID while 0010 is the product ID (Arduino Mega 2560).

3. To read the firmware from the connected DFU-capable device, use the -U option −

dfu-util -U backup_firmware.hex

4. To display help about the dfu-util command, use the -h option −

dfu-util -h
Using dfu-util Command 2

Conclusion

The dfutool in Linux updates the firmware of DFU-capable devices. It is used to archive and update the firmware. The dfutool has many alternatives, one of them is dfu-util. It is an open-source alternative that offers advanced options such as specifying the block sizes and configurations.

In this tutorial, we covered both dfutool and its alternative dfu-util, including their syntaxes, options, and usage through examples.

Advertisements