xref: /OK3568_Linux_fs/u-boot/doc/README.dfutftp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#
2*4882a593Smuzhiyun#  Copyright (C) 2015
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun#  Lukasz Majewski <l.majewski@majess.pl>
5*4882a593Smuzhiyun#
6*4882a593Smuzhiyun#
7*4882a593Smuzhiyun# SPDX-License-Identifier:	GPL-2.0+
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunDevice Firmware Upgrade (DFU) - extension to use TFTP
10*4882a593Smuzhiyun=====================================================
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunWhy?
13*4882a593Smuzhiyun----
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun* Update TFTP (CONFIG_UPDATE_TFTP) only supports writing
16*4882a593Smuzhiyuncode to NAND memory via TFTP.
17*4882a593Smuzhiyun* DFU supports writing data to the variety of mediums (NAND,
18*4882a593SmuzhiyuneMMC, SD, partitions, RAM, etc) via USB.
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunCombination of both solves their shortcomings!
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunOverview
24*4882a593Smuzhiyun--------
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunThis document briefly describes how to use DFU for
27*4882a593Smuzhiyunupgrading firmware (e.g. kernel, u-boot, rootfs, etc.)
28*4882a593Smuzhiyunvia TFTP protocol.
29*4882a593Smuzhiyun
30*4882a593SmuzhiyunBy using Ethernet (TFTP protocol to be precise) it is
31*4882a593Smuzhiyunpossible to overcome the major problem of USB based DFU -
32*4882a593Smuzhiyunthe relatively low transfer speed for large files.
33*4882a593SmuzhiyunThis was caused by DFU standard, which imposed utilization
34*4882a593Smuzhiyunof only EP0 for transfer. By using Ethernet we can circumvent
35*4882a593Smuzhiyunthis shortcoming.
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunBeagle Bone Black rev. C (BBB) powered by TI's am335x CPU has
38*4882a593Smuzhiyunbeen used as a demo board.
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunTo utilize this feature, one needs to first enable support
41*4882a593Smuzhiyunfor USB based DFU (CONFIG_DFU_*) and DFU TFTP update
42*4882a593Smuzhiyun(CONFIG_DFU_TFTP) described in ./doc/README.update.
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunThe "dfu" command has been extended to support transfer via TFTP - one
45*4882a593Smuzhiyunneeds to type for example "dfu tftp 0 mmc 0"
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunThis feature does not depend on "fitupd" command enabled.
48*4882a593Smuzhiyun
49*4882a593SmuzhiyunAs of this writing (SHA1:8d77576371381ade83de475bb639949b44941e8c v2015.10-rc2)
50*4882a593Smuzhiyunthe update.c code is not enabled (CONFIG_UPDATE_TFTP) by any board in the
51*4882a593Smuzhiyuncontemporary u-boot tree.
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunEnvironment variables
55*4882a593Smuzhiyun---------------------
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunThe "dfu tftp" command can be used in the "preboot" environment variable
58*4882a593Smuzhiyun(when it is enabled by defining CONFIG_PREBOOT).
59*4882a593SmuzhiyunThis is the preferable way of using this command in the early boot stage
60*4882a593Smuzhiyunas opposed to legacy update_tftp() function invocation.
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun
63*4882a593SmuzhiyunBeagle Bone Black (BBB) setup
64*4882a593Smuzhiyun-----------------------------
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun1. Setup tftp env variables:
67*4882a593Smuzhiyun   *  select desired eth device - 'ethact' variable ["ethact=cpsw"]
68*4882a593Smuzhiyun      (use "bdinfo" to check current setting)
69*4882a593Smuzhiyun   *  setup "serverip" and "ipaddr" variables
70*4882a593Smuzhiyun   *  set "loadaddr" as a fixed buffer where incoming data is placed
71*4882a593Smuzhiyun      ["loadaddr=0x81000000"]
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun#########
74*4882a593Smuzhiyun# BONUS #
75*4882a593Smuzhiyun#########
76*4882a593SmuzhiyunIt is possible to use USB interface to emulate ETH connection by setting
77*4882a593Smuzhiyun"ethact=usb_ether". In this way one can have very fast DFU transfer via USB.
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunFor 33MiB test image the transfer rate was 1MiB/s for ETH over USB and 200KiB/s
80*4882a593Smuzhiyunfor pure DFU USB transfer.
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun2. Setup update_tftp variables:
83*4882a593Smuzhiyun   *  set "updatefile" - the file name to be downloaded via TFTP (stored on
84*4882a593Smuzhiyun      the HOST at e.g. /srv/tftp)
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun3. If required, to update firmware on boot, put the "dfu tftp 0 mmc 0" in the
87*4882a593Smuzhiyun    "preboot" env variable. Otherwise use this command from u-boot prompt.
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun4. Inspect "dfu" specific variables:
90*4882a593Smuzhiyun   * "dfu_alt_info" - information about available DFU entities
91*4882a593Smuzhiyun   * "dfu_bufsiz"   - variable to set buffer size [in bytes] - when it is not
92*4882a593Smuzhiyun		    possible to set large enough default buffer (8 MiB @ BBB)
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun
96*4882a593SmuzhiyunFIT image format for download
97*4882a593Smuzhiyun-----------------------------
98*4882a593Smuzhiyun
99*4882a593SmuzhiyunTo create FIT image for download one should follow the update tftp README file
100*4882a593Smuzhiyun(./doc/README.update) with one notable difference:
101*4882a593Smuzhiyun
102*4882a593SmuzhiyunThe original snippet of ./doc/uImage.FIT/update_uboot.its
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun	images {
105*4882a593Smuzhiyun		update@1 {
106*4882a593Smuzhiyun			description = "U-Boot binary";
107*4882a593Smuzhiyun
108*4882a593Smuzhiyunshould look like
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun	images {
111*4882a593Smuzhiyun		u-boot.bin@1 {
112*4882a593Smuzhiyun			description = "U-Boot binary";
113*4882a593Smuzhiyun
114*4882a593Smuzhiyunwhere "u-boot.bin" is the DFU entity name to be stored.
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun
117*4882a593Smuzhiyun
118*4882a593SmuzhiyunTo do
119*4882a593Smuzhiyun-----
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun* Extend dfu-util command to support TFTP based transfers
122*4882a593Smuzhiyun* Upload support (via TFTP)
123