David-OConnor / stm32-hal

This library provides access to STM32 peripherals in Rust.
MIT License
147 stars 44 forks source link

G0B1 support #68

Open adamt55 opened 1 year ago

adamt55 commented 1 year ago

Should only be compiled with this PAC, which I am currently trying to merge.

David-OConnor commented 1 year ago

Btw, I made some pretty big DMA code changes over the past week (Just published in new version), so this PR may need some adjustments after the PAC issues are sorted.

(Hopefully no special code will be needed depending on how the PAC changes resolve? Ie ideally they have the same API as other G0 variants?)

adamt55 commented 1 year ago

Alright, the HAL compiles now, but unfortunately the G0B1 chip is also not yet supported on the probe-run project so I couldn't try the quickstart out yet :/ Could we keep this PR open until this is resolved? Not sure you want to merge something which hasn't been tested on hardware yet.

David-OConnor commented 1 year ago

Yes; this stays open. Are you able to make it work by selecting a diff target in probe-run? I've been able to do that in the past. We can still merge without hardware testing.

Great work.

Would you prefer a merge now, or after testing?

adamt55 commented 1 year ago

Hey again, sorry for the delay, lot of stuff going on in real-life. If merging now without hardware testing is fine with you I would prefer it. I have tried running probe-run with a different target, but unfortunately I can't get that to work :smile: the probe-rs project already has g0b1 support on their dev-branch but havent released yet, and compiling probe-run with the dev-branch of probe-rs opens up different issues as well. As soon as probe-run releases, I will try testing again and see if anything breaks.

David-OConnor commented 1 year ago

Sweet. I think I broke it with significant DMA changes. Will figure out how to resolve conflicts.

sspain commented 1 year ago

Sweet. I think I broke it with significant DMA changes. Will figure out how to resolve conflicts.

I tried to target a WB55RG this past weekend and was faced with a bunch of DMA-related errors, ostensibly due to some microcontrollers having two DMA peripherals. I'm just dipping my toe into Rust waters, so I'm not ready with a fix, but I'm looking at it myself. Below is the compiler output from my compilation attempt:

   Compiling stm32-hal2 v1.5.5
error[E0271]: type mismatch resolving `<&stm32wb::stm32wb55::dma2::RegisterBlock as Deref>::Target == stm32wb::stm32wb55::dma1::RegisterBlock`
    --> .../.cargo/registry/src/github.com-1ecc6299db9ec823/stm32-hal2-1.5.5/src/dma.rs:1532:27
     |
1532 |             stop_internal(&mut regs, channel);
     |             ------------- ^^^^^^^^^ expected struct `stm32wb::stm32wb55::dma1::RegisterBlock`, found struct `stm32wb::stm32wb55::dma2::RegisterBlock`
     |             |
     |             required by a bound introduced by this call
     |
note: required by a bound in `stop_internal`
    --> .../.cargo/registry/src/github.com-1ecc6299db9ec823/stm32-hal2-1.5.5/src/dma.rs:1380:14
     |
1378 | fn stop_internal<D>(regs: &mut D, channel: DmaChannel)
     |    ------------- required by a bound in this
1379 | where
1380 |     D: Deref<Target = dma1::RegisterBlock>,
     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `stop_internal`

.
.
.

Some errors have detailed explanations: E0271, E0599.
For more information about an error, try `rustc --explain E0271`.
error: could not compile `stm32-hal2` due to 19 previous errors

I plan to dig around a bit, and if I can figure out how to compile, I'll happily contribute a PR. (Again, I'm just starting with Rust, so we'll see what success I have.)

David-OConnor commented 1 year ago

This is due to my DMA changes; the Github repo is currently broken on WB due to this; I need to fix this before WB55 compiles again.

David-OConnor commented 1 year ago

OK, should now work.

sspain commented 1 year ago

That clinches it: You're about 62 or 63 kinds of awesome! Thank you for the quick turn on that, I look forward to continuing my exploration of Rust courtesy your help.