From 2b24ffee6deee0dd78604e8496e7154294d4f74a Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 7 Mar 2016 14:45:52 -0800 Subject: update.sh: write kernel and device tree into static UBI volumes Write kernel and device tree into seperate UBI Volumes. This allows to use a lot less UBI/UBIFS support in U-Boot, which should lower the risk of hitting bugs in this area. Boot times are also slightly faster (measurements showed an improvement of ~150ms). Signed-off-by: Stefan Agner Acked-by: Max Krummenacher --- .../files/colibri-vf/colibri-vf_bin/flash_blk.scr | 12 +++++++++--- .../files/colibri-vf/colibri-vf_bin/flash_eth.scr | 14 ++++++++++---- recipes/images/files/colibri-vf/update.sh | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/recipes/images/files/colibri-vf/colibri-vf_bin/flash_blk.scr b/recipes/images/files/colibri-vf/colibri-vf_bin/flash_blk.scr index 5c27563..a8166e2 100644 --- a/recipes/images/files/colibri-vf/colibri-vf_bin/flash_blk.scr +++ b/recipes/images/files/colibri-vf/colibri-vf_bin/flash_blk.scr @@ -1,11 +1,17 @@ setenv create_bcb 'nand erase.part vf-bcb && writebcb 0x20000 0x20000' setenv update_configblock 'fatload ${interface} 0:1 ${loadaddr} ${board_name}/configblock.bin && nand write ${loadaddr} 0x800 ${filesize}' -setenv prepare_rootfs 'ubi part ubi && ubi check rootfs || ubi create rootfs' +# Migrate to UBI volume based boot schema +setenv prepare_kernel_dtb 'ubi create kernel 0x800000 static && ubi create dtb 0x20000 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_dtb && run prepare_rootfs; fi; else run prepare_kernel_dtb && 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 && nand write ${loadaddr} u-boot' -setenv update_rootfs 'fatload ${interface} 0:1 ${loadaddr} ${board_name}/ubifs.img && run prepare_rootfs && ubi write ${loadaddr} rootfs ${filesize}' +setenv update_kernel 'fatload ${interface} 0:1 ${loadaddr} ${board_name}/zImage && ubi write ${loadaddr} kernel ${filesize}' +setenv update_dtb '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 update_new 'run update_uboot; run update_rootfs; reset' +setenv update_new 'run update_uboot; run prepare_ubi && run update_kernel && run update_dtb && run update_rootfs; reset' # Upgrade part 1, write new U-Boot, but with old ECC format still... # Store config block temporarly in memory at kernel_addr_r. diff --git a/recipes/images/files/colibri-vf/colibri-vf_bin/flash_eth.scr b/recipes/images/files/colibri-vf/colibri-vf_bin/flash_eth.scr index 776649e..b360987 100644 --- a/recipes/images/files/colibri-vf/colibri-vf_bin/flash_eth.scr +++ b/recipes/images/files/colibri-vf/colibri-vf_bin/flash_eth.scr @@ -1,16 +1,22 @@ setenv create_bcb 'nand erase.part vf-bcb && writebcb 0x20000 0x20000' setenv update_configblock 'tftpboot ${loadaddr} ${board_name}/configblock.bin && nand write ${loadaddr} 0x800 ${filesize}' -setenv prepare_rootfs 'ubi part ubi && ubi check rootfs || ubi create rootfs' +# Migrate to UBI volume based boot schema +setenv prepare_kernel_dtb 'ubi create kernel 0x800000 static && ubi create dtb 0x20000 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_dtb && run prepare_rootfs; fi; else run prepare_kernel_dtb && 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 && nand write ${loadaddr} u-boot' -setenv update_rootfs 'tftpboot ${loadaddr} ${board_name}/ubifs.img && run prepare_rootfs && ubi write ${loadaddr} rootfs ${filesize}' +setenv update_kernel 'tftpboot ${loadaddr} ${loadaddr} ${board_name}/zImage && ubi write ${loadaddr} kernel ${filesize}' +setenv update_dtb 'tftpboot ${loadaddr} ${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 update_new 'run update_uboot; run update_rootfs; reset' +setenv update_new 'run update_uboot; run prepare_ubi && run update_kernel && run update_dtb && run update_rootfs; reset' # Upgrade part 1, write new U-Boot, but with old ECC format still... # Store config block temporarly in memory at kernel_addr_r. setenv upgrade_part1 'run update_uboot && nand read ${kernel_addr_r} 0x800 0x20 && echo "${upgrade_part1_msg}"' -setenv upgrade_part1_msg 'Successfully updated U-Boot, NAND upgrade required. Enter "reset", interrupt boot process and enter "run setupdate; upgrade_part2" to complete upgrade.' +setenv upgrade_part1_msg 'Successfully updated U-Boot, NAND upgrade required. Enter "reset", interrupt boot process and enter "run setupdate; run upgrade_part2" to complete upgrade.' # Upgrade part 2, use new ECC format for the whole device... setenv upgrade_part2 'run create_bcb && nand write ${kernel_addr_r} 0x800 0x20 && run update_uboot && nand erase.part ubi && run update_rootfs && echo ${upgrade_part2_msg}' diff --git a/recipes/images/files/colibri-vf/update.sh b/recipes/images/files/colibri-vf/update.sh index 02c2791..b986479 100755 --- a/recipes/images/files/colibri-vf/update.sh +++ b/recipes/images/files/colibri-vf/update.sh @@ -74,6 +74,8 @@ OUT_DIR="" PAGE=2KiB BLOCK=124KiB MAXLEB=8112 +KERNEL_DEVICETREE="vf500-colibri-eval-v3.dtb vf610-colibri-eval-v3.dtb" +KERNEL_IMAGETYPE="zImage" while getopts "d:fhno:s" Option ; do case $Option in @@ -181,8 +183,21 @@ grep VF rootfs/etc/issue >> ${BINARIES}/versions.txt #create subdirectory for this module type sudo mkdir -p "$OUT_DIR" +# Copy device tree file +COPIED=false +if test -n "${KERNEL_DEVICETREE}"; then + for DTB_FILE in ${KERNEL_DEVICETREE}; do + echo ${BINARIES}/${KERNEL_IMAGETYPE}-${DTB_FILE} + if [ -e "${BINARIES}/${KERNEL_IMAGETYPE}-${DTB_FILE}" ]; then + sudo cp ${BINARIES}/${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_FILE} "$OUT_DIR/${DTB_FILE}" + COPIED=true + fi + done + [ $COPIED = true ] || { echo "Did not find the devicetrees from KERNEL_DEVICETREE, ${KERNEL_DEVICETREE}. Aborting."; exit 1; } +fi + #copy to $OUT_DIR -sudo cp ${BINARIES}/u-boot-nand.imx ${BINARIES}/ubifs.img ${BINARIES}/flash*.img ${BINARIES}/versions.txt "$OUT_DIR" +sudo cp ${BINARIES}/u-boot-nand.imx ${BINARIES}/zImage ${BINARIES}/ubifs.img ${BINARIES}/flash*.img ${BINARIES}/versions.txt "$OUT_DIR" sudo cp ${BINARIES}/fwd_blk.img "$OUT_DIR/../flash_blk.img" sudo cp ${BINARIES}/fwd_eth.img "$OUT_DIR/../flash_eth.img" sudo cp ${BINARIES}/fwd_mmc.img "$OUT_DIR/../flash_mmc.img" -- cgit v1.2.3