When one selects a board within Arduino IDE, a preprocessor definition is added to one of the behind-the-scenes files.
After a lot of hunting and some good fortune I found that the format of this definition is:
#define ARDUINO_<PROCESSOR-DESCRIPTOR>_<BOARDNAME>
Some are easy to guess (ARDUINO_AVR_UNO
, for example), but others are less so. The Pro Micro has '16' or '8' appended to the definition depending on the speed. I do not know if the definition is different for 5V or 3.3V. I haven't managed to guess the definition for the Mega2560, but it isn't anything obvious.
Question 1: Is there a list in existence of the possible definitions?
Question 2: Is there any distinction, as far as compilation and preprocessor involvement is concerned, between BoardX-5V and BoardX-3.3V, and how is this distinction defined?
-
What do you need it for? It would probably be more useful to differentiate between processors (e.g. ATMega328), instead of boards.Gerben– Gerben2016年01月23日 17:12:01 +00:00Commented Jan 23, 2016 at 17:12
-
2I have a multi-node project that uses an Uno, a Leonardo and a <collective noun> of Pro Minis. The code is nearly identical for the three versions but to ease debugging I want to be able to upload (or at least compile from) the same code for everything.CharlieHanson– CharlieHanson2016年01月23日 17:16:47 +00:00Commented Jan 23, 2016 at 17:16
-
Switch on File>Preferences>Compile Verbose. Then build/verify and inspect the output. You will see the -D defines that are passed to the compiler. This makes it easy to determine the difference between your boards.Visual Micro– Visual Micro2017年04月24日 10:53:59 +00:00Commented Apr 24, 2017 at 10:53
-
Grep did not work for me as shown. Found the path by looking at the verbose compiler output. I discovered the SparkFun boards.txt file on my computer was located here: C:\Users\Jim\AppData\Local\Arduino15\staging\packages\sparkfunboards.1.1.10.tar\avr-1.1.10\boards.txtJim_SD– Jim_SD2021年11月16日 21:17:08 +00:00Commented Nov 16, 2021 at 21:17
4 Answers 4
The list of board symbols can be generated by this shell command:
$ grep board= boards.txt | cut -f2 -d= | sort -u
AVR_ADK
AVR_BT
AVR_DUEMILANOVE
AVR_ESPLORA
AVR_ETHERNET
AVR_FIO
AVR_GEMMA
AVR_LEONARDO
AVR_LILYPAD
AVR_LILYPAD_USB
AVR_MEGA
AVR_MEGA2560
AVR_MICRO
AVR_MINI
AVR_NANO
AVR_NG
AVR_PRO
AVR_ROBOT_CONTROL
AVR_ROBOT_MOTOR
AVR_UNO
AVR_YUN
The boards are defined by the "build.board" property in the boards.txt file.
mini.build.board=AVR_MINI
This property is used by the build recipe together with ARDUINO_-prefix.
-DARDUINO_{build.board}
Cheers!
-
+1, thank you for that list. It's a shame it doesn't spit out the dual-speed versions to remove any doubt, but this answers the question more than well enough.CharlieHanson– CharlieHanson2016年01月23日 18:32:01 +00:00Commented Jan 23, 2016 at 18:32
-
The board property is the same for both versions of pro-mini while not for mega. Maybe boards.txt should be updated with distinctive names for the pro-mini variants, e.g. AVR_MINI_16MHZ, AVR_MINI_8MHZ.Mikael Patel– Mikael Patel2016年01月25日 15:42:50 +00:00Commented Jan 25, 2016 at 15:42
-
For those looking - I was trying to find the define for a NodeMCU ESP8266 - so based on the info in this answer, it is ARDUINO_ESP8266_NODEMCU Thanks !Phil– Phil2017年06月03日 00:13:40 +00:00Commented Jun 3, 2017 at 0:13
Mikael has the right answer, but there are multiple boards.txt files depending on the installed boards with board manager, modifying the command to:
grep board= `find . -name boards.txt` | cut -f2 -d= | sort -u
and running it from your base Arduino directory collects the whole set.
-
Adding detail to Bill's answer adding to Mikael's: The packages you download through the Board Manager reside in (as of 1.8.9 and many revs prior): > linux: /home/(your login)/.arduino15 You can also run Bill's one line script in your Arduino installation folder, to get the 'builtin' boards.user2543191– user25431912019年06月05日 22:52:42 +00:00Commented Jun 5, 2019 at 22:52
The first blank is the platform. This is "AVR" for AVRs, "SAM" for SAM-based Arduinos, etc. This is derived from the platform directory containing the core.
The second blank is the board. This comes from the entry in boards.txt
in the core itself, and is the identifier before the first period.
There is no difference between compilation processes with regards to voltages; any speed difference is given in F_CPU
and the board itself should not be checked for this.
So there is no definitive list, since the list is of arbitrary size due to its source.
-
This is true only when boards.txt doesn't define a
build.board
value and one is automatically generated by the Arduino IDE.per1234– per12342017年04月24日 12:07:53 +00:00Commented Apr 24, 2017 at 12:07
If you're looking for ESP32 boards this can be achieved using a similar technique to mentioned in other answers but the location of the boards.txt
files is different (although using the find
, or mdfind
on MacOS, command to locate works on unix based systems as mentioned in @bill's answer) - the base directory will be the same but a different sub directory: Arduino15/packages/esp32
If you want a list of only the unique defines then you can use this command:
awk '/board=/ {split(0,ドル a,"=");print a[2]}' `find ~ -path '*/esp32/*' -name boards.txt` | sort | uniq
Or on a Mac it is faster to use mdfind
:
awk '/board=/ {split(0,ドル a,"=");print a[2]}' `mdfind -name boards.txt -onlyin ~/Library/Arduino15/packages/esp32` | sort | uniq
The names of the boards can be useful so you list these with this alternate command:
grep 'board=' `find ~ -path '*/esp32/*' -name boards.txt`
Or on Mac:
grep 'board=' `mdfind -name boards.txt -onlyin ~/Library/Arduino15/packages/esp32`
-
bill's answer includes the esp32 boards if they are installed2024年07月07日 14:57:20 +00:00Commented Jul 7, 2024 at 14:57
-
That is true but for people are only interested in ESP32 boards they can use my approach - as I've added an esp32 specific path filter. Also folks searching for ESP32 board defines wouldn't have found this answer till now.Pierz– Pierz2024年07月07日 15:12:27 +00:00Commented Jul 7, 2024 at 15:12