Cloud compilation with Create Agent + CLI and Mapping VID/PID to FQBN

Hi Arduino Team,

I'm one of the developers of Cirkit Designer, which is a tool for designing + diagramming Arduino projects.

Our current version of Cirkit is a desktop app, which leverages the Arduino CLI for compiling and uploading Arduino code.

We're in the process of creating a web version of Cirkit and we would like to support Arduino compilation + uploading in the web version.

We've just started investigating, and it looks like the best approach would be to use the Arduino Create Agent for code uploading + serial communication, and then to perform compilation server-side using the Arduino CLI.

The issue I'm currently running into is that the Arduino Create Agent (javascript client) is outputing a VID / PID when I connect an Arduino board.

Since the goal is to compile code for that connected board, my understanding is that we would need to map the VID / PID to a FQBN in order to invoke the CLI.

One idea we have for mapping is to obtain the name of the Arduino board by mapping the VID / PID to the name via boards.txt, and then matching the name of the board to the output from the Arduino CLI listall to get the FQBN.

  • Here is some documentation I've found on mapping PID / VID to board (link)

  • Edit: I think I'm beginning to understand how FQBN is constructed, and that it may be doable to construct the FQBN on the fly. I see that the base of the FQBN is [platform name] : [architecture] : [board name] (link). It looks like board name comes from boards.txt, but I'm wondering where platform name and architecture are obtained from? In the Arduino-AvrCore for example, is it possible to find platform name and architecture?

I'm wondering if you have any suggestions on the approach we're taking. It would be amazing, and very much appreciated if we're able to get pointers from the Arduino team.

Best,

Austin

Hi @austin326small.

You should be aware that this is only possible for boards that produce a port with a unique VID/PID pair. Many 3rd party boards, and even the official classic Nano, use general purpose USB to serial bridge chips (e.g., WCH CH340, FTDI FT232R, Silicon Labs CP210x) with the VID/PID pair provided by the chip manufacturer. There is no way to know which board model is associated with the ports produced by these chips, or even whether the port is from an Arduino board vs. some random piece of consumer electronics.

So if you want to support those popular boards then you must provide a way for the user of your software to manually select their board model.

It is possible to get this for the official boards manufactured by Arduino as well as the 3rd party boards supported by Arduino Cloud from the "Arduino Builder API":

https://builder.arduino.cc/docs#!/boards95v3/boards_v3_byVidPid

The list of boards covered by the Builder API is available here:

https://builder.arduino.cc/v3/boards

For example, an UNO R3 has VID/PID pair 2341:0043, and when we do an API request for that VID/PID pair we can obtain its FQBN of arduino:avr:uno from the fqbn field of the response:

https://builder.arduino.cc/v3/boards/byVidPid/0x2341/0x0043

{
  "architecture": "avr",
  "fqbn": "arduino:avr:uno",
  "href": "/v3/boards/arduino:avr:uno",
  "id": "uno",
  "name": "Arduino Uno",
  "package": "arduino",
  "plan": "create-free"
}

These are defined by the names of the folders under which the platform is installed. The format is:

<vendor ID>/hardware/<architecture ID>/<platform version>/

For example, if the platform is installed under this folder:

C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Then the platform ID is arduino:avr.

The platform is installed by Boards Manager. Boards Manager names the folders according to the data from the package index, which is documented here:

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

The vendor ID is defined by the packages[*].name field.

The architecture ID is defined by the packages[*].platforms[*].architecture field.

Hi @ptillisch,

Thanks for taking the time to provide this super detailed reply! I really appreciate the help.

I've had good success working with the Builder API now, which is exactly what I needed. The limitation of using the VID/PID pair with 3rd party boards is definitely helpful to be aware of, since we want to support as many boards as possible.

I have a few follow-up questions relating to the Create Agent, as well as library management with the CLI, but I'll open those up as new threads to keep things organized.

Best,

Austin

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

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