cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo-L432KC program not starting

DD.14
Associate II

Hello, I'm new on this forum.

Last time I bought Nucleo-L432KC board. I have very strange issue with flashing binary. I created simple project in STM32CubeMX for blinking LED every 1 second. I use this command to flash:

st-flash --reset write blink.bin 0x8000000

Sometines after flashing program is not starting, even after resetting board. For example when flash 1st time it's working, then when flash again it's not starting. Then after 5th attempt to flash program starts blinking. There are no issues during flashing, no error messages:

st-flash --reset write blink.bin 0x8000000
st-flash 1.7.0
2022-10-13T23:56:27 INFO common.c: L43x/L44x: 48 KiB SRAM, 256 KiB flash in at least 2 KiB pages.
2022-10-13T23:56:27 INFO common.c: Attempting to write 5540 (0x15a4) bytes to stm32 address: 134217728 (0x8000000)
EraseFlash - Page:0x0 Size:0x800 2022-10-13T23:56:27 INFO common.c: Flash page at addr: 0x08000000 erased
EraseFlash - Page:0x1 Size:0x800 2022-10-13T23:56:27 INFO common.c: Flash page at addr: 0x08000800 erased
EraseFlash - Page:0x2 Size:0x800 2022-10-13T23:56:27 INFO common.c: Flash page at addr: 0x08001000 erased
2022-10-13T23:56:27 INFO common.c: Finished erasing 3 pages of 2048 (0x800) bytes
2022-10-13T23:56:27 INFO common.c: Starting Flash write for F2/F4/F7/L4
2022-10-13T23:56:27 INFO flash_loader.c: Successfully loaded flash loader in sram
2022-10-13T23:56:27 INFO flash_loader.c: Clear DFSR
2022-10-13T23:56:28 INFO common.c: Starting verification of write complete
2022-10-13T23:56:28 INFO common.c: Flash written and verified! jolly good!

I updated ST-LINK firmware to latest version.

Important information is that when program is not running after flashing I tried to reset it by connecting RST pin to GND without success. Only when I disconnect power and connect again program starts and LED is blinking.

When I use the same minimal blinking example, but generated for Nucleo-F446RE, I can flash it every time and it works every time.

Is it possible that my Nucleo-L432KC board is broken somehow or is it issue with st-flash? What can I do to check/further investigate issue?

6 REPLIES 6
EEbyKarl
Associate III

Have you tried the STM32Cube Programmer as well?

Paste the code for the clock configuration that Cube MX generated.

The L4's need to be power cycled if the memory was blank. It relates to how they safe boot into the System Loader for initial programming.

Gets to be less of an issue once just reprogramming.

Other tools cause an execution transfer to the FLASH's vector table and can start running that way.

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

Yes, the same thing happened. I read flash from STM and compared checksum with my produced binary. Were the same.

Here is the code:

void SystemClock_Config(void)
 
{
 
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
 
  /** Configure the main internal regulator output voltage
 
  */
 
  if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2) != HAL_OK)
  {
    Error_Handler();
  }
 
 
 
  /** Initializes the RCC Oscillators according to the specified parameters
 
  * in the RCC_OscInitTypeDef structure.
 
  */
 
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
 
  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_CLOCKTYPE_PCLK2;
 
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
 
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
 
}

Shirley.Ye
ST Employee

Did you erase the flash before programming?

yes, tried it by 'st-flash erase' and by stm32cubeprogrammer

I have the Nucleo-L432KC. I just started a new project using the default board configuration and what I have for the SystemClock_Config is not the same as what you've posted. When you started the new project, did you use the MCU selector or the Board selector?