Skip to main content
Graduate II
May 10, 2024
Question

ST-Link won't fully bootload successfully

  • May 10, 2024
  • 2 replies
  • 2379 views

A few months ago I made a post regarding a PCB I designed (see post here: https://www.reddit.com/r/PrintedCircuitBoard/comments/1b3wilu/pcb_design_review_request_mq2_gas_sensor/) where I used the STM32F030F4P6 MCU. I planned on boot loading this MCU with the ST-LINK/V2 : https://www.digikey.com/en/products/detail/stmicroelectronics/ST-LINK-V2/2214535 ,

6 pin tag connect: https://www.tag-connect.com/product/tc2030-idc-nl and the adaptor for the ST-LINK/V2: https://www.tag-connect.com/product/tc2030-idc-nl

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
ST-LINK FW : V2J40S7
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:

 
 

DRicc2_2-1715354413778.png

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. 

 

    This topic has been closed for replies.

    2 replies

    Graduate II
    May 10, 2024

    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?

    Graduate II
    May 10, 2024

    >>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.

    DRicc.2Author
    Graduate II
    May 10, 2024

    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)
    {
     HAL_Init();
    
     MX_GPIO_Init();
     MX_ADC_Init();
     
     while (1)
     {
    	 HAL_GPIO_WritePin(GPIOA,led0,GPIO_PIN_SET);
    	 HAL_Delay(250);
    	 HAL_GPIO_WritePin(GPIOA,led0,GPIO_PIN_RESET);
    	 HAL_Delay(250);
     }
     /* 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.OscillatorType = RCC_OSCILLATORTYPE_HSI14|RCC_OSCILLATORTYPE_HSE;
     RCC_OscInitStruct.HSEState = RCC_HSE_ON;
     RCC_OscInitStruct.HSI14State = RCC_HSI14_ON;
     RCC_OscInitStruct.HSI14CalibrationValue = 16;
     RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
     RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
     RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
     RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
     if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
     {
     Error_Handler();
     }
    
     /** Initializes the CPU, AHB and APB buses clocks
     */
     RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
     |RCC_CLOCKTYPE_PCLK1;
     RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
     RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
     RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
    
     if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
     {
     Error_Handler();
     }
    }
    
    /**
     * @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)
     {
     Error_Handler();
     }
    
     /** Configure for the selected ADC regular channel to be converted.
     */
     sConfig.Channel = ADC_CHANNEL_6;
     sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
     sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
     if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
     {
     Error_Handler();
     }
     /* 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 */
     __HAL_RCC_GPIOF_CLK_ENABLE();
     __HAL_RCC_GPIOA_CLK_ENABLE();
     __HAL_RCC_GPIOB_CLK_ENABLE();
    
     /*Configure GPIO pin Output Level */
     HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_7, GPIO_PIN_RESET);
    
     /*Configure GPIO pin Output Level */
     HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET);
    
     /*Configure GPIO pins : PA2 PA3 PA4 PA7 */
     GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_7;
     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
     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.Mode = GPIO_MODE_OUTPUT_PP;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
    
    }
    
    /* USER CODE BEGIN 4 */
    
    /* USER CODE END 4 */
    
    /**
     * @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 */
     __disable_irq();
     while (1)
     {
     }
     /* USER CODE END Error_Handler_Debug */
    }
    
    #ifdef USE_FULL_ASSERT
    /**
     * @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 CODE BEGIN 6 */
     /* 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. 

    Graduate II
    May 10, 2024

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

     

    KarlYamashita_0-1715383215650.png