From eb4e2c5fc55a6167c5f6feea4af2e8e89e8ad633 Mon Sep 17 00:00:00 2001 From: Dominik Sliwa Date: Mon, 19 Dec 2016 14:32:15 +0100 Subject: images: update.sh: Add Apalis TK1 Mainline machine Signed-off-by: Dominik Sliwa Acked-by: Max Krummenacher --- .../PM375_Hynix_2GB_H5TC4G63AFR_RDA_924MHz.bct | Bin 0 -> 8192 bytes .../apalis-tk1-mainline_bin/apalis-tk1.img.cfg | 22 ++++++ .../apalis-tk1-mainline_bin/flash_blk.scr | 31 ++++++++ .../apalis-tk1-mainline_bin/flash_eth.scr | 28 ++++++++ .../apalis-tk1-mainline_bin/fwd_blk.scr | 11 +++ .../apalis-tk1-mainline_bin/fwd_eth.scr | 6 ++ .../apalis-tk1-mainline_bin/fwd_mmc.scr | 3 + .../apalis-tk1-mainline_bin/mk-u-boot-scripts.sh | 5 ++ .../tegra-uboot-flasher/genext3fs.sh | 80 +++++++++++++++++++++ .../images/files/apalis-tk1-mainline/update.sh | 1 + .../images/files/library/tegra/update.sh | 13 +++- 11 files changed, 197 insertions(+), 3 deletions(-) create mode 100644 recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/PM375_Hynix_2GB_H5TC4G63AFR_RDA_924MHz.bct create mode 100644 recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/apalis-tk1.img.cfg create mode 100644 recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_blk.scr create mode 100644 recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_eth.scr create mode 100644 recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_blk.scr create mode 100644 recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_eth.scr create mode 100644 recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_mmc.scr create mode 100755 recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/mk-u-boot-scripts.sh create mode 100755 recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/genext3fs.sh create mode 120000 recipes-images/images/files/apalis-tk1-mainline/update.sh (limited to 'recipes-images/images/files') diff --git a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/PM375_Hynix_2GB_H5TC4G63AFR_RDA_924MHz.bct b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/PM375_Hynix_2GB_H5TC4G63AFR_RDA_924MHz.bct new file mode 100644 index 0000000..556a40e Binary files /dev/null and b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/PM375_Hynix_2GB_H5TC4G63AFR_RDA_924MHz.bct differ diff --git a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/apalis-tk1.img.cfg b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/apalis-tk1.img.cfg new file mode 100644 index 0000000..b9d203c --- /dev/null +++ b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/apalis-tk1.img.cfg @@ -0,0 +1,22 @@ +# Copyright (C) 2016 Toradex, Inc. +# +# This software is provided 'as-is', without any express or implied +# warranty. In no event will the authors be held liable for any damages +# arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not +# claim that you wrote the original software. If you use this software +# in a product, an acknowledgment in the product documentation would be +# appreciated but is not required. +# 2. Altered source versions must be plainly marked as such, and must not be +# misrepresented as being the original software. +# 3. This notice may not be removed or altered from any source distribution. + +Version = 0x00400001; +Bctcopy = 1; +Bctfile = PM375_Hynix_2GB_H5TC4G63AFR_RDA_924MHz.bct; +BootLoader = u-boot-dtb-tegra.bin,0x80108000,0x80108000,Complete; diff --git a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_blk.scr b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_blk.scr new file mode 100644 index 0000000..95b6ae5 --- /dev/null +++ b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_blk.scr @@ -0,0 +1,31 @@ +test -n ${interface} || setenv interface mmc +test -n ${drive} || setenv drive 1 + +setenv set_blkcnt 'setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200' +#workaround U-Boot counting in hex and split did in decimal +setenv incr_decimal 'setexpr filenum ${filenum} + 1; setexpr filenrlow1 ${filenum} % 0x100; setexpr filenrlow2 ${filenrlow1} % 0x10; test ${filenrlow1} -eq "9a" && test ${filenrlow2} -ne "9" && setexpr filenum ${filenum} + 0x66; test ${filenrlow1} -ne "9a" && test ${filenrlow2} -eq "a" && setexpr filenum ${filenum} + 0x6; true' +setenv set_nextnum 'run incr_decimal; setexpr blkstart ${blkstart} + ${blkcnt}' + +setenv check_1 'setenv conf_blk_offset 0x1fff; mmc read ${loadaddr} ${conf_blk_offset} 1' +setenv check_2 'setenv conf_blk_offset 0xfff; mmc read ${loadaddr} ${conf_blk_offset} 1' +setenv check_3 'setenv conf_blk_offset 0x7ff; mmc read ${loadaddr} ${conf_blk_offset} 1' +setenv check_configblock 'setexpr toradex_oui_addr ${loadaddr} + 8; mmc dev 0 1; run check_1 || run check_2 || run check_3; crc32 -v ${toradex_oui_addr} 3 94305232' + +setenv cp_file_chunk 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/root.ext3-${filenum} ${filesize} ${filepos}; run set_blkcnt; mmc dev 0 0 && mmc write ${loadaddr} ${blkstart} ${blkcnt}' + +setenv update_uboot 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/${board_name}.img && run set_blkcnt && mmc dev 0 1 && mmc write ${loadaddr} 0x0 ${blkcnt}' + +setenv update_kernel 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/uImage && fatwrite mmc 0:1 ${loadaddr} uImage ${filesize}' + +setenv update_fdt 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/${soc}-apalis-${fdt_board}.dtb && fatwrite mmc 0:1 ${loadaddr} ${soc}-apalis-${fdt_board}.dtb ${filesize}' + +setenv update_configblock 'run check_configblock; load ${interface} ${drive}:1 ${loadaddr} ${board_name}/configblock.bin && mmc dev 0 1 && mmc write ${loadaddr} ${conf_blk_offset} 1' + +setenv update_1 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/mbr.bin && mmc dev 0 0 && mmc write ${loadaddr} 0x0 0x1' +setenv update_2 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/boot.vfat && run set_blkcnt && mmc dev 0 0 && mmc write ${loadaddr} 0x2000 ${blkcnt}' +#do it in chunks of 64M to fit into DDR RAM of the smallest module +setenv update_rootfs 'setenv filesize 4000000; setenv filenum 100; setenv blkstart a000; while test ${filesize} -eq "4000000"; do run cp_file_chunk; run set_nextnum; done' + +setenv update 'run update_uboot; run update_1; run update_2; run update_kernel; run update_fdt; run update_rootfs; reset' + +echo 'enter "run update" to update the entire module' diff --git a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_eth.scr b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_eth.scr new file mode 100644 index 0000000..01da4bb --- /dev/null +++ b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_eth.scr @@ -0,0 +1,28 @@ +setenv set_blkcnt 'setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200' +#workaround U-Boot counting in hex and split did in decimal +setenv incr_decimal 'setexpr filenum ${filenum} + 1; setexpr filenrlow1 ${filenum} % 0x100; setexpr filenrlow2 ${filenrlow1} % 0x10; test ${filenrlow1} -eq "9a" && test ${filenrlow2} -ne "9" && setexpr filenum ${filenum} + 0x66; test ${filenrlow1} -ne "9a" && test ${filenrlow2} -eq "a" && setexpr filenum ${filenum} + 0x6; true' +setenv set_nextnum 'run incr_decimal; setexpr blkstart ${blkstart} + ${blkcnt}' + +setenv check_1 'setenv conf_blk_offset 0x1fff; mmc read ${loadaddr} ${conf_blk_offset} 1' +setenv check_2 'setenv conf_blk_offset 0xfff; mmc read ${loadaddr} ${conf_blk_offset} 1' +setenv check_3 'setenv conf_blk_offset 0x7ff; mmc read ${loadaddr} ${conf_blk_offset} 1' +setenv check_configblock 'setexpr toradex_oui_addr ${loadaddr} + 8; mmc dev 0 1; run check_1 || run check_2 || run check_3; crc32 -v ${toradex_oui_addr} 3 94305232' + +setenv cp_file_chunk 'tftpboot ${loadaddr} ${board_name}/root.ext3-${filenum}; run set_blkcnt; mmc dev 0 0 && mmc write ${loadaddr} ${blkstart} ${blkcnt}' + +setenv update_uboot 'tftpboot ${loadaddr} ${board_name}/${board_name}.img && run set_blkcnt && mmc dev 0 1 && mmc write ${loadaddr} 0x0 ${blkcnt}' + +setenv update_kernel 'tftpboot ${loadaddr} ${board_name}/uImage && fatwrite mmc 0:1 ${loadaddr} uImage ${filesize}' + +setenv update_fdt 'tftpboot ${loadaddr} ${board_name}/${soc}-apalis-${fdt_board}.dtb && fatwrite mmc 0:1 ${loadaddr} ${soc}-apalis-${fdt_board}.dtb ${filesize}' + +setenv update_configblock 'run check_configblock; tftpboot ${loadaddr} ${board_name}/configblock.bin && mmc dev 0 1 && mmc write ${loadaddr} ${conf_blk_offset} 1' + +setenv update_1 'tftpboot ${loadaddr} ${board_name}/mbr.bin && mmc dev 0 0 && mmc write ${loadaddr} 0x0 0x1' +setenv update_2 'tftpboot ${loadaddr} ${board_name}/boot.vfat && run set_blkcnt && mmc dev 0 0 && mmc write ${loadaddr} 0x2000 ${blkcnt}' +#do it in chunks of 64M to fit into DDR RAM of the smallest module +setenv update_rootfs 'setenv filesize 4000000; setenv filenum 100; setenv blkstart a000; while test ${filesize} -eq "4000000"; do run cp_file_chunk; run set_nextnum; done' + +setenv update 'run update_uboot; run update_1; run update_2; run update_kernel; run update_fdt; run update_rootfs; reset' + +echo 'enter "run update" to update the entire module' diff --git a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_blk.scr b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_blk.scr new file mode 100644 index 0000000..7af72e6 --- /dev/null +++ b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_blk.scr @@ -0,0 +1,11 @@ +#the update.sh script renames this. fwd_blk.scr -> ../flash_blk.img +test -n ${interface} || setenv interface mmc +test -n ${drive} || setenv drive 1 +test -z "${board_name}" && test "${soc}" = "vf500" && setenv board_name colibri_vf +test -z "${board_name}" && test "${soc}" = "vf610" && setenv board_name colibri_vf +test "${board_name}" = "colibri_imx7" && setenv drive 0 +test "${board_name}" = "colibri_t20" && setenv drive 0 +test "${board_name}" = "colibri_vf" && setenv drive 0 + +test -n ${board_name} || echo "board_name env not set!" && exit +fatload ${interface} ${drive}:1 ${loadaddr} ${board_name}/flash_blk.img && source ${loadaddr} diff --git a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_eth.scr b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_eth.scr new file mode 100644 index 0000000..d7ea35c --- /dev/null +++ b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_eth.scr @@ -0,0 +1,6 @@ +#the update.sh script renames this. fwd_eth.scr -> ../flash_eth.img +test -z "${board_name}" && test "${soc}" = "vf500" && setenv board_name colibri_vf +test -z "${board_name}" && test "${soc}" = "vf610" && setenv board_name colibri_vf + +test -n ${board_name} || echo "board_name env not set!" && exit +tftpboot ${loadaddr} "${board_name}/flash_eth.img" && source ${loadaddr} diff --git a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_mmc.scr b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_mmc.scr new file mode 100644 index 0000000..4c8f666 --- /dev/null +++ b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/fwd_mmc.scr @@ -0,0 +1,3 @@ +#the update.sh script renames this. fwd_mmc.scr -> ../flash_mmc.img +#flash_mmc has been renamed to flash_blk, ensure compatibilty when updating from older versions +fatload mmc ${drive}:1 ${loadaddr} flash_blk.img && source ${loadaddr} diff --git a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/mk-u-boot-scripts.sh b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/mk-u-boot-scripts.sh new file mode 100755 index 0000000..dda47d5 --- /dev/null +++ b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/mk-u-boot-scripts.sh @@ -0,0 +1,5 @@ +#!/bin/sh +for f in *.scr +do + mkimage -T script -C none -n 'Flash Apalis/Colibri module' -d $f `basename $f .scr`.img +done diff --git a/recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/genext3fs.sh b/recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/genext3fs.sh new file mode 100755 index 0000000..ffcf060 --- /dev/null +++ b/recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/genext3fs.sh @@ -0,0 +1,80 @@ +#!/bin/sh +#creates a file containing a ext3 binary blob of the content of the ../rootfs folder + +# sometimes we need the binary echo, not the shell builtin +ECHO=`which echo` + +MOUNTPOINT="mnt/trdx-rootfs" + +Usage() +{ + echo "creates a file containing a ext3 binary blob. Output file name taken from command line" + echo "Usage: genext3fs.sh [OPTION]... dest_file_name" + echo "-h : Prints this message" + echo "-b : Sets the partition size in MBytes, default 256" + echo "-d : Selects the directory which contains the partition content, default ../rootfs" + echo "" +} + +PARTITIONSIZE=256 +SRCPATH=../rootfs + +while getopts "b:d:h" Option ; do + case $Option in + h) Usage + # Exit if only usage (-h) was specfied. + if [[ "$#" -eq "1" ]] ; then + exit 10 + fi + exit 0 + ;; + b) PARTITIONSIZE=$OPTARG + ;; + d) SRCPATH=$OPTARG + ;; + esac +done +#adjust the commandline arg for the now used options +shift $(($OPTIND - 1)) + +#create the file used for the loopbackdevice and format it for ext3 +#answer y to "is not a block special device" +dd if=/dev/zero of=$@ bs=1024k count=$PARTITIONSIZE +mkfs.ext3 -F -L rootfs $@ +#disable fsck checks based on mount count or time interval +tune2fs -c 0 -i 0 $@ + +#prepare mountpoint for the loopdevice +sudo mkdir -p $MOUNTPOINT +sudo umount $MOUNTPOINT &> /dev/null +sudo rm -rf $MOUNTPOINT/* +#mount the file as a loopdevice +#there seems to be a race between mkfs.ext3 not yet finished and mount already trying to mount, so try until it works +MOUNTED=0 +while [ "$MOUNTED" -eq "0" ] ; do + sync + sleep 1 + sudo mount $@ $MOUNTPOINT/ -o loop -t ext3 + MOUNTED=`mount | grep -c "$MOUNTPOINT"` +done +#extract rootfs into the file +sudo cp -rpP $SRCPATH/* $MOUNTPOINT +if [ "$?" -ne "0" ] ; then + $ECHO -e "\033[1mCopying the rootfs failed.\033[0m" + echo "Check for error messages from cp" + sudo rm $@ + exit 1 +fi + +#unmount again +sudo umount $MOUNTPOINT + +#if the mounting was unsuccesful all rootfs data now still is in MOUNTPOINT, and $@ contains an empty fs +#delete $@ in that case to fail early +sync +FAILED=`ls $MOUNTPOINT | wc -l` +if [ "$FAILED" -ne "0" ] ; then + $ECHO -e "\033[1mMounting the loopdevice $@ failed.\033[0m" + sudo rm $@ + exit 1 +fi diff --git a/recipes-images/images/files/apalis-tk1-mainline/update.sh b/recipes-images/images/files/apalis-tk1-mainline/update.sh new file mode 120000 index 0000000..6ebea84 --- /dev/null +++ b/recipes-images/images/files/apalis-tk1-mainline/update.sh @@ -0,0 +1 @@ +../library/tegra/update.sh \ No newline at end of file diff --git a/recipes-images/images/files/library/tegra/update.sh b/recipes-images/images/files/library/tegra/update.sh index 3644511..a07b005 100755 --- a/recipes-images/images/files/library/tegra/update.sh +++ b/recipes-images/images/files/library/tegra/update.sh @@ -139,7 +139,14 @@ case $MODTYPE_DETECT in if [ "$CNT" -ge 1 ] ; then echo "Apalis TK1 rootfs detected" MODTYPE=apalis-tk1 + + CNT=`grep -ic "mainline" rootfs/etc/issue || true` + if [ "$CNT" -ge 1 ] ; then + echo "Mainline variant" + MODTYPE=apalis-tk1-mainline + fi fi + fi else CNT=`grep -ic "colibri" rootfs/etc/issue || true` @@ -197,7 +204,7 @@ case "$MODTYPE" in OUT_DIR="$OUT_DIR/apalis_t30" U_BOOT_BINARY=u-boot-dtb-tegra.bin ;; - "apalis-tk1") + "apalis-tk1" | "apalis-tk1-mainline") BCT=PM375_Hynix_2GB_H5TC4G63AFR_RDA_924MHz.bct CBOOT_IMAGE=apalis-tk1.img CBOOT_IMAGE_TARGET=tegra124 @@ -369,7 +376,7 @@ if [ "${MODTYPE}" = "colibri-t20" ] ; then echo "" echo "UBI image of root file system generated, copying data to target folder..." else - if [ "${MODTYPE}" = "apalis-t30" ] || [ "${MODTYPE}" = "apalis-tk1" ] || [ "${MODTYPE}" = "colibri-t30" ] ; then + if [ "${MODTYPE}" = "apalis-t30" ] || [ "${MODTYPE}" = "apalis-tk1" ] || [ "${MODTYPE}" = "apalis-tk1-mainline" ] || [ "${MODTYPE}" = "colibri-t30" ] ; then # Boot partition [in sectors of 512] BOOT_START=$(expr 4096 \* 2) # Rootfs partition [in sectors of 512] @@ -418,7 +425,7 @@ else fi fi done - [ "${MODTYPE}" = "apalis-tk1" ] && ([ $COPIED = true ] || { echo "Did not find the devicetrees from KERNEL_DEVICETREE, ${KERNEL_DEVICETREE}. Aborting."; exit 1; }) + ([ "${MODTYPE}" = "apalis-tk1" ] || [ "${MODTYPE}" = "apalis-tk1-mainline" ]) && ([ $COPIED = true ] || { echo "Did not find the devicetrees from KERNEL_DEVICETREE, ${KERNEL_DEVICETREE}. Aborting."; exit 1; }) fi echo "" -- cgit v1.2.3