#!/bin/sh

PATH=/env/bin
export PATH

# set a fancy prompt (if support is compiled in)
PS1="\e[1;31m[barebox@\h]:\w\e[0m\n# "

# these partitions are only used to ease flashing inside barebox
spi_parts="512k(barebox),3584k(kernel),57M(root),1M(splash),1M(jffs2),896k(reserve),128k(bootenv)"
addpart /dev/m25p0 $spi_parts

#bootdelay=-1

# configure the ethernet mac addr and boot delay
. /env/conf

gpio_get_value 1
if [ $? -eq 1 ]; then
   echo "Starting Firmware Upgrader"
   pwfu
   echo "Resetting Board"
   reset
fi

# the 0 timeout allows to interrupt boot by holding any key
# on serial console terminal while releasing the reset button
timeout -as $bootdelay && ./env/bin/boot
