okay let's try to make our own pac (it doesn't work)

This commit is contained in:
Artemis Tosini 2024-03-25 04:44:02 +00:00
parent 13e6bded6f
commit 44687b0067
Signed by: artemist
GPG key ID: EE5227935FE3FF18
10 changed files with 15003 additions and 93 deletions

View file

@ -55,10 +55,31 @@
"riscv32imac-unknown-none-elf"
];
};
rust-form = pkgs.rustPlatform.buildRustPackage rec {
pname = "form";
version = "0.10.0";
src = pkgs.fetchFromGitHub {
owner = "djmcgill";
repo = pname;
rev = "v${version}";
hash = "sha256-cqoc2sTtVdhTAQ65oaJKo1+YMfQu7eHCe8zjRPDz9zg=";
};
cargoHash = "sha256-dhPp93AH4VlOVJWXMMUwv8b53vLPdBY3WyaXE4kcEm4=";
};
in with pkgs;
mkShell {
packages =
[ rust cargo-binutils probe-rs cargo-generate gdb openocd ];
packages = [
cargo-binutils
cargo-generate
gdb
openocd
probe-rs
rust
rust-form
svd2rust
svdtools
];
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
};

View file

@ -2,27 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "aligned"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a785a543aea40f5e4e2e93bb2655d31bc21bb391fff65697150973e383f16bb"
dependencies = [
"as-slice",
]
[[package]]
name = "as-slice"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0"
dependencies = [
"generic-array 0.12.4",
"generic-array 0.13.3",
"generic-array 0.14.7",
"stable_deref_trait",
]
[[package]]
name = "bare-metal"
version = "0.2.5"
@ -38,19 +17,6 @@ version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
[[package]]
name = "cortex-m"
version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9075300b07c6a56263b9b582c214d0ff037b00d45ec9fde1cc711490c56f1bb9"
dependencies = [
"aligned",
"bare-metal",
"bitfield",
"cortex-m 0.7.7",
"volatile-register",
]
[[package]]
name = "cortex-m"
version = "0.7.7"
@ -89,7 +55,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c23234600452033cc77e4b761e740e02d2c4168e11dbf36ab14a0f58973592b0"
dependencies = [
"cortex-m 0.7.7",
"cortex-m",
]
[[package]]
@ -102,53 +68,22 @@ dependencies = [
"void",
]
[[package]]
name = "generic-array"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
dependencies = [
"typenum",
]
[[package]]
name = "generic-array"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309"
dependencies = [
"typenum",
]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "lpc1114-test"
version = "0.1.0"
dependencies = [
"cortex-m 0.7.7",
"cortex-m",
"cortex-m-rt",
"cortex-m-semihosting",
"lpc11xx",
"lpc111x-pac",
"panic-semihosting",
]
[[package]]
name = "lpc11xx"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c878f9fadd93bddb1a8255b0620bb32d909f178b1340d5d684ac0a6749a749a"
name = "lpc111x-pac"
version = "0.1.0"
dependencies = [
"bare-metal",
"cortex-m 0.6.7",
"cortex-m",
"vcell",
]
@ -173,7 +108,7 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee8a3e1233d9073d76a870223512ce4eeea43c067a94a445c13bd6d792d7b1ab"
dependencies = [
"cortex-m 0.7.7",
"cortex-m",
"cortex-m-semihosting",
]
@ -219,12 +154,6 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "syn"
version = "1.0.109"
@ -236,12 +165,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "unicode-ident"
version = "1.0.12"
@ -254,12 +177,6 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "void"
version = "1.0.2"

View file

@ -8,7 +8,7 @@ edition = "2021"
cortex-m = "0.7"
cortex-m-rt = "0.7"
cortex-m-semihosting = "0.5"
lpc11xx = "0.2"
lpc111x-pac = { path = "../lpc111x-pac" }
panic-semihosting = "0.6"
# Set the default for dependencies.

3
rust-embedded/lpc111x-pac/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*.patched
/target
Cargo.lock

View file

@ -0,0 +1,13 @@
[package]
name = "lpc111x-pac"
edition = "2021"
version = "0.1.0"
[dependencies]
cortex-m = "0.7"
cortex-m-rt = { version = "0.7", optional = true }
vcell = "0.1"
critical-section = { version = "1.0", optional = true }
[features]
rt = ["cortex-m-rt/device"]

View file

@ -0,0 +1,17 @@
#![doc = r" Builder file for Peripheral access crate generated by svd2rust tool"]
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
if env::var_os("CARGO_FEATURE_RT").is_some() {
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("device.x"))
.unwrap()
.write_all(include_bytes!("device.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed=device.x");
}
println!("cargo:rerun-if-changed=build.rs");
}

View file

@ -0,0 +1,30 @@
PROVIDE(PIO0_0 = DefaultHandler);
PROVIDE(PIO0_1 = DefaultHandler);
PROVIDE(PIO0_2 = DefaultHandler);
PROVIDE(PIO0_3 = DefaultHandler);
PROVIDE(PIO0_4 = DefaultHandler);
PROVIDE(PIO0_5 = DefaultHandler);
PROVIDE(PIO0_6 = DefaultHandler);
PROVIDE(PIO0_7 = DefaultHandler);
PROVIDE(PIO0_8 = DefaultHandler);
PROVIDE(PIO0_9 = DefaultHandler);
PROVIDE(PIO0_10 = DefaultHandler);
PROVIDE(PIO0_11 = DefaultHandler);
PROVIDE(PIO1_0 = DefaultHandler);
PROVIDE(SPI1 = DefaultHandler);
PROVIDE(I2C = DefaultHandler);
PROVIDE(CT16B0 = DefaultHandler);
PROVIDE(CT16B1 = DefaultHandler);
PROVIDE(CT32B0 = DefaultHandler);
PROVIDE(CT32B1 = DefaultHandler);
PROVIDE(SPI0 = DefaultHandler);
PROVIDE(UART = DefaultHandler);
PROVIDE(ADC = DefaultHandler);
PROVIDE(WDT = DefaultHandler);
PROVIDE(BOD = DefaultHandler);
PROVIDE(FMC = DefaultHandler);
PROVIDE(GPIO3 = DefaultHandler);
PROVIDE(GPIO2 = DefaultHandler);
PROVIDE(GPIO1 = DefaultHandler);
PROVIDE(GPIO0 = DefaultHandler);

View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
svdtools patch svd/LPC111x.yaml
svd2rust -i svd/LPC111x.svd.patched
rm -r src
form -i lib.rs -o src
rm lib.rs
cargo fmt

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
_svd: LPC111x.svd