Embedded configuration - Correct dummyrs? #749
-
I'm trying to get an embedded project on the Raspberry Pico started for days. Right now I am at the stage where it almost seems to build. It looks like the problem currently is that the default Upon build I get the following error (excerpt) in the compile phase of the dummyfied crate:
My flake.nix looks like this currently ( {
description = "Minimal crane flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
rust-overlay,
crane,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
inherit (pkgs) lib;
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
# Default files from crane (Rust and cargo files)
(craneLib.fileset.commonCargoSources ./.)
(craneLib.fileset.configToml ./.)
# Also keep linker script
(lib.fileset.maybeMissing ./memory.x)
];
};
commonArgs = {
inherit src;
cargoExtraArgs = "-p azimuth-firmware-pico --target thumbv6m-none-eabi";
strictDeps = true;
doCheck = false;
nativeBuildInputs = with pkgs; [
flip-link
];
};
# Common args for dependency builds
depsArgs = let
# Include linker scripts
linkerScriptsOnly = lib.cleanSourceWith {
inherit src;
filter = name: type: let
baseName = baseNameOf (toString name);
in (
# Compose filters with `||`
lib.hasSuffix ".x" baseName
);
};
in
commonArgs
// {
# dummyrs = pkgs.writeText "dummy.rs" ''
# #![allow(clippy::all)]
# #![allow(dead_code)]
# #![cfg_attr(any(target_os = "none", target_os = "uefi"), no_std)]
# #![cfg_attr(any(target_os = "none", target_os = "uefi"), no_main)]
# #[allow(unused_extern_crates)]
# extern crate core;
# //extern crate cortex_m;
# // use cortex_m as _;
# // use cortex_m_rt as _;
# // use rp_pico as bsp;
# // use bsp::entry;
# #[cfg_attr(any(target_os = "none", target_os = "uefi"), panic_handler)]
# fn panic(_info: &::core::panic::PanicInfo<'_>) -> ! {
# loop {}
# }
# // #[entry]
# pub fn main() {}
# '';
extraDummyScript = ''
cp -r ${linkerScriptsOnly} --no-target-directory $out/
'';
};
# Build artifacts
cargoArtifacts = craneLib.buildDepsOnly depsArgs;
firmware = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
inherit (craneLib.crateNameFromCargoToml {inherit src;}) version;
pname = "firmware";
});
in {
packages = {
inherit firmware;
};
devShells.default = craneLib.devShell {
inputsFrom = [self.packages.${system}.firmware];
buildInputs = with pkgs; [
cargo-hakari
];
};
});
} and for good measure, the crate-specific cargo-features = ["per-package-target"]
[package]
name = "azimuth-firmware-pico"
version.workspace = true
edition.workspace = true
authors.workspace = true
publish = false
default-target = "thumbv6m-none-eabi"
[[bin]]
name = "azimuth-firmware-pico"
test = false
doctest = false
bench = false
[dependencies]
azimuth-core = { path = "../azimuth-core", default-features = false }
cortex-m = "0.7"
cortex-m-rt = "0.7"
embedded-hal = { version = "1.0.0" }
rp-pico = "0.9"
defmt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }
workspace-hack = { version = "0.1", path = "../workspace-hack" } Here is an example hello-world What should |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Fixed by suggestion in #444 |
Beta Was this translation helpful? Give feedback.
Fixed by suggestion in #444