6

I am developing for several different target microcontrollers (on OS X 10.11), which requires some unique combinations of (Arduino) IDE version, library versions, USB drivers, support software, etc.

What are the pros and cons of using separate logged-in users for each environment as opposed to using Virtual Machines? Are there other methods commonly in use to separate environments, and also keep the environments archived for any legacy needs?

Update: I also have a desire to keep these environments as standard as possible: installing released components (e.g., IDE, drivers) and customizing IDE app settings, but trying to avoid source-level forks. This is for my own sanity, and to give best chance of replicating the environment in the future.

5
  • That sounds horrible. What about 1.6.x doesn't let you handle all the boards? – Ignacio Vazquez-Abrams May 28 '16 at 21:42
  • Even within 1.6.x there is a lot of variability between versions which can make things simply not work, especially for many alternate-hardware plugins. The "ordinary" Arduino installation organization for extensions and libraries is pretty seriously broken for any serious software development, being able to specify a custom library path would be a big help. Not needlessly complaining about .git folders would be a help, too. – Chris Stratton May 28 '16 at 22:41
  • 1
    You might be able to get custom per-version libraries/ and hardware/ folders by changing the sketchbook directory, the problem is that all versions from 1.5 on seem to want to store such configuration in the same place such as ~/.arduino15/preferences.txt - and it's not clear how you could change that without modifying the source or binary or playing some game like process-unique mounts (which are generally inheritable by children) – Chris Stratton May 28 '16 at 22:50
  • You can run multiple versions of the IDE just fine. Just rename Arduino.app to e.g. Arduino-1.5.app. For the different libraries, you can just put the libraries into the app-package /Applications/Arduino.app/Contents/Java/libraries , instead of the regular libraries folder ~/Documents/Arduino/libraries. – Gerben May 29 '16 at 13:25
  • @ignacio-vazquez-abrams, the other issue is wanting to avoid regression testing each working environment when updating IDE, libraries, etc. for just one. I'd like to pre-test updates in a non-production clone. – pseudon May 29 '16 at 14:38
4

I'm yet to see evidence that there is a sound or comprehensive way to do this, so would be pleased to read better suggestions. As for why you would want to, there are a number of board support plugins/extensions that are moderately functional on some recent Arduino versions, but partially or entirely incompatible with others.

You can achieve a very limited partial version segregation by creating a new sketchbook folder for each version, which would host your libraries and hardware folders.

To get the IDE to pick this up, you could have a custom preferences file (rather than preferences.txt) with that sketchbook location set. You can specify the file to use on the command line, for example:

/opt/arduino-1.6.8/arduino --preferences-file ~/.arduino15/alternate.txt

However, there is still quite a bit related to extra board support and similar stored in the settings folder, and at present that is hard coded to the same "Arduino15" or ".arduino15" path for all recent versions.

This hard-coding of the settings folder is implemented in the version of Platform.java applicable to the operating system you are running under, so it is not clear how you could change this except at the source level, by modifying the jar, or by playing file-system level tricks with the operating system (process-unique mounts, etc).

2
  • Thanks for your helpful comments and answer. I'll wait to see if someone chimes in specifically about VMs vs. users, etc. (I haven't tried yet, so I'm not even positive if VMs will have issues of their own, but I'm hopeful). I'll also edit my question to include my desire to keep each environment as standard an install as possible (so I don't go insane keeping track of meta-customizations). – pseudon May 29 '16 at 3:57
  • Either distinct user ID's (with the whole installation in a user-specific directory) or VMs would probably work pretty well... sorry I skipped over that, I just don't really consider it a reasonable thing to have to resort to for everyday development. – Chris Stratton May 29 '16 at 5:10
3

I ended up running arduino-buider, available in Arduino IDE 1.6.6 and newer.

When laying out your project, put a libraries/ and hardware/ folder along side your sketch directory, like so:

YourHipProject/
    Makefile
    hardware/
        Vendor/arch/{boards.txt,platform.txt}
    libraries/
        SomethingUseful/
        NoIdeaHowThisWorks/
    ProjectSketch/
        ProjectSketch.ino
        othersource.cpp

The hardware/ directory is only needed if you need support for 3rd party boards. Then, in the Makefile:

ARDUINO_DIR ?= /opt/arduino-1.6.13 # need to set this for your environment

.PHONY: ProjectSketch

ProjectSketch:
    arduino-builder -compile -verbose \
        -hardware $(ARDUINO_DIR)/hardware \
        -tools $(ARDUINO_DIR)/tools-builder \
        -tools $(ARDUINO_DIR)/hardware/tools/avr \
        -built-in-libraries $(ARDUINO_DIR)/libraries \
        -hardware ./hardware \
        -libraries ./libraries \
        -fqbn=Vendor:arch:board \
        ./ProjectSketch/ProjectSketch.ino

ARDUINO_DIR needs to point to where your Arduino is installed, be sure to set -fqbn= correctly too.

Running make should compile the firmware from ProjectSketch/ with the accompanying libraries and hardware definitions. Also, with verbose compile output enabled, the Arduino IDE will show you how it runs arduino-builder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.