-
Notifications
You must be signed in to change notification settings - Fork 76
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
unresolved import core::sync::atomic::AtomicPtr
#109
Comments
That would be because AVR doesn't have atomic types (of that size), so the standard library does not implement them. Using atomic-polyfill would be an option these days, without changing the rest of the architecture. |
Ahhh right. I presume that would just be a matter of forking usb-device and replacing I'll try it out later today, thanks! I wonder then if it would be worth providing a feature in usb-device, which does this. |
I've also seen this, which mentions atomics on AVR: https://crates.io/crates/portable-atomic |
That crate looks like it does a similar thing. As far as I know both of these are supposed to be drop-in replacements for platforms with atomics, and only require extra configuration on platforms that do not support atomics, so a feature might not even be necessary. |
As I was implementing it, I noticed the same thing and was about to type exactly what you said. I might format this as a PR once I've confirmed it working. |
Ok that's compiled. In order to test I'm going to have to finish writing my usb device test code. Hopefully shouldn't take too long. My usb-device branch with polyfill alteration can be found here: https://github.com/alexmadeathing/usb-device/tree/atomic-polyfill |
It seems I should also be able to set the |
Ok that's what I'm going with. I'll be deleting my fork and I'll close this issue. |
@alexmadeathing Isn't that for native atomics? Does AVR actually have atomic instructions? Or does it pull in the clang builtins that the rest of Rust seems to avoid? |
I don't know tbh. I guessed that if it compiled, there's probably a working intrinsic implementation. The atmega32u4 datasheet has example code for how to implement them and I've seen chat on the Rust project mentioning avr atomics, but I couldn't find anything definitive that suggests how they've implemented them. I'm slightly out of my depth though as this is my first rust embedded project. From the datasheet section 14.2, it seems there are no atomics at the instruction level, but they provide this example implementation: TIM16_ReadTCNTn:
; Save global interrupt flag
in r18,SREG
; Disable interrupts
cli
; Read TCNTn into r17:r16
in r16,TCNTnL
in r17,TCNTnH
; Restore global interrupt flag
out SREG,r18
ret |
I'm getting the following error when compiling for
atmega32u4
. Any ideas?The text was updated successfully, but these errors were encountered: