Skip to content
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

Consolidation of AVR pin headers (AVR pin names) #25361

Closed

Conversation

quiret
Copy link
Contributor

@quiret quiret commented Feb 9, 2023

Description

Now that the AVR platform is not expected to grow any further it is a good idea to discuss consolidation for good support into the future. The biggest problem for support continuation are the AVR board definitions in combination with the "AVR pin peripheral conflict". Unlike more modern MCUs on the AVR the peripherals are tied to a fixed set of pins, their connection being always enabled, thus being a troublesome situation with all the varying pin mappins by boards. A good way to combat this misunderstanding is to clearly specify the MCU pin name for pin mappings. It is a clarification that we are not encouraging use of random GPIO pins for stable Marlin board configurations but want people to keep the AVR realities in mind.

I welcome discussion on this proposal.

More rationale behind this PR can be extracted from the following videos:

Benefits

Improve the support situation of the AVR platform.

Related Issues

#24911 (depends on this PR)

thinkyhead and others added 6 commits December 10, 2022 11:25
- removed deprecated AVR fastio definitions
- added AVR_CHIPOSCILLATOR_FREQ AVR board definition that matches the oscillation frequency on the XTAL1/XTAL2 pins (commonly drives MCU clock)
- added board schematic links where they exist (since AVR is not an actively developed for platform anymore we can expect the set of board schematics to stay constant)
- transformed AVR pin numbers to AVR pin names for solidification, future-proofing, distinctiveness (initial version)
- fixed some conflicting pin definitions based on RAMPS and board-specific specializations
@EvilGremlin
Copy link
Contributor

EvilGremlin commented Feb 9, 2023

I'm all in for ditching of dumb arduino numbering! Just not quite what you named them, it should be exact same names as in datasheet, PA0......PL7

@quiret
Copy link
Contributor Author

quiret commented Feb 9, 2023

I'm all in for ditching of dumb arduino numbering! Just not quite what you named them, it should be exact same names as in datasheet, PA0......PL7

Sounds good that you share the vision! By the way, we cannot pick PA0 because the internal AVR toolchains clobbered those names. That is why Pin* has been chosen. No dependency framework would ever pick those names!

@EvilGremlin
Copy link
Contributor

EvilGremlin commented Feb 9, 2023

Better PortA0 then, to not imply any physical pins. Or PA_0

@quiret
Copy link
Contributor Author

quiret commented Feb 9, 2023

Better PortA0 then, to not imply any physical pins. Or PA_0

That would imply many changes to the code based on a convention change. I could do that if you would help me change the current code (can prob. be safely done using search&replace). But let's first hear out other voices on this PR. :)

@EvilGremlin
Copy link
Contributor

O_O you did all pin changes manually, not with script?

@quiret
Copy link
Contributor Author

quiret commented Feb 9, 2023

O_O you did all pin changes manually, not with script?

Yea, quite the effort... right? I mean I am that kind of guy. But I would appreciate any help on your end... Automation that is reliable.

@EvilGremlin You are right about the name choice. Sorry about picking Pin. My intention was not to include the GND, VREF, etc pins into consideration. Picking PortA0, etc would clarify that even further.

@Roxy-3D
Copy link
Member

Roxy-3D commented Feb 10, 2023

Better PortA0 then, to not imply any physical pins. Or PA_0

This nomenclature gets my vote....

@quiret
Copy link
Contributor Author

quiret commented Feb 10, 2023

This nomenclature gets my vote....

I appreciate the participation! I want all of Marlin to be comfortable with the inner workings and designs. 😁

@jmz52
Copy link
Contributor

jmz52 commented Feb 10, 2023

Not that I am fond of Arduino pins numbering, but here are tons of guides and documentation that use it.
I am not quite sure how regular will be able to find PinK3 on his MKS Gen L board.
Or how he would know that PinD3 on this pinout is actually not a D3 (X-) but D18 (Z-).
Does the improvement this renumbering provides justifies the need to create Marlin-Arduino dictionary?
MKS_Gen_L

@quiret
Copy link
Contributor Author

quiret commented Feb 10, 2023

(...) Does the improvement this renumbering provides justifies the need to create Marlin-Arduino dictionary?

I think that we have to reach out to anyone, even those who like the Arduino-style pin referencing. The image you have shown is not a schematic... Thus I do not advise to take such a reference as example.

Let me try to argue further why Marlin devs should think more clear than Arduino tinkerers. At Marlin implementation level we want to know what those numbers mean and dealing with a number system inside the firmware poses compatibility risks across AVR MCU families. The code may compile fine but is it actually correct? Having the pin names implies stronger safeguards.

Now, is the Arduino-Marlin mapping truly something new? I would point out that it is has been around since the beginning of Arduino itself. The work I have done is expose it to the Marlin firmware, more clearly, what the numbers truly mean on HW level. So I don't think that it is too much to ask to learn it if you did not care about the HW specifics before. Every professional pinout should have those alternate pin functions displayed anyway, so people have cared.. for example...

image
(https://sverige.energy/wp-content/uploads/2021/01/1611145426_606_Arduino-Mega-Pinout-Arduino-Mega-2560-Layout-Specifications.jpg)

@ellensp
Copy link
Contributor

ellensp commented Feb 16, 2023

No that is a pin diagram, that is what we get provided with by board manufactures

It uses standard Arduino A and D pin notation.

As we should.

Ie we should leave it alone,

Anything else will just add more levels of confusion, especially to those just starting out.

For better or worse Arduino A and D pin notation is the standard, we should follow it.

@quiret
Copy link
Contributor Author

quiret commented Feb 16, 2023

just add more levels of confusion

In my opinion those "levels of confusion" will be dismantled for those who matter the most, being Marlin Firmware developers. This is about removing technicalities of the past, the design decisions not changed due to being a project of volunteers. But let's hear your view.

By the way, you talking smack about MKS providing those weird "pin diagrams"... MKS has since been providing proper board schematics for their controller boards.

@ellensp
Copy link
Contributor

ellensp commented Feb 16, 2023

perhaps a system like LPC uses for analog pins

eg

#define TEMP_1_PIN                      P0_23_A0 
#define TEMP_BED_PIN                    P0_25_A2 

So both sets of information are in the define, Datasheet port name and Arduino Name

Then both sorts of user can just see the information they want to see, without having to look up any translation tables.

@quiret
Copy link
Contributor Author

quiret commented Feb 16, 2023

Then both sorts of user can just see the information they want to see, without having to look up any translation tables.

Your idea is possible in the current impl. The user can still pick. But the preference has to be set to be AVR Pin Names. Excuses are possible but should be proven that it is the definite way.

@thinkyhead thinkyhead force-pushed the bugfix-2.1.x branch 2 times, most recently from e90c213 to 4b9bb85 Compare March 7, 2023 05:17
@quiret
Copy link
Contributor Author

quiret commented Mar 23, 2023

I am sorry but I have decided to halt my activities on this PR for an indetermined amount of time. You are free to decide whether to continue it yourself. Thank you to the Marlin firmware community for providing this interesting playing ground for testing my ideas and vision. I hope that Marlin will continue to go towards the best 3D printing solution! Hopefully my ideas have inspired you on how to continue this software!

@quiret quiret closed this Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants