summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/at91sam9n12ek/env/bin/init_board
blob: 4931342a0b90b5a19f97b1ff3c35a88d63776f6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh

splash=/env/splash.png

if [ -f ${splash} -a -e /dev/fb0 ]; then
	splash -o ${splash}
	fb0.enable=1
fi

button_name="dfu_bp"
button_wait=5

dfu_config="/dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.rootfs.bb(rootfs)r"

if [ $at91_udc.vbus != 1 ]
then
	echo "No USB Device cable plugged, normal boot"
	exit
fi

gpio_get_value ${dfu_button}
if [ $? != 0 ]
then
	autoboot_timeout=16
	echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s"
	usbserial
	exit
fi

echo "${button_name} pressed detected wait ${button_wait}s"
timeout -s -a ${button_wait}

if [ $at91_udc.vbus != 1 ]
then
	echo "No USB Device cable plugged, normal boot"
	exit
fi

gpio_get_value ${dfu_button}
if [ $? != 0 ]
then
	echo "${button_name} released, normal boot"
	autoboot_timeout=16
	echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s"
	usbserial
	exit
fi

echo ""
echo "Start DFU Mode"
echo ""

led ds5 1
dfu ${dfu_config}