diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-11-28 22:15:56 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-11-28 22:15:56 +0100 |
commit | 27f5fc681c4039802977b6fe26623360f36af4de (patch) | |
tree | 03a749b374aed1c6b68d236e7639e7e1c272b547 /firmware/apps | |
parent | 7b250bfc8dc9cc4658b5793b1e2fd44810d95ff3 (diff) |
DFU: Move "Override DFU" (force DFU) code to board-specific section
Each board can define its own conditions on which the controller should
boot into DFU mode rather than normal application mode. Let's move the
"UART loopback jumper" to QMOD specific part. For SIMtrace we have an
actual button and can use that in a future patch.
Diffstat (limited to 'firmware/apps')
-rw-r--r-- | firmware/apps/dfu/main.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/firmware/apps/dfu/main.c b/firmware/apps/dfu/main.c index 5f683ce..01cf1e0 100644 --- a/firmware/apps/dfu/main.c +++ b/firmware/apps/dfu/main.c @@ -105,31 +105,10 @@ int USBDFU_handle_upload(uint8_t altif, unsigned int offset, return req_len; } -static int uart_has_loopback_jumper(void) +/* can be overridden by board specific code, e.g. by pushbutton */ +WEAK int board_override_enter_dfu(void) { - unsigned int i; - const Pin uart_loopback_pins[] = { - {PIO_PA9A_URXD0, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}, - {PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT} - }; - - /* Configure UART pins as I/O */ - PIO_Configure(uart_loopback_pins, PIO_LISTSIZE(uart_loopback_pins)); - - 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; - /* 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 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; + return 0; } /* using this function we can determine if we should enter DFU mode @@ -139,7 +118,7 @@ int USBDFU_OverrideEnterDFU(void) uint32_t *app_part = (uint32_t *)FLASH_ADDR(0); /* If the loopback jumper is set, we enter DFU mode */ - if (uart_has_loopback_jumper()) + if (board_override_enter_dfu()) return 1; /* if the first word of the application partition doesn't look |