Showing results for 
Search instead for 
Did you mean: 

ST-Link won't fully bootload successfully

Associate III

A few months ago I made a post regarding a PCB I designed (see post here: where I used the STM32F030F4P6 MCU. I planned on boot loading this MCU with the ST-LINK/V2 : ,

6 pin tag connect: and the adaptor for the ST-LINK/V2:

The boatload seems to run successfully by identifying the MCU and saying the file download is complete, but the LED seems to still be flashing orange as if it's trying to complete the upload. I can upload code to the board with the tag connect, although nothing happens after finishing the upload. For reference, I am first writing a simple blink-on blink-off LED program, and the LED doesn't blink (I checked the LED with a multimeter on the board and it does light up so it's not a hardware issue.

Here is the output from the console terminal:

                   STM32CubeProgrammer v2.12.0                  

Log output file:   C:\Users\ricci\AppData\Local\Temp\STM32CubeProgrammer_a19324.log
ST-LINK SN  : 38FF6A06304E4B3031321143
Board       : --
Voltage     : 3.25V
SWD freq    : 950 KHz
Connect mode: Under Reset
Reset mode  : Hardware reset
Device ID   : 0x444
Revision ID : Rev 1.0
Device name : STM32F03x
Flash size  : 16 KBytes
Device type : MCU
Device CPU  : Cortex-M0
BL Version  : 0x10

Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_a19324.srec
  File          : ST-LINK_GDB_server_a19324.srec
  Size          : 6.30 KB 
  Address       : 0x08000000 

Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 6]
Download in Progress:

File download complete
Time elapsed during download operation: 00:00:00.945

Verifying ...

Download verified successfully 


Here is the MCU IOC:



And my debugger settings: 

Screenshot 2024-05-10 104356.png

Screenshot 2024-05-10 104626.png

Screenshot 2024-05-10 104704.png

 Any help is greatly appreciated. 



Says it downloaded and verified the code is on the device..

Now you'll need to debug it and step through your code to understand what is and is not happening.

Perhaps instrument Error_Handler() and HardFault_Handler() so you'll know if they got there rather than die silently in a while(1) loop

What LED is orange? Your LED or the one on the ST-LINK? Is the ST-LINK just probing/observing connectivity after programming?

Did you set STM32 Cube Programmer to auto-run the code? Are you doing this from STM32 Cube Programmer or the IDE/Debugger? If in the debugger, STOP the code and see where it is stuck. Did it reach you LED blinking code?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

>>ST-Link won't fully bootload successfully

I'm not entirely clear WHAT this means.

The software says it's done.

Your code is on the device.

Disconnect and press reset, and the MCU should attempt to run your code. It may not be successful for a myriad of reasons.

>>STM32CubeProgrammer v2.12.0 

That's a bit antiquated, at v2.16 now. Use current tools where possible so old issues don't need to be re-litigated.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Sorry, what I meant was the STM32 Cube IDE claims that the bootloader is done, but the LED on the STLINK V2 still blinks green and red back and forth despite saying the program is finished.  Pressing the resume button after bootloader doesn't seem to do have the code run successfully, and the LED on the STLINK still flashes between red and green.  As for the code, right now I just want to blink an on board test LED, the code is as follows: 



#include "main.h"
#define led0 GPIO_PIN_7

int main(void)

  while (1)
  /* USER CODE END 3 */

void SystemClock_Config(void)
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  RCC_OscInitStruct.HSI14State = RCC_HSI14_ON;
  RCC_OscInitStruct.HSI14CalibrationValue = 16;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

  /** Initializes the CPU, AHB and APB buses clocks
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)

  * @brief ADC Initialization Function
  *  None
  * @retval None
static void MX_ADC_Init(void)

  /* USER CODE BEGIN ADC_Init 0 */

  /* USER CODE END ADC_Init 0 */

  ADC_ChannelConfTypeDef sConfig = {0};

  /* USER CODE BEGIN ADC_Init 1 */

  /* USER CODE END ADC_Init 1 */

  /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
  hadc.Instance = ADC1;
  hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
  hadc.Init.Resolution = ADC_RESOLUTION_12B;
  hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
  hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  hadc.Init.LowPowerAutoWait = DISABLE;
  hadc.Init.LowPowerAutoPowerOff = DISABLE;
  hadc.Init.ContinuousConvMode = DISABLE;
  hadc.Init.DiscontinuousConvMode = DISABLE;
  hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  hadc.Init.DMAContinuousRequests = DISABLE;
  hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  if (HAL_ADC_Init(&hadc) != HAL_OK)

  /** Configure for the selected ADC regular channel to be converted.
  sConfig.Channel = ADC_CHANNEL_6;
  sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
  if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
  /* USER CODE BEGIN ADC_Init 2 */

  /* USER CODE END ADC_Init 2 */


  * @brief GPIO Initialization Function
  *  None
  * @retval None
static void MX_GPIO_Init(void)
  GPIO_InitTypeDef GPIO_InitStruct = {0};

  /* GPIO Ports Clock Enable */

  /*Configure GPIO pin Output Level */

  /*Configure GPIO pin Output Level */

  /*Configure GPIO pins : PA2 PA3 PA4 PA7 */
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  /*Configure GPIO pin : PB1 */
  GPIO_InitStruct.Pin = GPIO_PIN_1;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);




  * @brief  This function is executed in case of error occurrence.
  * @retval None
