aboutsummaryrefslogtreecommitdiff
path: root/projects/bootloader/bootloader.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2016-07-10 22:42:57 -0400
committerPaul Selkirk <paul@psgd.org>2016-07-10 22:42:57 -0400
commit35b8b35dc6dbf8fff62817a1de3820004af085ae (patch)
tree80afeb616ab386b3d1a923fa0eb222c8b32bf332 /projects/bootloader/bootloader.c
parentef5a13f6f449979a472bcf875f27997042f39539 (diff)
Check jumpers JP7 and JP8 before accepting new firmware or bootloader images.
Unfortunately, we can't read the jumper GPIOs directly, as that just gives us the last values written to them, so we see if we can read the FPGA configuration memory.
Diffstat (limited to 'projects/bootloader/bootloader.c')
-rw-r--r--projects/bootloader/bootloader.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/projects/bootloader/bootloader.c b/projects/bootloader/bootloader.c
index 3040bd1..8417256 100644
--- a/projects/bootloader/bootloader.c
+++ b/projects/bootloader/bootloader.c
@@ -36,6 +36,7 @@
#include "stm-led.h"
#include "stm-uart.h"
#include "stm-fmc.h"
+#include "stm-fpgacfg.h"
#include "dfu.h"
#undef HAL_Delay
@@ -68,21 +69,27 @@ void check_early_dfu_jump(void)
}
}
-int should_dfu()
+static int should_dfu()
{
- int i;
- uint8_t rx = 0;
+ /* JP7 and JP8 must be installed in order to reprogram the FPGA.
+ * We extend this to an enabling mechanism for reflashing the firmware.
+ * Unfortunately, we can't read JP7 and JP8 directly, as that just gives
+ * us the last things written to them, so we see if we can read the
+ * FPGA configuration memory.
+ */
+ fpgacfg_access_control(ALLOW_ARM);
+ if (fpgacfg_check_id() != 1)
+ return 0;
/* While blinking the blue LED for 5 seconds, see if we receive a CR on the MGMT UART.
- * We've discussed also requiring one or both of the FPGA config jumpers installed
- * before allowing DFU of the STM32 - that check could be done here.
*/
led_on(LED_BLUE);
- for (i = 0; i < 50; i++) {
+ for (int i = 0; i < 50; i++) {
HAL_Delay(100);
led_toggle(LED_BLUE);
+ uint8_t rx = 0;
if (uart_recv_char2(STM_UART_MGMT, &rx, 0) == HAL_OK) {
- if (rx == 13) return 1;
+ if (rx == '\r') return 1;
}
}
return 0;