Skip to content

Instantly share code, notes, and snippets.

@andelf
Created January 12, 2021 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andelf/9b151b83ff4921bb5a3bd01507763142 to your computer and use it in GitHub Desktop.
Save andelf/9b151b83ff4921bb5a3bd01507763142 to your computer and use it in GitHub Desktop.
STM32_HID_Bootloader path for a STM32F407VGT board
diff --git a/bootloader/F4/Inc/main.h b/bootloader/F4/Inc/main.h
index a095644..e57185f 100644
--- a/bootloader/F4/Inc/main.h
+++ b/bootloader/F4/Inc/main.h
@@ -95,11 +95,11 @@
-#define BOOT_1_PIN GPIO_PIN_15 //DIYMROE STM32F407VGT board (Button PD15, LED PE0)
-#define BOOT_1_PORT GPIOD
+#define BOOT_1_PIN GPIO_PIN_4 //DIYMROE STM32F407VGT board (Button PD15, LED PE0)
+#define BOOT_1_PORT GPIOE
#define BOOT_1_ENABLED GPIO_PIN_RESET
-#define LED_1_PIN GPIO_PIN_0
-#define LED_1_PORT GPIOE
+#define LED_1_PIN GPIO_PIN_10
+#define LED_1_PORT GPIOF
// #define BOOT_1_PIN GPIO_PIN_2 //Black VET6 (http://wiki.stm32duino.com/index.php?title=STM32F407)
// #define BOOT_1_PORT GPIOB
diff --git a/bootloader/F4/Src/main.c b/bootloader/F4/Src/main.c
index abda443..854a18d 100644
--- a/bootloader/F4/Src/main.c
+++ b/bootloader/F4/Src/main.c
@@ -137,7 +137,7 @@ int main(void)
/* In case of incoming magic number or <BOOT_1_PIN> is LOW,
jump to HID bootloader */
- if ((magic_val != 0x424C)&&(HAL_GPIO_ReadPin(BOOT_1_PORT, BOOT_1_PIN) != BOOT_1_ENABLED)) {
+ if ((HAL_GPIO_ReadPin(BOOT_1_PORT, BOOT_1_PIN) != BOOT_1_ENABLED)) {
typedef void (*pFunction)(void);
pFunction Jump_To_Application;
uint32_t JumpAddress;
@@ -295,6 +295,7 @@ static void MX_GPIO_Init(void)
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
+ __HAL_RCC_GPIOF_CLK_ENABLE();
/* Configure GPIO pin Output Level */
@@ -309,14 +310,14 @@ static void MX_GPIO_Init(void)
-
-
/* Configure GPIO pin : PB2 */
GPIO_InitStruct.Pin = BOOT_1_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(BOOT_1_PORT, &GPIO_InitStruct);
+
+
/* Configure GPIO pin : PE0 */
GPIO_InitStruct.Pin = LED_1_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment