1*83d290c5STom Rini# SPDX-License-Identifier: GPL-2.0+ 25bf4475fSLukasz Majewski# 35bf4475fSLukasz Majewski# Copyright (C) 2015 45bf4475fSLukasz Majewski# 55bf4475fSLukasz Majewski# Lukasz Majewski <l.majewski@majess.pl> 65bf4475fSLukasz Majewski 75a608727SLukasz MajewskiDevice Firmware Upgrade (DFU) - extension to use TFTP 85a608727SLukasz Majewski===================================================== 95a608727SLukasz Majewski 105a608727SLukasz MajewskiWhy? 115a608727SLukasz Majewski---- 125a608727SLukasz Majewski 135a608727SLukasz Majewski* Update TFTP (CONFIG_UPDATE_TFTP) only supports writing 145a608727SLukasz Majewskicode to NAND memory via TFTP. 155a608727SLukasz Majewski* DFU supports writing data to the variety of mediums (NAND, 165a608727SLukasz MajewskieMMC, SD, partitions, RAM, etc) via USB. 175a608727SLukasz Majewski 185a608727SLukasz MajewskiCombination of both solves their shortcomings! 195a608727SLukasz Majewski 205a608727SLukasz Majewski 215a608727SLukasz MajewskiOverview 225a608727SLukasz Majewski-------- 235a608727SLukasz Majewski 245a608727SLukasz MajewskiThis document briefly describes how to use DFU for 255a608727SLukasz Majewskiupgrading firmware (e.g. kernel, u-boot, rootfs, etc.) 265a608727SLukasz Majewskivia TFTP protocol. 275a608727SLukasz Majewski 285a608727SLukasz MajewskiBy using Ethernet (TFTP protocol to be precise) it is 295a608727SLukasz Majewskipossible to overcome the major problem of USB based DFU - 305a608727SLukasz Majewskithe relatively low transfer speed for large files. 315a608727SLukasz MajewskiThis was caused by DFU standard, which imposed utilization 325a608727SLukasz Majewskiof only EP0 for transfer. By using Ethernet we can circumvent 335a608727SLukasz Majewskithis shortcoming. 345a608727SLukasz Majewski 355a608727SLukasz MajewskiBeagle Bone Black rev. C (BBB) powered by TI's am335x CPU has 365a608727SLukasz Majewskibeen used as a demo board. 375a608727SLukasz Majewski 385a608727SLukasz MajewskiTo utilize this feature, one needs to first enable support 395a608727SLukasz Majewskifor USB based DFU (CONFIG_DFU_*) and DFU TFTP update 405a608727SLukasz Majewski(CONFIG_DFU_TFTP) described in ./doc/README.update. 415a608727SLukasz Majewski 425a608727SLukasz MajewskiThe "dfu" command has been extended to support transfer via TFTP - one 435a608727SLukasz Majewskineeds to type for example "dfu tftp 0 mmc 0" 445a608727SLukasz Majewski 455a608727SLukasz MajewskiThis feature does not depend on "fitupd" command enabled. 465a608727SLukasz Majewski 475a608727SLukasz MajewskiAs of this writing (SHA1:8d77576371381ade83de475bb639949b44941e8c v2015.10-rc2) 485a608727SLukasz Majewskithe update.c code is not enabled (CONFIG_UPDATE_TFTP) by any board in the 495a608727SLukasz Majewskicontemporary u-boot tree. 505a608727SLukasz Majewski 515a608727SLukasz Majewski 525a608727SLukasz MajewskiEnvironment variables 535a608727SLukasz Majewski--------------------- 545a608727SLukasz Majewski 555a608727SLukasz MajewskiThe "dfu tftp" command can be used in the "preboot" environment variable 565a608727SLukasz Majewski(when it is enabled by defining CONFIG_PREBOOT). 575a608727SLukasz MajewskiThis is the preferable way of using this command in the early boot stage 585a608727SLukasz Majewskias opposed to legacy update_tftp() function invocation. 595a608727SLukasz Majewski 605a608727SLukasz Majewski 615a608727SLukasz MajewskiBeagle Bone Black (BBB) setup 625a608727SLukasz Majewski----------------------------- 635a608727SLukasz Majewski 645a608727SLukasz Majewski1. Setup tftp env variables: 655a608727SLukasz Majewski * select desired eth device - 'ethact' variable ["ethact=cpsw"] 665a608727SLukasz Majewski (use "bdinfo" to check current setting) 675a608727SLukasz Majewski * setup "serverip" and "ipaddr" variables 685a608727SLukasz Majewski * set "loadaddr" as a fixed buffer where incoming data is placed 695a608727SLukasz Majewski ["loadaddr=0x81000000"] 705a608727SLukasz Majewski 715a608727SLukasz Majewski######### 725a608727SLukasz Majewski# BONUS # 735a608727SLukasz Majewski######### 745a608727SLukasz MajewskiIt is possible to use USB interface to emulate ETH connection by setting 755a608727SLukasz Majewski"ethact=usb_ether". In this way one can have very fast DFU transfer via USB. 765a608727SLukasz Majewski 775a608727SLukasz MajewskiFor 33MiB test image the transfer rate was 1MiB/s for ETH over USB and 200KiB/s 785a608727SLukasz Majewskifor pure DFU USB transfer. 795a608727SLukasz Majewski 805a608727SLukasz Majewski2. Setup update_tftp variables: 815a608727SLukasz Majewski * set "updatefile" - the file name to be downloaded via TFTP (stored on 825a608727SLukasz Majewski the HOST at e.g. /srv/tftp) 835a608727SLukasz Majewski 845a608727SLukasz Majewski3. If required, to update firmware on boot, put the "dfu tftp 0 mmc 0" in the 855a608727SLukasz Majewski "preboot" env variable. Otherwise use this command from u-boot prompt. 865a608727SLukasz Majewski 875a608727SLukasz Majewski4. Inspect "dfu" specific variables: 885a608727SLukasz Majewski * "dfu_alt_info" - information about available DFU entities 895a608727SLukasz Majewski * "dfu_bufsiz" - variable to set buffer size [in bytes] - when it is not 905a608727SLukasz Majewski possible to set large enough default buffer (8 MiB @ BBB) 915a608727SLukasz Majewski 925a608727SLukasz Majewski 935a608727SLukasz Majewski 945a608727SLukasz MajewskiFIT image format for download 955a608727SLukasz Majewski----------------------------- 965a608727SLukasz Majewski 975a608727SLukasz MajewskiTo create FIT image for download one should follow the update tftp README file 985a608727SLukasz Majewski(./doc/README.update) with one notable difference: 995a608727SLukasz Majewski 1005a608727SLukasz MajewskiThe original snippet of ./doc/uImage.FIT/update_uboot.its 1015a608727SLukasz Majewski 1025a608727SLukasz Majewski images { 1035a608727SLukasz Majewski update@1 { 1045a608727SLukasz Majewski description = "U-Boot binary"; 1055a608727SLukasz Majewski 1065a608727SLukasz Majewskishould look like 1075a608727SLukasz Majewski 1085a608727SLukasz Majewski images { 1095a608727SLukasz Majewski u-boot.bin@1 { 1105a608727SLukasz Majewski description = "U-Boot binary"; 1115a608727SLukasz Majewski 1125a608727SLukasz Majewskiwhere "u-boot.bin" is the DFU entity name to be stored. 1135a608727SLukasz Majewski 1145a608727SLukasz Majewski 1155a608727SLukasz Majewski 1165a608727SLukasz MajewskiTo do 1175a608727SLukasz Majewski----- 1185a608727SLukasz Majewski 1195a608727SLukasz Majewski* Extend dfu-util command to support TFTP based transfers 1205a608727SLukasz Majewski* Upload support (via TFTP) 121