How to create a board variant as separate install

Wondering if there is a simple way to create a new variant of a board without necessarily needing to either copy the whole core or building it into the same hardware install.

Two cases, I am playing with:

Uno R4: Wifi using main processor for USB.
Currently I have a version working in the main install, when you install the github version under /hardware/arduino-dev...

This version, has several boards installed, including the R4 as well as the portenta C33.

But the actual install, has a script file (extras\package.sh) which makes multiple copies of the stuff and packages one for UNO R4 and another for the Portenta.

Now for my version: where maybe I want Kurts UNOR4->WIFI USB

I have it doing like above, replicating the whole thing...

Is there a way to do this which simply has it refer to the stuff installed for UNO R4 and only need to install the variant stuff?

Teensy boards:

Suppose I add optional minimal support in Teensy install for variant (variant.h and the like).
I have a version working where it detects this and for example can build with different pin mappings...

It was working with boards.local.txt, which defined the variant and the like.

Is there a clean way again to move the boards.local.txt file to new directory/install
And for example have it in boards like like: Kurts Teensy->NewT4x
And have it build using the currently installed Teensy core?
like: /packages\teensy\avr\cores\teensy4 ?

With some older AVR boards I used to see things like:
Adafruit AVR boards have things like:
flora8.build.core=arduino:arduino

Is there something similar I can do for the Teensy core?
Maybe need to do similar for the tools?

I know there is probably information up in the documetion
Platform specification - Arduino CLI
Which I am still trying to deciper...

Suggestions?

Hi @KurtE. You can reference resources from other platforms and packages:

You can reference the tools from another package in your platform's package index entry:

https://arduino.github.io/arduino-cli/latest/package_index_json-specification/#platforms-definitions

You can reference cores (also bringing in platform bundled libraries and programmer definitions), variants, and tool command patterns from another platform from your platform's configuration files:

https://arduino.github.io/arduino-cli/latest/platform-specification/#referencing-another-core-variant-or-tool

Yep. Keep in mind that the referenced platform will be a dependency of your platform. If the user doesn't install the "Arduino UNO R4 Boards" platform in addition to your platform, they will get confusing errors. There isn't any mechanism for configuring Boards Manager to automatically install the platform dependency so you must clearly document this as an addition step for the user to perform in the installation instructions.

This dependency can be easy for those of us who started with referencing in AVR-based platforms, where traditionally you could assume that the "Arduino AVR Boards" platform was always present (due to being installed with the IDE). It remains easy to forget because, unlike the average platform user, the platform developer will surely already have the dependency installed on their computer.

That line is referencing the arduino core from the arduino:avr platform (the avr architecture is implicit because the referencing system only allows referencing between platforms of the same architecture).


These referencing systems makes it possible to create a new platform consisting of as little as a handful of lines in a boards.txt file.

You can see an example of how a significant (at the time) platform was created at a minimum of development and maintenance effort by referencing most of the resources from an existing platform by looking at the foundational "attiny" boards platform by David Mellis:

Yes. If you are going to reference tools from the teensy package, keep in mind the user must have the Teensy package index URL in their "Additional Boards Manager URLs" preference in addition to the URL for your platform's package index. This is a difference when compared to referencing tools from the arduino package since that package is in the primary package index which is available by default.

2 Likes

Thanks,

Lots of information. which is great.

Right now with Teensy, trying to start off with a set of files under
/hardware.

And trying to figure out the required directory hierarch, to make it work for the Teensy.

Maybe something like /teensy-dev/avr
with variants under that as well as boards.txt and variants.

So far not working, but will keep experimenting.

You are welcome.

That will work.

The first folder is the "vendor" or "packager" folder. You can pick any name you like for this within reason. It is the differentiator of your platform from others of the same architecture. This identifier becomes a component of the FQBN used in command line operation (e.g., teensy-dev:avr:some_board), and when another platform references resources from your platform (e.g., another_board.build.core=teensy-dev:arduino).

If you create a package index for your platform, the identifier will be set via the packages[*].name field.


