aboutsummaryrefslogtreecommitdiff
path: root/projects/hsm/mgmt-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/hsm/mgmt-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/hsm/mgmt-bootloader.c')
-rw-r--r--projects/hsm/mgmt-bootloader.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/projects/hsm/mgmt-bootloader.c b/projects/hsm/mgmt-bootloader.c
index a062fd9..d2d7ffe 100644
--- a/projects/hsm/mgmt-bootloader.c
+++ b/projects/hsm/mgmt-bootloader.c
@@ -37,6 +37,8 @@
#include "stm-init.h"
#include "stm-uart.h"
#include "stm-flash.h"
+#include "stm-fpgacfg.h"
+
#include "mgmt-cli.h"
#include "mgmt-misc.h"
#include "mgmt-bootloader.h"
@@ -64,6 +66,18 @@ static int cmd_bootloader_upload(struct cli_def *cli, const char *command, char
return CLI_ERROR;
}
+ /* 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) {
+ cli_print(cli, "ERROR: Check that jumpers JP7 and JP8 are installed.");
+ return CLI_ERROR;
+ }
+
uint8_t buf[DFU_UPLOAD_CHUNK_SIZE];
dfu_offset = DFU_BOOTLOADER_ADDR;