Default FW generated by CubeMx for STM32H745I-DISCO board doesn't work after cycling power
I'm trying to generate a default FW image with CubeMx 5.3.0 for my STM32H745I-DISCO board with the only change being the addition of the code to blink an LED:
GPIO_InitTypeDef GPIO_InitStruct = {0};
__HAL_RCC_GPIOJ_CLK_ENABLE();
GPIO_InitStruct.Pin = LD1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(LD1_GPIO_Port, &GPIO_InitStruct);
while (1)
{
HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin);
HAL_Delay(500);
}
So I program the FW image with IAR (both CM4 and CM7 images), reset the board, and the LED starts blinking.
Resetting the board restarts the FW just fine.
Unplugging the USB cable from the STLK port and plugging it back in (this cable also provides power to the board) results in the FW not running anymore. IAR can't reprogram the MCU because it can't see the target anymore. Neither can the ST-LINK utility.
The Workaround
So I perform a "full chip erase" via ST-LINK (I have to hold the reset button down while plugging in the USB cable and pressing the full chip erase button, then release the reset button). I can program the chip with IAR, but the FW still doesn't run.
I erase the full chip again and program the GPIO_EXTI example from the CubeH7 package (version 1.4.0). The example works great (I can see LED's toggle when I press the user button. The example FW continues to work after multiple iterations of unplugging and plugging in the USB cable. OK, so my board is fine. I can now program the FW I generated with CubeMx and run it... until the USB cable is unplugged.
To get my FW running again, I have to repeat the steps above all over again.
The question is, what's so different between the default code that CubeMx generates and the code in the GPIO_EXTI example that I can't cycle USB power with the CubeMx-generated FW, but the example code runs ok after cycling USB power?
