summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/at91sam9260ek
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-01-05 14:36:37 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-01-06 09:42:30 +0100
commit6ac280d92e1edd7b8cceda08855d24243e911e22 (patch)
tree92a268b8c431617bf629ea71b708e67b32684cc1 /arch/arm/boards/at91sam9260ek
parent57baef09396f9af57b8e757755d3c2dc8cc7f83f (diff)
downloadbarebox-6ac280d92e1edd7b8cceda08855d24243e911e22.tar.gz
barebox-6ac280d92e1edd7b8cceda08855d24243e911e22.tar.xz
at91sam9260/9g20ek: add dfu and usb serial support
if bp3 is pressed 5s during boot enable dfu otherwise usbserial Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/boards/at91sam9260ek')
-rw-r--r--arch/arm/boards/at91sam9260ek/env/bin/init_board40
-rw-r--r--arch/arm/boards/at91sam9260ek/init.c2
2 files changed, 35 insertions, 7 deletions
diff --git a/arch/arm/boards/at91sam9260ek/env/bin/init_board b/arch/arm/boards/at91sam9260ek/env/bin/init_board
index 0da2781045..0a6baf722b 100644
--- a/arch/arm/boards/at91sam9260ek/env/bin/init_board
+++ b/arch/arm/boards/at91sam9260ek/env/bin/init_board
@@ -1,18 +1,44 @@
#!/bin/sh
-#PIOA_31
-gpio_get_value 63
+button_name="dfu_bp"
+button_wait=5
+
+product_id=0x1234
+vendor_id=0x4321
+
+dfu_config="/dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.rootfs.bb(rootfs)r"
+
+if [ $at91_udc0.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_udc0.vbus != 1 ]
+then
+ echo "No USB Device cable plugged, normal boot"
exit
fi
-echo "BP4 pressed detected wait 5s"
-timeout -s -a 5
-gpio_get_value 63
+gpio_get_value ${dfu_button}
if [ $? != 0 ]
then
- echo "BP4 released, normal boot"
+ 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
@@ -20,4 +46,4 @@ echo ""
echo "Start DFU Mode"
echo ""
-dfu /dev/self0(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.root.bb(root)r -P 0x1234 -V 0x4321
+dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
index b10d0dc14e..a11998a148 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -212,8 +212,10 @@ static void __init ek_add_device_buttons(void)
{
at91_set_gpio_input(AT91_PIN_PA30, 1); /* btn3 */
at91_set_deglitch(AT91_PIN_PA30, 1);
+ export_env_ull("dfu_button", AT91_PIN_PA30);
at91_set_gpio_input(AT91_PIN_PA31, 1); /* btn4 */
at91_set_deglitch(AT91_PIN_PA31, 1);
+ export_env_ull("btn4", AT91_PIN_PA31);
}
static int at91sam9260ek_devices_init(void)