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

Recommend defining standardized MCU and CPU identification macros in platform specification #988

Open
trlafleur opened this issue Jul 12, 2020 · 3 comments
Labels
topic: build-process Related to the sketch build process topic: documentation Related to documentation for the project type: enhancement Proposed improvement

Comments

@trlafleur
Copy link

The IDE, using the variant.h file knows what CPU the user has selected and then can make a decision on the proper flags to invoke to build the project...

On the compile line is uses the "-mcpu" to define the CPU family to use. "-mcpu=cortex-m4".
This information should ALSO be added as a "-D" flag, to give a consistent format for the user to determine the processor class he is using at run time. -Dcortex-m4

Also as the IDE knows the exact processor it using, it should also be added as a -D flag.
-D__SAMD51G19A__

In reviewing a number of variant.h file, it's very inconsistent from manufacturer to manufacturer on what -D flags are included.

Doing this would add a very consistent format that code developers could depend on...

@matthijskooijman
Copy link
Collaborator

On AVR, I believe gcc defines such a value based on the -mmcu=... option. I think for ARM gcc, this does not happen, so indeed Arduino/core/variants/something needs to handle that externally.

In reviewing a number of variant.h file, it's very inconsistent from manufacturer to manufacturer on what -D flags are included.

Do you mean variants within the same Arduino core? Or from core to core?

I guess that such defines are by definition not portable between architectures (processor families), and thus are essentially a core-specific API (i.e. from the core to the sketch). OTOH, when there are multiple cores for the same processor families (e.g. the Arduino and Adafruit SAMD cores), it would be useful if these defines would be consistent.

This might be something to add a recommendation for in the core documentation (part of arduino-cli). If so, this issue might be better moved to the arduino-cli repo?

@trlafleur
Copy link
Author

I stopped using 8bit processors a few years back, so my search of the variant.h files were ADAfruit, Arduino, STMicro, ESP32, and Teensy 32 bit, processors...

I also cross-posted this on Arduino-Pro Github site

@per1234 per1234 changed the title GCC complie time options Define macros to identify MCU and CPU Aug 1, 2020
@per1234 per1234 transferred this issue from arduino/Arduino Sep 28, 2020
@per1234 per1234 changed the title Define macros to identify MCU and CPU Recommend defining standardized MCU and CPU identification macros in platform specification Sep 28, 2020
@per1234
Copy link
Contributor

per1234 commented Sep 28, 2020

Related to #985

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: build-process Related to the sketch build process topic: documentation Related to documentation for the project type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

4 participants