I have an STM32F303RET MCU with Eclipse, Cross ARM GCC and HAL library environment. I am using an STM32F4Discovery board as SWD programmer. My problem is when I download the hex file to the MCU I got the following message:

Connected via SWD.
Target voltage = 2.9 V.
Connection mode : Normal.
Device ID:0x446
Device flash Size : 512 Kbytes
Device family :STM32F302xE/F303xE/F398xx

Loading file...
Flash Programming:
File : Line_Sensors2.hex
Address : 0x08000000
Memory programming...
0% ................................. 100%
Memory programmed in 1s and 358ms.
Programming Complete.

MCU Reset.

The core is halted!

My current configuration in STM32CUBEMX with an external 8MHz crystal is:

enter image description here

Soure files, generated by STM32CubeMX:


/* Includes ------------------------------------------------------------------*/
#include "stm32f3xx_hal.h"
#include "mxconstants.h"

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);

int main(void)
  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

  /* Configure the system clock */

  /* Initialize all configured peripherals */

  while (1)
      HAL_GPIO_WritePin(GPIOB, D42_LED_Pin, GPIO_PIN_SET);
      HAL_GPIO_WritePin(GPIOB, D43_LED_Pin, GPIO_PIN_SET);

/** System Clock Configuration
void SystemClock_Config(void)
    RCC_OscInitTypeDef RCC_OscInitStruct;
    RCC_ClkInitTypeDef RCC_ClkInitStruct;

    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
    RCC_OscInitStruct.HSEState = RCC_HSE_ON;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
    RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
    RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL2;

    RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
    RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
    HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);



    /* SysTick_IRQn interrupt configuration */
    HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

/** Configure pins as 
        * Analog 
        * Input 
        * Output
        * EVENT_OUT
        * EXTI
void MX_GPIO_Init(void)
  GPIO_InitTypeDef GPIO_InitStruct;

  /* GPIO Ports Clock Enable */

  /*Configure GPIO pins : D42_LED_Pin D43_LED_Pin */
  GPIO_InitStruct.Pin = D42_LED_Pin|D43_LED_Pin;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);   


/* Includes ------------------------------------------------------------------*/
#include "stm32f3xx.h"
#include "stm32f3xx_hal.h"
#include "stm32f3xx_hal_cortex.h"
  * Initializes the Global MSP.
void HAL_MspInit(void)


  /* System interrupt init*/
  /* SysTick_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);


/* Includes ------------------------------------------------------------------*/
#include "stm32f3xx_hal.h"
#include "stm32f3xx.h"
#include "stm32f3xx_it.h"

* @brief This function handles System tick timer.
void SysTick_Handler(void)

I have tried with the internal oscillator (calibrated to 8MHz) as PLL source, and without PLL. Also tried with different PLLMUL and PLLDIV values. The results are all the same, core is halted after programming.

I do not have any breakpoints, I do not even use debug session, I just simply download the hex file to the controller. The voltage on the reset pin is 2.96V.

I am flashing the device with ST-LINK_CLI, arguments are the following:

-c SWD -p  ${project_name}.hex  -Rst -Run

The -Run always fails as the core is halted.

I am out of ideas, I do not know what can be the problem here. Something is missing from the HAL project, but I do not know what since CubeMX should generate all necessary initialization.


I was able to successfully program the MCU using SPL library so the problem must be HAL library specific. The programmer/debugger should be OK.

  • \$\begingroup\$ Missing compiler or linker parameters could also be a problem, please post them. \$\endgroup\$
    – Turbo J
    Commented Nov 14, 2015 at 20:51
  • \$\begingroup\$ I add them right away. \$\endgroup\$ Commented Nov 14, 2015 at 20:58
  • \$\begingroup\$ @Turbo J, I have added some more details, let me know if there is something else. \$\endgroup\$ Commented Nov 14, 2015 at 21:18
  • \$\begingroup\$ You need to figure out if this is a program problem or a debugger one. Best ways to do that are either flashing a known-good example, or else writing a very simple program to toggle an I/O or generate serial output, flashing it, and then power cycling the board without the debugger connected. \$\endgroup\$ Commented Nov 14, 2015 at 21:36
  • \$\begingroup\$ The current code is consits of a clock configuration part and I am setting two IO to HIGH state, to lit up LEDs. I have tried to reset the MCU after disconnecting the programmer, no success. Debugger is unavailable as I did not find any usable config file with OpenOCD. @Chris , do you know any known-good example? \$\endgroup\$ Commented Nov 14, 2015 at 21:46

2 Answers 2


Have you seen this settings page? This is why my debugger halts before debugging:

enter image description here

  • \$\begingroup\$ I don't, and going to check right away. But unfortunately the core is halted when I do not used debug just downloaded the hex file with external tool (St-Link Utility). But it is a useful answer, thanks for it. \$\endgroup\$ Commented Nov 15, 2015 at 17:07

I have managed to solve the problem. The problem itself was the whole Eclipse project. I have tried to put together a project for the F3 using HAL based on the F4 HAL Eclipse project template. I must say that some details (necessary files or configurations) lost, and all in all the code could not run on the MCU.

To highlight one:

The file vectors_stm32f4xx.c (project/system/src/cmsis directory) should contain the startup code when MCU resets, and it is provided by the F4 Eclipse template. In my case I had to use an assembler file provided by ST, STM32CubeMX.

The file is startup_stm32f303xe.s. Now, since Eclipse is not able to manage files ending with .s, I should have changed the file extension to .S (capital 's'). I did not change the file extension so the MCU probably could not start up after reset. Maybe this was the biggest problem.

The complete soultion:

I have found a detailed description about how to use Eclipse + STM32Cube + any STM32 controller. Unfortunately it is too long to include all of it on here, so I just provide a link and hope it will stay available. It worked fine for me.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.