Go Down

Topic: Board Settings in *.ino file (Read 9254 times) previous topic - next topic


Well, it's pretty clear by the degree of support that I'm the only one who thinks this would be a good feature to incorporate into the IDE, so it's probably best to just forget that I posted this suggestion.
No, you're not and no, it's not...  I'm having the same question since I also have the very same issue. Trust me, we're not the only ones.

To me, it would be normal and logically if the board could be saved with the .ino file of a project since having different boards laying on your table is really not an exception.

I have different Arduino's, ESP8266 and ATTiny85 boards with which I'm working and each and every time I'm hitting the same stone (must be stupidity, I guess): forgot to change the board and bang... building is OK but uploading is, of course, not...

Hope this will change in the future.




Instead of using comments, I think using #pragma might be a better idea. The #pragma's would be picked up by the arduino-build tool and removed from the generated C++ sources. It is also technically backwards compatible since GCC will just ignore the unrecognized #pragmas.

Ideas I have:

Code: [Select]
#pragma arduino board "Arduino/Genuino Uno" // This selects the board in the sketch.
#pragma arduino board "Generic ESP8266" // You do meed to match the board title or identifier exactly though.
#pragma arduino upload programmer // Force uploading with programmer
#pragma arduino upload default // Default upload method.
#pragma arduino define SOME_VARIABLE // Passes -DSOME_VARIABLE to all calls of GCC
#pragma arduino import TFT // Pulls in a library without including its header file. There might be C++ header file collisions in some corner cases, and this alternative syntax can avoid that.
#pragma arduino config board.upload.arguments "-F" // This can even inject board.txt contents.


anyone have any luck with this ?


The #pragma idea is an excellent idea technix.

I try to use Atom PlatformIO when possible but I still use Arduino a lot. In PlatformIO all the settings are in an ini file, it's wonderful when you are working on multi-device setups. I would love to see this in the Arduino IDE as well!


I grepped the interweb for this topic and landed here.

Yes please. #pragma or something to set the board type!

I wonder where the "current settings" are stored; a tacky workaround could be to always launch Arduino.app from a command line script that read the .ino and munged the app prefs file.


Bumping this one - my filename normally includes the Boardtype. That would be a great improvement!


Will ide save the board settings?


FYI, the Arduino Web Editor does already have this feature. The board and port association is saved in a metadata file named sketch.json.


I found my way here as I'd like the same thing too. I'm always bumping into this, compiling for the wrong board because I'm working on a different project. I take no one's implemented a solutions? Of the suggestions, the #pragma idea seems best.


It's De-ja vu all over again.
I'll respond to the OP observation that there doesn't seem to be much interest in this feature.  Yes, there is much interest in this feature, and it's been asked for frequently over the years.  but the developers haven't shown any interest in implementing it, or to even reply why it can't be done.

Right now, I have an Arduino Uno R3 and two Wemos D1 Mini's on my bench.  They are all for a single project and you can bet that I have compiled for the wrong board at least two or three times a day.


arduino-cli has a "board attach" feature, which lets you associate a board and port to a sketch. The Arduino IDE will eventually be switched to using arduino-cli. So I think this feature is indeed being worked on by the Arduino developers. They're just doing it in a way that is consistent with the long term plans, rather than spending time implementing the feature into the Arduino IDE or arduino-builder, where it would just end up being thrown away as soon as the transition to arduino-cli happens.


I know this is an old thread but seems like the subject is still valid.
I let out a program for windows to do a bit of preference file shuffling before the INO is loaded.


Go Up