Updating firmware on AVR chips
Posted in Autonomous Bassline, Modules on May 10th, 2010 by Dann Green – Be the first to commentA number of 4ms devices use an AVR microcontroller. These chips run a small program. On most 4ms devices that use an AVR chip, there’s a 6-pin header (2 rows of 3 pins) near the chip. This header lets you update, upgrade, or hack the AVR chip.
Here’s how to do it:
You will need…
-
ISP (In-circuit Programmer): I recommend the AVR ISP MKII available from Mouser for $34, or elsewhere sometimes cheaper! In Europe, try Farnell
- A computer with a USB port. Windows actually has the most seamless installer, but I also use Mac and Linux to burn code just fine. Download and install one of these:
- Windows: AVR Studio 4, download it from atmel.com. I have not tested AVR Studio 6, I still use AVR Studio 4 (4.18, build 6), so consider downloading anarchived version. You’ll have to “register” by typing in a real email address.
- Mac OS X: Download and install Crosspack-AVR and then AVRFuses
- Linux: You just need the avrdude program to burn code, but can install the whole avr-gcc toolchain if you might be compiling your own firmware.
- The hex file: This is the actual file that contains the firmware update. If you’re upgrading a device, this will be available for download on the device’s web page. If you’re an advanced hacker, you’ll probably compile your own code using avr-gcc (part of AVR Studio and OSX_SAVE/Crosspack) which will generate a hex file for you. The file should be in intel hex format, ending in .hex
Detailed instructions:
Read this article specifically about the PEG, if that’s the device you’re programming. The article references this one, so you need to read them both.
Windows (AVR Studio 4):
- Download and install AVR Studio 4 from atmel.com. Make sure you are downloading AVRStudio4Setup.exe, not just a service pack upgrade!
- Run the installer and click OK/Next to everything. Yes, you want the “Jungo/USB” driver to be installed.
- Plug in your AVR ISP mkII into the USB port and make sure Windows finds and automatically installs the drivers. The green light near the USB plug should come on.
- Power your device up (that is, plug your Rotating Clock Divider into your Eurorack system, or power up your Bend Matrix, etc…). Your device should be running normally, but don’t plug any patch cables into it
- Plug the 6-pin ISP header of the AVRISP mkII into your device. Note the orientation: the red stripe should go towards the white box that’s printed on the PCB: see photo above.
- The light near the 6-pin cable on the AVRISP mkII should turn green, indicating that it detects power. If you plugged it in backwards, it might flash orange. Nothing’s damaged, just flip it around…
- Run AVRStudio 4
- Click the little “AVR Programmer” icon:

- If it doesn’t automatically detect your AVR ISP mkII, then select it from the box on the left, and click “USB”, and then click “Connect…”
- Click on the “Main” tab, and select “ISP mode” from the bottom box. Click “Settings” and choose an ISP Frequency of 125kHz.
- Select “ATmega168″ for the RCD, or ATtiny84 for the ABG, or ATmega32 for the BM, or ATmega328 for the PEG, from the top drop-down box. Click “Read Signature” and it should say “Signature matches device”
- Click the “Program” tab. Under “Flash” click the “…” button next to “Input HEX File” (the top one). Make sure you’re not under EEPROM! Select your hex file that you downloaded (or compiled yourself)
- Now, click “Program” (under the Flash section, not under the EEPROM section). It should give you no errors at the bottom of the window
- Unplug your ISP 6-pin header and you should be good to go!
Please let me know if you have any problems!
Mac OSX (AVR Fuses) –the easy way to upgrade your firmware:
- Download and install Crosspack-AVR
- Download and install AVR Fuses
- For programming an atmega328 chip (such as used in the P.E.G.), download and install this hacked version of AVRFuses and follow the README.txt instructions for installation
- For programming an atmega328 chip (such as used in the P.E.G.), download and install this hacked version of AVRFuses and follow the README.txt instructions for installation
- Download the hex file for your upgrade from 4mspedals.com
- Plug in your AVR ISP mkII. The green light by the USB plug might not come on.
- Do steps 4, 5, and 6 of the Windows installation (power up your device, plug in the AVR ISP mkII, make sure the green light comes on)
- Open up the AVR Fuses program that you downloaded.
- Select the AVR chip type that you’re using (the name of the chip is also printed on the chip itself, use a flashlight to read the tiny letters!)
- Pingable Envelope Generator (PEG) uses ATMEGA328
Bend Matrix uses ATMEGA32 or ATMEGA32A
RCD and SCM: ATMEGA168 or ATMEGA168P
AutoBassGen: ATTINY84 - Select the hex file you downlaoded in step 2, and burn it onto your chip!
Mac OSX (Crosspack) –the advanced way to hack your code:
- Download and install Crosspack from here: http://www.obdev.at/products/crosspack/index.html]
- Download the hex file for your upgrade. Save the file in your Home directory, so you can find it easily with the Terminal.
- Plug in your AVR ISP mkII. The green light by the USB plug might not come on.
- Do steps 4, 5, and 6 of the Windows installation (power up your device, plug in the AVR ISP mkII, make sure the green light comes on)
- Open up your Terminal program (in Utilities folder)
- In Terminal, type “ls” and hit enter. You should see the name of the hex file that you saved in your Home directory (along with everything else in your Home directory). If not, you didn’t save it in the right place.
- Now tell it to burn the code. For the RCD, type this command:
avrdude -P usb -c avrispmkII -p atmega168 -U flash:w:clocker.hex -v -v
And press enter. This assumes your hex file is named “clocker.hex”. It should say “avrdude: Thank you” and have no errors above that. If all goes well, unplug your 6-pin cable and your RCD is updated!
If you’re using a fresh chip, you’ll need to use this command to burn the fuses:
avrdude -P usb -c avrispmkII -p atmega168 -U hfuse:w:0xd7:m -U lfuse:w:0xef:m -U efuse:w:0x01:m -U flash:w:clocker.hex
Linux:
- Install avrdude. You can probably install it with your package manager, such as Aptitude: (type “sudo aptitude install avrdude”), or Ubuntu’s Synaptic
- Follow the OSX instructions starting at step 2. Hint, if avrdude is not finding a usb connection, you might need to type “sudo” before the avrdude commands. Then it’ll ask you for your password before running avrdude.






