Hi @KurtE.
Background
The "Arduino UNO Q" board definition in the "Arduino UNO Q Board" platform (machine identifier arduino:zephyr:unoq) is configured to provide a "custom board options" menu named "Link mode" (machine identifier link_mode), which has two options:
- "Dynamic" (machine identifier
dynamic) - "Static" (machine identifier
static)
When using Arduino IDE, we simply select the option we want from the Tools > Link mode menu.
When using Arduino CLI, we specify custom board option selections via the FQBN (the machine identifier of the board), either via the --fqbn command line flag, or via the fqbn key of the build profile. For example, if we want the "Static" option, we would use the FQBN arduino:zephyr:unoq:link_mode=static.
Unfortunately, no mechanism is provided for configuring the FQBN used by Arduino App Lab and Arduino App CLI. Instead, the FQBN is hardcoded:
Since a link_mode option is not specified by those FQBNs, the default option is used. The default option is determined by the order of the options in the board definition:
So we can see that the default option is "Dynamic".
Recommended Approach
The sole effect of selecting the "Static" custom board option is the definition of two platform properties:
build.link_mode=staticupload.extension=bin-zsk.bin
These properties are referenced by the command templates ("patterns") in the `platform.txt file.
We can accomplish the same thing by directly making the same property definitions. This can be done via the platform.local.txt file. Property definitions in this file override any definitions in the platform.txt file.
You can accomplish this by running the following command from the shell terminal:
echo "
build.link_mode=static
upload.extension=bin-zsk.bin
" > ~/.arduino15/packages/arduino/hardware/zephyr/0.53.0/platform.local.txt
This applies the modification to the release installation of version 0.53.0 of the platform. If you are using a different version of the platform, or if you are using a manual installation, adjust the path in the command accordingly.
When you want to switch back to using the "Dynamic" option, just delete the platform.local.txt file that was created by that command:
rm ~/.arduino15/packages/arduino/hardware/zephyr/0.53.0/platform.local.txt
Note that the modification will be lost each time you update to a new release version of the arduino:zephyr platform. So remember to run the command after doing so if you wish to continue to use the "Static" option.
If you are applying the modification to a manual installation of the Git repository, you can add an entry to the repository's .git/info/exclude file in order to cause Git to disregard the added platform.local.txt file:
echo "platform.local.txt" >> ~/Arduino/hardware/arduino/zephyr/.git/info/exclude
Alternative Approach
The fact that Arduino App CLI uses the implicit default option for the "Link mode" menu instead of explicitly specifying the option via the hardcoded FQBN provides us with a vector though which we can change the option. This would be utilized by editing the boards.txt file to reverse the order of the option definitions, from this:
to this:
unoq.menu.link_mode.static=Static
unoq.menu.link_mode.static.build.link_mode=static
unoq.menu.link_mode.static.upload.extension=bin-zsk.bin
unoq.menu.link_mode.dynamic=Dynamic
After this change, the default option becomes "Static".
The reason I do not consider this to be the recommended approach is because it requires the modification of boards.txt.
The modification needs to be performed after each update of the platform, and each time you want to change the "link mode" behavior of Arduino App CLI. That is simple to accomplish when the modification is contained within the dedicated user file platform.local.txt, which can simply be added to and removed from the platform installation folder as needed. Conversely, it is less convenient to modify boards.txt each time, as you will likely be performing a manual edit on the file. Editing boards.txt also opens up the possibility of introducing unintentional changes to the other content in the file.