Installation/MacOSX-legacy

= Intro =
This page contains the different installation approaches that did work on past versions of Mac OS X. They are currently not working any more on the newest versions of Mac OS X. They still might be useful as information sources for those that either want to install on a legacy mac os x or want to resurrect one of the installation approaches.
= Basic Install (Binary Installer) =
Depending on the version of Mac OS you have installed on your computer the installation process will vary slightly. Also this install process is only recommended for beginners. If you want to be able to use more up to date Paparazzi and be able to track the development more closely, you should consider installing Paparazzi tools using the source solution described in the next chapter.
== Installation Video Tutorials (On OS X 10.9.* Mavericks) ==
 
== Basic Install (Binary Installer) (On OS X 10.9.* Mavericks) ==
If your Apple Mac operation system is OSX Mavericks or newer then the easiest way to get started with Paparazzi on your Apple Mac is to start with the following Basic install. If you have an older version you want to follow the slightly longer Basic install, below.
The steps you need to take to enjoy Paparazzi are:
# Install XQuartz from MacOSForge. (You can alternatively use the X11.app if it is available for your version of Mac OS X.)
# Open the Terminal.app
# Install the command line tools by executing: xcode-select --install and clicking on the "Install" button in the dialog that will pop up.
# Install the Paparazzi Tools installer for your OS version from paparazziuav.org
## You might get an error saying: "paparazzi-tools-xxxxxx.mpkg can't be opened because it is from an unidentified developer." To get rid of this error you will need to:
### Open "System Preferences"->"Security&Privacy" and change the "Allow apps downloaded from:" setting to "Anywhere". (The option might be greyed out. To activate the selection you will need to authenticate yourself as system administrator. Click on the lock in the left lower corner of the "System Preferences" window, to open the authentication window.)
# Set up your environment variables and Python appropriately using the pprz-env-set script:
## Get the script: curl https://raw.githubusercontent.com/paparazzi/paparazzi-portability-support/master/darwin/install/Contents/Resources/pprz-env-set >~/Desktop/pprz-env-set
## Move script to right location: sudo mv ~/Desktop/pprz-env-set /opt/paparazzi/bin/pprz-env-set
## Change script permissions: sudo chmod 755 /opt/paparazzi/bin/pprz-env-set
## Run the script: sudo /opt/paparazzi/bin/pprz-env-set
## Close the terminal. (Do that before you try to move on to the next step. Otherwise the newly set environment will not take effect and you will end up with compilation errors.)
# That's it! To run Paparazzi you need to open the Terminal app and build and run Paparazzi.
## In spotlight type Terminal and then open the Terminal App
## then type: cd ~/paparazzi && make && ./paparazzi (The first time you start paparazzi it might take several minutes to show a window. It is because GTK is indexing the fonts the first time it starts up.) (If you get the error: "Fatal error: exception Gtk.error("GtkMain.init: initialization failed ml_gtk_init: initialization failed")" the most likely source of the issue is the lack of X11 server. Install either X11.app or XQuartz as mentioned in step 1.)
Notes: 
* the binary installer will check if ~/paparazzi exists on your system. If it does, then the installer does nothing. If this directory does NOT already exist, the installer will automatically clone the Paparazzi Git repository into that directory.
* the binary installer will add a few lines to your ~/.profile for PATH modification and for default PAPARAZZI_HOME and PAPARAZZI_SRC env vars. If you have something other than the default ~/paparazzi installation, please edit your ~/.profile and comment out the env var exports.
* the binary installer creates a symbolic link between the available /opt/paparazzi/bin/python2.7 and /opt/paparazzi/bin/python. Combined with the PATH modification, this will cause python something.py to call /opt/paparazzi/bin/python2.7 instead of any system pythons.
== Basic Install (Binary Installer) (Support: 10.7.* Lion, 10.8.* Mountain Lion) ==
If your Apple Mac operation system is OSX Snow Leopard or Lion or newer then the easiest way to get started with Paparazzi on your Apple Mac is to start with the Basic install.
The steps you need to take to enjoy Paparazzi are:
# Install XQuartz from MacOSForge. (You alternatively can install the X11.app from Apple. If it is available for your version of Mac OS X.)
# Install the latest available Xcode development tool for your OS, we had good success with Xcode v4.2 on Snow Leopard and v4.3.2 on Lion. For Snow Leopard, Xcode 3.2.6 also works and is still available as a free download with an Apple ID (search for xcode 3.2.6).
## With Xcode 4.3 and above you need to install the command line tools. Xcode --> Preferences --> Downloads --> Components --> Command line tools
## Check that the correct version of Xcode is being used for compilation /usr/bin/xcodebuild -version It should return the version of Xcode that has been installed, e.g. 4.2. In the rare case you need to change your XCode version run the following command in your terminal: sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer
# Install the Paparazzi Tools installer for your OS version from paparazziuav.org
# Set up your environment variables and Python appropriately using the pprz-env-set script:
## Get the script: curl https://raw2.github.com/paparazzi/paparazzi-portability-support/master/darwin/install/Contents/Resources/pprz-env-set > ~/Desktop/pprz-env-set
## Move script to right location: sudo mv ~/Desktop/pprz-env-set /opt/paparazzi/bin/pprz-env-set
## Change script permissions: sudo chmod 755 /opt/paparazzi/bin/pprz-env-set
## Run the script: sudo /opt/paparazzi/bin/pprz-env-set
## Close the terminal. (Do that before you try to move on to the next step. Otherwise the newly set environment will not take effect and you will end up with compilation errors.)
# That's it! To run Paparazzi you need to open the Terminal app and build and run Paparazzi.
## In spotlight type Terminal and then open the Terminal App
## then type: cd ~/paparazzi && make && ./paparazzi (The first time you start paparazzi it might take several minutes to show a window. It is because GTK is indexing the fonts the first time it starts up.) (If you get the error: "Fatal error: exception Gtk.error("GtkMain.init: initialization failed ml_gtk_init: initialization failed")" the most likely source of the issue is the lack of X11 server. Install either X11.app or XQuartz as mentioned in step 1.)
Notes: 
* the binary installer will check if ~/paparazzi exists on your system. If it does, then the installer does nothing. If this directory does NOT already exist, the installer will automatically clone the Paparazzi Git repository into that directory.
* the binary installer will add a few lines to your ~/.profile for PATH modification and for default PAPARAZZI_HOME and PAPARAZZI_SRC env vars. If you have something other than the default ~/paparazzi installation, please edit your ~/.profile and comment out the env var exports.
* the binary installer creates a symbolic link between the available /opt/paparazzi/bin/python2.7 and /opt/paparazzi/bin/python. Combined with the PATH modification, this will cause python something.py to call /opt/paparazzi/bin/python2.7 instead of any system pythons.
== Basic Uninstall ==
In the case you would like to uninstall Paparazzi after completing a basic installation, one must type the following in your terminal prompt:
Warning This first step removes your paparazzi source code, including any changes you may have made yourself locally. If you want to keep your git repository intact, skip this first step and only use the following two steps.
rm -rf ~/paparazzi
sudo pprz-env-set -u
sudo rm -rf /opt/paparazzi
Note that pprz-env-setup -u removes the entry from ~/.profile and also removes the /opt/paparazzi/bin/python symlink.
== Using Luftboot and PyUSB ==
UPDATE: The latest binary installer should have PyUSB included by default, no need to install it separately.
If you are planning on loading code onto a Luftboot-equipped STM32 board, you will need to have a Python version on your machine that is active and with PyUSB installed for that version.
To install PyUSB, execute
sudo python setup.py install
from inside the unzipped PyUSB source directory.
To test which Python version is the default and whether this Python version can find the PyUSB module, in Terminal simply type:
python
To start the default Python. At the Python prompt (>>>) type:
import usb
If another prompt line comes up, PyUSB is installed correctly and you will be able to use Luftboot. If an error is thrown, then your configuration is not correct.
== MacPorts and PyUSB ==
If you have MacPorts installed, you can install either py26-pyusb, py26-pyusb-devel or py27-pyusb-devel, depending on which Python(s) you have installed already, or wish to install. For example:
sudo port selfupdate
sudo port install py27-pyusb-devel
To find out what versions of Python are available on your system (via MacPorts):
port select --list python
Default Apple Python versions have a -apple ending.
Select a different version of python to be the active version if desired. For example:
sudo port select --set python python27
A good, working configuration would be to have MacPorts installed, and install py27-pyusb-devel, then ensure that python27 is the active version.
== Adjusting your PATH and Troubleshooting ==
There are sometimes path issues with OS X if you have MacPorts or a similar (Homebrew, Fink) system installed. The reason for this is there may be multiple copies of a binary required for Paparazzi in different places, and depending on the path, the desired instance is not correctly called. This often presents itself as an error when building the main Paparazzi source code. A typical error may involve the pkg-config program. This can often be corrected by checking and adjusting your PATH environment variable.
To check the currently configured default PATH:
echo $PATH
Ideally, the Paparazzi binary paths (/opt/paparazzi/bin and /opt/paparazzi/sbin) should come first. To move the Paparazzi paths to the highest search priority:
export PATH=/opt/paparazzi/bin:/opt/paparazzi/sbin:$PATH
This will only be active in the current terminal session. If you wish to manually modify the path permanently, you can edit ~/.profile and add the above line to the bottom of the file.
= Installing from source (MacPorts) =
Note: This is known to work for Mac OS X MountainLion. For newer Mac OS versions you should try the Homebrew based install.
The tools that are required to work with paparazzi on a Mac are installed from MacPorts. All of the commands are given by terminal commands, please open your terminal first.
In case you already have MacPorts installed, it is advised to run the following steps before proceeding:
# check that /opt/local/bin is the first entry in your PATH, easy to check by giving the following command echo $PATH
# Then give the following command to make sure your ports are up-to-date sudo port selfupdate && sudo port upgrade outdated
..great, you now can run the installation steps starting from step 4 below.
If you don't already have MacPorts installed run the following steps:
# Install the latest XCode. If you are using 10.9 (Mavericks) or newer you just need to run xcode-select --install
# If you are using Mountain Lion, X11 is no longer included by default, use the XQuartz project to install it.
# Install MacPorts
# Edit the file /opt/local/etc/macports/sources.conf and above the rsync://... line add rsync://rsync.paparazziuav.org/macports/ports/ It is important that this line comes before the path to the standard ports as some of the Paparazzi ports are intended to replace the standard versions. The file is write protected so it will be necessary to be root in order to edit it. The simplest way is to open a terminal window and use nano thus: sudo nano /opt/local/etc/macports/sources.conf
# Now update the available ports with the command: sudo port selfupdate
# To install all of the paparazzi prerequisites: sudo port install paparazzi-tools
# ...Then go and have lunch, get a coffee, get some sleep. This will probably take a long time.
# After installation, we need to set the correct python to override the default OS X python: sudo port select --set python python27
# You can also change the GTK theme
Now you can follow the generic instructions for installing the paparazzi source.
NOTE: If you had previously used MacPorts to install Paparazzi, you may need to manually uninstall arm-none-eabi-binutils, arm-none-eabi-gcc-linaro, and arm-none-eabi-gdb prior to upgrading paparazzi-tools. libcmsis, libopenstm32 and libopencm3 ports may need to be uninstalled as well. For example:
 sudo port uninstall -f libcmsis libopenstm32 libopencm3 arm-none-eabi-gdb arm-none-eabi-gcc-linaro arm-none-eabi-binutils
