From 389a4040d5772407085a5fac6ada6dbf33dd94c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Mon, 18 Nov 2019 20:23:20 +0100 Subject: [PATCH] add DFU enter override capability in case flashing the main application firmware using DFU failed, the main application might be broken and not allow to switch again to DFU mode to re-flash it correctly. the other board have a way to force entering (e.g. staying in) the bootloader using an external signal (e.g. a switch on the SIMtrace board). the OWHW DFU firmware did not have this functionality implemented. the design (e.g. schematic) already has the SIMTRACE_BOOTLOADER signal (on PA31) for this purpose. now the DFU bootloader will start the DFU mode when the SIMTRACE_BOOTLOADER is high. this change has been tested on OWHWv2. Change-Id: Iefff51a811ad0f3bf3a46b8e256b905d11344bea --- firmware/libboard/owhw/include/board.h | 3 +++ firmware/libboard/owhw/source/owhw.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/firmware/libboard/owhw/include/board.h b/firmware/libboard/owhw/include/board.h index 44472d06..f9297719 100644 --- a/firmware/libboard/owhw/include/board.h +++ b/firmware/libboard/owhw/include/board.h @@ -46,6 +46,9 @@ /** index for green LED in LEDs pin definition array */ #define LED_NUM_GREEN 1 +/* pin connected to the SIMTRACE_BOOTLOADER signal. set high to force DFU bootloader start */ +#define PIN_BOOTLOADER {PIO_PA31, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT} + /* USIM 2 interface (USART) */ #define PIN_USIM2_CLK {PIO_PA2, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT} #define PIN_USIM2_IO {PIO_PA6, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} diff --git a/firmware/libboard/owhw/source/owhw.c b/firmware/libboard/owhw/source/owhw.c index 3bf51ec0..516d5923 100644 --- a/firmware/libboard/owhw/source/owhw.c +++ b/firmware/libboard/owhw/source/owhw.c @@ -1,7 +1,7 @@ /* Card simulator specific functions * * (C) 2015-2017 by Harald Welte - * (C) 2018, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon + * (C) 2018-2019, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -65,3 +65,16 @@ void cardsim_gpio_init(void) { PIO_Configure(pins_cardsim, ARRAY_SIZE(pins_cardsim)); } + +int board_override_enter_dfu(void) +{ + const Pin bl_pin = PIN_BOOTLOADER; + + PIO_Configure(&bl_pin, 1); + + if (PIO_Get(&bl_pin) == 0) { // signal low + return 0; // do not override enter DFU + } else { + return 1; // override enter DFU + } +}