From cec07b83cf177f524c129f533a14723a4397586f Mon Sep 17 00:00:00 2001 From: Romain Reignier Date: Sun, 17 Nov 2024 14:40:30 +0100 Subject: [PATCH] Remove atomics usage to follow qingke recent changes (#10) --- .cargo/config.toml | 9 +++++---- Cargo.toml | 4 ++-- cargo-generate.toml | 7 +++++-- pre-script.rhai | 19 ++++++++++--------- riscv32imfc-unknown-none-elf.json | 19 +++++++++++++++++++ rust-toolchain.toml | 2 +- 6 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 riscv32imfc-unknown-none-elf.json diff --git a/.cargo/config.toml b/.cargo/config.toml index 0d3e488..250dceb 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,15 +1,16 @@ -{% if mcu_family == "ch32v003" or mcu_family == "ch641" -%} [build] +{% if target == "riscv32ec-unknown-none-elf" -%} target = "riscv32ec-unknown-none-elf.json" +{%- elsif target == "riscv32imfc-unknown-none-elf" -%} +target = "riscv32imfc-unknown-none-elf.json" {%- else -%} -[build] target = "{{ target }}" {%- endif %} [target."{{ target }}"] runner = "wlink -v flash --enable-sdi-print --watch-serial" -{% if mcu_family == "ch32v003" or mcu_family == "ch641" -%} +{% if target == "riscv32ec-unknown-none-elf" or target == "riscv32imfc-unknown-none-elf" -%} [unstable] build-std = ["core"] -{% endif %} +{% endif -%} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index a8de1ad..c83ac27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,8 +24,8 @@ embassy-executor = { version = "0.6.1", features = [ "task-arena-size-128", # or better use nightly, but fails on recent Rust versions ] } embassy-time = { version = "0.3.0" } -qingke-rt = "0.4.0" -qingke = "0.4.0" +qingke-rt = "0.5.0" +qingke = "0.5.0" embedded-hal = "1.0.0" panic-halt = "1.0.0" diff --git a/cargo-generate.toml b/cargo-generate.toml index b98b05c..345a03b 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -1,6 +1,6 @@ [template] cargo_generate_version = ">=0.19" -ignore = [".git", "README.md"] +ignore = [".git", ".github", "README.md"] [hooks] pre = ["pre-script.rhai"] @@ -24,9 +24,12 @@ choices = [ ] default = "ch32v003" -[conditional.'mcu_family != "ch32v003 || mcu_family != "ch641"'] +[conditional.'mcu_family != "ch32v003" && mcu_family != "ch641"'] ignore = ["riscv32ec-unknown-none-elf.json"] +[conditional.'mcu_family != "ch32v303" && mcu_family != "ch32v305" && mcu_family != "ch32v307"'] +ignore = ["riscv32imfc-unknown-none-elf.json"] + [conditional.'mcu_family == "ch32l003"'.placeholders] mcu = { type = "string", prompt = "Which ch32l003 variant to use?", choices = [ "ch32l103c8t6", diff --git a/pre-script.rhai b/pre-script.rhai index 2912152..2e44e0d 100644 --- a/pre-script.rhai +++ b/pre-script.rhai @@ -1,14 +1,15 @@ let targets = #{ - ch32l003: "riscv32imac-unknown-none-elf", + ch32l003: "riscv32imc-unknown-none-elf", ch32v003: "riscv32ec-unknown-none-elf", - ch32v103: "riscv32imac-unknown-none-elf", - ch32v203: "riscv32imac-unknown-none-elf", - ch32v208: "riscv32imac-unknown-none-elf", - ch32v303: "riscv32imafc-unknown-none-elf", - ch32v305: "riscv32imafc-unknown-none-elf", - ch32v307: "riscv32imafc-unknown-none-elf", - ch32x033: "riscv32imac-unknown-none-elf", - ch32x035: "riscv32imac-unknown-none-elf", + ch32v103: "riscv32imc-unknown-none-elf", + ch32v203: "riscv32imc-unknown-none-elf", + ch32v208: "riscv32imc-unknown-none-elf", + ch32v303: "riscv32imfc-unknown-none-elf", + ch32v305: "riscv32imfc-unknown-none-elf", + ch32v307: "riscv32imfc-unknown-none-elf", + ch32x033: "riscv32imc-unknown-none-elf", + ch32x035: "riscv32imc-unknown-none-elf", + ch641: "riscv32ec-unknown-none-elf", }; let mcu_family = variable::get("mcu_family"); diff --git a/riscv32imfc-unknown-none-elf.json b/riscv32imfc-unknown-none-elf.json new file mode 100644 index 0000000..fa0696e --- /dev/null +++ b/riscv32imfc-unknown-none-elf.json @@ -0,0 +1,19 @@ +{ + "arch": "riscv32", + "atomic-cas": false, + "cpu": "generic-rv32", + "crt-objects-fallback": "false", + "data-layout": "e-m:e-p:32:32-i64:64-n32-S128", + "eh-frame-header": false, + "emit-debug-gdb-scripts": false, + "features": "+m,+f,+c,+forced-atomics", + "is-builtin": false, + "linker": "rust-lld", + "linker-flavor": "gnu-lld", + "llvm-abiname": "ilp32f", + "llvm-target": "riscv32", + "max-atomic-width": 32, + "panic-strategy": "abort", + "relocation-model": "static", + "target-pointer-width": "32" +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e319b91..a25a397 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] channel = "nightly" -{% if mcu_family != "ch32v003" and mcu_family != "ch641" -%} +{% if target != "riscv32ec-unknown-none-elf" and target != "riscv32imfc-unknown-none-elf" -%} targets = ["{{ target }}"] {%- endif %}