Change in simtrace2[master]: DFU: re-enable UART after testing forced 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/.

Kévin Redon gerrit-no-reply at lists.osmocom.org
Sat Jul 7 13:28:54 UTC 2018


Kévin Redon has uploaded this change for review. ( https://gerrit.osmocom.org/9912


Change subject: DFU: re-enable UART after testing forced bootloader
......................................................................

DFU: re-enable UART after testing forced bootloader

The qmod does not have a separate force button as simtrace has.
Instead it check is TX and RX of UART are shorted using PIO.
If the pins are not set back to the UART peripheral, the TRACE/debug
console output will not work anymore.

Change-Id: Id434b49909d6395a2f93a00f39d2d770a5725466
---
M firmware/libboard/qmod/source/board_qmod.c
1 file changed, 20 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/12/9912/1

diff --git a/firmware/libboard/qmod/source/board_qmod.c b/firmware/libboard/qmod/source/board_qmod.c
index dd6e616..0eda1ef 100644
--- a/firmware/libboard/qmod/source/board_qmod.c
+++ b/firmware/libboard/qmod/source/board_qmod.c
@@ -261,20 +261,32 @@
 	/* Configure UART pins as I/O */
 	PIO_Configure(uart_loopback_pins, PIO_LISTSIZE(uart_loopback_pins));
 
+	/* Send pattern over UART TX and check if it is received on RX
+	 * If the loop doesn't get interrupted, RxD always follows TxD and thus a
+	 * loopback jumper has been placed on RxD/TxD, and we will boot
+	 * into DFU unconditionally
+	 */
+	int has_loopback_jumper = 1;
 	for (i = 0; i < 10; i++) {
 		/* Set TxD high; abort if RxD doesn't go high either */
 		PIO_Set(&uart_loopback_pins[1]);
-		if (!PIO_Get(&uart_loopback_pins[0]))
-			return 0;
+		if (!PIO_Get(&uart_loopback_pins[0])) {
+			has_loopback_jumper = 0;
+			break;
+		}
 		/* Set TxD low, abort if RxD doesn't go low either */
 		PIO_Clear(&uart_loopback_pins[1]);
-		if (PIO_Get(&uart_loopback_pins[0]))
-			return 0;
+		if (PIO_Get(&uart_loopback_pins[0])) {
+			has_loopback_jumper = 0;
+			break;
+		}
 	}
-	/* if we reached here, RxD always follows TxD and thus a
-	 * loopback jumper has been placed on RxD/TxD, and we will boot
-	 * into DFU unconditionally */
-	return 1;
+
+	/* Put pins back to UART mode */
+	const Pin uart_pins[] = {PINS_UART};
+	PIO_Configure(uart_pins, PIO_LISTSIZE(uart_pins));
+
+	return has_loopback_jumper;
 }
 
 int board_override_enter_dfu(void)

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id434b49909d6395a2f93a00f39d2d770a5725466
Gerrit-Change-Number: 9912
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180707/b8f38807/attachment.htm>


More information about the gerrit-log mailing list