aboutsummaryrefslogtreecommitdiff
path: root/projects/hsm
diff options
context:
space:
mode:
Diffstat (limited to 'projects/hsm')
-rw-r--r--projects/hsm/mgmt-bootloader.c14
-rw-r--r--projects/hsm/mgmt-firmware.c13
2 files changed, 27 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;
diff --git a/projects/hsm/mgmt-firmware.c b/projects/hsm/mgmt-firmware.c
index 1a0e184..e4d3b0c 100644
--- a/projects/hsm/mgmt-firmware.c
+++ b/projects/hsm/mgmt-firmware.c
@@ -38,6 +38,7 @@
#include "mgmt-cli.h"
#include "stm-uart.h"
#include "stm-flash.h"
+#include "stm-fpgacfg.h"
#undef HAL_OK
#define HAL_OK LIBHAL_OK
@@ -53,6 +54,18 @@ static int cmd_firmware_upload(struct cli_def *cli, const char *command, char *a
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;
+ }
+
/* reboot and let the bootloader handle the upload */
cli_print(cli, "\n\n\nRebooting\n\n\n");
HAL_NVIC_SystemReset();