add: all files

This commit is contained in:
Charles
2025-03-23 19:06:13 -07:00
parent fe87f5271e
commit 1bc99bd808
36 changed files with 1484 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
FROM ubuntu:18.04
RUN useradd -m avr-rust
# Install dependencies
RUN apt-get update -y && apt-get install -y wget gcc binutils gcc-avr avr-libc
RUN mkdir -p /code && chown avr-rust:avr-rust /code
USER avr-rust
# Install Rustup along with nightly
RUN wget -q https://sh.rustup.rs -O /tmp/rustup.sh && sh /tmp/rustup.sh -y --profile minimal --default-toolchain nightly -c rust-src --quiet
ENV PATH=/home/avr-rust/.cargo/bin:$PATH
COPY --chown=avr-rust:avr-rust . /code
WORKDIR /code
ENV AVR_CPU_FREQUENCY_HZ=16000000
ENTRYPOINT ["cargo"]
@@ -0,0 +1,27 @@
name: Test suite
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: "0 2 * * 1-5"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prepare the Rust build environment
run:
docker build . --file .github/Dockerfile.ci --tag rust-avr-ci:$GITHUB_RUN_NUMBER
- name: Compile the crate for the AVR atmega328p
run:
docker run rust-avr-ci:$GITHUB_RUN_NUMBER build -Z build-std=core --target avr-atmega328p.json --release --all --bins --examples
- name: Compile the crate for the host machine and and run tests
run:
docker run rust-avr-ci:$GITHUB_RUN_NUMBER test --all
+1
View File
@@ -0,0 +1 @@
/target
+16
View File
@@ -0,0 +1,16 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "avr-std-stub"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "839920177137ff472f3c35abf5b8166f331c6cf7f2dfa7ffd69f9aa7dc70b526"
[[package]]
name = "orangepunk-hardware"
version = "0.1.0"
dependencies = [
"avr-std-stub",
]
+10
View File
@@ -0,0 +1,10 @@
[package]
name = "orangepunk-hardware"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
avr-std-stub = "1.0"
+23
View File
@@ -0,0 +1,23 @@
# Rust AVR executable template
A template for Rust based AVR executables.
**NOTE**: This software template repository is offered in the public domain. It is free to use, adapt, modify, distribute, with no restrictions and no crediting required.
Provides:
* A Rust target specification JSON for ATmega328P - [`avr-atmega328p.json`](./avr-atmega328p.json)
* A GitHub-action based CI test pipeline
## Build instructions
Install Rust nightly.
Then run:
```
cargo build --target avr-atmega328p.json -Z build-std=core --release
```
The final ELF executable file will then be available at `target/avr-atmega328p/release/template-bin.elf`.
@@ -0,0 +1,32 @@
{
"arch": "avr",
"cpu": "atmega328p",
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
"env": "",
"executables": true,
"linker": "avr-gcc",
"linker-flavor": "gcc",
"linker-is-gnu": true,
"llvm-target": "avr-unknown-unknown",
"no-compiler-rt": true,
"os": "unknown",
"position-independent-executables": false,
"exe-suffix": ".elf",
"eh-frame-header": false,
"pre-link-args": {
"gcc": [
"-Os",
"-mmcu=atmega328p"
]
},
"late-link-args": {
"gcc": [
"-lc",
"-lgcc"
]
},
"target-c-int-width": "16",
"target-endian": "little",
"target-pointer-width": "16",
"vendor": "unknown"
}
+17
View File
@@ -0,0 +1,17 @@
#![no_std]
#![cfg_attr(not(test), no_main)] // #![no_main] interfers with 'cargo test' when targeting the host machine.
extern crate avr_std_stub;
#[no_mangle]
#[cfg(not(test))] // The main function interfers with 'cargo test' when targeting the host machine.
fn main() {
}
#[cfg(test)]
mod test {
#[test]
fn test_foo() {
assert_eq!(1, 1);
}
}