Patrick Delaunay | 5bce467 | 2019-10-14 09:27:59 +0200 | [diff] [blame^] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | Device Firmware Upgrade (DFU) |
| 4 | |
| 5 | Overview: |
| 6 | |
| 7 | The Device Firmware Upgrade (DFU) allows to download and upload firmware |
| 8 | to/from U-Boot connected over USB. |
| 9 | |
| 10 | U-boot follows the Universal Serial Bus Device Class Specification for |
| 11 | Device Firmware Upgrade Version 1.1 the USB forum (DFU v1.1 in www.usb.org). |
| 12 | |
| 13 | U-Boot implements this DFU capability (CONFIG_DFU) with the command dfu |
| 14 | (cmd/dfu.c / CONFIG_CMD_DFU) based on: |
| 15 | - the DFU stack (common/dfu.c and common/spl/spl_dfu.c), based on the |
| 16 | USB DFU download gadget (drivers/usb/gadget/f_dfu.c) |
| 17 | - The access to mediums is done in DFU backends (driver/dfu) |
| 18 | |
| 19 | Today the supported DFU backends are: |
| 20 | - MMC (RAW or FAT / EXT2 / EXT3 / EXT4 file system) |
| 21 | - NAND |
| 22 | - RAM |
| 23 | - SF (serial flash) |
| 24 | |
| 25 | These DFU backends are also used by |
| 26 | - the dfutftp (see README.dfutftp) |
| 27 | - the thordown command (cmd/thordown.c and gadget/f_thor.c) |
| 28 | |
| 29 | Configuration Options: |
| 30 | CONFIG_DFU |
| 31 | CONFIG_DFU_OVER_USB |
| 32 | CONFIG_DFU_MMC |
| 33 | CONFIG_DFU_NAND |
| 34 | CONFIG_DFU_RAM |
| 35 | CONFIG_DFU_SF |
| 36 | CONFIG_CMD_DFU |
| 37 | |
| 38 | Environment variables: |
| 39 | the dfu command use 3 environments variables: |
| 40 | "dfu_alt_info" : the DFU setting for the USB download gadget with a comma |
| 41 | separated string of information on each alternate: |
| 42 | dfu_alt_info="<alt1>;<alt2>;....;<altN>" |
| 43 | |
| 44 | "dfu_bufsiz" : size of the DFU buffer, when absent, use |
| 45 | CONFIG_SYS_DFU_DATA_BUF_SIZE (8MiB by default) |
| 46 | |
| 47 | "dfu_hash_algo" : name of the hash algorithm to use |
| 48 | |
| 49 | Commands: |
| 50 | dfu <USB_controller> <interface> <dev> list |
| 51 | list the alternate device defined in "dfu_alt_info" |
| 52 | |
| 53 | dfu <USB_controller> <interface> <dev> |
| 54 | start the dfu stack on the USB instance with the selected medium |
| 55 | backend and use the "dfu_alt_info" variable to configure the |
| 56 | alternate setting and link each one with the medium |
| 57 | The dfu command continue until receive a ^C in console or |
| 58 | a DFU detach transaction from HOST. |
| 59 | |
| 60 | The possible values of <interface> are : |
| 61 | (with <USB controller> = 0 in the dfu command example) |
| 62 | |
| 63 | "mmc" (for eMMC and SD card) |
| 64 | cmd: dfu 0 mmc <dev> |
| 65 | each element in "dfu_alt_info" = |
| 66 | <name> raw <offset> <size> raw access to mmc device |
| 67 | <name> part <dev> <part_id> raw acces to partition |
| 68 | <name> fat <dev> <part_id> file in FAT partition |
| 69 | <name> ext4 <dev> <part_id> file in EXT4 partition |
| 70 | |
| 71 | with <partid> is the GPT or DOS partition index |
| 72 | |
| 73 | "nand" (raw slc nand device) |
| 74 | cmd: dfu 0 nand <dev> |
| 75 | each element in "dfu_alt_info" = |
| 76 | <name> raw <offset> <size> raw access to mmc device |
| 77 | <name> part <dev> <part_id> raw acces to partition |
| 78 | <name> partubi <dev> <part_id> raw acces to ubi partition |
| 79 | |
| 80 | with <partid> is the MTD partition index |
| 81 | |
| 82 | "ram" |
| 83 | cmd: dfu 0 ram <dev> |
| 84 | (<dev> is not used for RAM target) |
| 85 | each element in "dfu_alt_info" = |
| 86 | <name> ram <offset> <size> raw access to ram |
| 87 | |
| 88 | "sf" (serial flash : NOR) |
| 89 | cmd: dfu 0 sf <dev> |
| 90 | each element in "dfu_alt_info" = |
| 91 | <name> ram <offset> <size> raw access to sf device |
| 92 | |
| 93 | Host tools: |
| 94 | When U-Boot runs the dfu stack, the DFU host tools can be used |
| 95 | to send/receive firmwares on each configurated alternate. |
| 96 | |
| 97 | For example dfu-util is a host side implementation of the DFU 1.1 |
| 98 | specifications(http://dfu-util.sourceforge.net/) which works with U-Boot. |
| 99 | |
| 100 | Usage: |
| 101 | Example for firmware located in eMMC or SD card, with: |
| 102 | - alternate 1 (alt=1) for SPL partition (GPT partition 1) |
| 103 | - alternate 2 (alt=2) for U-Boot partition (GPT partition 2) |
| 104 | |
| 105 | The U-Boot configuration is: |
| 106 | |
| 107 | U-Boot> env set dfu_alt_info "spl part 0 1;u-boot part 0 2" |
| 108 | |
| 109 | U-Boot> dfu 0 mmc 0 list |
| 110 | DFU alt settings list: |
| 111 | dev: eMMC alt: 0 name: spl layout: RAW_ADDR |
| 112 | dev: eMMC alt: 1 name: u-boot layout: RAW_ADDR |
| 113 | |
| 114 | Boot> dfu 0 mmc 0 |
| 115 | |
| 116 | On the Host side: |
| 117 | |
| 118 | list the available alternate setting: |
| 119 | |
| 120 | $> dfu-util -l |
| 121 | dfu-util 0.9 |
| 122 | |
| 123 | Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. |
| 124 | Copyright 2010-2016 Tormod Volden and Stefan Schmidt |
| 125 | This program is Free Software and has ABSOLUTELY NO WARRANTY |
| 126 | Please report bugs to http://sourceforge.net/p/dfu-util/tickets/ |
| 127 | |
| 128 | Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \ |
| 129 | alt=1, name="u-boot", serial="003A00203438510D36383238" |
| 130 | Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \ |
| 131 | alt=0, name="spl", serial="003A00203438510D36383238" |
| 132 | |
| 133 | To download to U-Boot, use -D option |
| 134 | |
| 135 | $> dfu-util -a 0 -D u-boot-spl.bin |
| 136 | $> dfu-util -a 1 -D u-boot.bin |
| 137 | |
| 138 | To upload from U-Boot, use -U option |
| 139 | |
| 140 | $> dfu-util -a 0 -U u-boot-spl.bin |
| 141 | $> dfu-util -a 1 -U u-boot.bin |
| 142 | |
| 143 | To request a DFU detach and reset the USB connection: |
| 144 | $> dfu-util -a 0 -e -R |