Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
  • Groups
    • Research Collaboration and Enablement
    • DesignStart
    • Education Hub
    • Innovation
    • Open Source Software and Platforms
  • 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
    • 中文社区论区
  • 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
    • Innovation blog
    • Internet of Things (IoT) blog
    • Operating Systems blog
    • Research Articles
    • 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
  • A bare-metal programming guide

    Sergey Lyubka
    Sergey Lyubka
    Get started with the Arm bare metal programming with only GCC compiler, text editor, and a datasheet. From blinky to an embedded Web device dashboard.
    • March 15, 2023
  • Arm takes Embedded Software Development to the next level with introduction of Keil MDK Version 6

    Reinhard Keil
    Reinhard Keil
    Keil MDK Version 6 delivers new features that are optimized for the entire Cortex-M and Ethos-U processor portfolio.
    • March 9, 2023
  • Cortex-M85: Enabling safety and boosting flexibility and performance even higher

    Dimos Rossidis
    Dimos Rossidis
    This blog outlines new updates to the Arm Cortex-M85 CPU to improve safety, flexibility and performance for IoT and automotive markets.
    • March 8, 2023