The second folder is the architecture folder. This must match the architecture of the platform you are referencing. You were correct to choose avr. It is an oddity of the Teensy platform that it contains boards of completely different architectures, only two of which are AVR.

2 Likes

Thanks @ptillisch - Will experiment more...

The reason I asked was I created the directory structure mentioned.
I copied my board.local.txt from the project into this directory.. Also simple platform.txt
copied variant directory...

The first part of the boards.txt was edited:

teensySDRAM.name=Teensy with SDRAM
#teensySDRAM.upload.maximum_size=16515072
teensySDRAM.build.board=TEENSY_SDRAM
teensySDRAM.build.flags.ld=-Wl,--gc-sections,--relax "-T{build.core.path}/imxrt1062_mm.ld"
#teensySDRAM.upload.maximum_data_size=524288
#teensySDRAM.upload.maximum_data_size=1048576
teensySDRAM.upload.tool=teensy:teensyloader
teensySDRAM.upload.tool.default=teensy:teensyloader
teensySDRAM.upload.tool.teensy=Teensy:teensyloader
teensySDRAM.upload.protocol=teensy
teensySDRAM.upload_port.modelID=0x26
teensySDRAM.build.core=teensy:teensy4
teensySDRAM.build.mcu=imxrt1062
teensySDRAM.build.variant=SDRAM
teensySDRAM.build.includes=-I{build.variant.path}


Mainly from the .local. version with: teensySDRAM.build.core=teensy:teensy4

If I try to build I get an error message:

Invalid FQBN: getting build properties for board teensy-dev:avr:teensySDRAM: invalid option 'keys'

Compilation error: Invalid FQBN: getting build properties for board teensy-dev:avr:teensySDRAM: invalid option 'keys'

I am probably doing something stupid....
Still investigating...

EDIT: Should mention if I build using the board variant added to Teensy using the boards.local.txt The build starts off like:

FQBN: teensy:avr:teensySDRAM
Using board 'teensySDRAM' from platform in folder: C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.59.5
Using core 'teensy4' from platform in folder: C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.59.5

Detecting libraries used...

I gave it a try and was not able to reproduce the fault. Try deleting the IDE's data folders in case it is one of those annoying caching bugs (like the one you reported here):

C:\Users\<username>\.arduinoIDE\
C:\Users\<username>\AppData\Roaming\arduino-ide\

:blush: - Sorry dumb mistake...

When I copied over the board definition, I only copied the data for that one board...

But it really needs the stuff at the top of the boards.txt file

menu.usb=USB Type
menu.speed=CPU Speed
menu.opt=Optimize
menu.keys=Keyboard Layout

With this it builds ... some other stuff to fix, but a start
Thanks for your help!

EDIT: Next thing I am debugging:
Generating function prototypes...
C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\tools\teensy-compile\11.3.1/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10607 -DARDUINO_TEENSY_DEVBRD4 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IC:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.59.5\cores\teensy4 -IC:\Users\kurte\Documents\Arduino\hardware\teensy-dev\avr\variants\SDRAM -Ic:\Users\kurte\Documents\Arduino\libraries\SDRAM_t4 -Ic:\Users\kurte\Documents\Arduino\libraries\Arduino_OV7670X\src -Ic:\Users\kurte\Documents\Arduino\libraries\ILI9488_t3\src -IC:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.59.5\libraries\SPI -IC:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.59.5\libraries\Wire C:\Users\kurte\AppData\Local\Temp\arduino\sketches\06FFED8E9C106A93EE309DB581CC0FAD\sketch\SDRAM_ov7670.ino.cpp -o C:\Users\kurte\AppData\Local\Temp\3475261858\sketch_merged.cpp
C:\Users\kurte\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\kurte\AppData\Local\Temp\3475261858\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-tools\\0.59.5/precompile_helper" "C:\\Users\\kurte\\Documents\\Arduino\\hardware\\teensy-dev\\avr/cores/teensy:teensy4" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\06FFED8E9C106A93EE309DB581CC0FAD" "C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-compile\\11.3.1/arm/bin/arm-none-eabi-g++" -x c++-header -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10607 -DARDUINO_TEENSY_DEVBRD4 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\kurte\\Documents\\Arduino\\hardware\\teensy-dev\\avr/cores/teensy:teensy4" "-IC:\\Users\\kurte\\Documents\\Arduino\\hardware\\teensy-dev\\avr\\variants\\SDRAM" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\06FFED8E9C106A93EE309DB581CC0FAD/pch/Arduino.h" -o "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\06FFED8E9C106A93EE309DB581CC0FAD/pch/Arduino.h.gch"
Unable to access C:\Users\kurte\Documents\Arduino\hardware\teensy-dev\avr/cores/teensy:teensy4
Multiple libraries were found for "ILI9488_t3.h"
  Used: D:\github\ILI9488_t3
  Not used: C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.59.5\libraries\ILI9488_t3
