Lpc21BootloaderUpload

From PaparazziUAV
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Bootloader from scatch

The goal of this page is to explain how to get the autopilot bootloader onto a brainless new ARM based autopilot board. Note that the bootloader only needs to be installed once, when the board is first built and has never been used. Most of the times if you bought a board somewhere, the bootloader is already installed for you. If you did not make your own autopilot board, but rather purchased it from a manufacturer, chances are high the bootloader is already uploaded onto your board by the manufacturer. You could ask the supplier of your board. In that case you can just skip the steps described here and just continue the part of Uploading the Flightplan code to your autopilot board or if you are more experienced you could go here

Bare_TWOG_Board.jpg

Why have Bootloader in the first place

Since the Airborne code and Flight-plans change frequently, it would be great if we could just simply upload new version with changes on the ground by connecting an USB cable to out airframes autopilot board. Well, the Bootloader makes this a simple reality.

How does it work

The Bootloader is uploaded through the serial interface UART0 (Serial1) by connecting certain point on the board to ground during power-up, sometimes referred to as: holding low. On the board Tiny V1.x pin P0.14, Tiny V2.x this pin is called BOOT). Also GPS_RESET has to be tied low during the serial programming to keep the GPS receiver quiet that shares the serial port with the download.

Connecting it all

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 Autopilot board. 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

The FTDI RS232 USB Cable

Some examples of suppliers: [1] [2] [3] [4]

It is strongly advised that you use a USB-serial converter with of the [FTDI brand] chip, as serial chips from the FTDI brand are by default working well in Linux. As a nice bonus, 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 Bootloader uploading.

Make up a wiring harness similar to the following.

You may vary the details, however this is a working solution:

Tiny V1.x (SERIAL_1):
TINY RXD0 <-- PC SERIAL TX (5V or 3.3V) TINY TXD0 --> PC SERIAL RX (5V or 3.3V) TINY P0.14 --> attach to ground, or wire through a pushbutton to ground TINY GND --> PC SERIAL ADAPTER GND TINY RESET --> optional wired to ground through a pushbutton so you can reset
Tiny V2.x (Connectorname - DOWNLOAD) :
TINY LPC_RXD0 <-- PC SERIAL TX (5V or 3.3V) TINY LPC_TXD0 --> PC SERIAL RX (5V or 3.3V) TINY BOOT --> attach to ground, or wire through a pushbutton to ground TINY GPS_RESET --> attach to ground, or wire through a pushbutton to ground TINY GND --> PC SERIAL ADAPTER GND
TWOG V1.x (Connectorname - DOWNLOAD):
TWOG LPC_RXD0 <-- PC SERIAL TX (5V or 3.3V) TWOG LPC_TXD0 --> PC SERIAL RX (5V or 3.3V) TWOG BOOT --> attach to ground, or wire through a pushbutton to ground TWOG GND --> PC SERIAL ADAPTER GND

For TWOG make sure the GPS module is unplugged from the board. This is to prevent GPS serial data to disturb the uploading of the bootloader.

Where to insert the Bootloader cable

Upload the bootloader

Once this wiring is ready you will be ready to upload the bootloader to the autopilot board from your PC.

To prepare the Autopilot board to accept uploads 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 the Bootloader firmware code upload over the serial connection.

The next step while your board is all connected and powered up is to type the commands for uploading the bootloader firmware.

In Linux

From your Paparazzi 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 board. 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.


Wait for the bootloader to upload


If everything is connected and setup correctly, after a while you will see the following messages


Shell Bootloader upload success


In Windows

If for some reason you need to program your autopilot board USB Bootloader in MS Windows you have to download the LPC2000 Flash Utility V2.2.3 or later. You will then prepare the autopilot board and start it in ISP bootloader state as described previously. This small utility will ony help uploading the Bootloder firmware. You will need to copy your compiled bl.hex file from Linux to your Windows OS. This file will be then uploaded.

Check if the usb bootloader is installed

Now if you type the following command in your terminal...

$ dmesg | tail

..you should see messages that look like:

[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 working, and ready to accept new airborne code. In case you do not see this message, check your battery voltage and connections and make sure the cables are not broken.

When you upload in the Paparazzi Center it will print out messages. 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

Which confirms that your device has the bootloader functioning...


Additional information

In depth info about the bootloader can be found on the Bootloader reference page.