Compiling

From PaparazziUAV
Revision as of 10:33, 3 January 2008 by HectoPascal (talk | contribs)
Jump to navigation Jump to search

Flight plans, tuning and configuration settings are compiled into a single binary image and transferred to the microcontroler flash rom through USB. Most tuning and flight plan parameters can be changed in-flight but after each power cycle, the autopilot reverts to the original settings. Permanent changes must be made in the source files, compiled, and uploaded to the autopilot.

Configuring Non-Root users to access USB

Non-Root users typically do not have access to hardware I/O with USB serial ports included. The user you are using to program the autpilots must be a member of the dialout group. Add yourself to this group with the following command:

 sudo adduser <your login> dialout 

It will be effective only on your next login or after the command

  newgrp dialout 


USB flashing

If you are using Ubuntu, the Braille TTY driver interferes with FTDI USB Serial adapters and should be removed:

sudo apt-get remove brltty
Example wiring for programming and telemetry

If the autopilot senses a connected USB cable during power-on, it will wait to receive a firmware image rather than booting normally. The firmware can be compiled and flashed by several means, the simplest way using the Paparazzi Center, the traditionnal way being:

make AIRCRAFT=myplane clean_ac ap.upload
(where myplane is the name of your airframe as defined in conf/conf.xml)

This command erases any compiled autopilot code from the PC, recompiles everything from scratch, and then sends it to the autopilot. Variations include:

  • make AIRCRAFT=myplane sim
    Compiles your code for use in the simulator - note that "clean_ac" will remove this code, so the simulator code must be rebuilt each time a clean has been performed.
  • make AIRCRAFT=myplane fbw.upload
    This is needed when configuring the separate "fly by wire" MCU on the Classix autopilot.
  • make AIRCRAFT=myplane ap
    This will simply build the portions of autopilot code that have changed since the last compile without attempting to flash. Note: this method may not detect certain changes (i.e. changes to the airframe makefile section or CVS updated code).
  • make AIRCRAFT=myplane ap.upload FLASH_MODE=IAP
    Specifies USB flashing. This should be specified at the top of the makefile section of your airframe file but can be overridden here. Use FLASH_MODE=IAS for serial flashing.

Installing the UART tunnel for direct access to the GPS

  • make AIRCRAFT=myplane tunnel.upload
    This will replace the normal autopilot code (leaving the USB bootloader in tact) with a simple serial-to-serial tunnel that connects the GPS serial port directly to the modem serial port. This is useful when testing/configuring the GPS with U-Center
    add FLASH_MODE=ISP to the commandline to specify ISP serial loading

Installing the USB Bootloader

The USB bootloader should only need to be installed once when the board is first built. It is loaded through the serial interface UART0 (Serial1) by holding pin P0.14 low during power-up. If you were supplied with a Tiny Autopilot it may have already had the USB bootloader installed, please check with your supplier.

You will need to convert the PC's RS232 Serial with voltage levels of +/-13V to 3.3V (or 5V) TTL in order to communicate directly with the device. This can be accomplished in multiple ways. The easiest and most convenient method is to purchase or build a USB -> Serial 3.3V adapter similar to this one TTL-232R-3V3 Here's a few other examples: [1] [2] [3] [4] Users are strongly urged to use FTDI usb-serial converters as they are well supported by default in the linux kernel and since the Paparazzi ground station software is configured to look for modems on FTDI ports by default, the converter can likely serve as a modem interface after it's use in programming.

Make up a wiring harness similar to the following. You may vary the details however this is a working solution:

TINY RXD0 <-- PC SERIAL TX (5V or 3.3V)
TINY TXD0 --> PC SERIAL RX (5V or 3.3V)
TINY RESET --> optional wired to ground through a pushbutton so you can reset
TINY P0.14 (SERIAL1-5) --> attach to ground, or wire through a pushbutton to ground
TINY GND --> PC SERIAL ADAPTER GND

Once this wiring is ready you will be ready to send the USB Bootloader to the Tiny from the PC.

To prepare the Tiny to accept programming over its serial port you must have pin P0.14 LOW for at least 3mS while it is powering up or resetting. While it is still powered up it is ready to accept code over serial. Proceed now to instructions to load it via software.

In Linux

From your paparazzi3 folder in linux, type:

make upload_bl PROC=GENERIC

This will begin compiling your USB Bootloader and then attempt to transfer it to the Autopilot. This will also assume you are using a USB -> Serial adapter for the connection. It uses /dev/ttyUSB0 by default. If your adapter is mapped to a different tty, you will need to modify the Makefile accordingly.

In Windows

If for some reason you need to program your Tiny's USB Bootloader in windows grab a copy of LPC2000 Flash Utility V2.2.3 or later. You will then prepare the Tiny and boot it into the ISP bootloader as mentioned above but program it with this utility. You will need to copy your compiled bl.hex file from Linux of course.

Troubleshooting

As a rapidly evolving open-source project, on occasion your software may fail to compile after a CVS Update. This is most likely due to a new or changed variable name that is now required in your airframe, flight plan, etc. Since the user-configured files are not updated automatically you may need to view the most recently changed sample airframe or flight plan files to find the required changes.
See the Software Troubleshooting page for help with common compiliation errors.