Using library SDRAM_t4 in folder: D:\github\SDRAM_t4 (legacy)
Using library Arduino_OV767X at version 0.0.2 in folder: D:\github\Arduino_OV767X 
Using library ILI9488_t3 at version 1.0 in folder: D:\github\ILI9488_t3 
Using library SPI at version 1.0 in folder: C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.59.5\libraries\SPI 
Using library Wire at version 1.0 in folder: C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.59.5\libraries\Wire 
exit status 1

Note: I renamed the board and the section name... earlier to see if maybe it was conflicting with the boards.local.txt version I have in Teensy

As I know @Merlin513 is also playing along...

Here is the current stuff...
teensy-dev.zip (6.2 KB)

Edit: I have platform.txt edit for running this app that is failing. On the teensy platform.locol.txt
I had edited from the default to add the -I to look in the variant folder as it was not doing this...
It looks like my version here got that directory right... but it failed to properly point at the core.

"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-tools\\0.59.5/precompile_helper" "C:\\Users\\kurte\\Documents\\Arduino\\hardware\\teensy-dev\\avr/cores/teensy:teensy4" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\06FFED8E9C106A93EE309DB581CC0FAD" "C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-compile\\11.3.1/arm/bin/arm-none-eabi-g++" -x c++-header -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10607 -DARDUINO_TEENSY_DEVBRD4 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\kurte\\Documents\\Arduino\\hardware\\teensy-dev\\avr/cores/teensy:teensy4" "-IC:\\Users\\kurte\\Documents\\Arduino\\hardware\\teensy-dev\\avr\\variants\\SDRAM" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\06FFED8E9C106A93EE309DB581CC0FAD/pch/Arduino.h" -o "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\06FFED8E9C106A93EE309DB581CC0FAD/pch/Arduino.h.gch"
Unable to access C:\Users\kurte\Documents\Arduino\hardware\teensy-dev\avr/cores/teensy:teensy4
Multiple libraries were found for "ILI9488_t3.h"

That is: "-I{runtime.platform.path}/cores/{build.core}"
Translated to:
"-IC:\Users\kurte\Documents\Arduino\hardware\teensy-dev\avr/cores/teensy:teensy4"

So probably need to edit this path generation here as well...

@ptillisch @Merlin513

Fixed this last issue (for IDE2):
updated the platform.txt line to:

## Precompile Arduino.h header
recipe.hooks.sketch.prebuild.1.pattern="{teensytools.path}precompile_helper" "{build.core.path}" "{build.path}" "{compiler.path}{build.toolchain}{build.command.g++}" -x c++-header {build.flags.optimize} {build.flags.common} {build.flags.dep} {build.flags.cpp} {build.flags.cpu} {build.flags.defs} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DF_CPU={build.fcpu} -D{build.usbtype} -DLAYOUT_{build.keylayout} "-I{build.core.path}" "-I{build.variant.path}" "{build.path}/pch/Arduino.h" -o "{build.path}/pch/Arduino.h.gch"

If I remember correctly Paul hacked this up originally to fix an issue where when building, with Arduino 2.x the above line worked fine. But with Arduino 1.x installed with Teensyduino, it was still using the Teensy install in the Arduino15 (board manager) install instead of the Teensyduino install which may be a different version installed directly into the Arduino 1.x installation location....

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.