Programming Arduino Bootloader using Avrdude with AVRISP mkII in Manjaro (Arch Linux)

Programming Arduino Bootloader using Avrdude with AVRISP mkII in Manjaro (Arch Linux)

18 Jul 2020, 12:50pm TZ +05:30
linux, manjaro, hardware, Arduino, AVR
Embedded

Programming Arduino Bootloader using Avrdude with AVRISP mkII

I use the original Arduino-UNO and Mega for development. They are reliable and work a charm. But for cost constrained projects, most of the times I have used Arduino clones. It’s a common hassle these days with some Arduino clones having wrong boot-loader.

I wanted to have a permanent and repeatable way fix the boot-loader in Arduino boards.

Let’s look at how I did this in my favorite Manjaro (Arch Linux)

In fact my earlier article on installing AVRISP mkII on Windows 10 is one of the most visited articles on this website.

1. Programmer #

I have the AVRISP mkII as my default AVR programmer.

AVRISP mkII Programmer

Image Source : Microchip.com

There are many other cost effective choices:

  1. Arduino as ISP : https://www.arduino.cc/en/Tutorial/ArduinoISP
  2. USBasp : https://www.fischl.de/usbasp/
  3. Pololu USB AVR Programmer : https://www.pololu.com/product/3172

We would be looking in detail the recommended official option AVRISP mkII.

2. Permission #

Most of the hassle in accessing the programmer is the permissions related.

Before we start just make sure you are part of the correct groups.

On Manjaro (Arch Linux) #

sudo usermod -aG uucp ${USER}
sudo usermod -aG lock ${USER}

On Ubuntu #

sudo usermod -aG dialout ${USER}

Next the Tricks to make access easy.

2.1 Direct Method #

Well do do this, we would first need to find out where our AVRISP mkII is connected.

lsusb | grep Atmel

You should see the following output:

Bus 002 Device 013: ID 03eb:2104 Atmel Corp. AVR ISP mkII

In this case the VID:PID combo is represented by 03eb:2104. The location of the device is Bus 002 and Device 013.

We can check the above device by the following command:

ls -al /dev/bus/usb/002/013
...
crw-rw---- 1 root uucp 189, 140 Jul 15 07:32 /dev/bus/usb/002/013
...

Deciphering the above path /dev/bus/usb/<Bus Number>/<Device Number> gives the location for the actual end point.

Now to force fully get access to the device:

sudo chmod 666 /dev/bus/usb/002/013

By this we are making sure that everyone has read / write access to this device.

This is very unsafe method. Do not employ this, other than while testing.

There is a much better way to do this.

2.2 UDEV Rules #

One can set the rules for a specific USB device. This is done by placing a rules file in the /etc/udev/rules.d/.

We have already seen an example of this when installing Zephyr tools .

Let’s look at the files we need this time:

File for Manjaro (Arch Linux) #

50-avrisp.rules

Files for Ubuntu / Debian #

50-avrisp-deb.rules

2.3 Installing the Files #

Copy these files to the /etc/udev/rules.d/ directory. Use the sudo to prefix our transfers.

2.4 Restarting the USB Service #

sudo udevadm control --reload

This would refresh the current USB configuration and load the newly assigned memory storage.

To make sure that the new configuration is updated - restart the computer.

That’s it you should now be able to Burn Bootloader the avrdude from Arduino IDE.

3. Installing avrdude #

Just in case you wish to independently program the boards you need avrdude.

Here is how you can install :

3.1 Install avrdude in Manjaro (Arch Linux) #

sudo pacman -S avrdude avr-binutils avr-gcc

3.2 Install avrdude in Ubuntu / Debian #

sudo apt install avrdude gcc-avr 

The above should get you running with avrdude.

Note that the Install location for avrdude is /usr/bin/avrdude

And the Configuration is stored in /etc/avrdude.conf.

4. GUI front end of avrdude in Linux #

Though there are many to support avrdude via GUI,

I have found the most useful to be AVR8-burn-o-mat .

It’s simpler to use. Only glitch is at first time you need configure the location of avrdude. Its configuration is not apparent at first run.

This is also an AUR pack for this in Manjaro (Arch Linux):

https://aur.archlinux.org/packages/avr8-burn-o-mat

They provide the Debian / Ubuntu package binary.

Wish you All the Best #

Hope that you now have a sure shot way to fix broken Arduino Clones.

As always, I look forward to your suggestion and comments. DM me on Twitter .

Reference #