From 5fe2de36e0380ee81c77dfb13b9b4ccebdbc3b0a Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 26 Oct 2016 15:15:17 -0700 Subject: flash scripts: implement FCB/BCB upgrade Newer U-Boot versions no longer write a BCB which includes the work around for errata e9609. However, we need to be able to upgrade modules which still have such BCB on-disk. Use the following process to upgrade modules: 1. Use the old U-Boot to flash a new U-Boot using the old format 2. Use the new U-Boot to replace the old BCB with the new BCB 3. Use the new U-Boot to flash the new U-Boot using the new format Signed-off-by: Stefan Agner Acked-by: Max Krummenacher --- .../colibri-imx7/colibri-imx7_bin/flash_blk.scr | 21 +++++++++++++++------ .../colibri-imx7/colibri-imx7_bin/flash_eth.scr | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/recipes-images/images/files/colibri-imx7/colibri-imx7_bin/flash_blk.scr b/recipes-images/images/files/colibri-imx7/colibri-imx7_bin/flash_blk.scr index b63366a..ae3a689 100644 --- a/recipes-images/images/files/colibri-imx7/colibri-imx7_bin/flash_blk.scr +++ b/recipes-images/images/files/colibri-imx7/colibri-imx7_bin/flash_blk.scr @@ -1,5 +1,4 @@ -setenv create_bcb 'nand erase.part mx7-bcb && writebcb 80000 200000' -setenv update_configblock 'fatload ${interface} 0:1 ${loadaddr} ${board_name}/configblock.bin && nand write ${loadaddr} 0x800 ${filesize} && nand write ${loadaddr} 0x20800 ${filesize}' +setenv create_bcb 'nand read ${loadaddr} 0x800 0x800 && nand erase.part mx7-bcb && writebcb 80000 200000 && nand write ${loadaddr} 0x800 0x800' # Migrate to UBI volume based boot schema setenv prepare_kernel_fdt 'ubi create kernel 0x800000 static && ubi create dtb 0x20000 static' @@ -7,13 +6,23 @@ setenv prepare_m4firmware 'ubi create m4firmware 0xe0000 static' setenv prepare_rootfs 'ubi create rootfs 0 dynamic' setenv prepare_ubi 'ubi part ubi && if ubi check rootfs; then if ubi check kernel; then else ubi remove rootfs && run prepare_kernel_fdt && run prepare_m4firmware && run prepare_rootfs; fi; else run prepare_kernel_fdt && run prepare_m4firmware && run prepare_rootfs; fi' -setenv update_uboot 'fatload ${interface} 0:1 ${loadaddr} ${board_name}/u-boot-nand.imx && nand erase.part u-boot && nand erase.part u-boot-env && writeboot ${loadaddr} 80000 200000 $filesize' +setenv upgrade_msg 'echo && echo "Upgraded U-Boot, please reset the board and complete update with" && echo "# run setupdate && run create_bcb && run update" && echo && echo "(note the create_bcb command in between!)"' +setenv update_uboot_old 'fatload ${interface} 0:1 ${loadaddr} ${board_name}/u-boot-nand.imx && nand erase.part u-boot && nand erase.part u-boot-env && writeboot ${loadaddr} 80000 200000 $filesize && nand erase.part u-boot-env && nand erase.part ubi && run upgrade_msg' +setenv update_uboot 'fatload ${interface} 0:1 ${loadaddr} ${board_name}/u-boot-nand.imx && nand erase.part u-boot1 && nand write ${loadaddr} u-boot1 ${filesize} && nand erase.part u-boot2 && nand write ${loadaddr} u-boot2 ${filesize}' setenv update_kernel 'fatload ${interface} 0:1 ${loadaddr} ${board_name}/zImage && ubi write ${loadaddr} kernel ${filesize}' setenv update_fdt 'fatload ${interface} 0:1 ${loadaddr} ${board_name}/${soc}-colibri-${fdt_board}.dtb && ubi write ${loadaddr} dtb ${filesize}' setenv update_rootfs 'fatload ${interface} 0:1 ${loadaddr} ${board_name}/ubifs.img && ubi write ${loadaddr} rootfs ${filesize}' -setenv upgrade_alpha1_msg 'Updated U-Boot, please reset the board and use "run setupdate && run update" again.' -setenv prepare_alpha1_uboot 'if test "${soc}" = "mx7"; then run update_uboot && echo ${upgrade_alpha1_msg} && reset; fi' -setenv update 'mtdparts default && run prepare_alpha1_uboot; run update_uboot && run prepare_ubi && run update_kernel && run update_fdt && run update_rootfs && reset' +# Test which version of U-Boot we are currently running on +setenv update 'mtdparts default && env default -f updlevel && if test $updlevel -lt 1; then; run update_uboot_old; else; run update_uboot && run prepare_ubi && run update_kernel && run update_fdt && run update_rootfs && reset; fi' +if itest.b *0x30360800 -lt 0x11; then +echo && +echo 'NOTE: The U-Boot provided with this BSP version does not support the' && +echo 'early tapeout/stepping of i.MX 7 used on your module. You still can' && +echo 'update the kernel/device-tree/rootfs manually using: ' && +echo '# run prepare_ubi && run update_kernel && run update_fdt && update_rootfs' && +echo && setenv update_uboot; setenv update_uboot_old; setenv update +else echo 'enter "run update" to update the entire module' +fi diff --git a/recipes-images/images/files/colibri-imx7/colibri-imx7_bin/flash_eth.scr b/recipes-images/images/files/colibri-imx7/colibri-imx7_bin/flash_eth.scr index 13025de..5a54bfa 100644 --- a/recipes-images/images/files/colibri-imx7/colibri-imx7_bin/flash_eth.scr +++ b/recipes-images/images/files/colibri-imx7/colibri-imx7_bin/flash_eth.scr @@ -1,5 +1,4 @@ -setenv create_bcb 'nand erase.part mx7-bcb && writebcb 80000 200000' -setenv update_configblock 'tftpboot ${loadaddr} ${board_name}/configblock.bin && nand write ${loadaddr} 0x800 ${filesize} && nand write ${loadaddr} 0x20800 ${filesize}' +setenv create_bcb 'nand read ${loadaddr} 0x800 0x800 && nand erase.part mx7-bcb && writebcb 80000 200000 && nand write ${loadaddr} 0x800 0x800' # Migrate to UBI volume based boot schema setenv prepare_kernel_fdt 'ubi create kernel 0x800000 static && ubi create dtb 0x20000 static' @@ -7,13 +6,23 @@ setenv prepare_m4firmware 'ubi create m4firmware 0xe0000 static' setenv prepare_rootfs 'ubi create rootfs 0 dynamic' setenv prepare_ubi 'ubi part ubi && if ubi check rootfs; then if ubi check kernel; then else ubi remove rootfs && run prepare_kernel_fdt && run prepare_m4firmware && run prepare_rootfs; fi; else run prepare_kernel_fdt && run prepare_m4firmware && run prepare_rootfs; fi' -setenv update_uboot 'tftpboot ${loadaddr} ${board_name}/u-boot-nand.imx && nand erase.part u-boot && nand erase.part u-boot-env && writeboot ${loadaddr} 80000 200000 $filesize' +setenv upgrade_msg 'echo && echo "Upgraded U-Boot, please reset the board and complete update with" && echo "# run setupdate && run create_bcb && run update" && echo && echo "(note the create_bcb command in between!)"' +setenv update_uboot_old 'tftpboot ${loadaddr} ${board_name}/u-boot-nand.imx && nand erase.part u-boot && nand erase.part u-boot-env && writeboot ${loadaddr} 80000 200000 $filesize && nand erase.part u-boot-env && nand erase.part ubi && run upgrade_msg' +setenv update_uboot 'tftpboot ${loadaddr} ${board_name}/u-boot-nand.imx && nand erase.part u-boot1 && nand write ${loadaddr} u-boot1 ${filesize} && nand erase.part u-boot2 && nand write ${loadaddr} u-boot2 ${filesize}' setenv update_kernel 'tftpboot ${loadaddr} ${board_name}/zImage && ubi write ${loadaddr} kernel ${filesize}' setenv update_fdt 'tftpboot ${loadaddr} ${board_name}/${soc}-colibri-${fdt_board}.dtb && ubi write ${loadaddr} dtb ${filesize}' setenv update_rootfs 'tftpboot ${loadaddr} ${board_name}/ubifs.img && ubi write ${loadaddr} rootfs ${filesize}' -setenv upgrade_alpha1_msg 'Updated U-Boot, please reset the board and use "run setupdate && run update" again.' -setenv prepare_alpha1_uboot 'if test "${soc}" = "mx7"; then run update_uboot && echo ${upgrade_alpha1_msg} && reset; fi' -setenv update 'mtdparts default && run prepare_alpha1_uboot; run update_uboot && run prepare_ubi && run update_kernel && run update_fdt && run update_rootfs && reset' +# Test which version of U-Boot we are currently running on +setenv update 'mtdparts default && env default -f updlevel && if test $updlevel -lt 1; then; run update_uboot_old; else; run update_uboot && run prepare_ubi && run update_kernel && run update_fdt && run update_rootfs && reset; fi' +if itest.b *0x30360800 -lt 0x11; then +echo && +echo 'NOTE: The U-Boot provided with this BSP version does not support the' && +echo 'early tapeout/stepping of i.MX 7 used on your module. You still can' && +echo 'update the kernel/device-tree/rootfs manually using: ' && +echo '# run prepare_ubi && run update_kernel && run update_fdt && update_rootfs' && +echo && setenv update_uboot; setenv update_uboot_old; setenv update +else echo 'enter "run update" to update the entire module' +fi -- cgit v1.2.3