bootloader user request on PA2/hinge TX

This commit is contained in:
mitxela
2025-08-03 12:21:24 +01:00
parent b7e80f0d8d
commit 70c04301dc
2 changed files with 18 additions and 0 deletions

View File

@@ -66,6 +66,7 @@ extern "C" {
#define bSegDecode7 0b0000011100 #define bSegDecode7 0b0000011100
#define bSegDecode8 0b0111111100 #define bSegDecode8 0b0111111100
#define bSegDecode9 0b0110111100 #define bSegDecode9 0b0110111100
#define bSegDecodeU 0b0011111000
#define bCat0 0b1111000000000000 #define bCat0 0b1111000000000000
#define bCat1 0b1110001000000000 #define bCat1 0b1110001000000000
@@ -94,6 +95,9 @@ extern "C" {
#define ERR_UNKNOWN bSegDecode9 #define ERR_UNKNOWN bSegDecode9
// User request bootloader hang for backup USB stack
#define ERR_USER bSegDecodeU
/* USER CODE END EC */ /* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/

View File

@@ -402,6 +402,11 @@ int main(void)
// debug force reload // debug force reload
// new_fw_crc=0; // new_fw_crc=0;
// Hinge TX connection shorted to ground - force bootloader to hang
if ((GPIOA->IDR & (1<<2))==0) {
hang_error(ERR_USER);
}
if (loaded_fw_crc == byteswap32(*(uint32_t*)(FLASH_BASE + BOOT_SIZE + APP_SIZE -4)) ) { // loaded firmware valid if (loaded_fw_crc == byteswap32(*(uint32_t*)(FLASH_BASE + BOOT_SIZE + APP_SIZE -4)) ) { // loaded firmware valid
@@ -717,6 +722,15 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/**USART2 GPIO Configuration
PA2 ------> USART2_TX
PA3 ------> USART2_RX
*/
GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2 HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2
|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6 |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6