Different boards for different sketches

I am puzzled by the way in which the IDE handles the type of board in use. If I change the board for one of my sketches, it's also changed for all the others, even if they are already active on-screen (this is for Windows, I don't know if the same applies for other systems).

There's a file in each of the Arduino folders (in the 'debug' subfolder) called 'board.buildinfo' and this defines, in the first line, a board (e.g. "name=Arduino/Genuino Uno") and, further down, an mcu ("build.mcu=atmega328p"). But this file appears to be created when he project is created, and never changed afterwards, so I'm not sure I see the point of these entries.

There is a file in the user's appdata folder (AppData>Local>Arduino15), 'preferences.txt', which defines a board in the first line. This is what is used to determine the board type of any sketch loaded, regardless of what board the sketch was used for previously.

So, I'm just wondering why the info in the 'board.buildinfo' file isn't used. If it was, it would be much easier (and more logical?) for designers who have more than one type of board. And (although it might not be a common requirement) it seems impossible to have two sketches open at the same time with different target devices.

You can have two different sketches open at the same time with different boards selected if you start two instances of the Arduino IDE from the Arduino shortcut, by running arduino.exe, or by opening an .ino file associated with the Arduino IDE. Any other window opened from one of those instances (File > New, File > Open, File > Examples, File > Sketchbook) will reflect changes made to any other window that belongs to that instance.

This is using Windows, I don't know about other operating systems.

quilkin:
There is a file in the user's appdata folder (AppData>Local>Arduino15), 'preferences.txt', which defines a board in the first line. This is what is used to determine the board type of any sketch loaded, regardless of what board the sketch was used for previously.

Correlation, not causation.

quilkin:
There's a file in each of the Arduino folders (in the 'debug' subfolder) called 'board.buildinfo' and this defines, in the first line, a board (e.g. "name=Arduino/Genuino Uno") and, further down, an mcu ("build.mcu=atmega328p"). But this file appears to be created when he project is created, and never changed afterwards, so I'm not sure I see the point of these entries.

I've never seen anything like that. Which Arduino folders do you mean? Which version of the Arduino IDE?

The CREATE online editor has partly taken that up a notch and a sketch is usually defined and held to the board it was last used on until the user selects a new board.

I can select a sketch and the board last used is automatically selected for it.

When I download a sketch to the computer there is even an attached JSON file with the relevant details.

Attaching so you can see if it covers the aspect you are talking about.

{"cpu":{"name":"Arduino/Genuino MKR1000","com_name":"COM6","fqbn":"arduino:samd:mkr1000","arch":"samd","network":false,"upload":[{"commandline":"\"{runtime.tools.bossac-1.7.0.path}/bossac\" {upload.verbose} --port={serial.port.file} -U true -i -e -w -v \"{build.path}/{build.project_name}.bin\" -R","ext":".bin","flavour":"default","options":{"maximum_size":"262144","native_usb":"true","protocol":"sam-ba","signature":"66695789d14908f52cb1964da58ec9fa816d6ddb321900c60ad6ec2d84a7c713abb2b71404030c043e32cf548736eb706180da8256f2533bd132430896437c72b396abe19e632446f16e43b80b73f5cf40aec946d00e7543721cc72d77482a84d2d510e46ea6ee0aaf063ec267b5046a1ace36b7eb04c64b4140302586f1e10eda8452078498ab5c9985e8f5d521786064601daa5ba2978cf91cfeb64e83057b3475ec029a1b835460f4e203c1635eaba812b076248a3589cd5d84c52398f09d255f8aae25d66a40d5ab2b1700247defbdfd044c77d44078197d1f543800e11f79d6ef1c6eb46df65fe2fffd81716b11d798ba21a3ca2cb20f6d955d8e1f8aef","tool":"bossac","use_1200bps_touch":"true","wait_for_upload_port":"true"},"params":{"quiet":"","verbose":"-i -d"},"tool":"bossac","tool_version":"1.7.0","package":"arduino"}],"flavour":"default","isOpen":false,"port":""}}

Pert can probably understand its use and function so much more than I ever could.

pert:
You can have two different sketches open at the same time with different boards selected if you start two instances of the Arduino IDE from the Arduino shortcut, by running arduino.exe, or by opening an .ino file associated with the Arduino IDE. Any other window opened from one of those instances (File > New, File > Open, File > Examples, File > Sketchbook) will reflect changes made to any other window that belongs to that instance.

Ok, many thanks, I tried that and it works. I had only tried opening another sketch from inside the IDE before.

Correlation, not causation.

fair enough.

I've never seen anything like that. Which Arduino folders do you mean? Which version of the Arduino IDE?

Aah! I have looked again and realised that not all of my sketch folders (in Documents>Ardunio) contain the 'debug' folder and the 'board.buildinfo' file. Only some, and these (I think) were all edited at some stage with VisualMicro. But the latest ones don't have it, so the latest version of VisualMicro doesn't do the same.

I'm glad I asked the question, some mysteries solved. And I can delete some rubbish. Thanks again.

Ballscrewbob:
The CREATE online editor has partly taken that up a notch and a sketch is usually defined and held to the board it was last used on until the user selects a new board.

I can select a sketch and the board last used is automatically selected for it.

That sounds more like it. I think the desktop IDE should do the same.

When I download a sketch to the computer there is even an attached JSON file with the relevant details.
Attaching so you can see if it covers the aspect you are talking about.

Well it contains all the relevant info that's needed.
Thanks.

As far as I can tell (but Pert could probably answer better) It almost gives you the complete command line for use with maybe an alternative IDE. ??

quilkin:
That sounds more like it. I think the desktop IDE should do the same.

I know this feature has been requested to the developers on the GitHub issue tracker at least once some time ago. I'm not sure if it was specifically rejected or not but certainly it was not made a development priority. I can understand the arguments against doing this but I do think any feature available in the web editor should also be available in the IDE and vice versa. It's frustrating to see the two diverging. It certainly makes providing support here more difficult.

Ballscrewbob:
As far as I can tell (but Pert could probably answer better) It almost gives you the complete command line for use with maybe an alternative IDE. ??

You should be able to parse the information that JSON provides for use with the Arduino IDE CLI or arduino-builder but you can't just plug it in directly. arduino-builder is not an alternative IDE, it's just the command line tool the Arduino IDE uses behind the scenes to compile sketches so you can use it by itself along with a flashing tool such as AVRDUDE for applications that don't require the IDE's GUI.