Skip to content

Commit

Permalink
chore: update examples to not use atomics
Browse files Browse the repository at this point in the history
This is a follow-up change to the `bugfix(broken atomics)` where we
removed all use of atomics. This update the qingke version and examples'
target setting to not include the atomic extension
  • Loading branch information
Codetector1374 committed Nov 3, 2024
1 parent 536fb82 commit 83c9f4e
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 93 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ jobs:
rustup default nightly
rustup component add rust-src
rustup update
rustup target add riscv32imac-unknown-none-elf
rustup target add riscv32imafc-unknown-none-elf
rustup target add riscv32imc-unknown-none-elf
rustup target add riscv32i-unknown-none-elf
- name: Fetch Deps
# if this is a pull request
Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,27 @@ jobs:
- ch641
include:
- chip: ch32l103f8u6
target: riscv32imac-unknown-none-elf
target: riscv32imc-unknown-none-elf
- chip: ch32v003f4u6
target: riscv32i-unknown-none-elf
- chip: ch32v103c8t6
target: riscv32imac-unknown-none-elf
target: riscv32imc-unknown-none-elf
- chip: ch32v203f8u6
target: riscv32imac-unknown-none-elf
target: riscv32imc-unknown-none-elf
- chip: ch32v208wbu6
target: riscv32imac-unknown-none-elf
target: riscv32imc-unknown-none-elf
- chip: ch32v303vct6
target: riscv32imafc-unknown-none-elf
# use rv32imc because ri32imfc does not exist, hal should not use FP anyways
target: riscv32imc-unknown-none-elf
- chip: ch32v305fbp6
target: riscv32imafc-unknown-none-elf
# use rv32imc because ri32imfc does not exist
target: riscv32imc-unknown-none-elf
- chip: ch32v307vct6
target: riscv32imafc-unknown-none-elf
# use rv32imc because ri32imfc does not exist
target: riscv32imc-unknown-none-elf
- chip: ch32x035f7p6
target: riscv32imafc-unknown-none-elf
# use rv32imc because ri32imfc does not exist
target: riscv32imc-unknown-none-elf
- chip: ch641
target: riscv32i-unknown-none-elf
runs-on: ubuntu-latest
Expand All @@ -57,8 +61,7 @@ jobs:
rustup default nightly
rustup component add rust-src
rustup update
rustup target add riscv32imac-unknown-none-elf
rustup target add riscv32imafc-unknown-none-elf
rustup target add riscv32imc-unknown-none-elf
rustup target add riscv32i-unknown-none-elf
- name: Fetch Deps
# if this is a pull request
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ ch32-metapac = { features = [
"rt",
], git = "https://github.com/ch32-rs/ch32-metapac", rev = "cef1944dadf3a5d198e687500b8f5964f29efdf6" }

qingke = { version = "0.4.0", features = ["critical-section-impl"] }
qingke-rt = { version = "0.4.0", optional = true }
qingke = { version = "0.5.0", features = ["critical-section-impl"] }
qingke-rt = { version = "0.5.0", optional = true }

# TODO: remove this
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [
Expand Down
4 changes: 2 additions & 2 deletions examples/ch32l103/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build]
target = "riscv32imac-unknown-none-elf"
target = "riscv32imc-unknown-none-elf"

[target."riscv32imac-unknown-none-elf"]
[target."riscv32imc-unknown-none-elf"]
runner = "wlink -v flash --enable-sdi-print --watch-serial"
# runner = "wlink -v flash"
12 changes: 7 additions & 5 deletions examples/ch32l103/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ embassy-executor = { version = "0.6.0", features = [
] }
embassy-time = { version = "0.3.2" }

qingke-rt = { version = "0.4.0" }
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
# This is okay because we should automatically use whatever ch32-hal uses
qingke = "*"
qingke-rt = "*"

panic-halt = "0.2.0"
panic-halt = "1.0"
embedded-hal = "1.0.0"

[profile.release]
strip = false # symbols are not flashed to the microcontroller, so don't strip them.
lto = true
opt-level = "z" # Optimize for size.

[profile.dev]
opt-level = 1 # At least some opt so binary is not insane
11 changes: 5 additions & 6 deletions examples/ch32v003/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ ch32-hal = { path = "../../", features = [
] }
embassy-executor = { version = "0.6.0", features = [
"integrated-timers",
"arch-riscv32",
"arch-spin",
"executor-thread",
"task-arena-size-128", # or better use nightly, but fails on recent Rust versions
] }
embassy-time = { version = "0.3.0" }

qingke-rt = { version = "0.4.0", features = ["highcode"] }
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
# This is okay because we should automatically use whatever ch32-hal uses
qingke = "*"
qingke-rt = { version = "*", features = ["highcode"] }


panic-halt = "0.2.0"
panic-halt = "1.0"

embedded-hal = "1.0.0"

Expand Down
4 changes: 2 additions & 2 deletions examples/ch32v103/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build]
target = "riscv32imac-unknown-none-elf"
target = "riscv32imc-unknown-none-elf"

[target."riscv32imac-unknown-none-elf"]
[target."riscv32imc-unknown-none-elf"]
rustflags = [
# "-C", "link-arg=-Tlink.x",
]
Expand Down
11 changes: 5 additions & 6 deletions examples/ch32v103/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ ch32-hal = { path = "../../", features = [
] }
embassy-executor = { version = "0.6.0", features = [
"integrated-timers",
"arch-riscv32",
"arch-spin",
"executor-thread",
] }
embassy-time = { version = "0.3.2" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
# This is okay because we should automatically use whatever ch32-hal uses
qingke-rt = "*"
qingke = "*"

# Not working for now
# defmt = "0.3"
# defmt-rtt = "0.4"

panic-halt = "0.2.0"
panic-halt = "1.0"

display-interface-spi = "0.5.0"
mipidsi = "0.7.1"
Expand Down
4 changes: 2 additions & 2 deletions examples/ch32v203/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build]
target = "riscv32imac-unknown-none-elf"
target = "riscv32imc-unknown-none-elf"

[target."riscv32imac-unknown-none-elf"]
[target."riscv32imc-unknown-none-elf"]
rustflags = [
# "-C", "link-arg=-Tlink.x",
]
Expand Down
15 changes: 6 additions & 9 deletions examples/ch32v203/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,22 @@ ch32-hal = { path = "../../", features = [
"rt",
"time-driver-tim2",
], default-features = false }
#ch32-metapac = { features = [
# "memory-x",
# "rt",
#], path = "../../../ch32-data/build/ch32-metapac" }

embassy-executor = { version = "0.6.0", features = [
"integrated-timers",
"arch-riscv32",
"executor-thread",
] }

embassy-time = { version = "0.3.2" }
embassy-usb = { version = "0.3.0" }
embassy-futures = { version = "0.1.0" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
#qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
# This is okay because we should automatically use whatever ch32-hal uses
qingke-rt = "*"
qingke = "*"

panic-halt = "0.2.0"
panic-halt = "1.0"

display-interface-spi = "0.5.0"
embedded-hal = "1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/ch32v208/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build]
target = "riscv32imac-unknown-none-elf"
target = "riscv32imc-unknown-none-elf"

[target."riscv32imac-unknown-none-elf"]
[target."riscv32imc-unknown-none-elf"]
runner = "wlink -v flash --enable-sdi-print --watch-serial"
# runner = "wlink -v flash"
9 changes: 4 additions & 5 deletions examples/ch32v208/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ embassy-executor = { version = "0.6.0", features = [
] }
embassy-time = { version = "0.3.2" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
# This is okay because we should automatically use whatever ch32-hal uses
qingke-rt = "*"
qingke = "*"

panic-halt = "0.2.0"
panic-halt = "1.0"

[profile.release]
strip = false # symbols are not flashed to the microcontroller, so don't strip them.
Expand Down
7 changes: 5 additions & 2 deletions examples/ch32v305/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[build]
target = "riscv32imafc-unknown-none-elf"
target = "riscv32imfc-unknown-none-elf.json"

[target.riscv32imafc-unknown-none-elf]
[unstable]
build-std = ["core"]

[target.riscv32imfc-unknown-none-elf]
# runner = "wlink flash --enable-sdi-print --watch-serial"
runner = "wlink flash"

Expand Down
20 changes: 10 additions & 10 deletions examples/ch32v305/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ embassy-executor = { version = "0.6.0", features = [
] }
embassy-time = { version = "0.3.2" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
qingke-rt = "*"
qingke = "*"

# Not working for now
# defmt = "0.3"
# defmt-rtt = "0.4"
panic-halt = "1.0"

panic-halt = "0.2.0"
portable-atomic = { version = "1", default-features = false, features = [
"critical-section",
] }

display-interface-spi = "0.5.0"
mipidsi = "0.7.1"
embedded-graphics = "0.8.1"
embedded-hal-bus = "0.1.0"
embedded-hal = "1.0.0"
micromath = "2.1.0"
nb = "1.1.0"
heapless = "0.8.0"
heapless = { version = "0.8.0", features = ["portable-atomic"] }


[profile.release]
strip = false # symbols are not flashed to the microcontroller, so don't strip them.
lto = true
opt-level = "z" # Optimize for size.

[profile.dev]
opt-level = 2 # At least some opt so binary size is not insane
19 changes: 19 additions & 0 deletions examples/ch32v305/riscv32imfc-unknown-none-elf.json
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 5 additions & 2 deletions examples/ch32v307/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[build]
target = "riscv32imafc-unknown-none-elf"
target = "riscv32imfc-unknown-none-elf.json"

[target.riscv32imafc-unknown-none-elf]
[unstable]
build-std = ["core"]

[target.riscv32imfc-unknown-none-elf]
runner = "wlink flash --enable-sdi-print --watch-serial"
# runner = "wlink -v flash --no-erase --dry-run"
# runner = "probe-rs run --chip CH32V307"
Expand Down
13 changes: 4 additions & 9 deletions examples/ch32v307/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@ embassy-time = "0.3.2"
embassy-usb = "0.3.0"
nb = "1.1.0"

qingke = "0.4.0"
qingke-rt = "0.4.0"
# This is okay because we should automatically use whatever ch32-hal uses
qingke = "*"
qingke-rt = "*"

# Not working for now
# defmt = "0.3"
# defmt-rtt = "0.4"

panic-halt = "0.2.0"
panic-halt = "1.0"

display-interface-spi = "0.5.0"
mipidsi = "0.7.1"
embedded-graphics = "0.8.1"
embedded-hal-bus = "0.2.0"
# for ssd1306
ssd1306 = "0.9"

Expand Down
19 changes: 19 additions & 0 deletions examples/ch32v307/riscv32imfc-unknown-none-elf.json
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 2 additions & 2 deletions examples/ch32x035/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build]
target = "riscv32imac-unknown-none-elf"
target = "riscv32imc-unknown-none-elf"

[target.riscv32imac-unknown-none-elf]
[target.riscv32imc-unknown-none-elf]
runner = "wlink flash --enable-sdi-print --watch-serial"
# runner = "wlink -v flash --no-erase --dry-run"
# runner = "probe-rs run --chip CH32V307"
Expand Down
9 changes: 3 additions & 6 deletions examples/ch32x035/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ embassy-executor = { version = "0.6.0", features = [
] }
embassy-time = { version = "0.3.2" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
qingke-rt = "*"
qingke = "*"

panic-halt = "0.2.0"
panic-halt = "1.0"

display-interface-spi = "0.5.0"
mipidsi = "0.7.1"
embedded-graphics = "0.8.1"
embedded-hal-bus = "0.2.0"
embedded-hal = "1.0.0"
heapless = "0.8.0"

Expand Down
Loading

0 comments on commit 83c9f4e

Please sign in to comment.