FirmwareFlashing

From PaparazziUAV
Revision as of 12:46, 1 May 2016 by Flixr (talk | contribs) (→‎STM32)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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"/>
<configure name="FLASH_MODE" value="JTAG_BMP"/>
<configure name="FLASH_MODE" value="SWD"/>

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 microcontroller 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 its new configurations settings, and re-uploading 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

There are two different DFU Bootloaders:

  • custom Luftboot bootloader (LisaM/Lia boards)
    • will automatically go into DFU mode
    • Choose/set FLASH_MODE=DFU
  • native DFU bootloader on STM32F4 (embedded in ROM)
    • To trigger DFU mode, connect BOOT0 with 3V (and BOOT1 with GND), reset and disconnect both. (BOOT1 is not always needed)
    • Choose/set FLASH_MODE=DFU-UTIL


The native DFU bootloader requires external software,the DFU site provides more information.

JTAG

Black Magic Probe

Set FLASH_MODE=JTAG_BMP.

Instructions are the same as FLOSS JTAG above, but it is not necessary to connect the UART cable.

DeprecatedThere is some additional information here.

To make this the default flash method add this in the airframe file firmware section:

   <configure name="FLASH_MODE" value="JTAG_BMP"/>
   <configure name="BMP_PORT" value="/dev/ttyACM0"/>

FLOSS 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"/>

SWD

Set FLASH_MODE=SWD.

E.g. using BlackMagicProbe.

STLINK

Install STLink and choose/set FLASH_MODE=STILINK to use STLink.

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.