summaryrefslogtreecommitdiffstats
path: root/defaultenv/defaultenv-1
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-02-20 10:18:10 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-02-21 17:06:46 +0100
commit464a531423f61b5d2c5108843e12ab7057a935bb (patch)
tree0f5310ab7854f639958f3ae16eaeebd2ac07aeaa /defaultenv/defaultenv-1
parent068f213bb3203e482334fa2130794c3ff25acb3b (diff)
downloadbarebox-464a531423f61b5d2c5108843e12ab7057a935bb.tar.gz
barebox-464a531423f61b5d2c5108843e12ab7057a935bb.tar.xz
move defaultenv-1 to defaultenv/defaultenv-1
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'defaultenv/defaultenv-1')
-rw-r--r--defaultenv/defaultenv-1/bin/_boot_help25
-rw-r--r--defaultenv/defaultenv-1/bin/_update47
-rw-r--r--defaultenv/defaultenv-1/bin/_update_help15
-rw-r--r--defaultenv/defaultenv-1/bin/boot141
-rw-r--r--defaultenv/defaultenv-1/bin/init37
-rw-r--r--defaultenv/defaultenv-1/bin/update82
-rw-r--r--defaultenv/defaultenv-1/config69
7 files changed, 416 insertions, 0 deletions
diff --git a/defaultenv/defaultenv-1/bin/_boot_help b/defaultenv/defaultenv-1/bin/_boot_help
new file mode 100644
index 0000000000..a07e4e0135
--- /dev/null
+++ b/defaultenv/defaultenv-1/bin/_boot_help
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+echo "boot: boot [-m <mode>] [-k <kernel_option>] [-r <rootfs_option>] [-i <ip_mode>] [-o <oftree_option]"
+echo ""
+echo "options"
+echo " - kernel nand, nor, nfs, tftp, disk"
+echo " - oftree nand, nor, nfs, tftp, disk or empty"
+echo " - rootfs nand, nor, net, disk"
+echo " - ip dhcp, dhcp-barebox none, empty"
+echo ""
+echo "mode option"
+echo " mode kernel rootfs"
+echo " nand nand nand"
+echo " nor nor nor"
+echo " nfs nfs net"
+echo " tftp fttp net"
+echo " disk disk disk"
+echo ""
+echo "ip option"
+echo " dhcp barebox and kernel will use DHCP"
+echo " dhcp-barebox barebox will use DHCP and pass the result to the kernel"
+echo " none do not pass ip parameter to the kernel and set it to none"
+echo " empty pass ip parameter to the kernel"
+echo ""
+echo "default mode are used from the /env/config"
diff --git a/defaultenv/defaultenv-1/bin/_update b/defaultenv/defaultenv-1/bin/_update
new file mode 100644
index 0000000000..8e27ee10c6
--- /dev/null
+++ b/defaultenv/defaultenv-1/bin/_update
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+if [ -z "$part" -o -z "$image" ]; then
+ echo "define \$part and \$image"
+ exit 1
+fi
+
+if [ ! -e "$part" ]; then
+ echo "Partition $part does not exist"
+ exit 1
+fi
+
+if [ x$mode = xtftp -o x$mode = xnfs ]; then
+ if [ x$ip = xdhcp -o x$ip = "xdhcp-barebox" ]; then
+ dhcp
+ fi
+
+ ping $eth0.serverip
+ if [ $? -ne 0 ] ; then
+ echo "Server did not reply! Update aborted."
+ exit 1
+ fi
+ load=$mode
+fi
+
+if [ x$mode = xxmodem ]; then
+ loadb -f $image -c
+ if [ $? -ne 0 ] ; then
+ echo "loadb failed or cancelled! Update aborted."
+ exit 1
+ fi
+ load="cp -v"
+fi
+
+unprotect $part
+
+echo
+echo "erasing partition $part"
+echo
+erase $part || exit 1
+
+echo
+echo "flashing $image to $part"
+echo
+$load $image $part || exit 1
+
+protect $part
diff --git a/defaultenv/defaultenv-1/bin/_update_help b/defaultenv/defaultenv-1/bin/_update_help
new file mode 100644
index 0000000000..b41e288ba0
--- /dev/null
+++ b/defaultenv/defaultenv-1/bin/_update_help
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+echo "usage: update -t <kernel|rootfs|barebox|bareboxenv|xload|oftree> -d <nor|nand> [-m tftp|xmodem] [-f imagename] -c"
+echo "update tools."
+echo ""
+echo "options"
+echo " -c to check the crc32 for the image and flashed one"
+echo ""
+echo "default mode is tftp"
+echo "type update -t kernel -d <nor|nand|disk> [-m tftp|xmodem|nfs] [-f imagename] to update kernel into flash"
+echo "type update -t rootfs -d <nor|nand> [-m tftp|xmodem|nfs] [-f imagename] to update rootfs into flash"
+echo "type update -t barebox -d <nor|nand> [-m tftp|xmodem|nfs] [-f imagename] to update barebox into flash"
+echo "type update -t bareboxenv -d <nor|nand> [-m tftp|xmodem|nfs] [-f imagename] to update bareboxenv into flash"
+echo "type update -t xload -d <nor|nand> [-m tftp|xmodem|nfs] [-f imagename] to update xload into flash"
+echo "type update -t oftree -d <nor|nand> [-m tftp|xmodem|nfs] [-f imagename] to update oftree into flash"
diff --git a/defaultenv/defaultenv-1/bin/boot b/defaultenv/defaultenv-1/bin/boot
new file mode 100644
index 0000000000..c17ccdb8f5
--- /dev/null
+++ b/defaultenv/defaultenv-1/bin/boot
@@ -0,0 +1,141 @@
+#!/bin/sh
+
+. /env/config
+
+if [ x$kernel_loc = xnet ]; then
+ kernel_loc=tftp
+fi
+
+while getopt "hk:r:i:m:o:" Option
+do
+if [ ${Option} = k ]; then
+ kernel_loc=${OPTARG}
+elif [ ${Option} = r ]; then
+ rootfs_loc=${OPTARG}
+elif [ ${Option} = o ]; then
+ oftree_loc=${OPTARG}
+elif [ ${Option} = i ]; then
+ ip=${OPTARG}
+elif [ ${Option} = m ]; then
+ mode=${OPTARG}
+else
+ . /env/bin/_boot_help
+ exit 0
+fi
+done
+
+if [ x$mode = xnand ]; then
+ rootfs_loc=nand
+ kernel_loc=nand
+elif [ x$mode = xnor ]; then
+ rootfs_loc=nor
+ kernel_loc=nor
+elif [ x$mode = xnfs ]; then
+ rootfs_loc=net
+ kernel_loc=nfs
+elif [ x$mode = xtftp ]; then
+ rootfs_loc=net
+ kernel_loc=tftp
+elif [ x$mode = xdisk ]; then
+ rootfs_loc=disk
+ kernel_loc=disk
+fi
+
+if [ x$ip = xdhcp -o x$ip = "xdhcp-barebox" ]; then
+ if [ x$kernel_loc = xnfs -o x$kernel_loc = xtftp ]; then
+ dhcp
+ if [ x${global.dhcp.rootpath} != x ]; then
+ nfsroot=${global.dhcp.rootpath}
+ fi
+ if [ x${global.dhcp.bootfile} != x ]; then
+ kernelimage=${global.dhcp.bootfile}
+ fi
+ if [ x$global.dhcp.oftree_file} != x ]; then
+ oftreeimage=${global.dhcp.oftree_file}
+ fi
+ fi
+fi
+
+if [ x$ip = xdhcp -o ]; then
+ bootargs="$bootargs ip=dhcp"
+elif [ x$ip = xnone ]; then
+ bootargs="$bootargs ip=none"
+else
+ bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
+fi
+
+
+if [ x$rootfs_loc = xnet ]; then
+ bootargs="$bootargs root=/dev/nfs nfsroot=$nfsroot,v3,tcp noinitrd"
+elif [ x$rootfs_loc = xdisk ]; then
+ bootargs="$bootargs root=/dev/$rootfs_part_linux_dev rootfstype=$rootfs_type noinitrd rootwait"
+elif [ x$rootfs_loc = xinitrd ]; then
+ bootargs="$bootargs root=/dev/ram0 rdinit=/sbin/init"
+else
+ if [ x$rootfs_loc = xnand ]; then
+ rootfs_mtdblock=$rootfs_mtdblock_nand
+ else
+ rootfs_mtdblock=$rootfs_mtdblock_nor
+ fi
+
+ if [ x$rootfs_type = xubifs ]; then
+ if [ -z $ubiroot ]; then
+ ubiroot="root"
+ fi
+ bootargs="$bootargs root=ubi0:$ubiroot ubi.mtd=$rootfs_mtdblock"
+ else
+ bootargs="$bootargs root=/dev/mtdblock$rootfs_mtdblock"
+ fi
+
+ bootargs="$bootargs rootfstype=$rootfs_type noinitrd"
+fi
+
+if [ -n $nor_parts ]; then
+ mtdparts="${mtdparts}physmap-flash.0:${nor_parts}"
+fi
+
+if [ -n $nand_parts ]; then
+ if [ -n ${mtdparts} ]; then
+ mtdparts="${mtdparts};"
+ fi
+ mtdparts="${mtdparts}${nand_device}:${nand_parts}"
+fi
+
+if [ -n $mtdparts ]; then
+ bootargs="${bootargs} mtdparts=${mtdparts}"
+fi
+
+if [ x$kernel_loc = xnfs -o x$kernel_loc = xtftp ]; then
+ kdev=/image
+ $kernel_loc $kernelimage $kdev || exit 1
+elif [ x$kernel_loc = xnor ]; then
+ kdev="/dev/nor0.kernel"
+elif [ x$kernel_loc = xnand ]; then
+ kdev="/dev/nand0.kernel.bb"
+elif [ x$kernel_loc = xdisk ]; then
+ kdev="/dev/$kernel_part"
+else
+ echo "error: set kernel_loc to one of 'tftp', 'nfs', 'nand', 'nor' or 'disk'"
+ exit 1
+fi
+
+if [ x$oftree_loc = xnfs -o x$oftree_loc = xtftp ]; then
+ odev=/oftree
+ $oftree_loc $oftreeimage $odev || exit 1
+elif [ x$oftree_loc = xnor ]; then
+ odev="/dev/nor0.oftree"
+elif [ x$oftree_loc = xnand ]; then
+ odev="/dev/nand0.oftree.bb"
+elif [ x$oftree_loc = xdisk ]; then
+ odev="/dev/$oftree_part"
+fi
+
+[ x$odev = x ] || bootm_opt="$bootm_opt -o $odev"
+
+echo "booting kernel from $kdev"
+
+#try to execute the file
+# it does not work as example for /dev as the file is not executable
+$kdev $bootm_opt
+# fall back on bootm
+bootm $bootm_opt $kdev
diff --git a/defaultenv/defaultenv-1/bin/init b/defaultenv/defaultenv-1/bin/init
new file mode 100644
index 0000000000..adb3c43a66
--- /dev/null
+++ b/defaultenv/defaultenv-1/bin/init
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+PATH=/env/bin
+export PATH
+
+global hostname
+
+. /env/config
+if [ -e /dev/nor0 -a -n "$nor_parts" ]; then
+ addpart /dev/nor0 $nor_parts
+fi
+
+if [ -e /dev/disk0 -a -n "$disk_parts" ]; then
+ addpart /dev/disk0 $disk_parts
+fi
+
+if [ -e /dev/nand0 -a -n "$nand_parts" ]; then
+ addpart /dev/nand0 $nand_parts
+ nand -a /dev/nand0.*
+fi
+
+if [ -f /env/bin/init_board ]; then
+ . /env/bin/init_board
+fi
+
+if [ -f /env/bin/boot_board ]; then
+ . /env/bin/boot_board
+elif [ -n $autoboot_timeout ]; then
+ echo
+ echo -n "Hit any key to stop autoboot: "
+ timeout -a $autoboot_timeout
+ if [ $? != 0 ]; then
+ exit
+ fi
+
+ boot
+fi
diff --git a/defaultenv/defaultenv-1/bin/update b/defaultenv/defaultenv-1/bin/update
new file mode 100644
index 0000000000..1578789a56
--- /dev/null
+++ b/defaultenv/defaultenv-1/bin/update
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+type=""
+device_type=""
+check=n
+mode=tftp
+
+. /env/config
+
+while getopt "ht:d:f:m:c" Option
+do
+if [ ${Option} = t ]; then
+ type=${OPTARG}
+elif [ ${Option} = d ]; then
+ device_type=${OPTARG}
+elif [ ${Option} = f ]; then
+ imagename=${OPTARG}
+elif [ ${Option} = c ]; then
+ check=y
+elif [ ${Option} = m ]; then
+ mode=${OPTARG}
+else
+ . /env/bin/_update_help
+ exit 0
+fi
+done
+
+if [ x${type} = xkernel ]; then
+ image=$kernelimage
+ disk_part=$kernel_part
+elif [ x${type} = xrootfs ]; then
+ image=$rootfsimage
+ type=root
+elif [ x${type} = xbarebox ]; then
+ image=$bareboximage
+ if [ -z ${image} ]; then
+ image=barebox.bin
+ fi
+elif [ x${type} = xoftree ]; then
+ image=$oftreeimage
+ if [ -z ${image} ]; then
+ image=oftree.bin
+ fi
+elif [ x${type} = xbareboxenv ]; then
+ image=$bareboxenvimage
+ if [ -z ${image} ]; then
+ image=bareboxenv.bin
+ fi
+elif [ x${type} = xxload ]; then
+ image=$xloadimage
+else
+ . /env/bin/_update_help
+ exit 1
+fi
+
+if [ -n ${imagename} ]; then
+ image=${imagename}
+fi
+
+if [ x${device_type} = xnand ]; then
+ part=/dev/nand0.${type}.bb
+elif [ x${device_type} = xnor ]; then
+ part=/dev/nor0.${type}
+elif [ x${device_type} = xdisk ]; then
+ part=/dev/${disk_part}
+else
+ . /env/bin/_update_help
+ exit 1
+fi
+
+if [ x${mode} != xtftp -a x${mode} != xxmodem -a x${mode} != xnfs ]; then
+ echo "unsupported mode ${mode}."
+ . /env/bin/_update_help
+ exit 1
+fi
+
+. /env/bin/_update || exit 1
+if [ x${check} = xy ]; then
+ crc32 -f $image -F $part
+else
+ true
+fi
diff --git a/defaultenv/defaultenv-1/config b/defaultenv/defaultenv-1/config
new file mode 100644
index 0000000000..391ba47c18
--- /dev/null
+++ b/defaultenv/defaultenv-1/config
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+hostname=FIXME
+if [ -z "$user" ]; then
+# user=
+fi
+
+# Enter MAC address here if not retrieved automatically
+#eth0.ethaddr=de:ad:be:ef:00:00
+
+# use 'dhcp' to do dhcp in barebox and in kernel
+# use 'none' if you want to skip kernel ip autoconfiguration
+ip=dhcp
+global.dhcp.vendor_id=barebox
+
+# or set your networking parameters here
+#eth0.ipaddr=a.b.c.d
+#eth0.netmask=a.b.c.d
+#eth0.serverip=a.b.c.d
+#eth0.gateway=a.b.c.d
+
+# can be either 'tftp', 'nfs', 'nand', 'nor' or 'disk'
+kernel_loc=tftp
+# can be either 'net', 'nand', 'nor', 'disk' or 'initrd'
+rootfs_loc=net
+# can be either 'tftp', 'nfs', 'nand', 'nor', 'disk' or none
+oftree_loc=tftp
+
+# for flash based rootfs: 'jffs2' or 'ubifs'
+# in case of disk any regular filesystem like 'ext2', 'ext3', 'reiserfs'
+rootfs_type=ubifs
+# where is the rootfs in case of 'rootfs_loc=disk' (linux name)
+rootfs_part_linux_dev=mmcblk0p4
+rootfsimage=rootfs-${global.hostname}.$rootfs_type
+
+# where is the kernel image in case of 'kernel_loc=disk'
+kernel_part=disk0.2
+
+kernelimage=zImage-${global.hostname}
+#kernelimage=uImage-${global.hostname}
+#kernelimage=Image-${global.hostname}
+#kernelimage=Image-${global.hostname}.lzo
+
+bareboximage=barebox-${global.hostname}.bin
+bareboxenvimage=barebox-${global.hostname}.bin
+
+if [ -n $user ]; then
+ bareboximage="$user"-"$bareboximage"
+ bareboxenvimage="$user"-"$bareboxenvimage"
+ kernelimage="$user"-"$kernelimage"
+ rootfsimage="$user"-"$rootfsimage"
+ nfsroot="/home/$user/nfsroot/${global.hostname}"
+else
+ nfsroot="/path/to/nfs/root"
+fi
+
+autoboot_timeout=3
+
+bootargs="console=ttyFIXME,115200"
+
+nor_parts="256k(barebox)ro,128k(bareboxenv),3M(kernel),-(root)"
+rootfs_mtdblock_nor=3
+
+nand_parts="256k(barebox)ro,128k(bareboxenv),3M(kernel),-(root)"
+nand_device="FIXME"
+rootfs_mtdblock_nand=7
+
+# set a fancy prompt (if support is compiled in)
+PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m "