Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions regarding CH582F chip #2

Open
happytm opened this issue Dec 28, 2023 · 21 comments
Open

Questions regarding CH582F chip #2

happytm opened this issue Dec 28, 2023 · 21 comments
Labels
question Further information is requested

Comments

@happytm
Copy link

happytm commented Dec 28, 2023

I am new to rust language. I have some questions regarding using CH582F chip.

I want to make an IOT project where I want to read 3 ADC pins every 5 minutes to read temperature, light level and battery level and then broadcast it using BLE (preferably coded phy 125kb for longer range). After broadcasting the chip should go to sleep for 5 minutes to conserve battery power.

Is this possible with current code in your repository?

Thanks.

@andelf
Copy link
Contributor

andelf commented Dec 31, 2023

read 3 ADC pins every 5 minutes to read temperature, light level and battery level

ADC and RTC part works as expected.

then broadcast it using BLE (preferably coded phy 125kb for longer range).

The BLE broadcaster example also works.

After broadcasting the chip should go to sleep for 5 minutes to conserve battery power

I haven't looked into lower power sleep. The current implementation uses WFI opcode and DCDC. I need to check the official EVT for a full low power implementation

@happytm
Copy link
Author

happytm commented Dec 31, 2023

Thank you.

@happytm
Copy link
Author

happytm commented Dec 31, 2023

Happy new year.

Sorry to bother you again. My goal is to flash board linked below using USB interface:

https://github.com/WeActStudio/WeActStudio.WCH-BLE-Core

I am trying to compile on Windows 7 machine but I am getting following errors:

Is there something I am missing in setting up rust environment?

Please help me get started.
Thank you.

Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\ebhynes>cd rusthome

C:\Users\ebhynes\rusthome>cd CH582F

C:\Users\ebhynes\rusthome\CH582F>cargo build --example blinky

warning: profiles for the non root package will be ignored, specify profiles at
the workspace root:
package:   C:\Users\ebhynes\rusthome\CH582F\Cargo.toml
workspace: C:\Users\ebhynes\rusthome\Cargo.toml
   Compiling proc-macro2 v1.0.71
   Compiling semver v1.0.20
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase"
"-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-w
indows-gnu\\lib\\rsbegin.o" "C:\\Users\\ebhynes\\AppData\\Local\\Temp\\rustcY6lY
NH\\symbols.o" "C:\\Users\\ebhynes\\rusthome\\target\\debug\\build\\semver-7f4cc
d7d3655b1e4\\build_script_build-7f4ccd7d3655b1e4.build_script_build.654219012952
fa1b-cgu.0.rcgu.o" "C:\\Users\\ebhynes\\rusthome\\target\\debug\\build\\semver-7
f4ccd7d3655b1e4\\build_script_build-7f4ccd7d3655b1e4.build_script_build.65421901
2952fa1b-cgu.1.rcgu.o" "C:\\Users\\ebhynes\\rusthome\\target\\debug\\build\\semv
er-7f4ccd7d3655b1e4\\build_script_build-7f4ccd7d3655b1e4.k0gpimmi8ji485e.rcgu.o"
 "-L" "C:\\Users\\ebhynes\\rusthome\\target\\debug\\deps" "-L" "C:\\Users\\ebhyn
