diff options
Diffstat (limited to 'recipes-images/images/files/colibri-vf')
9 files changed, 417 insertions, 0 deletions
diff --git a/recipes-images/images/files/colibri-vf/README b/recipes-images/images/files/colibri-vf/README new file mode 100644 index 0000000..8d283da --- /dev/null +++ b/recipes-images/images/files/colibri-vf/README @@ -0,0 +1,6 @@ +Toradex Linux BSP +================= + +Use the update.sh script to update your module. Check the Release Notes for +detailed instruction how to use flash your module. The Release Notes is located +in the same directory of the BSP release tarball. diff --git a/recipes-images/images/files/colibri-vf/colibri-vf_bin/flash_blk.scr b/recipes-images/images/files/colibri-vf/colibri-vf_bin/flash_blk.scr new file mode 100644 index 0000000..8fa5af9 --- /dev/null +++ b/recipes-images/images/files/colibri-vf/colibri-vf_bin/flash_blk.scr @@ -0,0 +1,28 @@ +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}' + +# Migrate to UBI volume based boot schema +setenv prepare_kernel_fdt '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_fdt && run prepare_rootfs; fi; else run prepare_kernel_fdt && 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_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 update_new 'run update_uboot; run prepare_ubi && run update_kernel && run update_fdt && 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; 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}' +setenv upgrade_part2_msg 'Successfully upgraded module, enter "reset" to restart the module.' + +# fsl_nfc indicates old NAND format (24-bit ECC), start migration process +setenv update 'mtdparts default && if test "${mtdids}" = "nand0=fsl_nfc"; then; run upgrade_part1; else run update_new; fi' + +echo 'enter "run update" to update the entire module' diff --git a/recipes-images/images/files/colibri-vf/colibri-vf_bin/flash_eth.scr b/recipes-images/images/files/colibri-vf/colibri-vf_bin/flash_eth.scr new file mode 100644 index 0000000..aa98b3a --- /dev/null +++ b/recipes-images/images/files/colibri-vf/colibri-vf_bin/flash_eth.scr @@ -0,0 +1,28 @@ +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}' + +# Migrate to UBI volume based boot schema +setenv prepare_kernel_fdt '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_fdt && run prepare_rootfs; fi; else run prepare_kernel_fdt && 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_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 update_new 'run update_uboot; run prepare_ubi && run update_kernel && run update_fdt && 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; 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}' +setenv upgrade_part2_msg 'Successfully upgraded module, enter "reset" to restart the module.' + +# fsl_nfc indicates old NAND format (24-bit ECC), start migration process +setenv update 'mtdparts default && if test "${mtdids}" = "nand0=fsl_nfc"; then; run upgrade_part1; else run update_new; fi' + +echo 'enter "run update" to update the entire module' diff --git a/recipes-images/images/files/colibri-vf/colibri-vf_bin/fwd_blk.scr b/recipes-images/images/files/colibri-vf/colibri-vf_bin/fwd_blk.scr new file mode 120000 index 0000000..5954646 --- /dev/null +++ b/recipes-images/images/files/colibri-vf/colibri-vf_bin/fwd_blk.scr @@ -0,0 +1 @@ +../../library/fwd_blk.scr
\ No newline at end of file diff --git a/recipes-images/images/files/colibri-vf/colibri-vf_bin/fwd_eth.scr b/recipes-images/images/files/colibri-vf/colibri-vf_bin/fwd_eth.scr new file mode 120000 index 0000000..decc214 --- /dev/null +++ b/recipes-images/images/files/colibri-vf/colibri-vf_bin/fwd_eth.scr @@ -0,0 +1 @@ +../../library/fwd_eth.scr
\ No newline at end of file diff --git a/recipes-images/images/files/colibri-vf/colibri-vf_bin/fwd_mmc.scr b/recipes-images/images/files/colibri-vf/colibri-vf_bin/fwd_mmc.scr new file mode 120000 index 0000000..3848cfa --- /dev/null +++ b/recipes-images/images/files/colibri-vf/colibri-vf_bin/fwd_mmc.scr @@ -0,0 +1 @@ +../../library/fwd_mmc.scr
\ No newline at end of file diff --git a/recipes-images/images/files/colibri-vf/colibri-vf_bin/mk-u-boot-scripts.sh b/recipes-images/images/files/colibri-vf/colibri-vf_bin/mk-u-boot-scripts.sh new file mode 120000 index 0000000..ce71dbd --- /dev/null +++ b/recipes-images/images/files/colibri-vf/colibri-vf_bin/mk-u-boot-scripts.sh @@ -0,0 +1 @@ +../../library/mk-u-boot-scripts.sh
\ No newline at end of file diff --git a/recipes-images/images/files/colibri-vf/format_sd.sh b/recipes-images/images/files/colibri-vf/format_sd.sh new file mode 100755 index 0000000..79cc985 --- /dev/null +++ b/recipes-images/images/files/colibri-vf/format_sd.sh @@ -0,0 +1,115 @@ +#! /bin/sh +# Format a SD card to be used for flashing a Colibri VFxx module +# Then calls update.sh to add needed files + +# sometimes we need the binary echo, not the shell builtin +ECHO=`which echo` + +Usage() +{ + echo "" + echo "Formats and fills a SD card with files for flashing the internal NAND of a" + echo "Colibri VFxx. Optionally creates a rootfs partition to allow booting and taking" + echo "kernel and rootfs from SD card." + echo "ALL DATA ON THE DEVICE GIVEN WITH -d WILL BE DELETED!!" + echo + echo "Requires a running U-Boot on the target. Either one already flashed on the NAND" + echo "or strapping the board to boot from SD card and booting U-Boot from the card" + echo "(only possible on older samples without blown boot fuses)." + echo "" + echo "-h : Prints this message" + echo "" + echo "-d FILE : device file of the SD card" + echo "-f : additionally copy the rootfs into the second partition" + echo "-s : optimise file system for 128MB NAND, increases usable space" + echo " on VF50 module a little, but on VF61 uses also only 128MB" + echo "" + echo "Example \"./format_sd.sh -d /dev/mmcblk0\" prepares the SD card /dev/mmcblk0" + echo "" +} + +#initialise options +DEV="/dev/null" +CFGBLOCK_ONLY=0 +DEBUG_ONLY=0 +KERNEL_ONLY=0 +UBOOT_ONLY=0 +CP_ROOTFS=0 + +while getopts "hd:fs" Option ; do + case $Option in + h) Usage + # Exit if only usage (-h) was specified. + if [[ $# -eq 1 ]] ; then + exit 10 + fi + exit 0 + ;; + d) DEV=$OPTARG + ;; + f) CP_ROOTFS=1 + ;; + s) UPDATE_OPTS="-s" + esac +done + +DEVNAME=`basename $DEV` +DEVNAMESTART=`echo $DEVNAME | cut -c 1-3` + +# sanity checks to try and not touch one of the users hard drives or other issues +if [ ! -b $DEV ] ; then + echo $DEV "is not a block device, " + echo "please specify the device file representing your SD card" + exit 1 +fi +if [ "$DEVNAMESTART" = "sda" ] ; then + echo $DEV "seems to be your primary hard disk," + echo "please specify the device file representing your SD card" + exit 1 +fi +if [ ! -d /sys/block/$DEVNAME ] ; then + echo "/sys/block/$DEVNAME" + echo $DEV "seems to not be a disk, please specify the device file" + echo "representing your SD card (without any trailing number)" + exit 1 +fi +IS_USB_MMC=`ls -l /sys/block/$DEVNAME | grep -c "usb\|mmc"` +if [ $IS_USB_MMC -eq 0 ] ; then + echo $DEV "seems not to be connected over USB or MMC, please specify the device file" + echo "representing your SD card (without any trailing number)" + exit 1 +fi + +if [ "$DEVNAMESTART" = "mmc" ] ; then + PART_PREFIX="p" +else + PART_PREFIX="" +fi +# make sure the partitions are unmounted +sudo umount ${DEV}${PART_PREFIX}? + +# partition and format the vfat partition +sudo parted -s $DEV mklabel msdos mkpart primary fat32 1MB 512MB mkpart primary ext3 512MB 100% +sudo umount ${DEV}${PART_PREFIX}1 +sudo mkfs.fat -n UPDATE ${DEV}${PART_PREFIX}1 + +# dd U-Boot onto the SD card +sudo dd if=colibri-vf_bin/u-boot.imx of=${DEV} bs=512 seek=2 + +sudo mkdir -p mntpoint1 +sudo mount -t vfat ${DEV}${PART_PREFIX}1 mntpoint1 -o umask=0 + +# now copy U-Boot, kernel and ubi-img to the KERNEL partition +DEST=`readlink -e mntpoint1` +./update.sh -o "$DEST" $UPDATE_OPTS + +#copy the rootfs +if [ "$CP_ROOTFS" -eq 1 ] ; then + sudo umount ${DEV}${PART_PREFIX}2 + sudo mkfs.ext3 -L RFS ${DEV}${PART_PREFIX}2 && sync + sudo mkdir -p mntpoint2 + sudo mount -t ext3 ${DEV}${PART_PREFIX}2 mntpoint2 + sudo cp -pPr rootfs/* mntpoint2/ +fi + +sudo umount ${DEV}${PART_PREFIX}? diff --git a/recipes-images/images/files/colibri-vf/update.sh b/recipes-images/images/files/colibri-vf/update.sh new file mode 100755 index 0000000..2c04342 --- /dev/null +++ b/recipes-images/images/files/colibri-vf/update.sh @@ -0,0 +1,236 @@ +#! /bin/sh +# Prepare files needed for flashing a Colibri VF50/VF61 module and +# copy them to a convenient location for using from a running U-Boot + +set -e + +Flash() +{ + echo "To flash the Colibri VF50/VF61 module a running U-Boot is required. Boot the" + echo "module to the U-Boot prompt and" + echo "" + echo "insert the SD card, USB flash drive or when using TFTP connect Ethernet only" + echo "and enter:" + echo "'run setupdate'" + echo "" + echo "then to update all components enter:" + echo "'run update'" + echo "" + echo "Alternatively, to update U-Boot enter:" + echo "'run update_uboot'" + echo "to update a component stored in UBI enter:" + echo "'run prepare_ubi'" + echo "followed by one of:" + echo "'run update_kernel'" + echo "'run update_fdt'" + echo "'run update_rootfs'" + echo "" + echo "" + echo "If you don't have a working U-Boot anymore, connect your PC to the module's" + echo "UART, bring the module into the serial download mode and start the update.sh" + echo "script with the -d option. This will copy U-Boot into the module's RAM and" + echo "execute it. Don't forget to also bridge RTS/CTS if using an USB-to-serial" + echo "converter without handshake signals." + echo "" + echo "Then use the following command to get U-Boot running:" + echo "'./update.sh -n -d /dev/ttyUSB0'" + echo "" + echo "Next, recreate the Boot Configuration Block and the Toradex Config Block:" + echo "'run setupdate'" + echo "'run update_uboot'" + echo "'run create_bcb'" + echo "'cfgblock create'" +} + +Usage() +{ + echo "" + echo "Prepares and copies files for flashing internal NAND of Colibri VF50/VF61" + echo "" + echo "The recommended way is to copy the files on a SD card or USB flash drive." + echo "The script format_sd.sh may be used to format the SD card." + echo "" + echo "The flash step requires a running U-Boot on the target. Either one already" + echo "flashed on the NAND or downloaded using serial downloader (argument -d)." + echo "" + echo "-d uart_dev : use UART connection to copy/execute U-Boot to/from module's RAM" + echo "-f : flash instructions" + echo "-h : prints this message" + echo "-m : module type: 0: autodetect from ./rootfs/etc/issues (default)" + echo " 1: Colibri VF50/VF61" + echo "-n : disable hardware flow control (bridge RTS/CTS!)" + echo "-o directory : output directory" + echo "-s : optimise file system for 128MB NAND, increases usable space" + echo " on VF50 module a little, but on VF61 uses also only 128MB" + echo "" + echo "Example \"./update.sh -o /media/KERNEL/\" copies the required files to SD card" + echo "" + echo "*** For detailed recovery/update procedures, refer to the following website: ***" + echo "http://developer.toradex.com/knowledge-base/flashing-linux-on-vybrid-modules" + echo "" +} + +# initialise options +KERNEL_DEVICETREE="vf500-colibri-eval-v3.dtb vf610-colibri-eval-v3.dtb" +KERNEL_IMAGETYPE="zImage" +MODTYPE_DETECT=0 +NORTSCTS=0 +OUT_DIR="" +UBOOT_RECOVERY=0 +# NAND parameters +PAGE=2KiB +BLOCK=124KiB +MAXLEB=8112 + +while getopts "d:fhm:no:s" Option ; do + case $Option in + d) UBOOT_RECOVERY=1 + UARTDEV=$OPTARG + ;; + f) Flash + exit 0 + ;; + h) Usage + exit 0 + ;; + m) MODTYPE_DETECT=$OPTARG + ;; + n) NORTSCTS=1 + ;; + o) OUT_DIR=$OPTARG + ;; + s) MAXLEB=982 + ;; + esac +done + +if [ "$OUT_DIR" = "" ] && [ "$UBOOT_RECOVERY" = "0" ] ; then + Usage + exit 1 +fi + +# is OUT_DIR an existing directory? +if [ ! -d "$OUT_DIR" ] && [ "$UBOOT_RECOVERY" = "0" ] ; then + echo "$OUT_DIR" "does not exist, exiting" + exit 1 +fi + +case $MODTYPE_DETECT in + 0) # auto detect MODTYPE from rootfs directory + if [ -f rootfs/etc/issue ] ; then + CNT=`grep -c "VF" rootfs/etc/issue || true` + if [ "$CNT" -ge 1 ] ; then + echo "Colibri VF rootfs detected" + MODTYPE=colibri-vf + fi + fi + if [ -e $MODTYPE ] ; then + echo "can not detect module type from ./rootfs/etc/issue" + echo "please specify the module type with the -m parameter" + echo "see help: '$ ./update.sh -h'" + echo "exiting" + exit 1 + fi + ;; + 1) MODTYPE=colibri-vf + echo "Colibri VF rootfs specified" + ;; + *) echo "-m paramter specifies an unknown value" + exit 1 + ;; +esac + +case "$MODTYPE" in + "colibri-vf") + IMAGEFILE=ubifs.img + LOCPATH="vf_flash" + OUT_DIR="$OUT_DIR/colibri_vf" + ;; + *) echo "script internal error, unknown module type set" + exit 1 + ;; +esac + +BINARIES=${MODTYPE}_bin + +#is only U-Boot to be copied to RAM? +if [ "$UBOOT_RECOVERY" -eq 1 ] ; then + LOADEROPTS="" + if [ ${NORTSCTS} = 1 ]; then + LOADEROPTS="--no-rtscts" + fi + + echo "Put the module in recovery mode and press [ENTER]..." + read RESULT + sudo ${LOCPATH}/imx_uart ${LOADEROPTS} ${UARTDEV} ${LOCPATH}/vybrid_usb_work.conf ${BINARIES}/u-boot.imx + exit +fi + +#sanity check for correct untared rootfs +DEV_OWNER=`ls -ld rootfs/dev | awk '{print $3}'` +if [ "${DEV_OWNER}x" != "rootx" ] +then + printf "rootfs/dev is not owned by root, but it should!\n" + printf "\033[1mPlease unpack the tarball with root rights.\033[0m\n" + printf "e.g. sudo tar xjvf Colibri_VF_LinuxImageV2.6_20160331.tar.bz2\n" + exit 1 +fi + +#sanity check, can we execute mkfs.ubifs, e.g. see the help text? +CNT=`sudo $LOCPATH/mkfs.ubifs -h | grep -c space-fixup || true` +if [ "$CNT" -eq 0 ] ; then + echo "The program mkfs.ubifs can not be executed or does not provide --space-fixup" + echo "option." + echo "Are you on a 64bit Linux host without installed 32bit execution environment?" + printf "\033[1mPlease install e.g. ia32-libs on 64-bit Ubuntu\033[0m\n" + printf "\033[1mMaybe others are needed e.g. liblzo2:i386 on 64-bit Ubuntu\033[0m\n" + exit 1 +fi + +#Install trap to write a sensible message in case any of the commands below +#exit premature... +trap '{ printf "\033[31mScript aborted unexpectedly...\033[0m\n"; }' EXIT + +#Prepare full flashing +sudo $LOCPATH/mkfs.ubifs --space-fixup -c ${MAXLEB} -e ${BLOCK} -m ${PAGE} -o ${BINARIES}/${IMAGEFILE} -r rootfs/ -v + +echo "" +echo "UBI image of root file system generated, copying data to target folder..." + +#make a file with the used versions for U-Boot, kernel and rootfs +sudo touch ${BINARIES}/versions.txt +sudo chmod ugo+w ${BINARIES}/versions.txt +echo "Component Versions" > ${BINARIES}/versions.txt +basename "`readlink -e ${BINARIES}/u-boot.imx`" >> ${BINARIES}/versions.txt +ROOTFSVERSION=`grep VF rootfs/etc/issue || echo "Version Unknown"` +echo "Rootfs ${ROOTFSVERSION}" >> ${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 + 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}/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" +#cleanup intermediate files +sudo rm ${BINARIES}/ubifs.img ${BINARIES}/versions.txt +sync + +#Remove trap and report success! +trap - EXIT +printf "\033[32mSuccessfully copied data to target folder.\033[0m\n\n" + +Flash |