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