-
Notifications
You must be signed in to change notification settings - Fork 0
Support for different atmega controllers #1
Comments
Hi! Sorry for not responding for so long ...
Yes! Back when I was working on this project, I had the plan to do exactly that. I have some files for attiny85 as well and I wanted to merge all of this into one big atmel crate similar to the stm-rs crates. Sadly some other stuff got inbetween so I did not have time to work on this project anymore. I'd love to see it going forward though, so if you are still interested, we could devise a plan how we can make this happen. I'll just brain-dump a few things here in case you care: SVDI'd still want to continue using Crate hierarchyI think there are so little avr chips that it makes sense to stuff them all into one crate or at max into a few ( I'd then suggest writing a crate for the hal macros (like the one for port) which are then used in the device-specific hal crates to instanciate the abstractions for each device. Here I am not yet sure if we should have a crate for each device or combine those in some way as well. I've heard that some people in the stm community are not too happy with the immense amount of crates they have ... InterruptsAs you mentioned in #2, it makes sense to follow the design used in the stm crates. |
Hi, thanks for your reply! My personal goal is to have rust running fairly well on an atmega1280 by October so I can do some course work at my uni that is typically done in C in Rust, but I’d like to not create a one-off solution but grow the ecosystem while I’m at it 😊 |
To get a rough overview (I am not that deep in the AVR scene ...): Which chips do you think we will need to support? From my side, it is |
The I'm honestly not that deep in the AVR scene myself, and lately I'm using more cortex-m based chips (mainly for ease of use), but the course uses the atmega, and of course most arduino products use one. |
I guess those six chips are a good starting point, we can always expand in the future ... But as long as the numbers stay small, I'd suggest keeping everything in one crate. Now, I just compiled the latest avr-rust and unfortunately it seems there is currently a bug that prevents me from getting anything working (avr-rust/rust-legacy-fork#128). Until that is resolved, we are stuck with theoretical work I'm afraid. |
I think I still have a working avr-rust from about a month ago, I’ll check when I get home |
I have a working rust-avr install on revision |
Hmm ... That revision does not exist for me anymore when checking out Looking at the history, it is missing this patch anyway without which I won't be able to build for Anyway, I'll see if I can get some hackish solution working ... Until then, there is already quite a few other things that we can work on: Me and some friends started working on |
It's online: https://github.com/Rahix/atdf2svd 🎉 |
Neat! |
They're distributed here in the |
I'll try to get a basic version of the register-access crate running as soon as possible. This means basically writing a Makefile which calls Once this all works in a most minimal version, we can start integrating support for the different chips. I would suggest you help there if that is ok with you? |
Sounds great |
We have liftoff: https://github.com/Rahix/avr-device 🚀 |
You can also get the .atdf files here, for example to put them in a submodule: https://github.com/avr-rust/avr-mcu |
So I guess I can try adding atmega1280 support? Do I have to consider anything when it comes to the svd patching, or is that universal? |
For each chip, there is an (optional) file in _include:
- "path/to/common.yaml as you can see in the existing files. (Technically, this would even work recursively, but right now there is not much need for it ...) A lot of patching will be the names of enumerated values, which is why @octycs added functionality for that to A little trick to get a starting point for things to patch is to run # -v enables more messages
atdf2svd vendor/atmega1280.atdf /dev/null -v Oh, and don't bother trying to patch everything before submitting, I'd rather start with a basic working version and then patch things as we notice them while working with it ... |
@aykevl: That might actually be a good idea at some point! Right now we only support <10 devices so I'm ok with storing the files in our tree as well. But thanks for the link, I wasn't aware Dylan had already pushed all of them into a crate ... |
@peacememories, finally got around to merging your PR. Thanks! I have some stuff ready, regarding the HAL design, though I still want to add a few more things before publishing it. Unfortunately, I'll be gone next week, so this might take a little longer ... If you want to, you can take a look at the patching stuff that @octycs added. Maybe some of the patches in |
Thanks for merging! |
Right, I should have done this before: I added some comments so you don't have to waste time ;) |
I did a thing: https://github.com/Rahix/avr-hal Still very barebones, just digital IO works at this point. Next step for me is probably porting the PWM stuff from the old crate. |
should i just throw a barebones version of the atmega1280 in there as well? |
That would be great! And if you have a board based on atmega1280, add a crate for it as well! Right now, documentation is really lacking, but I hope that by looking at the code of the other crates you can figure out what you need to do. You'll probably be able to implement the |
It seems I have destroyed my rust-avr install^^' when trying to compile core it complains about a host of stuff:
I know that's nothing to do with the project itself, but I'm hoping you have some wisdom about how to fix this^^' |
I'm on rust-avr commit |
Okay, after a full rebuild this is getting even weirder:
|
Ah I see that's the same problem you encountered. How did you fix it? |
Right, yes ... I rolled back to a working commit, |
I'll try the rollback first. Got a few free days right now so might as well get some stuff done ;) |
Btw, I'm fine using this issue as general conversation channel, but it may make sense to move this somewhere else^^ |
Needing pyyaml for avr-hal (and probably dependents) too right now is a bit awkward, especially if you haven't installed it globally (like me for example)^^ |
Yes, that is a sideeffect of the way we currently build Once the crates go up on crates.io, this issue will no longer exist, because |
Okay, I've gotten a bit further (leonardo-blink builds), but when trying to add an atmega1280-hal and bigavr6 crate i manage to crash my compiler^^ |
this is my stack trace ^ |
Please push that somewhere, so I can take a look ... This should definitely not happen ... |
here you go: Rahix/avr-hal#1 |
So ... I can't reproduce it ... I got some macro errors, but those were easy to fix with this patch: avr.patch |
Okay, apparently killing the shell and creating a new one fixed my problems. Something went very wrong there^^ |
Btw, isn't it a bit weird to have to specify all peripheral ports when constructing Pins? |
The bigavr6 has all pins of the atmega1280 exposed, since it is a big development board. This will probably become interesting when adding drivers for the display and such. I'm not sure if it's good for the user to have to manually pipe all pins the display needs to the constructor. Okay, that's a lot of free association for one post^^ I'm just trying to wrap my head around the api choices |
I made some changes to the pr which make it mergeable, as long as you don't mind horribly incomplete |
Hmm, the points you make all have to do with basically the same underlying issue: Rust is not able to encode partial moves in function signatures. In more practical terms: struct Parts {
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5, P5,
}
struct Foo(P2, P3);
fn take_p2_and_p3(p: Parts) -> Foo {
Foo(p.p2, p.p3)
}
fn main() {
let parts = Parts { /* ... */ };
let foo = take_p2_and_p3(parts);
// Rust doesn't know that parts.{p1, p4, p5} have not been moved
let p4 = parts.p4;
} There is absolutely no way to encode the above properly. I tried writing some typesystem magic using a procedural macro once, which actually worked, but was weird to use and produced horrible error messages and even worse type signatures. So unfortunately there isn't really a way around explicitly passing all PORTs/pins/whatever without dropping the strict tracking of ownership. This means that, for now at least, you should just pass all pins individually. The aliasing not being possible boils down to the same reason, so just choose 'generic' names for pins which are used for multiple things ... |
The new compiler was released! avr-rust/rust-legacy-fork#144 🎉 |
argh, i updated and now my compiler doesn't find |
I added crude But don't look at the code too closely, it is still very messy and probably not quite correct in all cases ;) |
I also changed the cargo profiles to produce smaller binaries (up to 2x reduction for some cases!). I also made the debug-build usable, so you can test new code more quickly (with incremental & parallel codegen). Be aware that the |
Hi, and thanks for creating this useful crate; especially the svd generator.
I've started working on modifying this library so it can support the atmega1280 mcu. It will obviously need a different svd, but at the same time it will use the same kind of interrupt logic etc.
The question here is, would it not be better to move the atmega core logic out of this crate into an
atmega
crate?The text was updated successfully, but these errors were encountered: