From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org, Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Patrice VILCHEZ <patrice.vilchez@atmel.com>
Subject: [PATCH 08/14] at91sam9261ek/9g10ek: add dfu and usb serial support
Date: Mon, 12 Mar 2012 12:17:56 +0100 [thread overview]
Message-ID: <1331551082-7730-8-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1331551082-7730-1-git-send-email-plagnioj@jcrosoft.com>
if bp3 is pressed 5s during boot enable dfu otherwise usbserial
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/at91sam9261ek/env/bin/init_board | 51 ++++++++++++++++++++++
arch/arm/boards/at91sam9261ek/init.c | 26 +++++++++++
arch/arm/configs/at91sam9261ek_defconfig | 6 ++-
arch/arm/configs/at91sam9g10ek_defconfig | 5 ++
4 files changed, 87 insertions(+), 1 deletions(-)
create mode 100644 arch/arm/boards/at91sam9261ek/env/bin/init_board
diff --git a/arch/arm/boards/at91sam9261ek/env/bin/init_board b/arch/arm/boards/at91sam9261ek/env/bin/init_board
new file mode 100644
index 0000000..a76a660
--- /dev/null
+++ b/arch/arm/boards/at91sam9261ek/env/bin/init_board
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+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
+
+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 ds7 1
+dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
+led ds7 0
diff --git a/arch/arm/boards/at91sam9261ek/init.c b/arch/arm/boards/at91sam9261ek/init.c
index 6327b59..2952a76 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/init.c
@@ -135,6 +135,30 @@ static void __init ek_add_device_dm9000(void)
static void __init ek_add_device_dm9000(void) {}
#endif /* CONFIG_DRIVER_NET_DM9K */
+#if defined(CONFIG_USB_GADGET_DRIVER_AT91)
+/*
+ * USB Device port
+ */
+static struct at91_udc_data __initdata ek_udc_data = {
+ .vbus_pin = AT91_PIN_PB29,
+ .pullup_pin = 0,
+};
+
+static void ek_add_device_udc(void)
+{
+ at91_add_device_udc(&ek_udc_data);
+}
+#else
+static void ek_add_device_udc(void) {}
+#endif
+
+static void __init ek_add_device_buttons(void)
+{
+ at91_set_gpio_input(AT91_PIN_PA27, 1);
+ at91_set_deglitch(AT91_PIN_PA27, 1);
+ export_env_ull("dfu_button", AT91_PIN_PA27);
+}
+
#ifdef CONFIG_LED_GPIO
struct gpio_led ek_leds[] = {
{
@@ -184,6 +208,8 @@ static int at91sam9261ek_devices_init(void)
ek_add_device_nand();
ek_add_device_dm9000();
+ ek_add_device_udc();
+ ek_add_device_buttons();
ek_device_add_leds();
devfs_add_partition("nand0", 0x00000, SZ_128K, PARTITION_FIXED, "at91bootstrap_raw");
diff --git a/arch/arm/configs/at91sam9261ek_defconfig b/arch/arm/configs/at91sam9261ek_defconfig
index f9f0ddd..3796e42 100644
--- a/arch/arm/configs/at91sam9261ek_defconfig
+++ b/arch/arm/configs/at91sam9261ek_defconfig
@@ -7,7 +7,8 @@ CONFIG_HUSH_FANCY_PROMPT=y
CONFIG_CMDLINE_EDITING=y
CONFIG_AUTO_COMPLETE=y
CONFIG_MENU=y
-CONFIG_PARTITION=y
+# CONFIG_CONSOLE_ACTIVATE_FIRST is not set
+CONFIG_CONSOLE_ACTIVATE_ALL=y
CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/at91sam9261ek/env"
CONFIG_CMD_EDIT=y
@@ -49,6 +50,9 @@ CONFIG_MTD=y
CONFIG_NAND=y
CONFIG_NAND_ATMEL=y
CONFIG_UBI=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DFU=y
+CONFIG_USB_GADGET_SERIAL=y
CONFIG_LED=y
CONFIG_LED_GPIO=y
CONFIG_LED_TRIGGERS=y
diff --git a/arch/arm/configs/at91sam9g10ek_defconfig b/arch/arm/configs/at91sam9g10ek_defconfig
index d074bdc..0d677b0 100644
--- a/arch/arm/configs/at91sam9g10ek_defconfig
+++ b/arch/arm/configs/at91sam9g10ek_defconfig
@@ -6,6 +6,8 @@ CONFIG_GLOB=y
CONFIG_CMDLINE_EDITING=y
CONFIG_AUTO_COMPLETE=y
CONFIG_PARTITION=y
+# CONFIG_CONSOLE_ACTIVATE_FIRST is not set
+CONFIG_CONSOLE_ACTIVATE_ALL=y
CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/at91sam9261ek/env"
CONFIG_CMD_EDIT=y
@@ -41,6 +43,9 @@ CONFIG_MTD=y
CONFIG_NAND=y
CONFIG_NAND_ATMEL=y
CONFIG_UBI=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DFU=y
+CONFIG_USB_GADGET_SERIAL=y
CONFIG_LED=y
CONFIG_LED_GPIO=y
CONFIG_LED_TRIGGERS=y
--
1.7.7
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-03-12 11:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-12 11:17 [PATCH 01/14] macb: fix mmu support Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:17 ` [PATCH 02/14] at91sam9263ek: add runtime nor detection Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:17 ` [PATCH 03/14] at91sam9263ek: add leds support Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:17 ` [PATCH 04/14] at91sam9263ek: add dfu and usb serial support Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:17 ` [PATCH 05/14] at91sam9263ek: update defconfig Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:17 ` [PATCH 06/14] at91sam9261ek/9g10ek: update partition layout Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:17 ` [PATCH 07/14] at91sam9261ek/9g10ek: add leds support Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:17 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-03-12 11:17 ` [PATCH 09/14] at91sam9261ek/9g10ek: add gpio Keyboard support Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:17 ` [PATCH 10/14] at91sam9261ek/9g10ek: update board supprt Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:17 ` [PATCH 11/14] at91sam9m10g45ek: update partition layout Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:18 ` [PATCH 12/14] at91sam9m10g45ek: add leds support Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:18 ` [PATCH 13/14] at91sam9m10g45ek: update defconfig Jean-Christophe PLAGNIOL-VILLARD
2012-03-12 11:18 ` [PATCH 14/14] at91sam9260ek/9g20ek: " Jean-Christophe PLAGNIOL-VILLARD
2012-03-13 13:37 ` [PATCH 01/14] macb: fix mmu support Sascha Hauer
2012-03-13 17:13 ` Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331551082-7730-8-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
--cc=nicolas.ferre@atmel.com \
--cc=patrice.vilchez@atmel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox