gd32v-rust / gd32vf103-hal Goto Github PK
View Code? Open in Web Editor NEWHardware abstract layer (HAL) `embedded-hal` for RISC-V microcontroller GD32VF103 in Rust. Contributions welcomed!
License: MIT License
Hardware abstract layer (HAL) `embedded-hal` for RISC-V microcontroller GD32VF103 in Rust. Contributions welcomed!
License: MIT License
Does it support DAC? I just found ADC but not DAC.
I see there's some unfinished timer code in timer.rs. Whats the status of that and could you give any pointers on what needs to be done to get it working?
Besides the overflow MR, I also have some less concrete feedback:
At first when I tried the code sample you provided in martindisch/gd32vf103-demo#1, I ran into an error
error[E0432]: unresolved import `gd32vf103_hal::rcu::Strict`
--> src/main.rs:11:55
|
11 | ctimer::CoreTimer, delay::Delay, pac, prelude::*, rcu::Strict,
| ^^^^^^^^^^^ no `Strict` in `rcu`
But I quickly noticed that this is just because I was using the 0.0.2 version from crates.io which doesn't work with that yet (even though it's pretty recent). Using the latest from Git solved it for me. This is not really an issue, as it will be fixed when you publish the next version of your crate.
Another thing concerns the delay accuracy. Just like you, I don't have any equipment I can use to do exact measurements, but small inaccuracies aren't the issue here. On my device it seems more like it's off by a factor of 2. I adjusted the delay blinky example to use a 10000 ms delay and when timing by hand, the LED only ended up being toggled about every 20 seconds. I didn't read any documentation so am not confident enough to go ahead and issue a MR, but it seems to me like maybe the divide by 2 in delay.rs
is wrong and should be 4 instead?
diff --git a/src/delay.rs b/src/delay.rs
index ad3af92..ccf1b52 100644
--- a/src/delay.rs
+++ b/src/delay.rs
@@ -32,7 +32,7 @@ impl<T: Into<u32>> DelayMs<T> for Delay {
// according to the clock diagram, but 2 is accurate. I suspect
// this will need to change with further documentation updates.
fn delay_ms(&mut self, ms: T) {
- let count: u32 = ms.into() * (self.clock_frequency.0 / 1000 / 2);
+ let count: u32 = ms.into() * (self.clock_frequency.0 / 1000 / 4);
// todo: avoid using u64 values in this function
let tmp: u64 = self.ctimer.get_value();
let end = tmp + count as u64;
At least on my device this fixed the problem and now I'm very close to the 10 seconds I set the delay for.
Hi, I've been working on building a toolchain for the gd32vf103 from these sources. I've encountered a number of issues along the way. In cb6ce40 you refer to a riscv64-unknown-elf
toolchain, which matches what I'm trying to build. I was wondering where you got this toolchain. If you built it from source would you be able point me at the sources?
Thanks in advance, and for your embedded Rust work.
Hello. Thanks for the create!
I'm trying to build the red-pill-lights.rs example and it fails with:
C:\lnano\rust-sipeed-longan-nano>cargo build
Compiling rust-sipeed-longan-nano v0.1.0 (C:\lnano\rust-sipeed-longan-nano)
error: linking with `rust-lld` failed: exit code: 1
|
= note: "rust-lld" "-flavor" "gnu" "-L" "C:\\Users\\Ant\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\riscv32
imac-unknown-none-elf\\lib" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\rust_sipeed_longa
n_nano-617646e91d3367f2.114wvbsmrijg5qf2.rcgu.o" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\de
ps\\rust_sipeed_longan_nano-617646e91d3367f2.13z4agnaycgjo4ei.rcgu.o" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknow
n-none-elf\\debug\\deps\\rust_sipeed_longan_nano-617646e91d3367f2.1mtyvdk1x8799efk.rcgu.o" "C:\\lnano\\rust-sipeed-longan-nano\\targe
t\\riscv32imac-unknown-none-elf\\debug\\deps\\rust_sipeed_longan_nano-617646e91d3367f2.21hsjmjrx0uegq4t.rcgu.o" "C:\\lnano\\rust-sipe
ed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\rust_sipeed_longan_nano-617646e91d3367f2.2c54n2n14ka8d2pp.rcgu.o"
"C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\rust_sipeed_longan_nano-617646e91d3367f2.3kqz
dzsdggs2cajg.rcgu.o" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\rust_sipeed_longan_nano-
617646e91d3367f2.3os1wso41lf3ahjb.rcgu.o" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\rus
t_sipeed_longan_nano-617646e91d3367f2.3sak5o4jv51o03fa.rcgu.o" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-
elf\\debug\\deps\\rust_sipeed_longan_nano-617646e91d3367f2.3xg79rescwlxrgsw.rcgu.o" "C:\\lnano\\rust-sipeed-longan-nano\\target\\risc
v32imac-unknown-none-elf\\debug\\deps\\rust_sipeed_longan_nano-617646e91d3367f2.4aydifjixnlhgo4k.rcgu.o" "C:\\lnano\\rust-sipeed-long
an-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\rust_sipeed_longan_nano-617646e91d3367f2.4utub3ih92ivewn1.rcgu.o" "C:\\ln
ano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\rust_sipeed_longan_nano-617646e91d3367f2.51h9patv7u9
vvhvv.rcgu.o" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\rust_sipeed_longan_nano-617646e
91d3367f2.5d3cmzwpp5fwjogt.rcgu.o" "-o" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\rust_
sipeed_longan_nano-617646e91d3367f2" "--gc-sections" "-L" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\
debug\\deps" "-L" "C:\\lnano\\rust-sipeed-longan-nano\\target\\debug\\deps" "-L" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32
imac-unknown-none-elf\\debug\\build\\riscv-6ec733f2da02301a\\out" "-L" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unkno
wn-none-elf\\debug\\build\\riscv-rt-c19718e5f4f0d573\\out" "-L" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none
-elf\\debug\\build\\riscv-rt-c19718e5f4f0d573\\out" "-L" "C:\\Users\\Ant\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\r
ustlib\\riscv32imac-unknown-none-elf\\lib" "-Bstatic" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debu
g\\deps\\libriscv_rt-39b1c9a2a1395b65.rlib" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\l
ibr0-efe72901102416ac.rlib" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\libgd32vf103_hal-
538bca3434265f1e.rlib" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\libembedded_hal-2c72b9
fec7e64643.rlib" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\libvoid-985251a018f76383.rli
b" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\libnb-28ce48cf2268bf08.rlib" "C:\\lnano\\r
ust-sipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\libgd32vf103_pac-5ad80dba649266fc.rlib" "C:\\lnano\\rust-s
ipeed-longan-nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\libvcell-39cabe94cbf2b783.rlib" "C:\\lnano\\rust-sipeed-longan-
nano\\target\\riscv32imac-unknown-none-elf\\debug\\deps\\libriscv-3b5219f3235fe512.rlib" "C:\\lnano\\rust-sipeed-longan-nano\\target\
\riscv32imac-unknown-none-elf\\debug\\deps\\libbit_field-c3928d8a522354d4.rlib" "C:\\lnano\\rust-sipeed-longan-nano\\target\\riscv32i
mac-unknown-none-elf\\debug\\deps\\libbare_metal-cb2583ed0460b656.rlib" "--start-group" "C:\\lnano\\rust-sipeed-longan-nano\\target\\
riscv32imac-unknown-none-elf\\debug\\deps\\libpanic_halt-70774feb86ea981d.rlib" "C:\\Users\\Ant\\.rustup\\toolchains\\nightly-x86_64-
pc-windows-msvc\\lib\\rustlib\\riscv32imac-unknown-none-elf\\lib\\librustc_std_workspace_core-c97e3f6a559ea894.rlib" "C:\\Users\\Ant\
\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\riscv32imac-unknown-none-elf\\lib\\libcore-5dfd3751a44e3b6a.rlib"
"--end-group" "C:\\Users\\Ant\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\riscv32imac-unknown-none-elf\\lib\
\libcompiler_builtins-d4a43db8016be8c7.rlib" "-Tlink.x" "-Bdynamic"
= note: rust-lld: error: undefined symbol: _max_hart_id
>>> referenced by riscv-rt.o:(.init+0x52) in archive C:\lnano\rust-sipeed-longan-nano\target\riscv32imac-unknown-none-elf\d
ebug\deps\libriscv_rt-39b1c9a2a1395b65.rlib
>>> referenced by riscv-rt.o:(.init+0x56) in archive C:\lnano\rust-sipeed-longan-nano\target\riscv32imac-unknown-none-elf\d
ebug\deps\libriscv_rt-39b1c9a2a1395b65.rlib
rust-lld: error: undefined symbol: _stack_start
>>> referenced by riscv-rt.o:(.init+0x5E) in archive C:\lnano\rust-sipeed-longan-nano\target\riscv32imac-unknown-none-elf\d
ebug\deps\libriscv_rt-39b1c9a2a1395b65.rlib
rust-lld: error: undefined symbol: _hart_stack_size
>>> referenced by riscv-rt.o:(.init+0x66) in archive C:\lnano\rust-sipeed-longan-nano\target\riscv32imac-unknown-none-elf\d
ebug\deps\libriscv_rt-39b1c9a2a1395b65.rlib
>>> referenced by riscv-rt.o:(.init+0x6A) in archive C:\lnano\rust-sipeed-longan-nano\target\riscv32imac-unknown-none-elf\d
ebug\deps\libriscv_rt-39b1c9a2a1395b65.rlib
rust-lld: error: undefined symbol: _mp_hook
>>> referenced by lib.rs:301 (C:\Users\Ant\.cargo\registry\src\github.com-1ecc6299db9ec823\riscv-rt-0.6.1\src\lib.rs:301)
>>> riscv_rt-39b1c9a2a1395b65.riscv_rt.c1eqovug-cgu.9.rcgu.o:(_start_rust) in archive C:\lnano\rust-sipeed-lo
ngan-nano\target\riscv32imac-unknown-none-elf\debug\deps\libriscv_rt-39b1c9a2a1395b65.rlib
rust-lld: error: undefined symbol: __pre_init
>>> referenced by lib.rs:302 (C:\Users\Ant\.cargo\registry\src\github.com-1ecc6299db9ec823\riscv-rt-0.6.1\src\lib.rs:302)
>>> riscv_rt-39b1c9a2a1395b65.riscv_rt.c1eqovug-cgu.9.rcgu.o:(_start_rust) in archive C:\lnano\rust-sipeed-lo
ngan-nano\target\riscv32imac-unknown-none-elf\debug\deps\libriscv_rt-39b1c9a2a1395b65.rlib
rust-lld: error: undefined symbol: trap_handler
>>> referenced by lib.rs:329 (C:\Users\Ant\.cargo\registry\src\github.com-1ecc6299db9ec823\riscv-rt-0.6.1\src\lib.rs:329)
>>> riscv_rt-39b1c9a2a1395b65.riscv_rt.c1eqovug-cgu.9.rcgu.o:(_start_trap_rust) in archive C:\lnano\rust-sipe
ed-longan-nano\target\riscv32imac-unknown-none-elf\debug\deps\libriscv_rt-39b1c9a2a1395b65.rlib
error: aborting due to previous error
error: could not compile `rust-sipeed-longan-nano`.
To learn more, run the command again with --verbose.
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.