Difference between revisions of "Compiling"
Line 26: | Line 26: | ||
* make AIRCRAFT=''myplane'' ap.upload FLASH_MODE=IAP | * 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. | *: 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. | ||
* make | * make AIRCRAFT=''myplane'' tunnel.upload | ||
*: | *: This will replace the normal autopilot code 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 [[GPS#GPS_configuration_using_U-Center|U-Center]] | ||
=== Installing the USB Bootloader === | === Installing the USB Bootloader === | ||
Revision as of 14:39, 8 February 2007
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.
Environment Variables
Before compiling you must have the Paparazi source and home environment variables set correctly in your shell. These variables can be automatically set in your shell by adding the following lines to your .bashrc file:
File: /home/your_username/.bashrc |
export PAPARAZZI_HOME=/home/your_username/paparazzi export PAPARAZZI_SRC=/home/your_username/paparazzi |
To manually set the env variables (i.e. when compiling a backup copy of your code in a different folder) execute the following command from the folder you wish to set as your active paparazzi folder:
export PAPARAZZI_HOME=`pwd`;export PAPARAZZI_SRC=`pwd`
You may wish to verify that your variables are set correctly with the following command:
env | grep PAPARAZZI
USB flashing
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 most common 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.
- make AIRCRAFT=myplane tunnel.upload
- This will replace the normal autopilot code 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
Installing the USB Bootloader
The USB bootloader should only need to be installed once. 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 start grabbing the following utility from Philips Philips Flash Utility. 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.