File:  [ELWIX - Embedded LightWeight unIX -] / elwix / install2uboot.sh
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Mon Sep 15 19:06:42 2014 UTC (10 years, 3 months ago) by misho
Branches: MAIN
CVS tags: elwix2_8, elwix2_7, elwix2_6, elwix2_3, HEAD, ELWIX2_7, ELWIX2_6, ELWIX2_5, ELWIX2_2p0
elwix 2.2

#!/bin/sh
#
# ELWIX install script for u-boot image
#
# (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
#    by Michael Pounov <misho@elwix.org>
#
# $Id: install2uboot.sh,v 1.2 2014/09/15 19:06:42 misho Exp $
#

[ -r ./config/rc.elwix ] && . ./config/rc.elwix
if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then
	echo
	echo "ELWIX project is not configured !?!"
	echo
	exit 1
fi

if [ "${USER}" != "root" ]; then
	echo
	echo "ELWIX project is not configured - install must build under root !?!"
	echo
	exit 1
fi

if [ -z "${UB_LOADADDR}" ]; then
	echo
	echo "ELWIX project is not configured for u-boot use !?!"
	echo
	exit 1
fi


### main()

if [ -z "$1" ]; then
	echo
	echo "Error:: ELWIX u-boot option not found ..."
	echo
	exit 2
fi

case $1 in
	kernel)
		oldlzma e ${KERNEL} ${REL}/kernel.${UB_COMPRESS}
		uboot_mkimage -A ${TARGET} -O linux -T kernel -C ${UB_COMPRESS} -n ELWIX \
			-a ${UB_LOADADDR} -e ${UB_ENTRYADDR} -d ${REL}/kernel.${UB_COMPRESS} \
			${REL}/kernel.${UB_COMPRESS}.uImage
		;;
	kernel_rootfs)
		oldlzma e ${KERNEL_ROOTFS} ${REL}/kernel_rootfs.${UB_COMPRESS}
		uboot_mkimage -A ${TARGET} -O linux -T kernel -C ${UB_COMPRESS} -n ELWIX_ROOTFS \
			-a ${UB_LOADADDR} -e ${UB_ENTRYADDR} -d ${REL}/kernel_rootfs.${UB_COMPRESS} \
			${REL}/kernel_rootfs.${UB_COMPRESS}.uImage
		;;
	rootfs)
		makefs -t ffs -B ${UB_ORDER} -f 1000 -s ${UB_ROOTFS_SIZE} \
			-o "version=1,bsize=4096,fsize=512,minfree=0" \
			${REL}/rootfs.dsk ${UBOOT_FS}
		mkulzma -v -s 131072 -o ${REL}/rootfs.${UB_COMPRESS_ROOTFS} ${REL}/rootfs.dsk
		;;
	bin)
		imgupd -ts ${UB_ROOTFS_NAND_SIZE} -f ${REL}/elwix_firmware.bin \
		       	${REL}/rootfs.${UB_COMPRESS_ROOTFS}
		imgupd -s ${UB_KERNEL_NAND_SIZE} -f ${REL}/elwix_firmware.bin \
			${REL}/kernel.${UB_COMPRESS}.uImage

#		dd bs=65536 count=$((${UB_ROOTFS_NAND_SIZE} + ${UB_KERNEL_NAND_SIZE})) \
#			if=/dev/zero of=${REL}/elwix_firmware.bin
#		dd bs=65536 count=${UB_ROOTFS_NAND_SIZE} conv=sync,notrunc \
#			if=${REL}/rootfs.${UB_COMPRESS_ROOTFS} \
#			of=${REL}/elwix_firmware.bin
#		dd bs=65536 count=${UB_KERNEL_NAND_SIZE} conv=sync,notrunc seek=${UB_ROOTFS_NAND_SIZE} \
#			if=${REL}/kernel.${UB_COMPRESS}.uImage \
#			of=${REL}/elwix_firmware.bin
		;;
	vendor)
		if [ ! -r "${3:-./elwix_cfg.bin}" ]; then
			echo "elwix_cfg.bin not found!"
			exit 1
		fi

		imgupd -ts ${UB_ROOTFS_NAND_SIZE} -f ${REL}/elwix_firmware_${2:-vendor}.bin \
		       	${REL}/rootfs.${UB_COMPRESS_ROOTFS}
		imgupd -s ${UB_KERNEL_NAND_SIZE} -f ${REL}/elwix_firmware_${2:-vendor}.bin \
			${REL}/kernel.${UB_COMPRESS}.uImage
		imgupd -s ${UB_CFG_NAND_SIZE} -f ${REL}/elwix_firmware_${2:-vendor}.bin \
			${3:-./elwix_cfg.bin}
		;;
	*)
		echo "Option $1 not supported at this moment"
		;;
esac

echo "ELWIX u-boot image $1 complete."

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>