== Lion and XCode 4.3 or newer notes ==
After installing Xcode 4.3 you will need to install the command line tools by opening the XCode preferences pane, Downloads and selecting Command Line Tools for installation. Otherwise you will not find GCC in your unix path.
Also if macports is complaining about xcodebuild and that you should run
 sudo xcode-select -switch /Applications/Xcode.app 
You should actually run
 sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
so that xcodebuild can find the needed executables for you.
== Troubleshooting ==
If you continually experience problems installing paparazzi or paparazzi-tools then it may be that you have some other conflicting software installed. i.e. an old version of a library in /usr.
One way to work around issues relating to prior MacPort installs that has been found is to clean out everything MacPorts has installed and install from scratch using the latest MacPorts
# sudo port -f uninstall installed
# sudo port clean --all uninstalled
# sudo port selfupdate
# sudo port install paparazzi-tools
This was in fact the process used to check that the code installed on a clean machine.
== Upgrading to Lion ==
If you already have MacPorts and Paparazzi installed and running and you then upgrade to Lion you'll probably find that some things are broken. (make can't be found for example)
To remedy this situation you need to do the following:
# Upgrade Xcode to the Lion version. (App Store --> Search for Xcode and install)
# Install the Lion version of MacPorts
# sudo port -f uninstall installed
# sudo port clean --all uninstalled
# sudo port selfupdate
Now here you have the opportunity to use the binary installer method detailed above or if installing from source then Macports can be used to build from source thus:
# sudo port install paparazzi-tools
If you use a USB to serial converter that isn't based on the FTDI chipset then you may also find that your USB to Serial driver needs to be updated.
# Start console
# Plug in your USB to serial converter
You may get a message similar to this Jul 26 23:14:48 Bernies com.apple.kextd[10]: Can't load /System/Library/Extensions/osx-pl2303.kext - no code for running kernel's architecture.
If you are fortunate enough to have a USB to serial converter that is using the PL2303 chipset then the Prolific driver should sort you out. Installation instructions are included in the readme.txt and are well worth following.
== Keeping source files for debugging ==
If you wish to debug code using the source install then you'll find that many of the source files for the libraries are missing.
This is because MacPorts cleans up the build artifacts and source files after the installation is complete. This behaviour can be changed by adding the -k option to the port command.
For example:
 sudo port -k install paparazzi-tools
This will result in all of the source and build artefact files being left on the hard disk.
Should you later wish to clean up these files you can do so with the clean command.
For example:
 sudo port clean installed
== Mavericks Notes ==
Q: Can not find the command line tools package in XCode any more.
A: Since Mavericks (10.9) it is not necessary to install xcode to install the command line tools package that is needed for macports and paparazzi. Just run in the command line:
 xcode-select --install
Q: libgcc is not compiling with error:
 :info:build The directory that should contain system headers does not exist:
 :info:build /usr/include
A: You probably upgraded from older OS X and are using old command line tools. Make sure to run xcode-select --install command. This should fix the libgcc compilation error.