Difference between revisions of "Compiling"

From PaparazziUAV
Jump to navigation Jump to search
Line 58: Line 58:
Secondly - download some firmare (here we're using a modified [http://paparazzi.enac.fr/wiki/index.php/Using_demo_programs_in_sw/airborne demo2] - which flashes the LEDs with a Tiny2.1 board):
Secondly - download some firmare (here we're using a modified [http://paparazzi.enac.fr/wiki/index.php/Using_demo_programs_in_sw/airborne demo2] - which flashes the LEDs with a Tiny2.1 board):


  $ export PAPARAZZI_HOME=.. if needed... etc.
  $ make AIRCRAFT=DEMO demo2.upload
     make[1]: Leaving directory `/usr/share/paparazzi'
     make[1]: Leaving directory `/usr/share/paparazzi'
     cd sw/airborne; make PAPARAZZI_SRC=/usr/share/paparazzi PAPARAZZI_HOME=/home/dirkx/paparazzi3 TARGET=demo2 all
     cd sw/airborne; make PAPARAZZI_SRC=/usr/share/paparazzi PAPARAZZI_HOME=/home/dirkx/paparazzi3 TARGET=demo2 all

Revision as of 11:10, 11 October 2008

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 ports included. The user you are using to program the autpilots must be a member of the plugdev group. The original user login given during the Linux install process usually is a member. If not, add yourself to this group with the following command:

 sudo adduser <your login> plugdev

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

  newgrp plugdev

USB flashing

The Paparazzi device rules are required for USB flashing. Copy them into place if you haven't already done so:

sudo cp $PAPARAZZI_HOME/conf/system/udev/rules/10-paparazzi.rules /etc/udev/rules.d/

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.

Verify that above downloads work

Step 1

Connect the USB cable to the USB port (U23, corner of the board). You then typically should see feedback like:

  ~/paparazzi3$ dmesg | tail -5
  [79212.484187] pl2303 1-2.3:1.0: device disconnected
  [82312.463077] usb 5-1: new high speed USB device using ehci_hcd and address 23
  [82327.555770] usb 5-1: device descriptor read/64, error -110
  [82342.752307] usb 5-1: device descriptor read/64, error -110
  [82342.968031] usb 5-1: new high speed USB device using ehci_hcd and address 24


which confirms that your device is powered up and visible. If not - check your power and connections. Failing that - prepare to download the USB Bootloader through the 'Download' connector.

Above output is for the Tiny2.1.

Step 2

Secondly - download some firmare (here we're using a modified demo2 - which flashes the LEDs with a Tiny2.1 board):

  $ export PAPARAZZI_HOME=.. if needed... etc.
  $ make AIRCRAFT=DEMO demo2.upload
    make[1]: Leaving directory `/usr/share/paparazzi'
   cd sw/airborne; make PAPARAZZI_SRC=/usr/share/paparazzi PAPARAZZI_HOME=/home/dirkx/paparazzi3 TARGET=demo2 all
   make[1]: Entering directory `/usr/share/paparazzi/sw/airborne'
   /home/dirkx/paparazzi3/var/demo/demo2/demo2.elf  :
   section    size         addr
   .text       956        16384
   .ctors        0        17340
   .dtors        0        17340
   .data         0   1073741824
   .bss         12   1073741824
   .stack     4096   1073742080
   .comment     54            0
   Total      5118
   make[1]: Leaving directory `/usr/share/paparazzi/sw/airborne'
   cd sw/airborne; make PAPARAZZI_SRC=/usr/share/paparazzi PAPARAZZI_HOME=/home/dirkx/paparazzi3 TARGET=demo2 upload
   make[1]: Entering directory `/usr/share/paparazzi/sw/airborne'
   /usr/share/paparazzi/sw/ground_segment/lpc21iap/lpc21iap  /home/dirkx/paparazzi3/var/demo/demo2/demo2.elf
   .
   Found USB device
   BootROM code: 2.12
   Part ID: 0x0402FF25 (LPC2148, 512k Flash, 32k+8k RAM)
   BootLoader version: 1.3
   #
   Starting software at 0x00004000
   make[1]: Leaving directory `/usr/share/paparazzi/sw/airborne'
   make: Leaving directory `/usr/share/paparazzi'
   ~/paparazzi3$

which confirms that your device has the bootloader functioning. The important bit of output is:

   Found USB device
   BootROM code: 2.12
   Part ID: 0x0402FF25 (LPC2148, 512k Flash, 32k+8k RAM)
   BootLoader version: 1.3
   #

Step 3

Observe the LEDs flashing.

Step 4

Disconnect the usb cable, powercylce the unit - LEDs should flash again.

Installing the UART tunnel for direct access to the GPS

Type the following command from your paparazzi folder, substituting the name of your airframe and paying attention to case sensitivity:

make AIRCRAFT=myplane tunnel.upload

Connect the usb cable and power on the autopilot to receive the code.

  • This completely replaces the normal autopilot code (leaving the USB bootloader intact) with a simple serial-to-serial pass-thru that essentially connects the GPS serial port directly to the modem serial port. You will have no LED indicators or other autopilot functionality with this code. Use this only to gain direct access to the GPS for testing/configuration with U-Center or other software.
  • This can be done without the USB bootloader by appending FLASH_MODE=ISP to the command line (specifing ISP serial loading). This will require a serial cable connection (i.e. FTDI USB-to-TTL). Installing tunnel code with the ISP method will erase any USB bootloader code.

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] [5] 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.