How to bootstrap support for a no_std target

Overview

The Embedonomicon

How to bootstrap support for a no_std target

This book is hosted at https://docs.rust-embedded.org/embedonomicon/

This project is developed and maintained by the Resources team.

License

The Embedonomicon (this project) is distributed under the following licenses:

  • The code samples and free-standing Cargo projects contained within this book are licensed under the terms of both the MIT License and the Apache License v2.0.
  • The written prose contained within this book is licensed under the terms of the Creative Commons CC-BY-SA v4.0 license.

Copies of the licenses used by this project may also be found here:

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

Code of Conduct

Contribution to this crate is organized under the terms of the Rust Code of Conduct, the maintainer of this crate, the Resources team, promises to intervene to uphold that code of conduct.

Comments
  • Switch to using GitHub Actions for CI

    Switch to using GitHub Actions for CI

    I have tried to keep it functionally identical to the travis workflow. This is a bit tricky for me to test.

    There are some minor changes though.

    • Added MSRV of 1.51.0 - I just picked a version out of thin air here.
    • I could not see an easy way of preventing master branch runs for PRs that have passed so this should run on all.
    • For deploying to github pages I'm using a 3rd party action. It looks reasonable and just uses the default repo scoped token.
    S-waiting-on-review T-resources 
    opened by robyoung 12
  • update macos homebrew install command

    update macos homebrew install command

    Hi,

    The brew cask command is updated. Will encounter this error when installing the tools.

    $ brew cask install gcc-arm-embedded
    Error: `brew cask` is no longer a `brew` command. Use `brew <command> --cask` instead.
    

    So this PR mainly just update that specific command for macos.

    S-waiting-on-review T-resources 
    opened by kiddkai 6
  • Fix CI: regenerate known-good outputs with latest Rust nightly

    Fix CI: regenerate known-good outputs with latest Rust nightly

    This was a little boring! There aren't any serious changes except to the exceptions app which has changed around a bit; I haven't thoroughly checked the new assembly but don't have any reason to think it's wrong, just the result of much newer LLVM/Rust.

    S-waiting-on-review T-resources 
    opened by adamgreig 6
  • Endless copy loop: Incorrect implementation or wrongly compiled?

    Endless copy loop: Incorrect implementation or wrongly compiled?

    First of all: I'm sorry if this is the wrong place to ask, but at least it's related to the book :)

    While reading the Embedonomicon I wrote some bare metal stuff without using any crate. Just for learning how everything works together. I didn't find out why this source code:

        // Copy DATA
        let mut sdata = &mut _sdata as *mut u32;
        let edata = &mut _edata as *mut u32;
        let mut sidata = &_sidata as *const u32;
        while sdata < edata {
            ptr::write(sdata, ptr::read(sidata));
            sdata = sdata.offset(1);
            sidata = sidata.offset(1);
        }
    

    was compiled to this assembly (copied from gdb):

    │   0x8000026 <rustymc::run+18>     ldmia   r1!, {r2}                                                │
    │   0x8000028 <rustymc::run+20>     stmia   r0!, {r2}                                                │
    │  >0x800002a <rustymc::run+22>     b.n     0x8000026 <rustymc::run+18>                              │
    

    An endless loop which will write to invalid memory sooner or later.

    I boiled it down to a minimal program which is attached. I used rustc 1.47.0 and cargo run --release.

    What's wrong with my code?

    v3mini.tar.gz

    opened by skoe 6
  • Added missing link to edition 2018 guide

    Added missing link to edition 2018 guide

    It looked like the link to the edition guide was missing. But it might have been intentional because the edition guide might be moved to doc.rust-lang.org later on (https://github.com/rust-lang-nursery/edition-guide/issues/76) :-)

    opened by caemor 5
  • Relocate to https://embedonomicon.rust-embedded.org

    Relocate to https://embedonomicon.rust-embedded.org

    As mentioned in rust-lang-nursery/embedded-wg#145

    Added a CNAME file, this requires related A records to take effect.

    See https://help.github.com/articles/setting-up-an-apex-domain/ for domain setup, needs at least 2x DNS A records for embedonomicon on rust-embedded.org pointing to 185.199.108.153 and 185.199.109.153 to become active (4x A records as in the instructions if you feel like it).

    opened by ryankurte 5
  • Can you replicate the examples on Windows?

    Can you replicate the examples on Windows?

    Let us know if you had to significantly deviate from the instructions! (Other than using different built-in commands if you were using cmd instead of bash).

    help wanted Blocks Rust 2018 
    opened by japaric 5
  • Add notes about creating a custom target

    Add notes about creating a custom target

    As we were discussing rust-lang/rust#58500, I realized that there is nowhere other than community blogs that actually discusses how to create a new target. This adds new documentation about creating custom targets and common pitfalls that you may encounter.

    S-waiting-on-review T-resources 
    opened by lights0123 4
  • dma: Mention store-buffer reordering on Cortex-M7

    dma: Mention store-buffer reordering on Cortex-M7

    The section on memory barrier requirements for DMA previously suggested that memory barriers are only required when using the data cache. This is not the complete story, as reordering can still occur in the write buffer.

    The details will depend on how the involved memory is marked (Normal/Device/…), but a common case where barriers will be needed on e.g. a STM32H7x3-series chip is when interfacing with the Ethernet DMA engine. Even if the dcache is disabled, a barrier will be needed before updating the DMA tail pointer to ensure the driver's writes to the newly-queued packet buffer and buffer descriptor will be seen by the hardware.

    I'm not sure whether a more thorough explanation would be in scope here, since it depends on platform details, but with this change, readers are at least made aware of the issue. (We recently stumbled over this in an open-source hardware/software project, see https://github.com/quartiq/stabilizer/issues/33.)

    S-waiting-on-review T-resources 
    opened by dnadlinger 4
  • Ignore whitespace within lines when validating objdump outputs in CI

    Ignore whitespace within lines when validating objdump outputs in CI

    Closes #55

    Based at #54

    If the output of cargo objdump changes only with regard to whitespace, it's probably OK to still pass CI. Most readers probably won't even notice whitespace differences in the first place.

    The diff documentation says of whitespace-suppressing options:

    The --ignore-space-change (-b) option is stronger than -E and -Z combined. It ignores white space at line end, and considers all other sequences of one or more white space characters within a line to be equivalent.

    This ignores only changes within a line -- changes which span multiple lines (i.e. the addition or removal of whitespace-only lines) will still compare as different. This is a good thing, because there are places the book includes a subset of a file based on line numbers.

    S-waiting-on-review T-resources 
    opened by austinglaser 4
  • Fix CI builds

    Fix CI builds

    Fixes #50, #52, #53

    ~This is a work-in-progress. I'm not sure when I'm going to have time to revisit it -- hopefully within the next week or two. If anyone else feels compelled to take it over, please feel free.~

    S-waiting-on-review T-resources 
    opened by austinglaser 4
  • Nightly/newer versions of llvm-binutils no longer recognize `--arch-name`

    Nightly/newer versions of llvm-binutils no longer recognize `--arch-name`

    In following the embedonomicon I discovered that cargo objdump --bin app -- -d -no-show-raw-insn no longer works, for two reasons

    1. llvm-objdump no longer accepts --arch-name
    2. -no-show-raw-insn must have two -s instead of one on stable.

    This is on https://docs.rust-embedded.org/embedonomicon/memory-layout.html#inspecting-it

    opened by StripedMonkey 0
  • Imlementation of Entirely new Embedded Architecture for Rust

    Imlementation of Entirely new Embedded Architecture for Rust

    I was wondering how one would go about creating a target for unsupported embedded architectures (as of now) for the Rust Embedded Ecosystem ?. Eg the 8051 families of Microcontrollers

    opened by ajprabhu09 1
  • Add triagebot configuration

    Add triagebot configuration

    This enables assignment through triagebot on this repository, in preparation for the migration from highfive to triagebot for PR assignment.

    cc rust-lang/highfive#258 rust-lang/triagebot#433

    S-waiting-on-review T-resources 
    opened by LeSeulArtichaut 5
  • The proposed DMA API is unsafe

    The proposed DMA API is unsafe

    It appears that the DMA API described in Chapter 8 - DMA is unsafe.

    Consider this example. It is basically the motivating example from the "Immovable buffers" section, but with the complete read_exact API from the end of the chapter, including Pining and the 'static bound. The example shows that it is still possible to pass a stack-allocated array into this (supposedly safe) read_exact function, which means the DMA operation will corrupt the stack. All you need to do is wrap the array in a newtype and impl DerefMut for it.

    I believe the root of the issue is a misunderstanding of the Pin API. Contrary to intuition, Pin does in most cases not pin the pointed-to data in memory: If the target type implements Unpin, Pin does nothing at all:

    Many types are always freely movable, even when pinned, because they do not rely on having a stable address. This includes all the basic types (like bool, i32, and references) as well as types consisting solely of these types. Types that do not care about pinning implement the Unpin auto-trait, which cancels the effect of Pin<P>.

    Basically all types we care about implement Unpin (I believe only self-referential types are supposed not to?). Which means Pining the buffer passed into the DMA doesn't help us make the code safe.

    The DMA chapter also mentions the StableDeref trait as an alternative. As far as I see, using this would actually lead to a safe API, so we should change the chapter accordingly.

    opened by teskje 1
  • Add Software Guide Posts for Board Crate Writers

    Add Software Guide Posts for Board Crate Writers

    My apologies if this is not the correct place to put this issue. I couldn't find a better one.

    I am looking into creating a new board crate, but am also a relative newbie to the ARM architecture. As a result, I am having to learn a lot about how the ARM ecosystem itself works.

    For example, the chip I'm looking at comes with an SDK, which is good enough if you are looking at their chip and writing one project in C. But in Rust, we want to look further than just one project on one chip, in addition to being a different language.

    As a result, I had to figure out that the SDK was really a version of CMSIS-RTOS with patches on top -- and that CMSIS was something ARM built for OEMs to make their SDKs, CMSIS-RTOS being a now-unsupported variant thereof. That gave me an approach to figuring out what was new, and what was already taken care of by the cortex-rt crate.

    There is an explanation of ARM's hardware designations and features, and how they map to Rust targets. I feel it would help others to have a similar section for software artifacts: a high-level overview of C code that ARM gave to OEMs to write their SDKs, what is handled already by equivalent libraries in the Rust ecosystem, and what kinds of things board crate writers should look for as they do a port to Rust from that source code.

    opened by jhwgh1968 0
Owner
Rust Embedded
Enabling usage of Rust on Embedded Platforms (Embedded Linux / RTOS / Bare Metal)
Rust Embedded
Cargo subcommand to easily bootstrap nocode applications. Write nothing; deploy nowhere.

cargo-nocode No code is the best way to write secure and reliable applications. Write nothing; deploy nowhere. cargo-nocode aims to bring the nocode a

Orhun Parmaksız 29 Jul 1, 2023
Rust no_std, embedded_hal board support package for the Electro-Smith Daisy platform.

Daisy Rust no_std, embedded_hal board support package for the Electro-Smith Daisy platform. This project was forked from antoinevg/daisy_bsp. Supporte

zlosynth 5 Dec 4, 2022
A nushell plugin for scanning ports on a target.

nu_plugin_port_scan A nushell plugin for scanning ports on a target Similar to nc -vz {ip} {port} -w {timeout} the parameters are mapped to port scan

Motalleb Fallahnezhad 4 Nov 9, 2023
Dyadic rationals for `no_std` targets

dyadic ?? Dyadic rationals for no_std targets.

Vitaly Domnikov 2 Dec 16, 2021
An unofficial and incomplete no_std Rust library for implementing the ElectricUI Binary Protocol

An unofficial and incomplete no_std Rust library for implementing the ElectricUI Binary Protocol

Jon 2 Mar 29, 2022
Garden monitoring system using m328p Arduino Uno boards. 100% Rust [no_std] using the avr hardware abstraction layer (avr-hal)

uno-revive-rs References Arduino Garden Controller Roadmap uno-revive-rs: roadmap Components & Controllers 1-2 Uno R3 m328p Soil moisture sensor: m328

Ethan Gallucci 1 May 4, 2022
A simple string parsing utility library for Rust, supporting no_std contexts.

strp Utility library for parsing data from an input string, or stdin if built with the std feature. Supports no_std contexts when built without the st

iqon 5 Nov 3, 2022
Error context library with support for type-erased sources and backtraces, targeting full support of all features on stable Rust

Error context library with support for type-erased sources and backtraces, targeting full support of all features on stable Rust, and with an eye towards serializing runtime errors using serde.

Findora Foundation 1 Feb 12, 2022
Utilities to gather data out of roms. Written in Rust. It (should) support all types.

snesutilities Utilities to gather data out of roms. Written in Rust. It (should) support all types. How Have a look at main.rs: use snesutilities::Sne

Layle | Luca 5 Oct 12, 2022
OpenAPI support for Poem

Poem OpenAPI Fast and Type-Safe OpenAPI implementation for Poem. Poem-openapi allows you to easily implement APIs that comply with the OpenAPIv3 speci

Poem Web 40 Sep 16, 2021
A rewrite of Phonelink for Windows Forms written in Rust, with cross-platform support.

phonelink-rs A rewrite of Phonelink for Windows Forms written in Rust, with cross-platform support. Usage Clone the repository and build, or download

ahsan-a 4 Aug 6, 2022
Use enum to filter something, support | and & operator.

Filter Use enum to filter something, support | and & operator. Just need to implement Filter Trait with filter-macros crate. How to work Example #[add

上铺小哥 9 Feb 8, 2022
`xrandr` for Gnome/wayland, on distros that don't support `wlr-randr`

gnome-randr-rust A reimplementation of xrandr for Gnome on Wayland, especially for systems that don't support wlr-output-management-unstable-v1 (e.g.

Max Ainatchi 40 Dec 21, 2022
Board Support Crate for Arduino Leonardo in Rust

Deprecation Note: This crate will soon be deprecated in favor of avr-hal. avr-hal is a new approach to writing the HAL crate, that was designed with s

Rahix 5 May 6, 2021
Universal changelog generator using conventional commit+ with monorepo support. Written in Rust.

chlog Universal changelog generator using conventional commit+ with monorepo support. chlog can generate the changelog from the conventional commits w

Jeff Yang 3 Nov 27, 2022
🦀 Rust support library for semaphore

?? semaphore-rs Rust support library for using semaphore. It's mostly a Rust rewrite of zk-kit, but just focuses on semaphore (for now) and still cove

Worldcoin 31 Dec 21, 2022
Rust usb-device support for ATmega chips

atmega-usbd usb_device support for ATmega microcontrollers. NOTE: This is an experimental library, and certainly not production-ready. Expect bugs, an

Adam Gausmann 20 Jan 8, 2023
⚙️ A cute .gitignore generator with support for custom templates

Gign A Gitignore Generator Table of Contents Examples Install Custom templates Help Examples # This is how you going to use it probably most of the ti

Vadim 6 Dec 7, 2022
Lapce vue plugin, support vue (SFC) syntax highlight, autocomplate,types check

Lapce Plugin for Vue (based volar) Preview Usage Required: Lapce version must be greater than 2.0, and you can use Lapce nightly version. click here t

xiaoxin 32 Dec 26, 2022