Skip to content

lucasdietrich/stm32l011k4-bare-metal

Repository files navigation

Bare metal development nucleo_l011k4

This project shows how to build, flash and debug a bare metal application on the nucleo_l011k4 board, main characteristics :

  • STM32L0
  • ARM Cortex-M0+ core
  • 16KB of Flash, 2KB of SRAM
  • Embedded ST-Link for programming and debugging

Two build methods are available:

  • Makefile
  • CMake

Get repositoy + prerequisites

Clone with : git clone https://github.com/lucasdietrich/stm32l011k4-bare-metal.git --recurse-submodules

Prerequisites:

  • cmake version 3.22.2
  • arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)
  • Open On-Chip Debugger 0.11.0
  • GNU gdb (GDB) Fedora 12.1-1.fc36

This project is fully integrated with Visual Studio Code, with extensions:

  • ms-vscode.cpptools
  • marus25.cortex-debug

Build, flash, debug

Build using cmake :

  • cmake -DCMAKE_TOOLCHAIN_FILE=./toolchain-arm-none-eabi.cmake -DCMAKE_BUILD_TYPE=Debug -S . -B build

Build using Makefile :

  • make --file=LegacyMakefile

Flash the application to the board :

  • make flash

Debug:

  • Select Target Debug VS code debug confication
  • Ctrl + F5 in VS Code

Clean :

  • make clean

Debug in QEMU using GDB

Run make qemu Select Qemu Debug VS code debug configuration and then press Ctrl + F5

Important note: as only the core is emulated in QEMU following parts should be disabled:

  • Startup code for SRAM initialization
  • Peripheral handling

Note

Topics:

  • startup code
  • mixing assembly and c code
  • newlibc
  • linker script
  • STM32L0Cube drivers:
    • syslock
    • rcc
    • gpio
    • mco
    • uart
  • Makefile / cmake
  • debug

Sources

About

Bare metal dev on stm32l011k4 (makefile, arm-none-eabi, openocd, vs code)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published