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.
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 …
… 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.