Template:GLSDK DFU

{{#ifeq:{{{platform}}}|DRA7xx|

Device Firmware Upgrade (DFU)
The Device Firmware Upgrade (DFU) feature is used to program or flash the firmware to memory devices such as eMMC/MMCSD/QSPI/NOR/NAND/RAM devices. The u-boot has DFU support for eMMC, MMC/SD, QSPI and RAM devices.

DFU Supported Devices in u-boot

 * eMMC
 * MMC/SD
 * RAM
 * QSPI

SPL-DFU support (USB Peripheral boot mode)
This method is used to flash the binary images from ubuntu Host PC (using dfu-utils tool) to EVM over usb interface using Device Firmware Update (DFU) feature. This is used to flash the eMMC, or QSPI to fresh/factory boards. # make dra7xx_evm_defconfig
 * Use default "dra7xx_evm_defconfig" to build spl/u-boot-spl.bin, u-boot.img.

# make SW2[7..0] = 0000000 $ sudo ./usbboot -S spl/u-boot-spl.bin
 * select SPL->DFU support from menuconfig->"Boot Images"->"Enable SPL with DFU to load binares to memory device"
 * Build spl/u-boot-spl.bin and u-boot.img
 * Set SYSBOOT SW2 switch to USB Peripheral boot mode
 * Connect EVM Superspeed port (USB1 port) to PC (Ubuntu) through USB cable.
 * From Ubuntu PC, load spl/u-boot-spl.bin to EVM. Issue below command and reset the board.


 * Load the u-boot.img to RAM.
 * 1) sudo dfu-util -l

Found DFU: [0451:d022] devnum=0, cfg=1, intf=0, alt=0, name="kernel" Found DFU: [0451:d022] devnum=0, cfg=1, intf=0, alt=1, name="fdt" Found DFU: [0451:d022] devnum=0, cfg=1, intf=0, alt=2, name="ramdisk"

$ sudo dfu-util c 1 -i 0 -a 0 -D "u-boot.img" -R


 * Now EVM will boot to u-boot prompt.

DFU Usage from u-boot
Use default "dra7xx_evm_defconfig" to build MLO and u-boot.img. make dra7xx_evm_defconfig make Connect the EVM with Ubuntu Host through micro USB device cable (USB1 port on EVM).

Reset the default environment variable set the dfu_alt_info environment variable to emmc dfu settings
 * From target u-boot prompt
 * 1) env default -a
 * 1) setenv dfu_alt_info ${dfu_alt_info_emmc}

dfu mmc <1-eMMC, 0-mmc/sd> set_config: high speed config #1: usb_dnload
 * Run DFU command chosing eMMC as memory device
 * 1) dfu 0 mmc 1

To list the available partition to load the file.
 * From PC host side (Ubuntu)

dfu-util 0.5 (C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. (C) 2010-2011 Tormod Volden (DfuSe support) This program is Free Software and has ABSOLUTELY NO WARRANTY dfu-util does currently only support DFU version 1.0 Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=0, name="rawemmc" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=1, name="boot" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=2, name="rootfs" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=3, name="MLO" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=4, name="MLO.raw" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=5, name="u-boot.img.raw" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=6, name="spl-os-args.raw" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=7, name="spl-os-image.raw" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=8, name="spl-os-args" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=9, name="spl-os-image" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=10, name="u-boot.img" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=11, name="uEnv.txt
 * 1) sudo dfu-util -l

The above list shows list of dfu partitions or file name.

Flashing rawemmc partition
The "rawemmc" partition is used to update the disk image to raw eMMC sector 0. This is used to flash the eMMC to fresh boards. Please refer to section Using USB peripheral boot mode

Update existing MLO and u-boot.img of eMMC boot partition (vfat)
This method is used to update the MLO/u-boot.img files in boot(vfat) partion of eMMC
 * To update the MLO file
 * 1) sudo dfu-util -D MLO -c 1 -i 0 -a 3


 * To update the u-boot.img file
 * 1) sudo dfu-util -D u-boot.img -c 1 -i 0 -a 10

Update existing boot and rootfs partition (ext4) of eMMC
This method is used to update the existing boot partition (vfat) or rootfs partition (ext4) images in eMMC
 * To update the boot partition disk image
 * 1) sudo dfu-util -D boot.img -c 1 -i 0 -a 1


 * To update the rootfs partition disk image
 * 1) sudo dfu-util -D rootfs.img -c 1 -i 0 -a 2

Steps to create boot (vfat) and rootfs (ext4) raw disk image
In order to create raw boot and rootfs disk image along with partition structure follow the steps mentioned below. #mount /dev/sdY1 /media/boot #mount /dev/sdY2 /media/rootfs #cp /media/boot/uenv-emmc.c /media/boot/uenv.txt #sync Create the vfat raw boot disk image along with partition structure Create the ext4 raw rootfs disk image along with partition structure
 * 1) Insert the mmc/sd card to Ubuntu PC, the size of sdcard shall be less than or equal to size of eMMC populated in EVM.
 * 2) Prepare mmc/sd card mentioned in step4 of Processor SDK Linux Automotive User Guide. By default the mksdboot.sh script creates two partitions, 64MB of boot partition with vfat filesystem and remaining size of sd card with rootfs partition with ext4 filesystem.
 * 3) After sd card is created with boot and rootfs partition, mount the sdcard to update uenv.txt and overwrite uenv.txt by uenv-emmc.txt in "boot" partition. Copy any additional files required to boot/rootfs partition.
 * 1) dd if=/dev/ of=boot.img bs=1M &
 * 1) dd if=/dev/ of=rootfs.img bs=1M &

