diff options
author | Max Krummenacher <max.krummenacher@toradex.com> | 2015-03-28 13:59:29 +0100 |
---|---|---|
committer | Max Krummenacher <max.krummenacher@toradex.com> | 2015-05-12 10:04:34 +0200 |
commit | 495ad28eadc1733c58fb644586f8f9ce60e4a6ce (patch) | |
tree | 823c2d2ca93396be5075922c76f9a0592705d55b /recipes/images/files/colibri-t20 | |
parent | 48d95d0878b84c42a194800d904ff93908b9b785 (diff) |
trdx-image-fstype: drop tarball in favour of files
Drop the burnflash.tar.bz2 tarball and put the individual files under
version control.
Only create minimal set for colibri-t20 for now and move it with the
change to tegra-uboot-flasher.
Diffstat (limited to 'recipes/images/files/colibri-t20')
-rw-r--r-- | recipes/images/files/colibri-t20/colibri-t20_bin/configblock_256.bin | bin | 0 -> 2048 bytes | |||
-rw-r--r-- | recipes/images/files/colibri-t20/colibri-t20_bin/configblock_512.bin | bin | 0 -> 2048 bytes | |||
-rwxr-xr-x | recipes/images/files/colibri-t20/colibri-t20_bin/mk-u-boot-scripts.sh | 5 | ||||
-rwxr-xr-x | recipes/images/files/colibri-t20/create_configblock.sh | 168 | ||||
-rwxr-xr-x | recipes/images/files/colibri-t20/t20_nvflash/genext3fs.sh | 80 |
5 files changed, 253 insertions, 0 deletions
diff --git a/recipes/images/files/colibri-t20/colibri-t20_bin/configblock_256.bin b/recipes/images/files/colibri-t20/colibri-t20_bin/configblock_256.bin Binary files differnew file mode 100644 index 0000000..35068f7 --- /dev/null +++ b/recipes/images/files/colibri-t20/colibri-t20_bin/configblock_256.bin diff --git a/recipes/images/files/colibri-t20/colibri-t20_bin/configblock_512.bin b/recipes/images/files/colibri-t20/colibri-t20_bin/configblock_512.bin Binary files differnew file mode 100644 index 0000000..b58dbaa --- /dev/null +++ b/recipes/images/files/colibri-t20/colibri-t20_bin/configblock_512.bin diff --git a/recipes/images/files/colibri-t20/colibri-t20_bin/mk-u-boot-scripts.sh b/recipes/images/files/colibri-t20/colibri-t20_bin/mk-u-boot-scripts.sh new file mode 100755 index 0000000..2a4e898 --- /dev/null +++ b/recipes/images/files/colibri-t20/colibri-t20_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 iMX6' -d $f `basename $f .scr`.img +done diff --git a/recipes/images/files/colibri-t20/create_configblock.sh b/recipes/images/files/colibri-t20/create_configblock.sh new file mode 100755 index 0000000..bf0bc62 --- /dev/null +++ b/recipes/images/files/colibri-t20/create_configblock.sh @@ -0,0 +1,168 @@ +#! /bin/sh + +Usage() +{ + echo "create_configblock creates a configblock binary from the info on the module sticker." + echo "This can be used when the configblock got lost during a failed update attempt." + echo "The created configblock can then be written to the module with:" + echo "update.sh -c" + echo "" +} + +while getopts "h" Option ; do + case $Option in + h) Usage + # Exit if only usage (-h) was specfied. + if [[ $# -eq 1 ]] ; then + exit 10 + fi + exit 0 + ;; + esac +done + +# autotect MODTYPE from from rootfs directory +CNT=`grep -c "T20" rootfs/etc/issue || true` +if [ ${CNT} -ge 1 ] ; then + echo "Colibri T20 rootfs detected" + MODTYPE=colibri-t20 + BOOT_DEVICE=nand +else + CNT=`grep -c "T30" rootfs/etc/issue || true` + if [ ${CNT} -ge 1 ] ; then + CNT=`grep -c "Apalis" rootfs/etc/issue || true` + if [ ${CNT} -ge 1 ] ; then + echo "Apalis T30 rootfs detected" + MODTYPE=apalis-t30 + else + echo "Colibri T30 rootfs detected" + MODTYPE=colibri-t30 + fi + else + CNT=`grep -c "VF" rootfs/etc/issue || true` + if [ "$CNT" -ge 1 ] ; then + CNT=`grep -c "VF50" rootfs/etc/issue || true` + if [ "$CNT" -ge 1 ] ; then + echo "Colibri VF50 rootfs detected" + MODTYPE=colibri-vf50 + else + echo "Colibri VF61 rootfs detected" + MODTYPE=colibri-vf61 + fi + else + echo "can not detect modulue type from ./rootfs/etc/issue" + echo "exiting" + exit 1 + fi + fi +fi + +echo "Enter the modules serial number on the modules sticker or" +echo "use a barcode scanner to enter the content of the stickers barcode" + +# read a barcode and test it to be 8 or 16 numbers only 0025100102489109 0115100000000024 +# 1234567890123456 1234567890123456 +until [ "${BARCODE}x" != "x" ] +do + read BARCODE + #remove all whitespace + BARCODE=`echo $BARCODE | tr -d ' '` + #get strlen and the number of numeric characters + STRLEN=`echo $BARCODE | wc -c` + NUMCNT=`echo $BARCODE | sed 's/[^0-9]//g' | wc -c` + if [ $STRLEN -ne 17 ] ; then + if [ $STRLEN -ne 9 ] ; then + echo "The serial number must be 8 numbers long (the barcode 16)" + BARCODE="" + fi + fi + if [ $NUMCNT -ne $STRLEN ] ; then + echo "The serial number must contain all numeric characters" + BARCODE="" + fi +done +DATECODE=19700101000000 +if [ $STRLEN -eq 17 ] ; then + SERIALNR=`echo $BARCODE | awk 'BEGIN{ FIELDWIDTHS = "8 8"} {print $2}'` + PRODUCTNR=`echo $BARCODE | awk 'BEGIN{ FIELDWIDTHS = "8 8"} {print $1}'` +else + SERIALNR=$BARCODE + CONFIGBLOCK_FILE=${MODTYPE}_bin/configblock.bin + case ${MODTYPE} in + "colibri-t20") + RAM_SIZE=256 + echo "Enter the RAM size ( 256 / 512 ):" + read RAM_SIZE + echo "Enter I for IT version, nothing otherwise" + read IT + if [ $RAM_SIZE -eq 512 ] ; then + if [ "$IT"x = "I" ] ; then + PROD_ID="0022" + else + PROD_ID="0021" + fi + CONFIGBLOCK_FILE=${MODTYPE}_bin/configblock_512.bin + + else + if [ "$IT"x = "I" ] ; then + PROD_ID="0024" + else + PROD_ID="0020" + fi + PROD_ID="0020" + CONFIGBLOCK_FILE=${MODTYPE}_bin/configblock_256.bin + fi + ;; + "colibri-t30") + PROD_ID="0023" + ;; + "apalis-t30") + PROD_ID="0025" + ;; + "colibri-vf50") + PROD_ID="0010" + ;; + "apalis-vf61") + PROD_ID="0011" + ;; + esac + + echo "Enter the module version, e.g. V1.2 C" + read PRODVERSION + VER_MAJ=`echo $PRODVERSION | awk 'BEGIN{ FIELDWIDTHS = "1 1 1 1 1 1"} {print $2}'` + VER_MIN=`echo $PRODVERSION | awk 'BEGIN{ FIELDWIDTHS = "1 1 1 1 1 1"} {print $4}'` + #VARIANT: A=0, B=1 ... + VARIANT=`echo $PRODVERSION | awk 'BEGIN{ FIELDWIDTHS = "1 1 1 1 1 1"} {print $6}'` + VARIANT=`printf "%d\n" "'$VARIANT"` + VARIANT=`expr $VARIANT - 65` + if [ "$VARIANT" -lt 10 ] ; then + VARIANT=0$VARIANT + fi + PRODUCTNR=${PROD_ID}${VER_MAJ}${VER_MIN}${VARIANT} +fi + +#write the config block file +if [ "${MODTYPE}" = "colibri-t20" ] ; then + PROD_ID=`echo $PRODUCTNR | awk 'BEGIN{ FIELDWIDTHS = "4 4"} {print $1}'` + CONFIGBLOCK_FILE=${MODTYPE}_bin/configblock_256.bin + if [ ${PROD_ID} = "0021" ] ; then + CONFIGBLOCK_FILE=${MODTYPE}_bin/configblock_512.bin + fi + if [ ${PROD_ID} = "0022" ] ; then + CONFIGBLOCK_FILE=${MODTYPE}_bin/configblock_512.bin + fi +else + CONFIGBLOCK_FILE=${MODTYPE}_bin/configblock.bin +fi +sudo chown ${USER}: ${MODTYPE}_bin +sudo rm -f $CONFIGBLOCK_FILE +#file header +awk 'function sc(c) {return (c<128?c:(c-256))} BEGIN{printf "%c%c%c%c",0,64,1,-49}' > $CONFIGBLOCK_FILE +#mac addr / serial +echo $SERIALNR | awk 'function sc(c) {return (c<128?c:(c-256))} {printf "%c%c%c%c%c%c%c%c%c%c%c%c",2,64,0,0, 0,20,45, sc(int($0/256/256)), sc(int($0/256)%256), sc($0%256),0,0 }' >> $CONFIGBLOCK_FILE +#product describtion, $1 char 0/1: ??, $2 char 2/3: ProdID, $3 char 4:VerMaj, $4 char 5:VerMin, $5 char 6/7:Variant +echo $PRODUCTNR | awk 'BEGIN{ FIELDWIDTHS = "2 2 1 1 2"} function sc(c) {return (c<128?c:(c-256))} {printf "%c%c%c%c%c%c%c%c%c%c%c%c",2,64,8,0 ,sc($3),0, sc($4),0, sc($5),0, sc($2),0 }' >> $CONFIGBLOCK_FILE +#fill to 32 bytes +awk 'function sc(c) {return (c<128?c:(c-256))} BEGIN{printf "%c%c%c%c",-1,-1,-1,-1}' >> $CONFIGBLOCK_FILE + +exit 0 diff --git a/recipes/images/files/colibri-t20/t20_nvflash/genext3fs.sh b/recipes/images/files/colibri-t20/t20_nvflash/genext3fs.sh new file mode 100755 index 0000000..3c8ecc8 --- /dev/null +++ b/recipes/images/files/colibri-t20/t20_nvflash/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 arm $@ +#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 |