Change in osmo-asf4-dfu[master]: add button to force DFU bootloader

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Jan 17 12:14:30 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/12593 )

Change subject: add button to force DFU bootloader
......................................................................

add button to force DFU bootloader

Change-Id: I163ab2de0fcbe13532c1992f6b78d49f4cda2d88
---
M atmel_start_pins.h
M driver_init.c
M usb_dfu_main.c
3 files changed, 12 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/atmel_start_pins.h b/atmel_start_pins.h
index 23b8d33..86e1dfb 100644
--- a/atmel_start_pins.h
+++ b/atmel_start_pins.h
@@ -27,9 +27,12 @@
 #define GPIO_PIN_FUNCTION_M 12
 #define GPIO_PIN_FUNCTION_N 13
 
-/** LED pin to indicate system state (pull low to switch on */
+/** LED pin to indicate system state (pull low to switch on) */
 #define LED_SYSTEM GPIO(GPIO_PORTC, 18)
 
+/** User button to force DFu bootloader (connected to ground when pressed) */
+#define BUTTON_FORCE_DFU GPIO(GPIO_PORTB, 31)
+
 /** USB D+/D- pins */
 #define PA24 GPIO(GPIO_PORTA, 24)
 #define PA25 GPIO(GPIO_PORTA, 25)
diff --git a/driver_init.c b/driver_init.c
index 0b07cc1..a91b0eb 100644
--- a/driver_init.c
+++ b/driver_init.c
@@ -148,6 +148,11 @@
 	gpio_set_pin_direction(LED_SYSTEM, GPIO_DIRECTION_OUT);
 	gpio_set_pin_function(LED_SYSTEM, GPIO_PIN_FUNCTION_OFF);
 
+	// configure force DFU user button
+	gpio_set_pin_direction(BUTTON_FORCE_DFU, GPIO_DIRECTION_IN);
+	gpio_set_pin_pull_mode(BUTTON_FORCE_DFU, GPIO_PULL_UP);
+	gpio_set_pin_function(BUTTON_FORCE_DFU, GPIO_PIN_FUNCTION_OFF);
+
 	USB_DEVICE_INSTANCE_init();
 	FLASH_0_init();
 }
diff --git a/usb_dfu_main.c b/usb_dfu_main.c
index 91748a5..449b311 100644
--- a/usb_dfu_main.c
+++ b/usb_dfu_main.c
@@ -48,6 +48,8 @@
  */
 static bool check_force_dfu(void)
 {
+	gpio_set_pin_pull_mode(BUTTON_FORCE_DFU, GPIO_PULL_UP); // pull button high
+	return (0 == gpio_get_pin_level(BUTTON_FORCE_DFU)); // signal is low when button is pressed
 }
 
 /** Check if the application is valid
@@ -87,7 +89,7 @@
 			delay_ms(500);
 		}
 	}
-	if (check_application()) { // application is valid
+	if (!check_force_dfu() && check_application()) { // application is valid
 		start_application(); // start application
 	} else {
 		usb_dfu(); // start DFU bootloader

-- 
To view, visit https://gerrit.osmocom.org/12593
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I163ab2de0fcbe13532c1992f6b78d49f4cda2d88
Gerrit-Change-Number: 12593
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190117/603ff302/attachment.htm>


More information about the gerrit-log mailing list