HOW-TO Update DVMega firmware without a programmer or an Arduino

DISCLAIMER: The following *WILL* invalidate any warranties with your DVMega and I will not be held responsible for any damage caused to any item during any attempts to replicate the following.

NOTE: I do not own a DVMega (yet!) and have been unable to confirm this process.  Whilst it is achievable, there may be some slight inaccuracy in my interpretation of the process as relayed to me by others.  Some tinkering may be required to get it to work.

UPDATE: Since delivery of my own DVMega, I have used this procedure countless times and have proved it to work!

UPDATE (30/9/16): v3.04 of the DVMega firmware has been available for a couple of days and I have again successfully used this procedure to flash my DVMega.  I can assure the nay-sayers that it does work.  I will caveat my last comment – getting this to work hasn’t always been smooth sailing for me either – it’s always worked on my own kit, but others I have assisted seem to have been more problematic but once you have dedicated access to the serial port on the Raspberry Pi, this works 100%.  It’s following the steps to free up the serial port that seem to be the sticking point for most.  If you already have a working DVMega setup, in all likelihood you’ve already followed the instructions to free up the serial port or you are using an image that has had this done already.  If not, you need to go to my other HOW-TO on setting up MMDVMHost and more specifically disabling system processes which by default use the serial port.  This is normally enough to gain dedicated access to the serial port for the DVMega, however here are some further pointers on RPi serial ports should you run into difficulty (thanks to  “Steve” for putting me onto this one in the comments).

If you own a  DVMega, you will know that periodically, new firmware is released to introduce new features.  To reprogramme the on-board ATMEGA328 chip on a single band DVMega is fairly straight forward – just unplug the chip from the DVMega and place it in an Arduino.  What about the dual band DVMega with its SMD ATMEGA328 and what if you don’t own an Arduino?

Tom, ON4TOP has come to your rescue.  He has figured out that it is possible to flash the DVMega firmware using the Rpi itself with the DVMega still in situ by wiring the reset pin of the ATMEGA328 directly to a spare GPIO port and then using (a slightly modified version of) avrdude to flash the hex file straight over /dev/ttyAMA0.  The same procedure works just as well on a single band DVMega if you don’t have an Arduino UNO to hand.

The first step will invalidate the warranty on your DVMega, proceed with caution and at your own risk.

Solder a wire between the reset pin of the ATMEGA328 and GPIO4/Pin7 of the header  on the DVMega.

Foto+12-03-16,+13+09+52
Solder a wire between the reset pin of the ATMEGA328 and GPIO4/Pin7 of the GPIO header – picture by Giampiero, IW2ESL
20160916_143908
The wire soldered to a single-band DVMega – the wire goes back to the same point on the GPIO header as in the previous picture. 

The first picture above depicts the dual band DVMega.  On a single band DVMEga (second picture) you can achieve the same result by soldering to the bottom edge of the SMD capacitor (C45) to the left of the ATMEGA328 chip.  In all cases, the wire goes back to GPIO4/Pin7 as shown in the first picture.

I cannot stress the last point strongly enough, so I will repeat it – If you have previously followed the instructions available on the DVMega website and soldered the wire to Pin4 (yes, Pin4 and GPIO4 are 2 separate things – this can cause confusion!) for programming using the BlueStack board, YOU MUST RESOLDER TO GPIO4/Pin7.

Have a look at this …

ct2jg
Raspberry Pi 40 Pin GPIO header

… no prizes for getting the answer that if you connect a DVMega with the wire soldered as per the instructions for the BlueStack board, the reset pin will be held high all the time – that’s not going to work for this method!  Anyway, I digress …

Next you need to download a couple of bits of software to the Rpi.

sudo apt-get update
sudo apt-get install git avrdude python-dev python-rpi.gpio
git clone https://github.com/openenergymonitor/avrdude-rpi.git
cd avrdude-rpi
sudo cp autoreset /usr/bin
sudo cp avrdude-autoreset /usr/bin
sudo mv /usr/bin/avrdude /usr/bin/avrdude-original
sudo ln -s /usr/bin/avrdude-autoreset /usr/bin/avrdude

After ensuring that no other software is attempting to use /dev/ttyAMA0 (such as ser2net or MMDVMHost) you can flash the firmware directly to the ATMEGA328 and avrdude will signal the ATMEGA328 to reset to bootloader before flashing …

avrdude -p m328p -c arduino -P /dev/ttyAMA0 -b 115200 -F -U flash:w:<filename> -v

Where <filename> is the firmware file downloaded from here.

Advertisements

95 thoughts on “HOW-TO Update DVMega firmware without a programmer or an Arduino

  1. So… could I do this on the pi-star image or would it be best to do on a clean image on the Pi3 , sorry all new to this stuff but the guide seems simple enough to follow , what would be the best image to do this on. many thanks

    Like

  2. I got some errors. was working with Arduino UNO. but i’m still interested to have this way working. May be is related with pi-star version. WIP.

    Like

  3. A friend of mine has a single band dvmega about 3-4 years old and never done anything to it. He currently uses it for dstar and runs Maryland dstar on a pi3 B+. If he creates a pi-star image and tries to boot it currently will he be able to upgrade the dvmega firmware using pi-star SSH method or will the dvmega not talk to the pi-star image. All of this after adding the wire of course. I am trying to guide him at a distance and find the easiest and simplest way possible. Thanks for the advise

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s