Difference between revisions of "FirmwareFlashing"

From PaparazziUAV
Jump to: navigation, search
(trying to make an overview for different firmware flashing methods)
 
Line 13: Line 13:
 
or add it to the commandline invocation:
 
or add it to the commandline invocation:
 
  make AIRCRAFT=<aircraftname> ap.upload FLASH_MODE=JTAG
 
  make AIRCRAFT=<aircraftname> ap.upload FLASH_MODE=JTAG
 +
 +
== Newbie explanation ==
 +
The goal of this part of the documentation is to give you insight in how to give your Autopilot board a ''Brain''. Airborne autopilot code, flight plans and configuration settings are compiled into a single file, sometimes referred to as a ''binary image''. After compilation this file is transferred to the Autopilot board micro-controller flash ROM through use of an USB cable. Note that 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 are made by recompiling the airborne code and it's new configurations settings, and re-upload this to the autopilot board. It may sound complicated but in fact it is quite simple if you follow the steps below.
  
 
== USB ==
 
== USB ==

Revision as of 08:33, 7 February 2013

This is about how to flash new firmware to you favorite new gadget :-)

Generally speaking there are several different ways to flash the firmware on your autopilot board. Not all boards support every method though.
Every board has a sensible default flash mode set, but where supported you can override that. Either specify the FLASH_MODE in the firmware section of your airframe file, e.g.:

<configure name="FLASH_MODE" value="JTAG"/>

or add it to the commandline invocation:

make AIRCRAFT=<aircraftname> ap.upload FLASH_MODE=JTAG

Newbie explanation

The goal of this part of the documentation is to give you insight in how to give your Autopilot board a Brain. Airborne autopilot code, flight plans and configuration settings are compiled into a single file, sometimes referred to as a binary image. After compilation this file is transferred to the Autopilot board micro-controller flash ROM through use of an USB cable. Note that 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 are made by recompiling the airborne code and it's new configurations settings, and re-upload this to the autopilot board. It may sound complicated but in fact it is quite simple if you follow the steps below.

USB

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 traditional 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.

For boards where USB flashing is not the default you will have to specify it explicitly.

LPC21

Set FLASH_MODE=IAP.
This requires that you uploaded the LPC bootloader.

Connect an USB cable to the USB port on the autopilot board.

STM32

Set FLASH_MODE=DFU.
This requires that you have the Luftboot bootloader on the board.

JTAG

Set FLASH_MODE=JTAG.
Lisa/L has an onboard JTAG, otherwise you need a JTAG adapter. You should have OpenOCD already installed.

  1. Connect your JTAG adapter the board via the cortex cable (little black socket)
  2. Attach the UART port on the bottom of the jtag to UART2 on the autopilot.
  3. Plug in USB port of the jtag
  4. Plug in USB port of the Autopilot
  5. Click upload, wait until complete, then click Upload. You should see something like the following towards the end:

{{{ ... Info : device id = 0x10016418 Info : flash size = 256kbytes stm32x mass erase complete Info : Padding image section 1 with 7972 bytes wrote 152576 bytes from file src/paparazzi/var/Hexa_LisaL/ap/ap.elf in 7.498179s (19.871 KiB/s) Info : JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3) Info : JTAG tap: stm32.bs tap/device found: 0x06418041 (mfg: 0x020, part: 0x6418, ver: 0x0) shutdown command invoked }}} During an upload the JTAG RxTx LEDs should blink.

STM32

If you have a Lisa/M v2.0, using JTAG will not overwrite the bootloader by default. To overwrite the luftboot bootloader configure

<configure name="NO_LUFTBOOT" value="1"/>

Serial

You can also flash via serial cable or modem, but it takes a longer time. You can't just consider the baud rate to estimate the duration of the operation are there are many exchanges in the flashing protocol and the com latency over RF becomes significant.

Have a look at the page for your autopilot board to see how to enter serial flashing mode.
Firmware upload using the factory integrated bootloader can be useful e.g. if you have overwritten your USB bootloader.

LPC21

Set FLASH_MODE=ISP.
NOTES:

- Make sure you connect your serial device to UART0
- Make sure you pull P0.14 boot pin low on power on to enable the LPC ISP mode

STM32

Set FLASH_MODE=SERIAL.