Avrdude
Using avrdude under Linux
The Uzebox bootloader can be found within the uzebox/demos/Bootloader5 directory of the official Uzebox git repository.
After building the bootloader, connect your AVR programmer to the ISP header of your Uzebox. Flash the bootloader by running:
avrdude -c avrispmkII -P usb -p m644 -U flash:w:Bootloader5.hex
Note that you do not need root permissions nor do you have to connect the Uzebox's power adapter to use avrdude.
Flash the fuse settings with:
avrdude -c avrispmkII -P usb -p m644 -U hfuse:w:0xd2:m -U lfuse:w:0xf7:m -U efuse:w:0xfc:m
If you aren't using an AVR ISP mkII, then change avrispmkII to the correct device name for your programmer. The USBasp ISP and USBtinyISP chip programmers are also supported by avrdude. If you don't own a compatible chip programmer, it is also possible to use avrdude via GPIO if you have a RaspberryPi or similar with a GPIO header.
Changing the efuse configuration raises the brownout detection to 4.5V so that the chip doesn't come out of reset until the power is sufficiently stable. This helps provide a more reliable video signal when powering on with the new bootloader. If you don't want to mess with the brownout detection, then you can exclude:
-U efuse:w:0xfc:m
From the previous avrdude command. If you are reflashing this bootloader on a Uzebox DTV, you will have to change the device name in the above commands to m644p.
The ICSP pinouts for the Uzebox DTV are: GND, VCC, RESET, SCK, MISO, MOSI with GND being the pin closest to the uSD card.
Using avrdude with a Raspberry Pi
On the Raspberry Pi, avrdude can use the GPIOs to program the Uzebox microcontroller. It is not necessary to build avrdude from source as the one available in the repositories works just fine.
sudo apt install avrdude
When avrdude is installed, you need to edit /etc/avrdude.conf to enable the linux gpio programmer. Search for "linuxgpio" in the file and you should see this:
#programmer # id = "linuxgpio"; # desc = "Use the Linux sysfs interface to bitbang GPIO lines"; # type = "linuxgpio"; # reset = ?; # sck = ?; # mosi = ?; # miso = ?; #;
Change it to:
programmer id = "linuxgpio"; desc = "Use the Linux sysfs interface to bitbang GPIO lines"; type = "linuxgpio"; reset = 4; sck = 11; mosi = 10; miso = 9; ;
You should wire the Raspberry Pi GPIOs to the Uzebox like shown on this image
Now you can run the following command to confirm that your raspberry pi can communicate with the microcontroller:
sudo avrdude -c linuxgpio -p m644 -v
It should return something like this:
avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e9609 (probably m644) avrdude: safemode: lfuse reads as F7 avrdude: safemode: hfuse reads as D2 avrdude: safemode: efuse reads as FC avrdude: safemode: lfuse reads as F7 avrdude: safemode: hfuse reads as D2 avrdude: safemode: efuse reads as FC avrdude: safemode: Fuses OK (E:FC, H:D2, L:F7) avrdude done. Thank you.
When you are certain that communication with the microcontroller is working, you can burn the bootloader and fuses like above.
sudo avrdude -c linuxgpio -p m644 -U flash:w:Bootloader5.hex
sudo avrdude -c linuxgpio -p m644 -U hfuse:w:0xd2:m -U lfuse:w:0xf7:m -U efuse:w:0xfc:m
Using avrdude under Windows with an AVRISPMKII programmer
When Microchip Studio (previously Atmel Studio) is installed, it also deploys the Jungo USB driver that will conflict with libusb, required by avrdude. To be able to use both, you need to install the libusb filter driver. Read the installation instructions here.. The installer uses a simple GUI that will let you attach the filter driver on top of the Jungo driver.
After installation, open a command window and run:
C:\WinAVR-20100110\bin>avrdude -c avrispmkii -p m644 -P usb:xx -v
avrdude: Version 5.11-Patch#7610, compiled on Aug 31 2011 at 08:02:19
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"
Using Port : usb:xx
Using Programmer : avrispmkii
avrdude: usbdev_open(): Found AVRISP mkII, serno: 0000B0038732
avrdude: usbdev_open(): did not find any (matching) USB device "usb:xx"
Your device should be listed with it's serial number (in the above case it's "serno: 0000B0038732"). Use the last 4 digits of the serial number to invoke avrdude:
C:\WinAVR-20100110\bin>avrdude -c avrispmkii -p m644 -P usb:87:32 -v
avrdude: Version 5.11-Patch#7610, compiled on Aug 31 2011 at 08:02:19
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"
Using Port : usb:87:32
Using Programmer : avrispmkii
avrdude: usbdev_open(): Found AVRISP mkII, serno: 0000B0038732
AVR Part : ATMEGA644
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
....
Also when using multiple avrdude commands in a batch file, if only the first command works and the next fails, insert a delay between command using the sleep command.