xref: /openbmc/u-boot/doc/README.update (revision 3f42dc87b4fbcc99baa26c7be8d0b74aaa4c2f30)
14bae9090SBartlomiej SiekaAutomatic software update from a TFTP server
24bae9090SBartlomiej Sieka============================================
34bae9090SBartlomiej Sieka
44bae9090SBartlomiej SiekaOverview
54bae9090SBartlomiej Sieka--------
64bae9090SBartlomiej Sieka
74bae9090SBartlomiej SiekaThis feature allows to automatically store software updates present on a TFTP
84bae9090SBartlomiej Siekaserver in NOR Flash. In more detail: a TFTP transfer of a file given in
94bae9090SBartlomiej Siekaenvironment variable 'updatefile' from server 'serverip' is attempted during
104bae9090SBartlomiej Siekaboot. The update file should be a FIT file, and can contain one or more
114bae9090SBartlomiej Siekaupdates. Each update in the update file has an address in NOR Flash where it
124bae9090SBartlomiej Siekashould be placed, updates are also protected with a SHA-1 checksum. If the
134bae9090SBartlomiej SiekaTFTP transfer is successful, the hash of each update is verified, and if the
144bae9090SBartlomiej Siekaverification is positive, the update is stored in Flash.
154bae9090SBartlomiej Sieka
164bae9090SBartlomiej SiekaThe auto-update feature is enabled by the CONFIG_UPDATE_TFTP macro:
174bae9090SBartlomiej Sieka
184bae9090SBartlomiej Sieka#define CONFIG_UPDATE_TFTP		1
194bae9090SBartlomiej Sieka
204bae9090SBartlomiej Sieka
214bae9090SBartlomiej SiekaNote that when enabling auto-update, Flash support must be turned on.  Also,
224bae9090SBartlomiej Siekaone must enable FIT and LIBFDT support:
234bae9090SBartlomiej Sieka
244bae9090SBartlomiej Sieka#define CONFIG_FIT		1
254bae9090SBartlomiej Sieka#define CONFIG_OF_LIBFDT	1
264bae9090SBartlomiej Sieka
274bae9090SBartlomiej SiekaThe auto-update feature uses the following configuration knobs:
284bae9090SBartlomiej Sieka
294bae9090SBartlomiej Sieka- CONFIG_UPDATE_LOAD_ADDR
304bae9090SBartlomiej Sieka
314bae9090SBartlomiej Sieka  Normally, TFTP transfer of the update file is done to the address specified
324bae9090SBartlomiej Sieka  in environment variable 'loadaddr'. If this variable is not present, the
334bae9090SBartlomiej Sieka  transfer is made to the address given in CONFIG_UPDATE_LOAD_ADDR (0x100000
344bae9090SBartlomiej Sieka  by default).
354bae9090SBartlomiej Sieka
364bae9090SBartlomiej Sieka- CONFIG_UPDATE_TFTP_CNT_MAX
374bae9090SBartlomiej Sieka  CONFIG_UPDATE_TFTP_MSEC_MAX
384bae9090SBartlomiej Sieka
394bae9090SBartlomiej Sieka  These knobs control the timeouts during initial connection to the TFTP
404bae9090SBartlomiej Sieka  server. Since a transfer is attempted during each boot, it is undesirable to
414bae9090SBartlomiej Sieka  have a long delay when a TFTP server is not present.
427c84fe6aSBartlomiej Sieka  CONFIG_UPDATE_TFTP_MSEC_MAX specifies the number of milliseconds to wait for
437c84fe6aSBartlomiej Sieka  the server to respond to initial connection, and CONFIG_UPDATE_TFTP_CNT_MAX
444bae9090SBartlomiej Sieka  gives the number of such connection retries. CONFIG_UPDATE_TFTP_CNT_MAX must
454bae9090SBartlomiej Sieka  be non-negative and is 0 by default, CONFIG_UPDATE_TFTP_MSEC_MAX must be
467c84fe6aSBartlomiej Sieka  positive and is 100 by default.
474bae9090SBartlomiej Sieka
484bae9090SBartlomiej SiekaSince the update file is in FIT format, it is created from an *.its file using
494bae9090SBartlomiej Siekathe mkimage tool. dtc tool with support for binary includes, e.g. in version
504bae9090SBartlomiej Sieka1.2.0 or later, must also be available on the system where the update file is
514bae9090SBartlomiej Siekato be prepared. Refer to the doc/uImage.FIT/ directory for more details on FIT
524bae9090SBartlomiej Siekaimages.
534bae9090SBartlomiej Sieka
54*3f42dc87SVagrant CascadianThis mechanism can be also triggered by the command "fitupd".
557130a579SAndreas PretzschIf an optional, non-zero address is provided as argument, the TFTP transfer
567130a579SAndreas Pretzschis skipped and the image at this address is used.
577130a579SAndreas PretzschThe fitupd command is enabled by CONFIG_CMD_FITUPD.
587130a579SAndreas Pretzsch
594bae9090SBartlomiej Sieka
604bae9090SBartlomiej SiekaExample .its files
614bae9090SBartlomiej Sieka------------------
624bae9090SBartlomiej Sieka
634bae9090SBartlomiej Sieka- doc/uImage.FIT/update_uboot.its
644bae9090SBartlomiej Sieka
654bae9090SBartlomiej Sieka  A simple example that can be used to create an update file for automatically
664bae9090SBartlomiej Sieka  replacing U-Boot image on a system.
674bae9090SBartlomiej Sieka
684bae9090SBartlomiej Sieka  Assuming that an U-Boot image u-boot.bin is present in the current working
694bae9090SBartlomiej Sieka  directory, and that the address given in the 'load' property in the
704bae9090SBartlomiej Sieka  'update_uboot.its' file is where the U-Boot is stored in Flash, the
714bae9090SBartlomiej Sieka  following command will create the actual update file 'update_uboot.itb':
724bae9090SBartlomiej Sieka
734bae9090SBartlomiej Sieka  mkimage -f update_uboot.its update_uboot.itb
744bae9090SBartlomiej Sieka
754bae9090SBartlomiej Sieka  Place 'update_uboot.itb' on a TFTP server, for example as
764bae9090SBartlomiej Sieka  '/tftpboot/update_uboot.itb', and set the 'updatefile' variable
774bae9090SBartlomiej Sieka  appropriately, for example in the U-Boot prompt:
784bae9090SBartlomiej Sieka
794bae9090SBartlomiej Sieka  setenv updatefile /tftpboot/update_uboot.itb
804bae9090SBartlomiej Sieka  saveenv
814bae9090SBartlomiej Sieka
824bae9090SBartlomiej Sieka  Now, when the system boots up and the update TFTP server specified in the
834bae9090SBartlomiej Sieka  'serverip' environment variable is accessible, the new U-Boot image will be
844bae9090SBartlomiej Sieka  automatically stored in Flash.
854bae9090SBartlomiej Sieka
864bae9090SBartlomiej Sieka  NOTE: do make sure that the 'u-boot.bin' image used to create the update
874bae9090SBartlomiej Sieka  file is a good, working image. Also make sure that the address in Flash
884bae9090SBartlomiej Sieka  where the update will be placed is correct. Making mistake here and
894bae9090SBartlomiej Sieka  attempting the auto-update can render the system unusable.
904bae9090SBartlomiej Sieka
914bae9090SBartlomiej Sieka- doc/uImage.FIT/update3.its
924bae9090SBartlomiej Sieka
934bae9090SBartlomiej Sieka  An example containing three updates. It can be used to update Linux kernel,
944bae9090SBartlomiej Sieka  ramdisk and FDT blob stored in Flash. The procedure for preparing the update
954bae9090SBartlomiej Sieka  file is similar to the example above.
965a608727SLukasz Majewski
975a608727SLukasz MajewskiTFTP update via DFU
985a608727SLukasz Majewski-------------------
995a608727SLukasz Majewski
1005a608727SLukasz Majewski- It is now possible to update firmware (bootloader, kernel, rootfs, etc.) via
1015a608727SLukasz Majewski  TFTP by using DFU (Device Firmware Upgrade). More information can be found in
1025a608727SLukasz Majewski  ./doc/README.dfutftp documentation entry.
103