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
This commit is contained in:
Kevin Redon 2019-11-18 20:23:20 +01:00
parent 5db9402a5f
commit 389a4040d5
2 changed files with 17 additions and 1 deletions

View File

@ -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}

View File

@ -1,7 +1,7 @@
/* Card simulator specific functions
*
* (C) 2015-2017 by Harald Welte <hwelte@hmw-consulting.de>
* (C) 2018, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
* (C) 2018-2019, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
*
* 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
}
}