summaryrefslogtreecommitdiffstats
path: root/defaultenv/defaultenv-2-base
diff options
context:
space:
mode:
Diffstat (limited to 'defaultenv/defaultenv-2-base')
-rw-r--r--defaultenv/defaultenv-2-base/bin/bootargs-ip11
-rw-r--r--defaultenv/defaultenv-2-base/bin/ifup67
-rw-r--r--defaultenv/defaultenv-2-base/bin/init80
-rw-r--r--defaultenv/defaultenv-2-base/bin/mtdparts-add49
-rw-r--r--defaultenv/defaultenv-2-base/boot/net19
-rw-r--r--defaultenv/defaultenv-2-base/config25
-rw-r--r--defaultenv/defaultenv-2-base/data/ansi-colors30
-rw-r--r--defaultenv/defaultenv-2-base/data/boot-template14
-rw-r--r--defaultenv/defaultenv-2-base/init/automount22
-rw-r--r--defaultenv/defaultenv-2-base/init/ps17
-rw-r--r--defaultenv/defaultenv-2-base/network/eth016
11 files changed, 340 insertions, 0 deletions
diff --git a/defaultenv/defaultenv-2-base/bin/bootargs-ip b/defaultenv/defaultenv-2-base/bin/bootargs-ip
new file mode 100644
index 0000000000..2d4486caf8
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/bin/bootargs-ip
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# pass either static ip or dhcp to kernel based on barebox settings
+
+. /env/network/eth0
+
+if [ $ip = dhcp ]; then
+ global.linux.bootargs.dyn.ip="ip=dhcp"
+else
+ global.linux.bootargs.dyn.ip="ip=$ipaddr:$serverip:$gateway:$netmask::eth0:"
+fi
diff --git a/defaultenv/defaultenv-2-base/bin/ifup b/defaultenv/defaultenv-2-base/bin/ifup
new file mode 100644
index 0000000000..37b986c44b
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/bin/ifup
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+mkdir -p /tmp/network
+
+if [ $# != 1 ]; then
+ echo "usage: ifup <interface>"
+ exit 1
+fi
+
+interface="$1"
+
+if [ -f /tmp/network/$interface ]; then
+ exit 0
+fi
+
+cmd=/env/network/$interface
+
+if [ ! -e $cmd ]; then
+ echo "$f: no such file"
+ exit 1
+fi
+
+ip=
+ipaddr=
+netmask=
+gateway=
+serverip=
+ethaddr=
+
+. $cmd
+
+if [ $? != 0 ]; then
+ echo "failed to bring up $interface"
+ exit 1
+fi
+
+if [ -f /env/network/${interface}-discover ]; then
+ /env/network/${interface}-discover
+ if [ $? != 0 ]; then
+ echo "failed to discover eth0"
+ exit 1
+ fi
+fi
+
+if [ -n "$ethaddr" ]; then
+ ${interface}.ethaddr=$ethaddr
+fi
+
+if [ "$ip" = static ]; then
+ ${interface}.ipaddr=$ipaddr
+ ${interface}.netmask=$netmask
+ ${interface}.serverip=$serverip
+ ${interface}.gateway=$gateway
+ ret=0
+elif [ "$ip" = dhcp ]; then
+ dhcp
+ ret=$?
+ if [ $ret = 0 -a -n "$serverip" ]; then
+ ${interface}.serverip=$serverip
+ fi
+fi
+
+if [ $ret = 0 ]; then
+ echo -o /tmp/network/$interface up
+fi
+
+exit $ret
diff --git a/defaultenv/defaultenv-2-base/bin/init b/defaultenv/defaultenv-2-base/bin/init
new file mode 100644
index 0000000000..3a0e93b49d
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/bin/init
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+export PATH=/env/bin
+
+global hostname
+global user
+global autoboot_timeout
+global boot.default
+global allow_color
+global linux.bootargs.base
+global linux.bootargs.console
+#linux.bootargs.dyn.* will be cleared at the beginning of boot
+global linux.bootargs.dyn.ip
+global linux.bootargs.dyn.root
+global editcmd
+
+[ -z "${global.hostname}" ] && global.hostname=generic
+[ -z "${global.user}" ] && global.user=none
+[ -z "${global.autoboot_timeout}" ] && global.autoboot_timeout=3
+[ -z "${global.boot.default}" ] && global.boot.default=net
+[ -z "${global.allow_color}" ] && global.allow_color=true
+[ -z "${global.editcmd}" ] && global.editcmd=sedit
+
+[ -e /env/config-board ] && /env/config-board
+/env/config
+
+# request password to login if a timeout is specified and password set
+if [ -n ${global.login.timeout} ]; then
+ [ ${global.login.timeout} -gt 0 ] && login_cmd=login
+fi
+# allow the input if not
+[ -n ${global.console.input_allow} ] && global.console.input_allow=1
+
+# allow to stop the boot before execute the /env/init/*
+# but without waiting
+timeout -s -a -v key 0
+
+if [ "${key}" = "q" ]; then
+ ${login_cmd}
+ exit
+fi
+
+[ -n ${login_cmd} ] && global.console.input_allow=0
+
+for i in /env/init/*; do
+ . $i
+done
+
+if [ -e /env/menu ]; then
+ echo -e -n "\nHit m for menu or any other key to stop autoboot: "
+else
+ echo -e -n "\nHit any key to stop autoboot: "
+fi
+
+[ -n ${login_cmd} ] && global.console.input_allow=1
+
+timeout -a $global.autoboot_timeout -v key
+autoboot="$?"
+
+[ -n ${login_cmd} ] && global.console.input_allow=0
+
+if [ "${key}" = "q" ]; then
+ ${login_cmd}
+ exit
+fi
+
+if [ "$autoboot" = 0 ]; then
+ boot
+fi
+
+if [ -e /env/menu ]; then
+ ${login_cmd}
+ if [ "${key}" != "m" ]; then
+ echo -e "\ntype exit to get to the menu"
+ sh
+ fi
+ /env/menu/mainmenu
+fi
+
+${login_cmd}
diff --git a/defaultenv/defaultenv-2-base/bin/mtdparts-add b/defaultenv/defaultenv-2-base/bin/mtdparts-add
new file mode 100644
index 0000000000..58c9fa7a21
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/bin/mtdparts-add
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+mkdir -p /tmp/mtdparts
+
+parts=
+device=
+kernelname=
+bbdev=
+
+while getopt "p:d:k:b" opt; do
+ if [ ${opt} = p ]; then
+ parts=${OPTARG}
+ elif [ ${opt} = d ]; then
+ device=${OPTARG}
+ elif [ ${opt} = k ]; then
+ kernelname=${OPTARG}
+ elif [ ${opt} = b ]; then
+ bbdev=true
+ fi
+done
+
+if [ -z "${device}" ]; then
+ echo "$0: no device given"
+ exit
+fi
+
+if [ -z "${parts}" ]; then
+ echo "$0: no partitions given"
+ exit
+fi
+
+if [ -e /tmp/mtdparts/${device} ]; then
+ if [ -n "/dev/${device}.*.bb" ]; then
+ nand -d /dev/${device}.*.bb
+ fi
+ delpart /dev/${device}.*
+fi
+
+addpart -n /dev/${device} "$parts" || exit
+mkdir -p /tmp/mtdparts/${device}
+
+if [ -n "${bbdev}" ]; then
+ nand -a /dev/${device}.*
+fi
+
+if [ -n ${kernelname} ]; then
+ global linux.mtdparts.${device}
+ global.linux.mtdparts.${device}="${kernelname}:${parts}"
+fi
diff --git a/defaultenv/defaultenv-2-base/boot/net b/defaultenv/defaultenv-2-base/boot/net
new file mode 100644
index 0000000000..05bb728fa1
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/boot/net
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+ boot-menu-add-entry "$0" "network (tftp, nfs)"
+ exit
+fi
+
+path="/mnt/tftp"
+
+global.bootm.image="${path}/${global.user}-linux-${global.hostname}"
+
+oftree="${path}/${global.user}-oftree-${global.hostname}"
+if [ -f "${oftree}" ]; then
+ global.bootm.oftree="$oftree"
+fi
+
+nfsroot="/home/${global.user}/nfsroot/${global.hostname}"
+bootargs-ip
+global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
diff --git a/defaultenv/defaultenv-2-base/config b/defaultenv/defaultenv-2-base/config
new file mode 100644
index 0000000000..784ae52b80
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/config
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# change network settings in /env/network/eth0
+# change mtd partition settings and automountpoints in /env/init/*
+
+#global.hostname=
+
+# set to false if you do not want to have colors
+#global.allow_color=true
+
+# user (used for network filenames)
+#global.user=none
+
+# timeout in seconds before the default boot entry is started
+#global.autoboot_timeout=3
+
+# list of boot entries. These are executed in order until one
+# succeeds. An entry can be:
+# - a filename in /env/boot/
+# - a full path to a directory. All files in this directory are
+# treated as boot files and executed in alphabetical order
+#global.boot.default=net
+
+# base bootargs
+#global.linux.bootargs.base="console=ttyS0,115200"
diff --git a/defaultenv/defaultenv-2-base/data/ansi-colors b/defaultenv/defaultenv-2-base/data/ansi-colors
new file mode 100644
index 0000000000..636532979a
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/data/ansi-colors
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+if [ ${global.allow_color} != "true" ]; then
+ exit
+fi
+
+# Colors
+export RED='\e[1;31m'
+export BLUE='\e[1;34m'
+export GREEN='\e[1;32m'
+export CYAN='\e[1;36m'
+export YELLOW='\e[1;33m'
+export PINK='\e[1;35m'
+export WHITE='\e[1;37m'
+
+export DARK_RED='\e[2;31m'
+export DARK_BLUE='\e[2;34m'
+export DARK_GREEN='\e[2;32m'
+export DARK_CYAN='\e[2;36m'
+export DARK_YELLOW='\e[2;33m'
+export DARK_PINK='\e[2;35m'
+export DARK_WHITE='\e[2;37m'
+
+export RED_INV='\e[1;41m'
+export BLUE_INV='\e[1;44m'
+export GREEN_INV='\e[1;42m'
+export CYAN_INV='\e[1;46m'
+export ORANGE_INV='\e[1;43m'
+export PINK_INV='\e[1;45m'
+export NC='\e[0m' # No Color
diff --git a/defaultenv/defaultenv-2-base/data/boot-template b/defaultenv/defaultenv-2-base/data/boot-template
new file mode 100644
index 0000000000..9297499036
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/data/boot-template
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+ boot-menu-add-entry "$0" "<menu text here>"
+ exit
+fi
+
+global.bootm.image=<path to image>
+#global.bootm.oftree=<path to oftree>
+#global.bootm.initrd=<path to initrd>
+
+#bootargs-ip
+
+global.linux.bootargs.dyn.root="root=<rootfs here>"
diff --git a/defaultenv/defaultenv-2-base/init/automount b/defaultenv/defaultenv-2-base/init/automount
new file mode 100644
index 0000000000..fe56d920e7
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/init/automount
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+ init-menu-add-entry "$0" "Automountpoints"
+ exit
+fi
+
+# automount tftp server based on $eth0.serverip
+
+mkdir -p /mnt/tftp
+automount /mnt/tftp 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp'
+
+# automount nfs server example
+
+#nfshost=somehost
+#mkdir -p /mnt/${nfshost}
+#automount /mnt/$nfshost "ifup eth0 && mount -t nfs ${nfshost}:/tftpboot /mnt/${nfshost}"
+
+# FAT on usb disk example
+
+#mkdir -p /mnt/fat
+#automount -d /mnt/fat 'usb && [ -e /dev/disk0.0 ] && mount /dev/disk0.0 /mnt/fat'
diff --git a/defaultenv/defaultenv-2-base/init/ps1 b/defaultenv/defaultenv-2-base/init/ps1
new file mode 100644
index 0000000000..02d7b4b780
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/init/ps1
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ ${global.allow_color} = "true" ]; then
+ export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m "
+else
+ export PS1="barebox@\h:\w "
+fi
diff --git a/defaultenv/defaultenv-2-base/network/eth0 b/defaultenv/defaultenv-2-base/network/eth0
new file mode 100644
index 0000000000..7e731cae00
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/network/eth0
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# ip setting (static/dhcp)
+ip=dhcp
+global.dhcp.vendor_id=barebox-${global.hostname}
+
+# static setup used if ip=static
+ipaddr=
+netmask=
+gateway=
+serverip=
+
+# MAC address if needed
+#ethaddr=xx:xx:xx:xx:xx:xx
+
+# put code to discover eth0 (i.e. 'usb') to /env/network/eth0-discover