es\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-w
indows-gnu\\lib" "-Wl,-Bstatic" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable
-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-c39a333
01a990d4c.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windo
ws-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-cca52022a9e303
e0.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\
\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-87ab4ba6115beae7.rlib" "C:\
\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib
\\x86_64-pc-windows-gnu\\lib\\libmemchr-5cb7fa9a12663885.rlib" "C:\\Users\\ebhyn
es\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-w
indows-gnu\\lib\\libaddr2line-63721decd0530f88.rlib" "C:\\Users\\ebhynes\\.rustu
p\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu
\\lib\\libgimli-f46ca0e8336ae9ce.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\
\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librust
c_demangle-eb7f3864ed6b2a68.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stab
le-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detec
t-7a1913f37e63e841.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64
-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-bc9416be
95f71206.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-window
s-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-58
3427bdf1f371c2.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-
windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libminiz_oxide-cda0273dfc
900176.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-
gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libadler-9e3a606a7eac348e.rlib" "
C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rust
lib\\x86_64-pc-windows-gnu\\lib\\libunwind-17b9231d7a9331b7.rlib" "C:\\Users\\eb
hynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-p
c-windows-gnu\\lib\\libcfg_if-dcab4b455bc920a1.rlib" "C:\\Users\\ebhynes\\.rustu
p\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu
\\lib\\liblibc-9852f6e85c86dae7.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\
stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc
-2b83ab5495098fa8.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-
pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace
_core-baa2c1aeb27e5083.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x8
6_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-b5f8c582e
1776c2a.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows
-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-d13d1e3b0b5
41614.rlib" "-Wl,-Bdynamic" "-lkernel32" "-ladvapi32" "-lbcrypt" "-lkernel32" "-
lntdll" "-luserenv" "-lws2_32" "-lkernel32" "-lws2_32" "-lkernel32" "-lntdll" "-
lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgc
c" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "C:\\Users\\ebhynes\
\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-wind
ows-gnu\\lib" "-o" "C:\\Users\\ebhynes\\rusthome\\target\\debug\\build\\semver-7
f4ccd7d3655b1e4\\build_script_build-7f4ccd7d3655b1e4.exe" "-Wl,--gc-sections" "-
no-pie" "-nodefaultlibs" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64
-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: C:/Users/ebhynes/gcc/bin/../lib/gcc/x86_64-w64-mingw32/14.0.0/../../..
/../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh: No such file or directo
ry
          collect2.exe: error: ld returned 1 exit status


error: could not compile `semver` (build script) due to previous error
warning: build failed, waiting for other jobs to finish...
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase"
"-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\\Users\\ebhyn
es\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-w
indows-gnu\\lib\\rsbegin.o" "C:\\Users\\ebhynes\\AppData\\Local\\Temp\\rustcoZFq
4P\\symbols.o" "C:\\Users\\ebhynes\\rusthome\\target\\debug\\build\\proc-macro2-
3b93dc464602e6e6\\build_script_build-3b93dc464602e6e6.build_script_build.82d338d
2bdf02644-cgu.0.rcgu.o" "C:\\Users\\ebhynes\\rusthome\\target\\debug\\build\\pro
c-macro2-3b93dc464602e6e6\\build_script_build-3b93dc464602e6e6.build_script_buil
d.82d338d2bdf02644-cgu.1.rcgu.o" "C:\\Users\\ebhynes\\rusthome\\target\\debug\\b
uild\\proc-macro2-3b93dc464602e6e6\\build_script_build-3b93dc464602e6e6.build_sc
ript_build.82d338d2bdf02644-cgu.2.rcgu.o" "C:\\Users\\ebhynes\\rusthome\\target\
\debug\\build\\proc-macro2-3b93dc464602e6e6\\build_script_build-3b93dc464602e6e6
.44x3wag1o4q3hom1.rcgu.o" "-L" "C:\\Users\\ebhynes\\rusthome\\target\\debug\\dep
s" "-L" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\
lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "C:\\Users\\ebhynes\\.r
ustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows
-gnu\\lib\\libstd-c39a33301a990d4c.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchain
s\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpa
nic_unwind-cca52022a9e303e0.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stab
le-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-87
ab4ba6115beae7.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-
windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-5cb7fa9a1266388
5.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\
lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-63721decd0530f88.rlib" "C
:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustl
ib\\x86_64-pc-windows-gnu\\lib\\libgimli-f46ca0e8336ae9ce.rlib" "C:\\Users\\ebhy
nes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-
windows-gnu\\lib\\librustc_demangle-eb7f3864ed6b2a68.rlib" "C:\\Users\\ebhynes\\
.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windo
ws-gnu\\lib\\libstd_detect-7a1913f37e63e841.rlib" "C:\\Users\\ebhynes\\.rustup\\
toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\l
ib\\libhashbrown-bc9416be95f71206.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains
\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librus
tc_std_workspace_alloc-583427bdf1f371c2.rlib" "C:\\Users\\ebhynes\\.rustup\\tool
chains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\
libminiz_oxide-cda0273dfc900176.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\
stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libadler
-9e3a606a7eac348e.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-
pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-17b9231d7a93
31b7.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gn
u\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-dcab4b455bc920a1.rlib" "C
:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustl
ib\\x86_64-pc-windows-gnu\\lib\\liblibc-9852f6e85c86dae7.rlib" "C:\\Users\\ebhyn
es\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-w
indows-gnu\\lib\\liballoc-2b83ab5495098fa8.rlib" "C:\\Users\\ebhynes\\.rustup\\t
oolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\li
b\\librustc_std_workspace_core-baa2c1aeb27e5083.rlib" "C:\\Users\\ebhynes\\.rust
up\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gn
u\\lib\\libcore-b5f8c582e1776c2a.rlib" "C:\\Users\\ebhynes\\.rustup\\toolchains\
\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcomp
iler_builtins-d13d1e3b0b541614.rlib" "-Wl,-Bdynamic" "-lkernel32" "-ladvapi32" "
-lbcrypt" "-lkernel32" "-lntdll" "-luserenv" "-lws2_32" "-lkernel32" "-lws2_32"
"-lkernel32" "-lntdll" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lm
ingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat"
"-L" "C:\\Users\\ebhynes\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib
\\rustlib\\x86_64-pc-windows-gnu\\lib" "-o" "C:\\Users\\ebhynes\\rusthome\\targe
t\\debug\\build\\proc-macro2-3b93dc464602e6e6\\build_script_build-3b93dc464602e6
e6.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\Users\\ebhynes\\.rus
tup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-g
nu\\lib\\rsend.o"
  = note: C:/Users/ebhynes/gcc/bin/../lib/gcc/x86_64-w64-mingw32/14.0.0/../../..
/../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh: No such file or directo
ry
          collect2.exe: error: ld returned 1 exit status


error: could not compile `proc-macro2` (build script) due to previous error

C:\Users\ebhynes\rusthome\CH582F>```

@andelf
Copy link
Contributor

andelf commented Jan 1, 2024

Check out rust-lang/rust#44787 (comment)
It seems mingw32's version is buggy while linking against some rust libs.
The MSVC toolchains might work.

@happytm
Copy link
Author

happytm commented Jan 1, 2024

@andelf I searched on google for silutions for whole day but was unsuccessful.

Finally I removed all old installation of rust and installed standalone rust application which can compile hello world example created by typing "cargo new hello".

But when I try to compile your repository it gives following errors:

Please help.
Thanks.

Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\ebhynes>cargo --version
cargo 1.75.0 (1d8b05cdd 2023-11-20)

C:\Users\ebhynes>cd CH582F

C:\Users\ebhynes\CH582F>cargo build --example blinky
    Updating crates.io index
  Downloaded autocfg v1.1.0
  Downloaded display-interface-spi v0.4.1
  Downloaded embassy-sync v0.4.0
  Downloaded embedded-hal-nb v1.0.0-rc.1
  Downloaded embedded-io v0.6.1
  Downloaded display-interface-i2c v0.4.0
  Downloaded hash32 v0.2.1
  Downloaded heapless v0.7.17
  Downloaded pin-project-lite v0.2.13
  Downloaded scopeguard v1.2.0
  Downloaded rustc_version v0.4.0
  Downloaded unicode-ident v1.0.12
  Downloaded ch32v-rt-macros v0.0.1
  Downloaded panic-halt v0.2.0
  Downloaded embassy-futures v0.1.1
  Downloaded syn v2.0.44
  Downloaded futures-core v0.3.30
  Downloaded embedded-hal-async v1.0.0-rc.1
  Downloaded lock_api v0.4.11
  Downloaded portable-atomic v1.6.0
  Downloaded vcell v0.1.3
  Downloaded micromath v2.1.0
  Downloaded cfg-if v1.0.0
  Downloaded display-interface v0.4.1
  Downloaded darling_macro v0.20.3
  Downloaded syn v1.0.109
  Downloaded embedded-hal v1.0.0-rc.1
  Downloaded embedded-hal v0.2.7
  Downloaded nb v0.1.3
  Downloaded az v1.2.1
  Downloaded byteorder v1.5.0
  Downloaded quote v1.0.34
  Downloaded embassy-time v0.1.5
  Downloaded embedded-io-async v0.6.1
  Downloaded embassy-executor v0.3.3
  Downloaded linked_list_allocator v0.10.5
  Downloaded semver v1.0.20
  Downloaded byte-slice-cast v0.3.5
  Downloaded nb v1.1.0
  Downloaded float-cmp v0.9.0
  Downloaded gcd v2.3.0
  Downloaded embedded-graphics v0.8.1
  Downloaded ssd1306 v0.8.4
  Downloaded critical-section v1.1.2
  Downloaded fnv v1.0.7
  Downloaded embedded-alloc v0.5.1
  Downloaded version_check v0.9.4
  Downloaded pin-utils v0.1.0
  Downloaded ch58x v0.2.0
  Downloaded proc-macro2 v1.0.73
  Downloaded embedded-graphics-core v0.4.0
  Downloaded strsim v0.10.0
  Downloaded proc-macro-error v1.0.4
  Downloaded ident_case v1.0.1
  Downloaded darling_core v0.20.3
  Downloaded ch32v-rt v0.0.2
  Downloaded riscv v0.10.1
  Downloaded bit_field v0.10.2
  Downloaded futures-util v0.3.30
  Downloaded qingke v0.1.5
  Downloaded embassy-macros v0.2.1
  Downloaded proc-macro-error-attr v1.0.4
  Downloaded void v1.0.2
  Downloaded num-traits v0.2.17
  Downloaded stable_deref_trait v1.2.0
  Downloaded futures-task v0.3.30
  Downloaded fugit v0.3.7
  Downloaded darling v0.20.3
  Downloaded spin v0.9.8
  Downloaded 69 crates (4.8 MB) in 12.80s (largest was `embedded-graphics` at 2.
5 MB)
   Compiling nb v1.1.0
   Compiling void v1.0.2
error[E0463]: can't find crate for `core`
  |
  = note: the `riscv32imac-unknown-none-elf` target may not be installed
  = help: consider downloading the target with `rustup target add riscv32imac-un
known-none-elf`

error[E0463]: can't find crate for `compiler_builtins`

error[E0463]: can't find crate for `core`
  --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\void
-1.0.2\src\lib.rs:16:5
   |
16 |     extern crate core;
   |     ^^^^^^^^^^^^^^^^^^ can't find crate
   |
   = note: the `riscv32imac-unknown-none-elf` target may not be installed
   = help: consider downloading the target with `rustup target add riscv32imac-u
nknown-none-elf`

error: cannot find attribute `derive` in this scope
  --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\void
-1.0.2\src\lib.rs:28:3
   |
28 | #[derive(Copy)]
   |   ^^^^^^

error[E0463]: can't find crate for `core`
   --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\nb-
1.1.0\src\lib.rs:192:5
    |
192 | use core::fmt;
    |     ^^^^ can't find crate
    |
    = note: the `riscv32imac-unknown-none-elf` target may not be installed
    = help: consider downloading the target with `rustup target add riscv32imac-
unknown-none-elf`

error: cannot find attribute `derive` in this scope
   --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\nb-
1.1.0\src\lib.rs:201:3
    |
201 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
    |   ^^^^^^

error[E0405]: cannot find trait `Clone` in this scope
  --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\void
-1.0.2\src\lib.rs:31:6
   |
31 | impl Clone for Void {
   |      ^^^^^ not found in this scope

error[E0412]: cannot find type `Option` in this scope
  --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\void
-1.0.2\src\lib.rs:56:37
   |
56 |     fn partial_cmp(&self, _: &T) -> Option<cmp::Ordering> {
   |                                     ^^^^^^ not found in this scope

error[E0405]: cannot find trait `Sized` in this scope
  --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\void
-1.0.2\src\lib.rs:85:29
   |
85 | pub trait ResultVoidExt<T>: Sized {
   |                             ^^^^^ not found in this scope

error[E0412]: cannot find type `Result` in this scope
  --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\void
-1.0.2\src\lib.rs:90:30
   |
90 | impl<T> ResultVoidExt<T> for Result<T, Void> {
   |                              ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Ok` in this scope
  --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\void
-1.0.2\src\lib.rs:97:13
   |
97 |             Ok(val) => val,
   |             ^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Err` in this scope
  --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\void
-1.0.2\src\lib.rs:98:13
   |
98 |             Err(e) => unreachable(e)
   |             ^^^ not found in this scope

error[E0405]: cannot find trait `Sized` in this scope
   --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\voi
d-1.0.2\src\lib.rs:104:32
    |
104 | pub trait ResultVoidErrExt<E>: Sized {
    |                                ^^^^^ not found in this scope

error[E0412]: cannot find type `Result` in this scope
   --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\voi
d-1.0.2\src\lib.rs:109:33
    |
109 | impl<E> ResultVoidErrExt<E> for Result<Void, E> {
    |                                 ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Ok` in this scope
   --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\voi
d-1.0.2\src\lib.rs:116:13
    |
116 |             Ok(v) => unreachable(v),
    |             ^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Err` in this scope
   --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\voi
d-1.0.2\src\lib.rs:117:13
    |
117 |             Err(e) => e
    |             ^^^ not found in this scope

Some errors have detailed explanations: E0405, E0412, E0463, E0531.
For more information about an error, try `rustc --explain E0405`.
error[E0463]: can't find crate for `core`
   --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\nb-
1.1.0\src\lib.rs:195:27
    |
195 | pub type Result<T, E> = ::core::result::Result<T, Error<E>>;
    |                           ^^^^ can't find crate
    |
    = note: the `riscv32imac-unknown-none-elf` target may not be installed
    = help: consider downloading the target with `rustup target add riscv32imac-
unknown-none-elf`

error[E0405]: cannot find trait `FnOnce` in this scope
   --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\nb-
1.1.0\src\lib.rs:239:12
    |
239 |         F: FnOnce(E) -> T,
    |            ^^^^^^ not found in this scope

error[E0405]: cannot find trait `From` in this scope
   --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\nb-
1.1.0\src\lib.rs:248:9
    |
248 | impl<E> From<E> for Error<E> {
    |         ^^^^ not found in this scope

error: could not compile `void` (lib) due to 14 previous errors
warning: build failed, waiting for other jobs to finish...
Some errors have detailed explanations: E0405, E0463.
error: could not compile `nb` (lib) due to 7 previous errors

@andelf
Copy link
Contributor

andelf commented Jan 1, 2024

the riscv32imac-unknown-none-elf target may not be installed

> rustup target add riscv32imac-unknown-none-elf

@happytm
Copy link
Author

happytm commented Jan 1, 2024

I tried "hello world and seems like rust setup works fine.
I am missing something but not able to figure out.

Thanks.

Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\ebhynes>cd hello

C:\Users\ebhynes\hello>cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target\debug\hello.exe`
Hello, world!

C:\Users\ebhynes\hello>

@happytm
Copy link
Author

happytm commented Jan 1, 2024

@andelf Unfortunately, with rust standalone I dont have rustup available.

Is there any manual setting where I can add target?

Thanks.

This is the installation I have:


The official Rust standalone installers contain a single release of Rust, and are suitable for offline installation. They come in three forms: tarballs (extension .tar.gz), that work in any Unix-like environment, Windows installers (.msi), and Mac installers (.pkg). These installers come with rustc, cargo, rustdoc, the standard library, and the standard documentation, 
but do not provide access to additional cross-targets like rustup does.

The most common reasons to use these are:

Offline installation
Prefering a more platform-integrated, graphical installer on Windows
Each of these binaries is signed with the [Rust signing key](https://static.rust-lang.org/rust-key.gpg.ascii), which is [available on keybase.io](https://keybase.io/rust), by the Rust build infrastructure, with [GPG](https://gnupg.org/). In the tables below, the .asc files are the signatures.

@andelf
Copy link
Contributor

andelf commented Jan 1, 2024

https://rustup.rs/

@happytm
Copy link
Author

happytm commented Jan 1, 2024

@andelf Seems like I am getting closer.
Thank you for your patience and help.

I get fewer errors now:

Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\ebhynes>cd hello

C:\Users\ebhynes\hello>cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.57s
     Running `target\debug\hello.exe`
Hello, world!

C:\Users\ebhynes\hello> rustup target add riscv32imac-unknown-none-elf
info: downloading component 'rust-std' for 'riscv32imac-unknown-none-elf'
info: installing component 'rust-std' for 'riscv32imac-unknown-none-elf'
  8.4 MiB /   8.4 MiB (100 %)   3.7 MiB/s in  2s ETA:  0s

C:\Users\ebhynes\hello>cd hellocd..
The system cannot find the path specified.

C:\Users\ebhynes\hello>cd..

C:\Users\ebhynes>cd CH582F

C:\Users\ebhynes\CH582F>cargo build --example blinky
   Compiling nb v1.1.0
   Compiling void v1.0.2
   Compiling nb v0.1.3
   Compiling embedded-hal v0.2.7
   Compiling byteorder v1.5.0
   Compiling semver v1.0.20
   Compiling critical-section v1.1.2
   Compiling proc-macro-error-attr v1.0.4
   Compiling rustc_version v0.4.0
   Compiling embassy-time v0.1.5
   Compiling syn v1.0.109
   Compiling heapless v0.7.17
   Compiling hash32 v0.2.1
   Compiling proc-macro-error v1.0.4
   Compiling syn v2.0.44
   Compiling embedded-hal v1.0.0-rc.1
   Compiling pin-project-lite v0.2.13
   Compiling fnv v1.0.7
   Compiling autocfg v1.1.0
   Compiling futures-core v0.3.30
   Compiling pin-utils v0.1.0
   Compiling az v1.2.1
   Compiling futures-task v0.3.30
   Compiling riscv v0.10.1
   Compiling strsim v0.10.0
   Compiling ident_case v1.0.1
   Compiling stable_deref_trait v1.2.0
   Compiling darling_core v0.20.3
   Compiling futures-util v0.3.30
   Compiling num-traits v0.2.17
   Compiling cfg-if v1.0.0
   Compiling embedded-io-async v0.6.1
   Compiling bit_field v0.10.2
   Compiling darling_macro v0.20.3
   Compiling embedded-hal-async v1.0.0-rc.1
error[E0554]: `#![feature]` may not be used on the stable release channel
 --> C:\Users\ebhynes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\embed
ded-hal-async-1.0.0-rc.1\src\lib.rs:4:1
  |
4 | #![feature(async_fn_in_trait, impl_trait_projections)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the attr
ibute
  |
  = help: the feature `impl_trait_projections` has been stable since `1.74.0` an
d no longer requires an attribute to enable
  = help: the feature `impl_trait_projections` has been stable since `1.74.0` an
d no longer requires an attribute to enable

For more information about this error, try `rustc --explain E0554`.
error: could not compile `embedded-hal-async` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...

C:\Users\ebhynes\CH582F>

@andelf
Copy link
Contributor

andelf commented Jan 1, 2024

That's a common error, use rustup default nightly to use the nightly release.

@andelf andelf added the question Further information is requested label Jan 1, 2024
@happytm
Copy link
Author

happytm commented Jan 1, 2024

Finally. It compiled with some warnings.

Thank you so much for your help.

Now how can I download compiled Hex file using USB interface to above mentioned development board?

@andelf
Copy link
Contributor

andelf commented Jan 1, 2024

@happytm
Copy link
Author

happytm commented Jan 1, 2024

@andelf I will take a look.

Thanks.

@happytm
Copy link
Author

happytm commented Jan 2, 2024

@andelf Pardon my ignorance. I was able to compile "brodcaster" example with your help.

I have WeActstudio ch582f board with built in USB port.
I need to flash the compiled "broadcaster" code from my windows 7 machine to this board but do not know how to do it.

I have installed official WCHISP tool on my computer. Usually , With Mounriver studio it creates *.hex file and I download this *.hex file using USB port on my board and WCHISP tool.

Can you give me step by step instructions please?

Thanks.

@andelf
Copy link
Contributor

andelf commented Jan 3, 2024

I have a WeActStudio CH582F too. It's the primary board I used to develop ch58x-hal. 😄

You need to locate the objcopy tool to convert ELF to bin or ihex(.hex) files.
You can use the objcopy bundled with Rust's llvm-tools.

> rustup component add llvm-tools
Then you will have `cargo objcopy` available

> cargo objcopy --release --example blinky -- -O binary blinky.bin
This generates the binary firmware

> cargo objcopy --release --example blinky -- -O ihex blinky.hex
This generates the .hex file for WCHISPTool

@happytm
Copy link
Author

happytm commented Jan 3, 2024

@andelf Thank you. I get following message:

info: component 'llvm-tools' for target 'x86_64-pc-windows-gnu' is up to date

C:\Users\ebhynes\CH582F>cargo objcopy --release --example blinky -- -O ihex blin
ky.hex
error: no such command: `objcopy`

        View all installed commands with `cargo --list`
        Find a package to install `objcopy` with `cargo search cargo-objcopy`

@happytm
Copy link
Author

happytm commented Jan 3, 2024

C:\Users\ebhynes\CH582F>cargo search cargo-objcopy
thingy-91-nrf9160-bsp = "0.1.0" # BSP for the Nordic Thingy:91 nRF9160

C:\Users\ebhynes\CH582F>

@andelf
Copy link
Contributor

andelf commented Jan 3, 2024

Try this:

$ cargo install cargo-binutils

$ rustup component add llvm-tools

https://github.com/rust-embedded/cargo-binutils

@happytm
Copy link
Author

happytm commented Jan 3, 2024

@andelf It did a trick. I got blinky.hex file.

Thank you so much for helping me setup end to end environment for Rust embedded.

Now is time to play with all your great code for this amazing little chip . I will sleep better. Goodnight.

@happytm
Copy link
Author

happytm commented Jan 3, 2024

@andelf

I will leave this instructions here for future user of this repository using windows 7 machine:


 1. Download Rust installer from here https://rustup.rs/
 2. Use option 2 and enter default host triple as "x86_64-pc-windows-gnu" and use enter key for all other options.
 3. Now use option 1 to proceed with installation(default). This will use default host triple "x86_64-pc-windows-gnu".
 4. Now use following 3 commands in project root directory:
          cargo install cargo-binutils
          rustup component add llvm-tools
          cargo objcopy --release --example blinky -- -O ihex blinky.hex

 5. Use official WCHISP tool from WCH to flash *.hex file. Tool can be downloaded from here https://www.wch-ic.com/downloads/WCHISPTool_Setup_exe.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants