Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
  • Groups
    • Education Hub
    • Distinguished Ambassadors
    • Open Source Software and Platforms
    • Research Collaboration and Enablement
  • Forums
    • AI and ML forum
    • Architectures and Processors forum
    • Arm Development Platforms forum
    • Arm Development Studio forum
    • Arm Virtual Hardware forum
    • Automotive forum
    • Compilers and Libraries forum
    • Graphics, Gaming, and VR forum
    • High Performance Computing (HPC) forum
    • Infrastructure Solutions forum
    • Internet of Things (IoT) forum
    • Keil forum
    • Morello forum
    • Operating Systems forum
    • SoC Design and Simulation forum
    • SystemReady Forum
  • Blogs
    • AI and ML blog
    • Announcements
    • Architectures and Processors blog
    • Automotive blog
    • Graphics, Gaming, and VR blog
    • High Performance Computing (HPC) blog
    • Infrastructure Solutions blog
    • Internet of Things (IoT) blog
    • Operating Systems blog
    • SoC Design and Simulation blog
    • Tools, Software and IDEs blog
  • Support
    • Arm Support Services
    • Documentation
    • Downloads
    • Training
    • Arm Approved program
    • Arm Design Reviews
  • Community Help
  • More
  • Cancel
Arm Community blogs
Arm Community blogs
Internet of Things (IoT) blog A bare-metal programming guide
  • Blogs
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
More blogs in Arm Community blogs
  • AI and ML blog

  • Announcements

  • Architectures and Processors blog

  • Automotive blog

  • Embedded blog

  • Graphics, Gaming, and VR blog

  • High Performance Computing (HPC) blog

  • Infrastructure Solutions blog

  • Internet of Things (IoT) blog

  • Operating Systems blog

  • SoC Design and Simulation blog

  • Tools, Software and IDEs blog

Tags
  • Open Source Projects
  • Keil
  • GCC
  • Baremetal
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

A bare-metal programming guide

Sergey Lyubka
Sergey Lyubka
March 15, 2023
2 minute read time.

Embedded programming these days usually implies the use of development frameworks, which make development faster and easier. For example, Arm Keil comes with an integrated IDE, debugger, and a set of software packages that provide an RTOS, drivers, middleware like TCP/IP stack, and libraries like mbedTLS (SSL/TLS) or lvgl (graphics). Cube IDE from STMicroelectronics provides similar capabilities, and MCUXpresso from NXP, TI CCS, Microchip's MPLAB, and so on.

When developers start a project in one of those frameworks, they develop an application code on top of various software layers. Often, a developer may choose to bypass all these layers, and develop code that directly communicates with the hardware. That is often referred as bare-metal programming. The motivation of doing so can be one of the following:

  • To have a full control and understanding of every bit of the developed application, which often decreases the maintenance burden
  • To achieve the maximum performance and flexibility from the target hardware. while initially more time consuming that can pay off greatly as the
    project moves along
  • To avoid spending time to fix and debug an underlying software layer, especially if they are poorly tested, documented, and buggy

Developing on a bare-metal could be done without an IDE, just using any editor and an Arm GCC compiler. Also it can be done using an IDE, for example using Arm Keil. In any case, a developer needs to understand several key concepts:

  • How memory is organized
  • How peripherals work
  • The layout of the generated binary code
  • How linker script is used to generate a necessary layout
  • Vector table, interrupts, and weak symbols
  • CMSIS headers: Arm core and vendor peripheral

These are covered in the bare-metal programming guide written by Sergey Lyubka.

The guide starts at the very foundation, and assumes no prior embedded development experience. Only the knowledge of the C programming language is required. The guide is written as a step-by-step walk-through over all necessary topics - memory map organization, peripheral I/O, and so on. It begins with a classic LED blink, through a more advanced topic of timers, interrupts, and finally to an embedded web server that exposes an interactive device dashboard. The guide ends by covering crucial topics of automated software build and automated test on a target hardware.

Sergey Lyubka is an Engineering Director at Cesanta. Cesanta is an Arm partner, and develops the following products:
https://mongoose.ws: An open-source HTTP/MQTT/Websocket network library
https://vcon.io: A remote firmware update and serial monitor framework

Anonymous
Internet of Things (IoT) blog
  • Software, Tools, and Ecosystem for ML Edge Devices

    Reinhard Keil
    Reinhard Keil
    Learn how Arm and our Partners enable developers and the IoT software ecosystem to deliver smart, energy efficient ML edge devices.
    • July 17, 2024
  • Uniting Arm Enthusiasts: Recap of the hands-on Arm Developer Community Meetup at Texas A&M University

    Fidel Makatia
    Fidel Makatia
    Arm enthusiasts gathered in Texas A&M for a hands-on GPIO workshop using STM Nucleo-F410R3 boards from the Arm Developer Program, fostering knowledge sharing and community bonding.
    • June 13, 2024
  • Introducing Cortex-M52: Bringing Arm’s AI-optimized Helium architecture to the smallest IoT devices

    Tim Menasveta
    Tim Menasveta
    Today, Arm announces the Cortex-M52, delivering dramatic increases in DSP and ML performance.
    • November 22, 2023