Friday, May 25, 2012

Building ArduPilot Mega on Mac

Here how I set up Arduino to compile ArduPlane and ArduCopter on the Mac.

Install Arduino

Download ArduPlane and create a working directory

  • Get the newest copy of Arduplane from the Ardupilot repository.  I grabbed version 2.34.
  • My home directory is /Users/mh, and my working directory is /Users/mh/apm
  • Change to the working directory and unzip ArduPlane-2.34.zip.
  • You should see these directories.  There's some others that you can ignore.
/Users/mh/apm/ArduPlane-2.34
/Users/mh/apm/ArduPlane-2.34/ArduPlane
/Users/mh/apm/ArduPlane-2.34/libraries


Connect your APM to the computer via USB

  • IF YOUR APM IS ON AN AIRCRAFT, DISCONNECT THE AIRCRAFT BATTERIES OR REMOVE THE PROPS!
  • No kidding, the props can spin up unexpectedly and send you to the hospital for stitches!



Run Arduino and configure the environment

  • Run the Arduino program.  Restart it if it was already running so that it can see the APM USB connection.
  • Set the CPU type: Tools / Board / Arduino Mega 2560 (AtMega 1280 for APM1)
  • Set the APM serial port: Tools / Serial Port / /dev/tty.*usb*  The name will vary, look for tty and usb.
  • Set the sketchbook location:  Arduino / Preferences... / Sketchbook Location
  • Set it to the unzipped directory; In my case: /Users/mh/apm/ArduPlane-2.34
  • Quit Arduino and Restart.
  • Double check that the above three settings are still good.

Compile (Verify) the ArduPlane software

  • File / Open... and navigate to /Users/mh/apm/ArduPlane-2.34/ArduPlane
  • Open ArduPlane.pde.  This will give you a window with several files opened in tabs.
  • Click the Verify button.
  • After a while, you should get a message like "Binary sketch size: 157,232 bytes (of a 258,048 byte maximum)"

Upload to APM

  • Click the Upload button.
  • You should see the APM serial light blink furiously
  • You should get the message "*******"

Working on the Arducopter software

  • note: There's some unorthogonality with the downloaded Arducopter zip file.  There's no intermediate directory with a version number.
  • Grab the newest copy of ArduCopter from the ArduCopter repository. I grabbed version 2.5.5.
  • Unzip ArduCopter-2.5.5.zip  in some scratch directory.  This will give you two directories, Arducopter and libraries.  libraries is identical to the ArduPlane version, so you can ignore it.
  • Delete the directory ArduPlane-2.34/ArduCopter
  • Copy ArduCopter to ArduPlane-2.34.
  • You should see the directory ArduPlane-2.34/ArduCopter.
  • In Arduino, open the file ArduPlane-2.34/ArduCopter/ArduCopter.pde.
  • Compile and Upload as described above!

Working with git

  • The Arduplane projects are hosted on Google Code.  Get a Google account if you don't have one.
  • Instructions for checking out are on the ArduPilot source page.
  • You don't need to grab ArduCopter separately.  It will be in the ArduCopter directory as described above.  If you do grab it, it will have a single file pointing you to the ArduPlane repository.
Using command line tools
  • There are notes in README.txt
  • tl;dr: cd ArduPlane; make configure; edit ../config.mk; make; make upload
  • I had to edit the following entry in libraries/AP_Common/Arduino.mk to add the -C parameter.
upload: $(SKETCHHEX)        $(AVRDUDE) -c $(UPLOAD_PROTOCOL) -p $(MCU) -P $(PORT) -b$(UPLOAD_SPEED) -U flash:w:$(SKETCHHEX):i -C /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf

No comments:

Post a Comment