1*4bae9090SBartlomiej SiekaAutomatic software update from a TFTP server 2*4bae9090SBartlomiej Sieka============================================ 3*4bae9090SBartlomiej Sieka 4*4bae9090SBartlomiej SiekaOverview 5*4bae9090SBartlomiej Sieka-------- 6*4bae9090SBartlomiej Sieka 7*4bae9090SBartlomiej SiekaThis feature allows to automatically store software updates present on a TFTP 8*4bae9090SBartlomiej Siekaserver in NOR Flash. In more detail: a TFTP transfer of a file given in 9*4bae9090SBartlomiej Siekaenvironment variable 'updatefile' from server 'serverip' is attempted during 10*4bae9090SBartlomiej Siekaboot. The update file should be a FIT file, and can contain one or more 11*4bae9090SBartlomiej Siekaupdates. Each update in the update file has an address in NOR Flash where it 12*4bae9090SBartlomiej Siekashould be placed, updates are also protected with a SHA-1 checksum. If the 13*4bae9090SBartlomiej SiekaTFTP transfer is successful, the hash of each update is verified, and if the 14*4bae9090SBartlomiej Siekaverification is positive, the update is stored in Flash. 15*4bae9090SBartlomiej Sieka 16*4bae9090SBartlomiej SiekaThe auto-update feature is enabled by the CONFIG_UPDATE_TFTP macro: 17*4bae9090SBartlomiej Sieka 18*4bae9090SBartlomiej Sieka#define CONFIG_UPDATE_TFTP 1 19*4bae9090SBartlomiej Sieka 20*4bae9090SBartlomiej Sieka 21*4bae9090SBartlomiej SiekaNote that when enabling auto-update, Flash support must be turned on. Also, 22*4bae9090SBartlomiej Siekaone must enable FIT and LIBFDT support: 23*4bae9090SBartlomiej Sieka 24*4bae9090SBartlomiej Sieka#define CONFIG_FIT 1 25*4bae9090SBartlomiej Sieka#define CONFIG_OF_LIBFDT 1 26*4bae9090SBartlomiej Sieka 27*4bae9090SBartlomiej SiekaThe auto-update feature uses the following configuration knobs: 28*4bae9090SBartlomiej Sieka 29*4bae9090SBartlomiej Sieka- CONFIG_UPDATE_LOAD_ADDR 30*4bae9090SBartlomiej Sieka 31*4bae9090SBartlomiej Sieka Normally, TFTP transfer of the update file is done to the address specified 32*4bae9090SBartlomiej Sieka in environment variable 'loadaddr'. If this variable is not present, the 33*4bae9090SBartlomiej Sieka transfer is made to the address given in CONFIG_UPDATE_LOAD_ADDR (0x100000 34*4bae9090SBartlomiej Sieka by default). 35*4bae9090SBartlomiej Sieka 36*4bae9090SBartlomiej Sieka- CONFIG_UPDATE_TFTP_CNT_MAX 37*4bae9090SBartlomiej Sieka CONFIG_UPDATE_TFTP_MSEC_MAX 38*4bae9090SBartlomiej Sieka 39*4bae9090SBartlomiej Sieka These knobs control the timeouts during initial connection to the TFTP 40*4bae9090SBartlomiej Sieka server. Since a transfer is attempted during each boot, it is undesirable to 41*4bae9090SBartlomiej Sieka have a long delay when a TFTP server is not present. 42*4bae9090SBartlomiej Sieka CONFIG_UPDATE_TFTP_MSEC_MAX specifies the number of seconds to wait for the 43*4bae9090SBartlomiej Sieka server to respond to initial connection, and CONFIG_UPDATE_TFTP_CNT_MAX 44*4bae9090SBartlomiej Sieka gives the number of such connection retries. CONFIG_UPDATE_TFTP_CNT_MAX must 45*4bae9090SBartlomiej Sieka be non-negative and is 0 by default, CONFIG_UPDATE_TFTP_MSEC_MAX must be 46*4bae9090SBartlomiej Sieka positive and is 1 by default. 47*4bae9090SBartlomiej Sieka 48*4bae9090SBartlomiej SiekaSince the update file is in FIT format, it is created from an *.its file using 49*4bae9090SBartlomiej Siekathe mkimage tool. dtc tool with support for binary includes, e.g. in version 50*4bae9090SBartlomiej Sieka1.2.0 or later, must also be available on the system where the update file is 51*4bae9090SBartlomiej Siekato be prepared. Refer to the doc/uImage.FIT/ directory for more details on FIT 52*4bae9090SBartlomiej Siekaimages. 53*4bae9090SBartlomiej Sieka 54*4bae9090SBartlomiej Sieka 55*4bae9090SBartlomiej SiekaExample .its files 56*4bae9090SBartlomiej Sieka------------------ 57*4bae9090SBartlomiej Sieka 58*4bae9090SBartlomiej Sieka- doc/uImage.FIT/update_uboot.its 59*4bae9090SBartlomiej Sieka 60*4bae9090SBartlomiej Sieka A simple example that can be used to create an update file for automatically 61*4bae9090SBartlomiej Sieka replacing U-Boot image on a system. 62*4bae9090SBartlomiej Sieka 63*4bae9090SBartlomiej Sieka Assuming that an U-Boot image u-boot.bin is present in the current working 64*4bae9090SBartlomiej Sieka directory, and that the address given in the 'load' property in the 65*4bae9090SBartlomiej Sieka 'update_uboot.its' file is where the U-Boot is stored in Flash, the 66*4bae9090SBartlomiej Sieka following command will create the actual update file 'update_uboot.itb': 67*4bae9090SBartlomiej Sieka 68*4bae9090SBartlomiej Sieka mkimage -f update_uboot.its update_uboot.itb 69*4bae9090SBartlomiej Sieka 70*4bae9090SBartlomiej Sieka Place 'update_uboot.itb' on a TFTP server, for example as 71*4bae9090SBartlomiej Sieka '/tftpboot/update_uboot.itb', and set the 'updatefile' variable 72*4bae9090SBartlomiej Sieka appropriately, for example in the U-Boot prompt: 73*4bae9090SBartlomiej Sieka 74*4bae9090SBartlomiej Sieka setenv updatefile /tftpboot/update_uboot.itb 75*4bae9090SBartlomiej Sieka saveenv 76*4bae9090SBartlomiej Sieka 77*4bae9090SBartlomiej Sieka Now, when the system boots up and the update TFTP server specified in the 78*4bae9090SBartlomiej Sieka 'serverip' environment variable is accessible, the new U-Boot image will be 79*4bae9090SBartlomiej Sieka automatically stored in Flash. 80*4bae9090SBartlomiej Sieka 81*4bae9090SBartlomiej Sieka NOTE: do make sure that the 'u-boot.bin' image used to create the update 82*4bae9090SBartlomiej Sieka file is a good, working image. Also make sure that the address in Flash 83*4bae9090SBartlomiej Sieka where the update will be placed is correct. Making mistake here and 84*4bae9090SBartlomiej Sieka attempting the auto-update can render the system unusable. 85*4bae9090SBartlomiej Sieka 86*4bae9090SBartlomiej Sieka- doc/uImage.FIT/update3.its 87*4bae9090SBartlomiej Sieka 88*4bae9090SBartlomiej Sieka An example containing three updates. It can be used to update Linux kernel, 89*4bae9090SBartlomiej Sieka ramdisk and FDT blob stored in Flash. The procedure for preparing the update 90*4bae9090SBartlomiej Sieka file is similar to the example above. 91