Friday 12 December 2014


From version 10 the BlueFlyVario models include a bootloader so you can upgrade the firmware. The firmware is the chunk of code on the microprocessor which makes the Bluefly wield its magic. Current firmware versions use about 60% of the code space on the microprocessor, so there is some flexibility to add a few features within the limits of the hardware. Normally you need a special microcontroller programmer to update the firmware, however with the bootloader you can do it over a serial connection without the special programmer. In this post I will describe how the the bootloader works and how to update the firmware.

The ds30loader bootloader

The bootloader is a small section of code which runs before the main Bluefly code. For a whole range of reasons I selected the ds30loader that Michael worked on a few years ago as an open source project (it is GNU licensed, it is used in other devices, I could make it work... etc. ). This same bootloader is used in the bus pirate and other open products. Since Michael did the open source project the bootloader is also available in a commercial version, but I used the GNU licensed one as I wanted to customise it.

You can download the modified source code for the bootloader from my github. You do not need the source, but some people might find it interesting. The source for the bootloader is in assembly and is set up as an XC16 MPLABX project. The bootloader is modified from Michael's original version with the following features:
  • The various settings (configuration bits, timeouts, processor, etc) recommended to be adjusted have been made to match the Bluefly hardware.
  • The bootloader mode will only be entered if RA0 is positive. This corresponds to programming pad #5 on the Bluefly hardware (PGEC). As programming pad #2 is positive then the bootloader mode will be entered if pins #2 and #5 are shorted.
  • When in bootloader mode the green LED is lit but there are no normal startup beeps. This provides some feedback so you know you are in bootloader mode.
To use the bootloader you will need the ds30loader gui PC application. You can download it directly from here.

Firmware Versions

The firmware is contained in a .hex file. From version 10 I started a new numbering system for firmware. I will put all version 10 firmware versions on the support page of the website. The numbering scheme works like this:
  • BlueFlyVario_{DEVICE_TYPE}_v{MODEL_NO}.{TYPE_NO}{SUB_VERSION_NO}.hex where:
    • {DEVICE_TYPE} = Bluetooth, TTL_GPS or USB
    • {MODEL_NO} is associated with a particular series of hardware. (i.e. version 10 for the version 10 models).
    • {TYPE_NO} is associated with the DEVICE_TYPE (Bluetooth = 1, TTL_GPS = 2 and USB = 3).
    • {SUB_VERSION_NO} is the version of the firmware.

For example BlueFlyVario_Bluetooth_v10.102.hex is the second release of firmware for model 10 Bluetooth hardware.

Step 1 - Get the software

Get the ds30loader gui application using the link above and make sure it runs on your pc. Download the right version of the firmware you will need.

Step 2 - Prepare the hardware

You will need access to the programming pads on the pcb so you can short pads #2 and #5. You might need to disassemble the Bluefly so you can access the pads. A small hole in the heatshrink might be sufficient. See the image below for an indication of which pads I am talking about.

You will also need to establish a serial connection. You can test your serial connection using the BFV Desktop application or a terminal emulator like Realterm:
  • Bluetooth version: you should add the vario as a device to the PC (you might need to use code 1234 to pair it via the Devices and Setting menu, it depends on your Bluetooth adapter). You will need to work out what serial port it was assigned by looking at its properties.
  • TTL_GPS version: you will need a TTL to serial adapter. Depending on how you installed the TTL_GPS you might need to solder things. Again you need to work out what serial port the TTL to serial adapter has been assigned.
  • USB version: the serial port is assigned when the device is first connected to your PC.
Step 3 - Open the ds30laoder application

Open up the ds30loader application. Adjust the settings to match the following:
  • Hex file: Browse to the location of the firmware hex file you downloaded (make sure to unzip it)
  • Device: PIC24F
  • Model: 32KA301
  • Baud: 57600
  • Port: What ever serial port you plan to use based on the one you determined in Step 2.
  • Write flash: Checked
  • Flow control: None

Step 4 - Start up the Bluefly in bootloader mode

You will need to short programming pads #2 and #5 then power on the Bluefly module as described in the image above. You should just be able to use a paperclip bent appropriately.
  • For the Bluetooth version, press the power on button while the pads are shorted. As soon as the green led lights up solid you can remove the short. 
  • For the TTL_GPS you will need to power the module using something like a TTL to Serial adapter. Press power then when the green LED lights you can remove the short. 
  • For the USB version it will power on as soon as you attach it to the USB port of your PC, so make sure the pads are shorted when you attach it (you might need three hands).

If the green led lights up and stays lit you are in bootloader mode. You should not hear any of the normal beeps associated with startup.

After entering bootloader mode you have 60 seconds to complete the next step. If you do not program within 60 seconds the device will exit the bootloader mode.

Step 5 - Program the device

Press the Write button in the ds30loader application. The application should connect to the Bluefly and start programming. It takes about 20 seconds.

When programming is complete the Bluefly will start like normal with the new firmware. You can connect it to the BFV Desktop application to confirm the new version is uploaded.