Sometimes we need to figure out unecessary complexities, so that we can make things more accessable.

I'm talking about Arduino Board Type.  Something you'd think is very straight forward, yet .. its not.  Not because it can't be, but I think because few have taken the time to make sense of it.

"Board Type" is a general term, but there are potentially 2 things which depend on it.

  • bootloaders are paired with board types - if we don't get the board type correct, we can not upload mrlcomm .. and that would be sad :(
  • pin definitions - the number and types of pins

I think other definitions of board type may have come around because of marketing or licensing and no real difference between the two important aspects I listed.

I found this little gold mine - 
http://arduino.stackexchange.com/questions/21137/arduino-how-to-get-the-board-type-in-code
- the author rightfully wrote : "Because it is a pity that every Arduino programmer has to go through the same pain to figure out how to get the board name"

It gives a list of defines, so I think we could use these ... but once the board type for the uploader is defined, the rest of the software needs to know the PinDefinitions ... 

Guess I need to work on that mapping ..

calamity

7 years ago

There is a file in one of the arduino folder called boards.txt

it contains all the parametters to upload the code to the different arduino types. you can use a parser to dig out all the arduino type. the arduino board are always define like this

uno.build.board=AVR_UNO

Sadly, knowing the board name is not enough to be able to upload the code to the arduino, some board need extra parametters, by example, for the nano, I had need to add the parameters ":cpu=atmega328" or the code won't even compile

 

Ya .. I've looked through it before ..

It has the following names ..

Arduino Yun
Arduino/Genuino Uno
Arduino Duemilanove or Diecimila
Arduino Nano
Arduino/Genuino Mega or Mega 2560
Arduino Mega ADK
Arduino Leonardo
Arduino Leonardo ETH
Arduino/Genuino Micro
Arduino Esplora
Arduino Mini
Arduino Ethernet
Arduino Fio
Arduino BT
LilyPad Arduino USB
LilyPad Arduino
Arduino Pro or Pro Mini
Arduino NG or older
Arduino Robot Control
Arduino Robot Motor
Arduino Gemma
Adafruit Circuit Playground
Arduino Yun Mini
Arduino Industrial 101
Linino One
Arduino Uno WiFi
 
Which correspond to Arduino IDE dropdown menu.

You mean you can't compile by just selecting "Arduino nano" in the dropdown ?
 
Upload protocol can vary - but it looks like there are only 3 types   wiring, arduino or avr109
 
3/26/2017 9:40:54 PM
Search String: upload.protocol
Replace String: 
Path: C:\tools\arduino-1.8.1\hardware\arduino\avr\
File Mask: boards.txt
Search Subdirectories
Line  20 - yun.<upload.protocol>=avr109
Line  61 - uno.<upload.protocol>=arduino
Line  85 - diecimila.<upload.protocol>=arduino
Line 130 - nano.<upload.protocol>=arduino
Line 206 - mega.menu.cpu.atmega2560.<upload.protocol>=wiring
Line 221 - mega.menu.cpu.atmega1280.<upload.protocol>=arduino
Line 246 - megaADK.<upload.protocol>=wiring
Line 278 - leonardo.<upload.protocol>=avr109
Line 313 - leonardoeth.<upload.protocol>=avr109
Line 371 - micro.<upload.protocol>=avr109
Line 410 - esplora.<upload.protocol>=avr109
Line 441 - mini.<upload.protocol>=arduino
Line 486 - ethernet.<upload.protocol>=arduino
Line 510 - fio.<upload.protocol>=arduino
Line 534 - bt.<upload.protocol>=arduino
Line 581 - LilyPadUSB.<upload.protocol>=avr109
Line 612 - lilypad.<upload.protocol>=arduino
Line 658 - pro.<upload.protocol>=arduino
Line 737 - atmegang.<upload.protocol>=arduino
Line 791 - robotControl.<upload.protocol>=avr109
Line 830 - robotMotor.<upload.protocol>=avr109
Line 901 - circuitplay32u4cat.<upload.protocol>=avr109
Line 922 - yunmini.<upload.protocol>=avr109
Line 959 - chiwawa.<upload.protocol>=avr109
Line 996 - one.<upload.protocol>=avr109
Line 1029 - unowifi.<upload.protocol>=arduino
 
its just a big properites file .. 
We could just use a copy of the file ...  certainly would be easy to maintain in the future .. (just copy paste from Arduino IDE)
 
Hmmm....
 
boards.txt gives us the name & and board identifier

uno.name=Arduino/Genuino Uno

 
Still two things are still missing :
  1. The pin definitions - for many I think this is the same - if they follow Uno's footprint 
    Teensey & Mega's I know have different pin layouts
  2. Sadly, there is no hardware memory to be read - which identifies the board type (this could have been a single int !!!)   This would have aided greatly to 'plug & play'
    The next best thing is to have it compiled in.

    Now I ask you, if the compiler knows what board it is, why doesnt the compiler compile this info into the board ? - Instead its still 'sort of' added with a variety of macros :(

 

You mean you can't compile by just selecting "Arduino nano" in the dropdown ? 

I mean by compiling script with the command line, using ArduinoUtils

When using the menu, it seem that some default value are selected, but are not when compiling from command line

 

So yes it sad that those board info are not easily available, so you have to do identify and maintain a list a value ourself.

 

About the pin definition, they are also only defined by macro wich make it hard to retrieve a pin definition directly from the board, as the board type, we need to manually check the macro to build the definition list. And for other board than arduino, like espressif board (ESP32) the macro managing the pin definition seem to be different (so my code for the neopixel is not working on the espressif board)

 

 

cyberhedz

7 years ago

any this is yet another reason why I'm trying to develop teh board I've been designing.  eliminate all the others and have a standard centralized goal and focus.  I'm working on the PDN now, and testing code on a prototype, once I get the initial code working, I'll make a post too.