diff --git a/firmware/Core/Src/main.c b/firmware/Core/Src/main.c
index 8a4a460..44b3aa0 100644
--- a/firmware/Core/Src/main.c
+++ b/firmware/Core/Src/main.c
@@ -41,6 +41,7 @@
#define VENDOR_REQUEST_KEYS 0xfe
#define VENDOR_REQUEST_CONFIG 0xff
#define VENDOR_REQUEST_RESET_CONFIG 0xfd
+#define VENDOR_REQUEST_DFU_MODE 0xfc
#define VENDOR_VALUE_GET_LENGTH 0x00
#define VENDOR_VALUE_GET 0x01
@@ -137,6 +138,26 @@ static void remove_from_hid_report(struct key *key, uint8_t layer);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
+
+// https://stm32f4-discovery.net/2017/04/tutorial-jump-system-memory-software-stm32/
+void jump_to_bootloader(void) {
+ __enable_irq();
+ HAL_RCC_DeInit();
+ HAL_DeInit();
+ SysTick->CTRL = SysTick->LOAD = SysTick->VAL = 0;
+ __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
+
+ const uint32_t p = (*((uint32_t *)0x1FFF0000));
+ __set_MSP(p);
+
+ void (*SysMemBootJump)(void);
+ SysMemBootJump = (void (*)(void))(*((uint32_t *)0x1FFF0004));
+ SysMemBootJump();
+
+ while (1) {
+ }
+}
+
void readConfig() {
memcpy(&user_config, (uint32_t *)CONFIG_ADDRESS, sizeof(user_config));
}
@@ -953,6 +974,17 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
}
}
+ case VENDOR_REQUEST_DFU_MODE: {
+ if (request->wValue == VENDOR_VALUE_SET) {
+ if (stage == CONTROL_STAGE_SETUP) {
+ jump_to_bootloader();
+ return tud_control_status(rhport, request);
+ }
+
+ break;
+ }
+ }
+
case VENDOR_REQUEST_KEYS: {
switch (request->wValue) {
case VENDOR_VALUE_GET_LENGTH: {
diff --git a/web-app/app/routes/_layout.configurator.tsx b/web-app/app/routes/_layout.configurator.tsx
index deb6a16..dbec803 100644
--- a/web-app/app/routes/_layout.configurator.tsx
+++ b/web-app/app/routes/_layout.configurator.tsx
@@ -148,6 +148,7 @@ export default function Index() {
+
>
)}
diff --git a/web-app/app/useDevice.ts b/web-app/app/useDevice.ts
index 312b2d2..e4d02a0 100644
--- a/web-app/app/useDevice.ts
+++ b/web-app/app/useDevice.ts
@@ -7,6 +7,7 @@ const vendorRequests = {
VENDOR_REQUEST_KEYS: 0xfe,
VENDOR_REQUEST_CONFIG: 0xff,
VENDOR_REQUEST_RESET_CONFIG: 0xfd,
+ VENDOR_REQUEST_DFU_MODE: 0xfc,
}
const vendorValues = {