Flashing/Upgrading custom file to eMMC vfat/ext4 partition
1. If eMMC device is not partitoned, then first the eMMC device must be partitioned to vfat or ext4 filesystem. Refer 2. Once the eMMC device has been partitioned to vfat/ext4, user can write into existing file or partition. For example as shown in above list of dfu interfaces, user can upgrade the MLO or u-boot.img file from ubuntu PC. The alternate interface number 3 need to selected for upgrading MLO, and 10 need to selected for u-boot.img.
 * 1) sudo dfu-util -D MLO -c 1 -i 0 -a 3
 * 2) sudo dfu-util -D u-boot.img -c 1 -i 0 -a 10

Adding a custom file to DFU configuration
1. Add a custom/new file to the root directory of existing rootfs(ext4) or boot(vfat) partition of sdcard and flash the filesystem raw disk images to eMMC. For example consider the file zImage, dra7-evm-lcd10.dtb is added to root directory of rootfs(ext4) and README file in boot(vfat) partition. Make sure file read/write permission is set. 2. From u-boot source repository, edit the file include/configs/dra7xx_evm.h, add a new entry to DFU_ALT_INFO_EMMC macro. "dfu_alt_info_emmc=" \ "rawemmc raw 0 3751936;" \ "boot part 1 1;" \ "rootfs part 1 2;" \ "MLO fat 1 1;" \ "ZImage ext4 1 2;" \ "dra7-evm-lcd10.dtb ext4 1 2;" \ "README fat 1 1;" \ "MLO.raw raw 0x100 0x100;" \ "u-boot.img.raw raw 0x200 0x400;" \ "spl-os-args.raw raw 0x80 0x80;" \ "spl-os-image.raw raw 0x900 0x2000;" \ "spl-os-args fat 1 1;" \ "spl-os-image fat 1 1;" \ "u-boot.img fat 1 1;" \ "uEnv.txt fat 1 1\0" 3. Compile the u-boot to create MLO, u-boot.img and load MLO/u-boot.img to EVM 4. Execute "dfu-util -l" from PC host, the new interfaces added will be listed dfu-util 0.5 (C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. (C) 2010-2011 Tormod Volden (DfuSe support) This program is Free Software and has ABSOLUTELY NO WARRANTY dfu-util does currently only support DFU version 1.0 Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=0, name="rawemmc" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=1, name="boot" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=2, name="rootfs" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=3, name="MLO" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=4, name="zImage" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=5, name="dra7-evm-lcd10.dtb" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=6, name="README" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=7, name="MLO.raw" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=8, name="u-boot.img.raw" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=9, name="spl-os-args.raw" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=10, name="spl-os-image.raw" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=11, name="spl-os-args" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=12, name="spl-os-image" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=13, name="u-boot.img" Found DFU: [0403:bd00] devnum=0, cfg=1, intf=0, alt=14, name="uEnv.txt" 6. Now you can upgrade the new added files by chosing the respective alternate interface number (alt= ) Upgrade the zImage Upgrade the dra7-evm-lcd10.dtb
 * 1) define DFU_ALT_INFO_EMMC \
 * 1) sudo dfu-util -l
 * 1) sudo dfu-util -c 1 -i 0 -a 4 -D zImage
 * 1) sudo dfu-util -c 1 -i 0 -a 4 -D dra7-evm-lcd10.dtb

Using dfu-utils from Windows PC Host
Follow the below steps to install the dfu-tools. 1. Download the dfu-utils dfu-util-0.6-win32.zip.bz2 and unzip to some folder (say c:\dfu) 2. Download the zdaig application and execute zdaig application, install winUSB driver. 3. Go through DFU section mentioned above for setup the EVM for DFU. Note: For flashing fresh boards, refer to peripheral usb boot mode section. The initial bootloader (u-boot-spl.bin) shall be loaded to EVM using usbboot tool running from Ubuntu Host PC. For more details refer 4. Connect the EVM (running DFU) to windows PC through superspeed usb cable. Windows host will detect the EVM as "download gadget". 5. Copy required binary files to flash c:\dfu folder. Open command prompt and execute dfu-util.exe. c:\dfu> dfu-util –l This will list all dfu interfaces 6. Follow DFU section mentioned above for flashing the binaries to eMMC. c:\dfu> dfu-util -D  -c 1 -i 0 -a

}}

Description
This template describes how to use DFU (Device Firmware Upgrade} on.

Parameters
This template takes following parameters - platform, in DRA7xx

Example
To use this template simply add the following line to your wiki page.

Here's how it will look in your wiki page: