-
Notifications
You must be signed in to change notification settings - Fork 2
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
Problems following the readme #1
Comments
Thanks for the feedback, and sorry I didn't notice it for so long. I'm going to change this project back to using the riscv32imac-unknown-none-elf target until I can get cargo-blflash updated with the correct target. |
I've committed the necessary changes to get everything working properly again. Anyway - If you get a chance to test this, I'd appreciate hearing how it goes. |
First of all thanks for this - it's the only example I could find that doesn't use JTAG (and I don't own an JTAG adapter currently - just ordered one) I tried this with a DT-BL10 but unfortunately I get the same results as the thread-opener. I can built and flash it (with blflash) but nothing happens on the GPIO or on the serial port. I tried the C samples from the Pine64 port of the original C SDK and those work fine. I tried a recent Rust nightly and the current stable one - always the same. I have really no idea what is going wrong for me. If you have any idea or did anything special I'd be happy to try that. Beside that I'm waiting for my JTAG adapter and maybe that might help me to investigate this |
That's no good, but thanks for speaking up. |
I tried it on Windows 10. On OSX I cannot get blflash to work but since I'm sure blflash is working fine I will try to flash the binary built on OSX via my Windows box. I can also try WSL/Ubuntu later today |
Quick update: I was able to test the binary built on OSX with the same results unfortunately |
I've bumped the hal dependency as that was causing some build issues. |
Thanks for all your efforts. The serial stuff is still not working for me - it apparently crashes quite early - so I removed everything from So I finally managed to get Blinky working - I guess I can work my way from that now. Again - thanks a lot for your support on this - it's been a long time since I was so much happy about a blinking LED |
Glad to hear you got something going! |
I'll keep you posted when I find out something - probably the JTAG adapter I ordered will improve my debug experience a lot from a simple first test it seems to crash as early as it executes this let clocks = Strict::new()
.use_pll(40_000_000u32.Hz())
.sys_clk(SysclkFreq::Pll160Mhz)
.uart_clk(UART_PLL_FREQ.Hz())
.freeze(&mut parts.clk_cfg); |
Update: Big step forward! As soon as I change .sys_clk(SysclkFreq::Pll160Mhz) to .sys_clk(SysclkFreq::Rc32Mhz) it works ... using any of the |
Yeah, so it's likely that it's in the clock init code I wrote. I could change it so that the clocks are only reconfigured if they're not already correct - since the ROM bootloader will init the external oscillator and PLL based on the config values (40mhz external, 160mhz PLL). We'll want to have better clock control for low power modes though. Having a path where it does nothing will only make it more surprising when it fails. |
Could you upload a release and a debug build with the code as it is in the repo? |
Really strange it works for you but not for me - I attached the generated binaries for debug and release here. Hope it helps |
Practically the same as my binaries, works on my board We've got a matrix chat room specifically for Rust on BL602 at https://app.element.io/#/room/#bl602-rust:matrix.org |
I was able to track my problem down to the call to I also ordered a couple more BL602 modules since it seems like a problem specific to this board - while it would be certainly good to figure out how to fix it for this board since it might not be the only chip with this problem. But unfortunately those modules will take a long time to get delivered I also hope that Rust on BL602 will attract a lot of devs - it's really nice and there is hope to have blob free Wifi and BLE support some day if Pine's NutCracker challenge is successful - and even with some blobs it would be awesome |
The most likely cause is hbn_set_root_clk_sel_pll() in that function, which switches the core clock to use the PLL.
So really, the best options in front of me are
I did actually try the load-to-ram option, but riscv-rt doesn't appear to do static initialization correctly, so it just breaks :( |
I guess I understand it so far and I also think moving that function to RAM would be the best option. I also tried to use a function in RAM and it doesn't work for me, too. Seems that https://github.com/rust-embedded/riscv-rt/blob/47ece5f5163a2e38ce5e4685b5d3145713d7954a/src/lib.rs#L382 doesn't work Indeed at runtime I see that a RAM function has an address in RAM but at that address it's all zero. Also global I tried to make sense of this and tried to look at the value of |
Oh - _sidata is a pointer not an address - so the value looks fine - still don't know what is going wrong there |
Ok so ...
Do you know if there is some kind of MMU on this chip which needs to be configured to make ITCM writable? |
Now I found the original problem running the code on my board: https://github.com/sipeed/bl602-hal/blob/6d2209b14d95badd3e0116cc3a2f56f03e20aad3/src/clock.rs#L476 No matter how long I delay and how high I set the Tomorrow I will look into the C examples and see if they actually configure the clock and if they do I will check if and why it is working on my board. |
Chip doesn't have an MMU, and ITCM is just regular SRAM that can be used by one of the flash caching units, so it should be writable. With regard to static data init: |
Ok I guess this proves that I got an faulty cursed chip. I can write parts of ITCM but not the lower 16k ... together with the other problems I was facing I will have to wait until my orders arrive. Thanks for your support and sorry for the noise. Being able to use probe-rs would be awesome by the way. |
I'm having a similar problem as the OP.
fails with I downloaded Where must I copy the compiled I'm using a BL10 board with rustc 1.54.0-nightly (4de757209 2021-05-01) under macOS 10.13.6 |
You need to install cargo-blflash to be able to run |
Thank you for the reply
|
Yeah, there was a clash with the name BITS earlier in the year, it took some time to resolve |
I cloned blflash and did a I executed and got the LED blinking with serial output :-) |
fixes issue which happens here 9names/bl602-rust-example#1 (comment)
fixes issue which happens here 9names/bl602-rust-example#1 (comment)
When following the readme I can not program the bl602.
cargo blflash --port /dev/ttyUSB0
ends up in a bunch ofrust-lld: error: undefined symbol: <something>
. I suspect I might not have something installed which is required for building there.Output
Compiling bl602-rust-example v0.1.0 (/home/edjopato/git/pine/bl602-rust-example) error: linking with `rust-lld` failed: exit code: 1 | = note: "rust-lld" "-flavor" "gnu" "-L" "/home/edjopato/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.19rzuhug5jgffkt4.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.1bagfflw3iymmsl1.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.1c2xza23b52988e1.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.1s82tq9z5yffh9w3.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.1umrxqjyuwpb9tmu.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.212u42na95mlm36j.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.2e7hgu7twroaveb1.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.2m989adu15p6i8fc.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.2t1pty9y7i51cega.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.3g56zditx5qedan.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.3vzvdip2stbq37g7.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.41pzrc0lmerfsgqr.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.483xdn0c5fkd3w3r.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.4ayc8jyioig2cl8r.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.4j1pfyaprjqod1nd.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.4ko2iqxfc87akhct.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.4rt7c5zsld64czhl.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.52s0f98d4bsyla2t.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.55hteh3izcd0w6yx.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.9m4mtrr4234z9w4.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.c9dtk4c6kzopwy6.rcgu.o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09.mpv7t0ckrh72903.rcgu.o" "-o" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/bl602_rust_example-2c5807f90e5d5a09" "--gc-sections" "-L" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps" "-L" "/home/edjopato/git/pine/bl602-rust-example/target/debug/deps" "-L" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/build/bl602-rust-example-7e85585145c875d2/out" "-L" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/build/riscv-9417f4984cfd2398/out" "-L" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/build/riscv-rt-eb206a37a3506ab2/out" "-L" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/build/riscv-rt-eb206a37a3506ab2/out" "-L" "/home/edjopato/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib" "-Bstatic" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libriscv_rt-f894b1c28319eca3.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libr0-3bddc3009785bc51.rlib" "--start-group" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libpanic_halt-6c25fb084d56260a.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libbl602_hal-e05e5cf62ac57337.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libembedded_time-c01ec075b066ef34.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libnum-5fa3ed64c096ec6d.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libnum_iter-7f4ac91d196edd92.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libnum_rational-911f7e942a3425aa.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libnum_integer-c371862d9a657de6.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libnum_complex-f197e1bdbb85422a.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libnum_traits-25f41c1789ee1297.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libembedded_hal-ad33db3098802071.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libnb-d18bf94afae8128e.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libbl602_pac-ed9cda13cfd47903.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libriscv-fc8e3be9fc8cc1b5.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libbit_field-e2bcb677dea1b3b8.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libbare_metal-08115285c3d30b9f.rlib" "/home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libvcell-20d459121750863b.rlib" "/home/edjopato/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib/librustc_std_workspace_core-62f575e3ae6178b4.rlib" "/home/edjopato/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib/libcore-4c7d2a9096081455.rlib" "--end-group" "/home/edjopato/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib/libcompiler_builtins-d5745c1f152f4617.rlib" "-Bdynamic" = note: rust-lld: error: undefined symbol: _max_hart_id >>> referenced by asm.S:55 >>> riscv-rt.o:(.init+0x5A) in archive /home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libriscv_rt-f894b1c28319eca3.rlib >>> referenced by asm.S:55 >>> riscv-rt.o:(.init+0x5E) in archive /home/edjopato/git/pine/bl602-rust-example/target/riscv32imac-unknown-none-elf/debug/deps/libriscv_rt-f894b1c28319eca3.rlib
error: aborting due to previous error
error: could not compile
bl602-rust-example
To learn more, run the command again with --verbose.
When I use
cargo build
everything works. Which is interesting to me.Switching runner in
.cargo/config.toml
torunner = "blflash flash --port /dev/ttyUSB0"
I can simply usecargo run
.(Currently openocd is still mentioned in the runner, this might be something overlooked when creating this example?)
Programming the BL602 that way works fine according to blflash.
Then opening minicom or other serial port thingies do not result in any activity (Pressed EN / Reset multiple times).
Any ideas what might be wrong here and how to improve the example to get these problems out of the way for others? And thanks for the example showcasing the bl602-hal usage!
The text was updated successfully, but these errors were encountered: