Code Monkey home page Code Monkey logo

zero-to-main's Introduction

Bootstrapping C (and rust) applications on Cortex-M MCUs

Quick explorations of different ways to bootstrap a GNU C (or rust) application on a cortex-M based MCU.

While the concepts apply broadly, these examples run on an Arduino M0 Pro (they should work fine on an Arduino Zero as well).

I chose the M0 Pro because:

  1. It was available at my local electronics shop
  2. It comes with an integrated SWD debugger (Atmel EDBG)
  3. It sports a cortex-M mcu (cortex-M0+)
  4. It is reasonably cheap ($40)

An STM32-based Nucleo or an mbed board would do just as well.

In my experience, many of the techniques highlighted here are often glossed over, poorly documented, and rarely understood. Most people rely on startup files and linker scripts bundled with their vendor's BSP that they tweak haphazardly as their needs evolve.

The following scenarios are currently covered:

  • default: simple LED blink using the default startup file & linker script from the BSP
  • minimal: a bare minimum LED blink app with a pared down script, startup, and no libc
  • with-libc: builds on minimal to add newlib support, including printf
  • reloc: builds on with-libc to add functions relocated to RAM as well as ROM
  • bootload: splits the code into two applications, a bootloader and an application. The bootloader simply starts the applications
  • bootload-reloc: builds on bootload but runs the applications entirely in RAM. The bootloader thus needs to copy it over first.
  • rust: barebones rust app

More to come, and blog posts will follow.

Dependencies

Building

make builds all apps, the resulting elfs and bins are in their respective folders under build

make <app-name> builds a specific app. E.g. make bootload-reloc

Flashing

make flash-<app-name> flashes a specific app (it needs to have been built first)

Credits

zero-to-main's People

Contributors

franc0is avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.