{"id":13418125,"url":"https://github.com/memfault/zero-to-main","last_synced_at":"2026-01-12T09:30:09.297Z","repository":{"id":55525168,"uuid":"74603189","full_name":"memfault/zero-to-main","owner":"memfault","description":"Bootstrap C code on a Cortex-M MCU","archived":false,"fork":false,"pushed_at":"2019-11-13T05:24:45.000Z","size":16951,"stargazers_count":201,"open_issues_count":0,"forks_count":28,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-07-31T22:41:12.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/memfault.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-23T18:23:05.000Z","updated_at":"2024-07-22T08:03:20.000Z","dependencies_parsed_at":"2022-08-15T02:30:26.719Z","dependency_job_id":null,"html_url":"https://github.com/memfault/zero-to-main","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memfault%2Fzero-to-main","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memfault%2Fzero-to-main/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memfault%2Fzero-to-main/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memfault%2Fzero-to-main/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/memfault","download_url":"https://codeload.github.com/memfault/zero-to-main/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221532202,"owners_count":16838916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:00:58.725Z","updated_at":"2026-01-12T09:30:09.289Z","avatar_url":"https://github.com/memfault.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# Bootstrapping C (and rust) applications on Cortex-M MCUs\n\nQuick explorations of different ways to bootstrap a GNU C (or rust) application on a cortex-M\nbased MCU.\n\nWhile the concepts apply broadly, these examples run on an Arduino M0 Pro (they\nshould work fine on an Arduino Zero as well).\n\nI chose the M0 Pro because:\n  1. It was available at my local electronics shop\n  2. It comes with an integrated SWD debugger (Atmel EDBG)\n  3. It sports a cortex-M mcu (cortex-M0+)\n  4. It is reasonably cheap ($40)\n\nAn STM32-based Nucleo or an mbed board would do just as well.\n\nIn my experience, many of the techniques highlighted here are often glossed\nover, poorly documented, and rarely understood. Most people rely on startup\nfiles and linker scripts bundled with their vendor's BSP that they tweak\nhaphazardly as their needs evolve.\n\nThe following scenarios are currently covered:\n  * `default`: simple LED blink using the default startup file \u0026 linker script\n    from the BSP\n  * `minimal`: a bare minimum LED blink app with a pared down script, startup,\n    and no libc\n  * `with-libc`: builds on `minimal` to add newlib support, including printf\n  * `reloc`: builds on `with-libc` to add functions relocated to RAM as well as\n    ROM\n  * `bootload`: splits the code into two applications, a bootloader and an\n    application. The bootloader simply starts the applications\n  * `bootload-reloc`: builds on `bootload` but runs the applications entirely in\n    RAM. The bootloader thus needs to copy it over first.\n  * `rust`: barebones rust app\n\nMore to come, and blog posts will follow.\n\n### Dependencies\n  * A unix-like environment\n  * A version of openOCD that works with your board (in my case I used the\n  [Arduino fork](https://github.com/arduino/OpenOCD)).\n  * GNU Make\n  * [GNU ARM embedded toolchain](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm)\n\n### Building\n\n`make` builds all apps, the resulting elfs and bins are in their respective folders under\n`build`\n\n`make \u003capp-name\u003e` builds a specific app. E.g. `make bootload-reloc`\n\n### Flashing\n\n`make flash-\u003capp-name\u003e` flashes a specific app (it needs to have been built\nfirst)\n\n### Credits\n\n* https://github.com/cbiffle/minimal-embedded-rust/ - A minimal embedded rust\n  app on cortex-M MCU by @cbiffle\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmemfault%2Fzero-to-main","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmemfault%2Fzero-to-main","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmemfault%2Fzero-to-main/lists"}