atmega: refactor cpu/board code and build/flash variables#9130
atmega: refactor cpu/board code and build/flash variables#9130ZetaR60 merged 6 commits intoRIOT-OS:masterfrom
Conversation
|
@Josar I'm not sure if you included arduino-common because you really need it or just to import toolchain and flasher requirements. Can you confirm? |
|
Thanks for picking this up @kYc0o. Is it possible to split this PR into 2 (or more) PR's? One with the makefile refactor and one with the cpu code refactor? |
| @@ -28,6 +33,17 @@ | |||
| #define ENABLE_DEBUG (0) | |||
There was a problem hiding this comment.
#include <avr/pgmspace.h>
#include "cpu.h"
missing new line?
fd5cc94 to
2720b68
Compare
|
Update on this:
@Josar or @shr70, can you test on jiminy if everything still works? Especially flashing. @bergzand, I don't mind to decompose this PR in several, but if someone here can review it as is, it would be more practical. |
|
@kYc0o flashing seems to work. May i ask you to also change this depency to arduino? I would suggest just add all |
I like! |
|
Another update, and I think I'm triggering a more larger discussion. Currently, atmega based boards are "forced" to import the CPU features from arduino-atmega/Makefile.features, which in my opinion doesn't make sense since 3 atmega based I moved the features to cpu/atmega_common/Makefile.features where I thing they suit better, actually they are implemented in the same tree, which IMHO it's clear to understand why the features are defined there as well. Finally, I left the arduino feature where I think it belongs, arduino-atmega/Makefile.features. If nobody objects, I'd propose to start a "cleanup" in the future of these definitions, since currently every single board define features which are implemented at the cpu level. Additionally, I removed the grouping needed previously by the CI, and if I'm not mistaken, Murdock doesn't need it anymore (@kaspar030 please correct me if I'm wrong). |
ZetaR60
left a comment
There was a problem hiding this comment.
I like the refactor! Did a proofread with some suggested changes, and also noted where behavior has changed.
This currently does not work on mega-xplained, due to problems with PROGRAMMER_SPEED.
Some features depend on cpu support and board configuration (periph_conf.h). That's why e.g., periph_uart is usually in a board's Makefile.features, even though the CPU provides the underlying implementation. |
|
I think @bergzand is right, this PR is getting very large. Difficult to spot problems. |
|
I'm not sure about moving Makefile.features entries to a common area. How do you handle, for instance, a board that has all of the ADC pins connected to LED outputs? That board would not provide ADC support, even though the CPU supports it. EDIT: kaspar030 was just slightly faster than me on this comment. ;) |
|
My logic behind the features is that they might be provided by the CPU, but might not be used by the board. I think it's manageable to make a difference between both and express it in the code. Actually, shouldn't my change break some compiles? I was experimenting with the change expecting Murdock to complain about it. |
|
What's next then on this PR? Should I squash to try a split in different PRs? What about the features? Should they stay at the board level or at the CPU level? |
|
tested with arduino Uno/Duemilanove boards 👍 |
|
@mali thanks for testing! Any thoughts about the overall cleanup? |
|
@kYc0o I haven't looked in details, but looks cleaner and more logical in general and well ... +215 -843 :-) I've also noticed that some .hex are a little smaller than before, while others are little bigger, but we talk about an handful of bytes... |
511c742 to
02cfde4
Compare
smlng
left a comment
There was a problem hiding this comment.
minor (but blocking) issue ... otherwise looks good, tested with meg2560
makefiles/arch/atmega.inc.mk
Outdated
| endif | ||
|
|
||
| # the atmel port uses uart_stdio | ||
| USEMODULE += uart_stdio |
There was a problem hiding this comment.
typo: this is actually named stdio_uart
There was a problem hiding this comment.
The module was actually renamed in d55616a7f56ca17440 (so after this PR was opened) so not sure this really is a typo ;-)
There was a problem hiding this comment.
You're both right, it's not a typo but it should be renamed. Thanks for spotting this!
I'll update asap.
|
to me this is good, please squash and rebase on latest master (had an issue which was solved in master while testing) |
f6e20b0 to
c31f65f
Compare
|
I guess #7306 needs another rework if this is merged? |
|
please rebase |
|
Sorry for the delay. The issues from my review seem to be resolved. Once it is rebased I will test on mega-xplained and arduino-uno. |
|
@kYc0o: ping |
Allows to use avrdude as a flashing tool in any context (e.g. not dependent on arduino or atmega) though it only works (AFAIK) on atmega, but I thought it's better to have it here as we have other flashing tools.
Everything is now defined in atmega.inc.mk, following the common RIOT-like reusability of rules and variables (e.g. cortexm.inc.mk).
Leverages common flasher (avrdude) and removes unnecessary exports. Moreover, a reuse of serial.inc.mk is perfomed from the same atmega_common/Makefile.include
Additionally, it removes unnecessary exports and cleans up waspmote-pro toolchain variables (not needed) which are taken from atmega_common.
Features must be provided by the board if they're actually available on board. Other features might be provided by the CPU. Some grouping is also removed as it is not necessary.
c31f65f to
7139393
Compare
|
Rebased. |
|
@ZetaR60: ping (Sorry for making all the fuzz. I waiting for this PR to get merged in order to move two existing PRs forward and create a third on. Normally I'm less annoying ;-)) |
|
Final double-check on mega-xplained looks good. Thanks for the cleanup @kYc0o ! |
|
Thanks everyone for your review! 🎉 |
Contribution description
This PR proposes a refactor of the atmega based boards to match the code reuse done in other architectures. In summary:
I hope I factored out as much as possible, if you find something else that can be reused please let me know.
Issues/PRs references
Fixes #9001