Programming the AVR without using the Arduino IDE

Most recently , a lot of students from a particular school has been asking if this is possible. It appears that they have been asked by their instructor to build robots but without using the Arduino IDE to discourage “copy-paste” programming. The problem arises when the instructor is unable to give direction as to how this is done.

This quick article discusses the very basics in hope that the reader can pickup critical information and get a decent starting point.

HARDWARE

Almost all AVR’s are programmable or are supported byt the hardware and software tools we shall discuss. Your AVR should have the essential circuits already build and ready for use: regulated power , crystal oscillator if not using the internal one, and access to the ICSP pins: SCK, MISO, MISO, RESET, VCC and GND.

SOFTWARE REQUIREMENTS:

What you can NOT use in this premise

While some users complain of the lack of functionality, the Arduino IDE is a great in many ways in that it has the full package of compilers, linkers, editor etc. that are essential to do programming and that it is particularly simple, lightweight and open source. Other software have repackaged it into their own environment such as what is done in Visual Micro – a Visual Studio plugin that allows the Arduino IDE to be integrated into Visual Studio. There is also an Arduino plugin for Eclipse but again this uses the existing Arduino IDE core tools. Others simple repackage the editor such as in the case of the code editor in Fritzing .

What we can use

Before Arduino, there were several IDE’s that were floating around the internet. We can list some of them below:

There are all capable IDE’s/tools suite with varying strengths and weaknesses. Some of these are paid software while some are freeware wit limitations. WinAVR is open-source however, it is not the friendliest of these bunch.

Atmel/Microchip has released its official development IDE called the Atmel Studio, previously known as AVR studio. It is a very capable and professional tool suite for AVR’s. It works with C/C++ so it should not be too difficult for someone used to Arduino programming. In recent years, this IDE has improved by leaps that we could consider this as currently the best IDE, bar the Arduino environment,  for AVRs.

HARDWARE PROGRAMMER

Now that we have identified our software tool, we need a hardware tool to program (and debug) the AVR using the ICSP port. This tool sits in between the computer and your target AVR circuit and is responsible to uploading the bits and bytes of the machine code into the AVR’s flash. You may use any of the following:

Atmel ICE – this is the official tool supported by Atmel Studio, highly capable but is the most expensive.

AVRISP mk II – this is also an official tool but is nearing the end of its life. It is less than half the price of the Atmela ICE but is still capable  and supported in Atmel Studio 7 although no longer actively being maintained. This tool has been cloned and is found in many Chinese stores with mixed experience from users.

STK500 and compatibles – Atmel has previously released the STK500 development board way back before Arduino and its programmer has been included in several compatible programmers such as that from Sparkfun or Olimex . To date, the original STK500 dev board from Atmel is still being sold.

USBASP – One of the cheapest tool but several users have complained of the difficulty in using this tool with Atmel Studio and the support for newer AVR chips. Using this with the Atmel Studio should be fine, however, a proper guide from online may be necessary to use the pair. Note that this programmer tool appears to have stopped active maintenance of its firmware nor does Atmel Studio officially support it.

USBISP – This is being sold by chinese outlets with some labled as USBASP. so care should be taken when doing so. While we have had success using this to flash AVR’s off a compiled hex file, we have not tried it with the Atmel Studio.

OTHER METHODS and THOUGHTS

The optiboot, used in some Arduino boards, is a powerful bootloader when we consider what it can do. The bootloader is pre-programmed into the AVR chip and works as a self-programming code that is able to fetch data from its UART (“serial” port) and write these into the chips program memory. This is why we do not use a special hardware programming tool when we use the Arduino as it is intended –  we simply use a USB cable.

Granting that the students with this problem are at least allowed to use the optiboot , or any other bootloader, then the issue with programmers may be elimited following this sequence:

  • Burn the bootloader into the chip – this can be done with an Arduino board such as the Uno wired up to the target AVR. The firmware for the Arduino acting as a programmer is already build and is ready to use. Read more about it here. It should be noted that we will use the Arduino IDE and an extra Arduino board just to upload/burn the bootloader into the chip
  • Generate the machine code in Atmel Studio. Develop the code in C/C++ in Atmel Studio (or other IDE’s) and then compile it. You should be able to find the machine code as hex or bin file.
  • Download a software programmer. Atmel FLIP, AVRdude and several other tools downloadable from the internet or try Xloader, though it is not confirmed if it can support machine codes generated outside the Arduino IDE.
  • Upload the machine code into the target AVR using a USB-Serial converter (FTDI, Prolific, CP2102 or CH340G) via the Serial port, usually UART0 or D0 and D1 in most AVR’s

Where to get the hardware programmers mentioned here

Layad Circuits may get them for you. While they may not be onstock, we can import the tools from you direct from the manufacturers. Contact us today – 09164428565, info@layadcircuits.com, facebook.com/layadcircuits or visit our physical store at B314 Lopez bldg., Session Rd. Baguio City.

Leave a Reply

Your email address will not be published. Required fields are marked *