Board parameters when compiling Arduino code via command line

I need to upload my codes using Arduino IDE via command line. I'm basing my studies on this manual: Arduino/manpage.adoc at master · arduino/Arduino · GitHub

From it, I know that I need to define the architecture (most cases avr) and the board name. In some cases, I also need to define the cpu. For example, when using mega and nano boards:

arduino --board arduino:avr:nano:cpu=atmega168
The manual defines the --board option as:

--board package:arch:board[:parameters]
where :parameters "is a comma-separated list of boards specific parameters that are normally shown under submenus of the "Tools" menu".

I need to know what are the other available parameters and if there is some board that needs more information.

Thanks :slight_smile:

Related:

Annygnr:
I know that I need to define the architecture (most cases avr) and the board name.

This is universal, though the only thing that would make the statement “most cases avr” valid is that the AVR boards are very popular in the Arduino world.

Annygnr:
In some cases, I also need to define the cpu. For example, when using mega and nano boards:

arduino --board arduino:avr:nano:cpu=atmega168
The manual defines the --board option as:

–board package:arch:board[:parameters]
where :parameters “is a comma-separated list of boards specific parameters that are normally shown under submenus of the “Tools” menu”.

I need to know what are the other available parameters

You need to understand the mechanism behind these parameters. It is documented here:

After reading that, you will see that the parameters are completely arbitrary. The author of each board definition is free to add any parameters they like with any names. You can’t infer any standardized rules about these parameters. You only need to understand how to determine what they are for your target board. You can do this in two different ways:

The first option is to open the boards.txt of the target board and look at the custom menus definitions for that board. You can follow these instructions to easily find the boards.txt for any board:

  • Select a board from the hardware package you want to find from the Tools > Board menu
  • File > Examples > SPI > BarometricPressureSensor (or any other SPI example sketch)
  • Sketch > Show Sketch Folder
  • Move up folder levels until you reach the one that contains boards.txt
  • Open boards.txt in a text editor.

The second option, which is more crude, but also easier:

  • Start the Arduino IDE’s GUI.
  • File > Preferences
  • Check the box next to Show verbose output during: > compilation.
  • Click “OK”.
  • File > New
  • Tools > Board > select the target board
  • Select your preferred options for any custom Tools menus.
  • Sketch > Verify/Compile

After the compilation finishes, scroll the black console window at the bottom of the Arduino IDE window all the way to the top. The first line will look something like this:

C:\ArduinoIDE\arduino-1.8.9\arduino-builder -dump-prefs -logger=machine -hardware C:\ArduinoIDE\arduino-1.8.9\hardware -hardware C:\Users\per\AppData\Local\Arduino15\packages -hardware E:\electronics\arduino\hardware -tools C:\ArduinoIDE\arduino-1.8.9\tools-builder -tools C:\ArduinoIDE\arduino-1.8.9\hardware\tools\avr -tools C:\Users\per\AppData\Local\Arduino15\packages -built-in-libraries C:\ArduinoIDE\arduino-1.8.9\libraries -libraries E:\electronics\arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10809 -build-path C:\Users\per\AppData\Local\Temp\arduino_build_852912 -warnings=all -build-cache C:\Users\per\AppData\Local\Temp\arduino_cache_520918 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14 -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14 -prefs=runtime.tools.avr-gcc.path=C:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.arduinoOTA.path=C:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.2.0 -prefs=runtime.tools.arduinoOTA-1.2.0.path=C:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.2.0 -verbose C:\Users\per\AppData\Local\Temp\untitled1347178501.tmp\sketch_mar28a\sketch_mar28a.ino

You will find the complete FQBN for the board you compiled for in the -fqbn option:

-fqbn=arduino:avr:nano:cpu=atmega328

A Python script written by one of the contributors to the ESP8266 core for Arduino might provide the glimpse of a 3rd option:

I think it might need some adaptation to be universally useful, since it is written with the assumption that all boards will use the same custom menus. That is the case with the ESP8266 core for Arduino, but no the case with most other hardware packages.

Annygnr:
if there is some board that needs more information.

There sure is. I think the ESP8266 boards might have the most parameters:

esp8266:esp8266:d1_mini:xtal=80,vt=flash,exception=disabled,eesz=4M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600