ch32-rs / ch32v00x-hal

HAL for the CH32V003 family of microcontrollers
29 stars 11 forks source link

Blinky example: Flashing appears to work, but no action on PD6 #9

Closed Garbaz closed 3 months ago

Garbaz commented 4 months ago

Hi,

I have the CH32V00F4P6-R0-1v1 board & WCH-LinkE.

Running cargo run --release --example=blinky I get a promising output:

warning: Patch `riscv-rt v0.11.0 (https://github.com/9names/riscv-rt?branch=rv32e#963b8965)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
warning: field `clocks` is never read
  --> src/pwr.rs:21:5
   |
19 | pub struct Pwr {
   |            --- field in this struct
20 |     pwr: PWR,
21 |     clocks: Clocks,
   |     ^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: `ch32v00x-hal` (lib) generated 1 warning
    Finished `release` profile [optimized] target(s) in 0.06s
     Running `wlink -v flash --enable-sdi-print target/rv32ec/release/examples/blinky`
21:38:06 [DEBUG] (1) wlink::usb_device::libusb: Serial number: "BA3C8F063F12"
21:38:06 [INFO] Connected to WCH-Link v2.11(v31) (WCH-LinkE-CH32V305)
21:38:06 [INFO] Attached chip: CH32V003 [CH32V003F4P6] (ChipID: 0x00300500)
21:38:06 [INFO] Chip UID: cd-ab-a4-c0-11-bc-82-28
21:38:06 [INFO] Flash protected: false
21:38:06 [INFO] Read target/rv32ec/release/examples/blinky as ELF format
21:38:06 [DEBUG] (1) wlink::firmware: Found loadable segment, physical address: 0x00000000, virtual address: 0x00000000, flags: 0x5
21:38:06 [DEBUG] (1) wlink::firmware: Matching section: ".init" offset: 0x1000 size: 0x4
21:38:06 [DEBUG] (1) wlink::firmware: Section names: [".init"]
21:38:06 [DEBUG] (1) wlink::firmware: Found loadable segment, physical address: 0x00000004, virtual address: 0x00000004, flags: 0x4
21:38:06 [DEBUG] (1) wlink::firmware: Matching section: ".vector_table" offset: 0x1004 size: 0x98
21:38:06 [DEBUG] (1) wlink::firmware: Section names: [".vector_table"]
21:38:06 [DEBUG] (1) wlink::firmware: Found loadable segment, physical address: 0x0000009c, virtual address: 0x0000009c, flags: 0x5
21:38:06 [DEBUG] (1) wlink::firmware: Matching section: ".text" offset: 0x109c size: 0x266
21:38:06 [DEBUG] (1) wlink::firmware: Section names: [".text"]
21:38:06 [DEBUG] (1) wlink::firmware: Found loadable segment, physical address: 0x00000304, virtual address: 0x00000304, flags: 0x4
21:38:06 [DEBUG] (1) wlink::firmware: Matching section: ".rodata" offset: 0x1304 size: 0x3a
21:38:06 [DEBUG] (1) wlink::firmware: Section names: [".rodata"]
21:38:06 [DEBUG] (1) wlink::firmware: found 4 sections
21:38:06 [INFO] Flashing 830 bytes to 0x08000000
21:38:06 [DEBUG] (1) wlink::operations: Reattach chip
21:38:06 [DEBUG] (1) wlink::operations: Reattach chip
21:38:07 [INFO] Read protected: false
21:38:07 [DEBUG] (1) wlink::operations: Using write pack size 1024 data pack size 64
21:38:07 [DEBUG] (1) wlink::operations: Flash OP written
███████████████████████████████████████████████████████████ 830/830
21:38:07 [DEBUG] (1) wlink::operations: Fastprogram done
21:38:07 [INFO] Flash done
21:38:07 [INFO] Now reset...
21:38:07 [INFO] Now connect to the WCH-Link serial port to read SDI print

but sadly there is no action whatsoever on PD6.

Any ideas why that might be?

I should add: I have rustc nightly and wlink both up to date.

I'll next try getting a blinky example running from ch32v003fun, just to be sure that it's not my board that's the problem.

Garbaz commented 4 months ago

Flashing ch32v003fun/examples/blink/blink.bin with either wlink or minichlink neither does anything.

Next stop, the official toolchain (:shudder:)

Garbaz commented 4 months ago

Good news, using Arduino for ch32 does work. The LED blinks.

So my board is not at fault.

Flashing the bin generated by Arduino with wlink also works, so wlink isn't at fault either (probably).

I will try to figure out more tomorrow.

andelf commented 3 months ago

Thanks. This should be the same issue as #10. I had pushed a fix.

Garbaz commented 3 months ago

Awesome! Blinky now successful :)