Phew!!!!! Because quite a few people asked me how to do programming in AVR microcontrollers. There may be the case that they are starting up all this or they are switching from another microcontroller to AVR now [though it is old too 😦 or you may say obselete…] So, here I am going to explain in short and working way to “make” the things up.
Obviously this tutorial is for linux users, OPEN SOURCE advocates, so we will be learning how to program AVR chips in linux environment open source way. We will be using Open source tools/techniques and softwares. The programmer AVRDUDE, the toolchain, VIM editor, usbasp programmer; All are Open Source. One can use Windows being loyal to Microsoft, (Ughhhh,, I am not going to get a job there if I praise them or boast about them…ooopss…is there is anything to boast upon for them… 😉 lolzzz..) Really, In case of windows things works `I DONT KNOW HOW & WHY` and one actually needs to do nothing to make the program compile and burn and thus getting no knowledge about the things being done, what all is involved, who is doing what, etc. etc. etc. So, in case of linux systems, programming AVR is really easy NOW because of some lazy linux users. People want that they can program in linux without getting much of the pain. (Yeah, you are thinking right, I am saying for the scary compilation of the toolchains).
One has to make the binary utilities ready for cross compilation, gcc for AVR architecture, avrdude, avrlibc, simulAVR, gdb for avr before starting to think to program AVR in linux. Frankly saying, I was screwed up when I compiled the toolchain for the first time. I referenced 4-5 tutorials for it even then it took a lot of time. Thanks to Atmel AVR because they provide toolchain for AVR architecture both 8 bit and 32bit. http://www.atmel.com/tools/ATMELAVRTOOLCHAINFORLINUX.aspx
One can simply download the toolchain, and start working out. For very obvious reasons, things are not as easy as they appear to be. Toolchain contains essential binutils and avr-gcc, avr-objcopy etc. but the two most important things are still left.
So, download avrlibc from here : http://savannah.nongnu.org/projects/avr-libc/
Avrdude from here: http://savannah.nongnu.org/projects/avrdude/
Go for our favorite method of building program from source code, (obviously iff you like it, you may opt for direct use of it, but I just like to make things work from as low level as I can do).Download the avr-libc from the link provided, and just unzip it, then go for compiling 1.AVRLIBC:
- $ cd avr-libc-<version>
- $ ./configure –build=`./config.guess` –host=avr
- $ make
- $ sudo make install
now here, config.guess is intelligent script that checks for your systems and configures itself. Rest is self-explanatory. Or download directly in case of package managers. Ubuntu/debian:
sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude
Read the rest of this entry →