Ground Embedded KO Subscribe

Notes / MCU Firmware

Development environment: up to the first blinking LED

Set up STM32CubeIDE, the compiler and a debugger, then flash your first firmware. When the first LED lights up, the whole toolchain has been verified.

GROUND EMBEDDED · NOTEMCU Firmware 01Development environmentAvg 30%D1 period
Source codemain.cCompilerarm-none-eabi-gccExecutable.elf / .binDebuggerST-LinkMCU Flash
From source code to running inside the MCU. When the first LED lights, this whole chain is connected correctly.

What you need

Part Example
IDE STM32CubeIDE, VS Code + extensions
Compiler arm-none-eabi-gcc (bundled with the IDE)
Debugger ST-LINK (built into Nucleo boards), J-Link
Configuration tool STM32CubeMX (set pins and clocks, then generate code)
Board A development board such as the Nucleo-F411RE

Steps for the first project

  1. Create a new project by board name
  2. In the CubeMX view, set the LED pin (for example PA5) to GPIO_Output
  3. Generate code and add the toggle code inside while(1)
  4. Build → start a debug session → check that the LED blinks
while (1) {
    HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
    HAL_Delay(500);
}

When the LED does not light up

  • Check the board schematic: is the LED really on that pin?
  • Does the debugger connect? (The ST-LINK firmware often needs an update.)
  • Did you write your code outside a /* USER CODE BEGIN */ block, so it was erased when the code was regenerated?

Once this step works, the compiler, linker, startup code and debugger are all known to be good.

FREE PDFGet the 3 free ebooksIf you want to keep reading this topic as one book: BLDC motor control, serial communication and sensors at book length. PDFs are in Korean.Get them free →