Friday, 12 December 2014

Firmware

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.

37 comments:

  1. Hello,
    anyone able to describe a way to do the firmware upgrade using telnet on a BFV 10 gps ttl?
    greetings Achim

    ReplyDelete
  2. I've just spent the morning soldering my TTL_GPS_V10 onto a kobo mini. I've tried to adjust the vario settings and now the audio isn't working at all! Everything else works fine as far as I can tell, with the vario being picked up by XCSoar. It just won't beep at me. I assume this will be fixed by the firmware update? If so, can you post some step-by-step instructions for updating the firmware on a TTL_GPS which is soldered onto the kobo? Please please don't say I have to take it all apart?! Shorting pins 2 & 5 should be possible by removing the printed cover, but even here this is quite a bit of disassembling...... Otherwise, it all works wonderfully. Thanks!

    ReplyDelete
    Replies
    1. Thanks for the feedback. If you adjust the audio volume back to 1.0 then it should work again (with the old firmware). To update the firmware you might be able to just hold a usb to serial converter on to the BlueFly input provided the Kobo is powered off (perhaps using some Kobo pins). I am not actually sure that will work and it is possible to damage the Kobo so I think the timely disassembling is probably what will be needed.

      Delete
  3. Ok, great. Beeps are back, and I don't mind this too much without a volume control as long as it "works". The most important thing is the button, which I love. Thanks for all your work on this. I'm not going to disassemble and upgrade the firmware..... Perhaps you might email people who have a V10 and suggest they upgrade firmware before soldering onto the Kobo! Could you also post some details of the bugs? Does this affect any other settings?

    ReplyDelete
  4. Good morning, it is very gratifying for me to tell your product I liked and it works perfectly, I want to congratulate you for the good work and hope to go ahead with it.
    I found it very interesting part of the firmware update and I'd like to recommend some improvements such as power control three volume levels from the button to turn it on and also to let sustained beyond a few seconds like to pay it.

    a question, I would like to know what is the maximum time that should I charge the battery?

    Thank you very much and I will be sure of his outstanding work.

    ReplyDelete
    Replies
    1. Carlos, I think I can have different 'button modes' in a future firmware upgrade. One of the modes would be like it is now. Another mode would be like you describe it, and then I could add other modes for other behaviours.

      What do you mean by "... and also to let sustained beyond a few seconds like to pay it"? I do not understand.

      The battery should fully charge in about two or three hours, then the red LED should go out. Sometimes the tolerances between the battery charger IC and the battery over-voltage protection IC mean that the LED will not go out. But do not worry, the circuit should not be damaged if you leave it on charge for too long.

      Delete
  5. Tip: USB to Serial Adapter
    I've just successfully updated my TTL BFV. For me the easiest adapter to buy was one based on the CP2102. And at $7 it won't break the bank. For reference it looks like this:
    http://i884.photobucket.com/albums/ac50/randomdyer/Arduino/CP2102_breakout_zps4a8b428c.jpg
    Al's instructions for updating the firmware were spot on.
    Thanks Al for all the hard work, in producing such a good device.

    ReplyDelete
    Replies
    1. Great. Thanks for the feedback.

      You can get the adapters even cheaper from ebay. Search for "usb ttl serial". I use the ftdi based ones as I am very confident in the potability of the drivers, but it is good to hear the CP2102 ones work as well.

      Delete
  6. Is it necessary to disconnect the BlueFly cables from the Kobo connection points or is it enough to remove battery cable from Kobo? I want to avoid a second time soldering...

    ReplyDelete
    Replies
    1. I am not 100% sure. Just try and let us know how it goes.

      Delete
    2. I am not 100% sure. Just try and let us know how it goes.

      Delete
  7. Dear Al, with connected wires it will not work to start the boot mode. I disconnected and tried 2 different chip connectors USB to TTL as mentioned above. So far it is not working. Probably the drivers are wrong, because if I connect with your BlueFly Desktop, I see no signals coming in. I will continue trying.

    ReplyDelete
    Replies
    1. If you are confident that the USB-TTL adapter is working the most common problem is having tx and rx the wrong way around. There is no point trying the firmware update until you are sure you have a working connection with the BFVDesktop application.

      Delete
  8. Your new firmware functionality makes it worth keep on trying. :)
    Rx/Tx is clear. I will get 2 more adapters from China, different models and see what happens.

    ReplyDelete
  9. I tried 4 different adapters, one is working luckily after a lot of tryout. The firmware is updated, thanks a lot!

    ReplyDelete
  10. Flashing my BFV Bluetooth V10, the Loader sais:
    Initiating write...
    Searching for bl .
    Found dsPIC33FJ128MC506A fw ver. 2.5.3
    Wrong pic detected(80/50)/selected(35/23), aborting
    Tx 1 byte / Rx 4 bytes / 5s
    Write failed

    But following the guide above, I should select:
    Device: PIC24F
    Model: 32KA301

    What did I wrong?

    ReplyDelete
    Replies
    1. When it says found dsPIC33FJ128MC506A it means that there was an error communicating between the PIC and the ds30loader program. Did you select the baud rate properly as well?

      Delete
    2. Ok,misunderstood the error message. Than I'm sure the BFV is not entering the bootloader mode (because I can hear the normal beeps). But #2 and #5 are shorted during power on ... 100% sure.

      Delete
    3. Can you do the hardware reset procedure by shorting #2 and #4?

      Delete
  11. If I'm shorting #2 and #4, nothing happens (neither BFV is on nor off)

    ReplyDelete
    Replies
    1. For the hardware reset it must be shorted during power on and then stay shorted for 10 seconds or so. For entering bootloader mode then it must be shorted only during power on (and then it stays in bootloader mode for 60 seconds).

      There is a remote possibility I flashed the wrong firmware. When it is connected to the BFV Desktop app what firmware version number does it report at power on?

      Delete
    2. It should work with that firmware. If you are properly shorting #2 and #4 at power on then the hardware reset procedure will work, even if the bootloader is not working. Please send me an email using the contact details on the website and we can do some more debugging.

      Delete
  12. Good evening I put the BlueFlyVario_TTL_GPS_v10 on my kobo.
    I wanted to ask how can I remove the sound while flying in descendants because I do not care.
    Possibly without having to use USB adapters
    Thank you very much

    ReplyDelete
    Replies
    1. See step 8 this blog post for how to adjust hardware settings over telnet: http://blueflyvario.blogspot.com.au/2014/04/blueflyvariottl-integration-with-kobo.html

      You will want to change sinkThreshold and sinkOffThreshold. Use the following commands in the :

      echo '$BFS 400*'>/dev/ttymxc0' will make the sink alarm come on at -4.0 m/s.

      echo '$BOS 390*'>/dev/ttymxc0' will make the sink alarm go off at -3.9 m/s.

      Delete
  13. HI I cant seem to get BFVDesktop application to work. it just comes up with a quick error message then nothing I just want to change the sinkrate any advice.Ive tried to follow the instructions but but it just doesnt work

    ReplyDelete
  14. The $BST* command says: BFV 10 205
    Could you please describe what does it mean? I guess 10 is the HW number and 205 is the software id. Are there newest software? Is there some useful?
    There are no details in the manual

    ReplyDelete
    Replies
    1. That means firmware version 10.205. This page http://www.blueflyvario.com/firmware/ has the firmware for download, and it will lead you back to this blog post. You will want firmware version 10.208.

      Delete
  15. Hello Al I would like to know if there is a version for the Mac Os of ds30loader thanks

    ReplyDelete
    Replies
    1. I am sorry, I do not think so. I do not have a mac os device to try to hack solutions with. Please contact me by email if you would like me to do the firmware update for you.

      Delete
    2. I am sorry, I do not think so. I do not have a mac os device to try to hack solutions with. Please contact me by email if you would like me to do the firmware update for you.

      Delete
  16. Hello, it is interesting that i successfully upgrade the firmware but i cannot connect my BFV ttl 10 device to BFVDesktop,it only makes a short beep and nothing apears on the program, no led's lights up ... and after the last firmware update I flyed with it inside a kobo touch and in termic it started to make weird sound like high downward or high ascending, i need some help on this, thanks

    ReplyDelete
    Replies
    1. Please make sure that you do the Reset Hardware Defaults procedure after the firmware update. Start the vario while shorting programming pads 2 and 4. See the hardware settings manual on the support page of the website: http://www.blueflyvario.com/support/.

      Delete
    2. Thanks for the quick replay, i did the hardware reset shorting programming pads 2 and 4 and after that it started to work well, but now the main problem is that when I start BFV when connected to BFVDesktop it makes a little beep and shows that i have "Harware Version: 10.208" and shows all the parameters but I can't change any of them, what am I dooing wrong ?

      Delete
    3. Please send me an email to alistair@blueflyvario.com showing me a photo of the connection between your device and the ttl serial module you are using to connect to the BFVDesktop app. Also show me a screenshot of your BFVDesktop app.

      Delete