void Error_Handler(void)
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  while (1)
  /* USER CODE END Error_Handler_Debug */

  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  *   file: pointer to the source file name
  *   line: assert_param error line source number
  * @retval None
void assert_failed(uint8_t *file, uint32_t line)
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
#endif /* USE_FULL_ASSERT */


The code can fully upload but the LED on my board doesn't blink. I have D27 tied to PA7, making GPIO pin 7 and port A with GPIO_PIN. Every time I upload the code it says the project requires code generation, and it successfully uploads but the LED doesn't blink nor do I see a signal on my scope. I checked the 6 programming pins and they all seem to be operating as expected, tried also holding down the reset switch while uploading although this seemed to stop the boatload or program from uploading successfully. 

You don't have a pull-up on the reset input, it's just floating.




If you find my answers useful, click the accept button so that way others can see the solution.

Do I need the pull up though? It recognized the STM MCU type and said that it uploaded successfully, reference schematics online didn't have it either. 

No Pull-up needed, but a 100 nF capacitor to ground to ensure reset timing.

So where do I go from here? I've tried tweaking my debug settings for the ST-Link but nothing seems to work. It successfully bootloads every time and identifies the correct MCU, but this is what I get in the debug window: 


I feel like its something trivial with the way I have the ide setup or possibly my clock configuration but I'm really not sure. 

Don't know if this helps, but I tried a different debug configuration, and this is the result I got: 


Open On-Chip Debugger 0.12.0-00029-gf77e7cb03 (2023-12-15-13:25) []
Licensed under GNU GPL v2
For bug reports, read
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J45S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.213158
Info : clock speed 1800 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x0bb11477
Info : [STM32F030F4Px.cpu] Cortex-M0 r0p0 processor detected
Info : [STM32F030F4Px.cpu] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for STM32F030F4Px.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x10006444
Info : flash size = 16 KiB
Warn : GDB connection 1 on target STM32F030F4Px.cpu not halted
undefined debug reason 8 - target needs reset
Info : accepting 'gdb' connection on tcp/3333
Warn : GDB connection 2 on target STM32F030F4Px.cpu not halted
undefined debug reason 8 - target needs reset
[STM32F030F4Px.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x0800060c msp: 0x20001000
[STM32F030F4Px.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x0800060c msp: 0x20001000
Info : [STM32F030F4Px.cpu] external reset detected
Info : [STM32F030F4Px.cpu] external reset detected
shutdown command invoked
shutdown command invoked

(Note: Shutdown command invoked was when I stopped the program)

I found the solution, 

the board uploads when I have the crystal set internal instead of the external setup I have but I'm not entirely sure why. I chose the ECS-80-12-30-JGN-TR with two 20pF caps at CL1 & CL2, and have Rext at 0 ohm acting as a jumper for now. 


I'm not entirely sure what's causing the bootloader to essentially get stuck at the end of the cycle when uploading it, but I'm assuming it has something to do with the way I set up the crystal.

Here is the layout on the board: 



And the ide setup: 



But at least now I can upload code to it and the ADC channel is working, albeit not accurately but it is reading values.