Developing for the Atmel AVR Microcontroller on Linux
Program space is a contiguous block of Flash memory, 16-bits wide that can be erased/rewritten 10,000 times. You can design your circuit to allow firmware upgrades in-circuit, using in-system programming.
All AVRs have some EEPROM, and most have SRAM; both are 8-bits wide. The EEPROM is designed to withstand at least 100,000 erase/write cycles. EEPROM is useful because it can be written from within your embedded program to retain data, even without a power supply, or during programming, such as for production-line calibration.
All AVRs, from the tiny 8-pin DIPs to the 44-pin Megas, have at least one data port. Data ports allow for input or output of logic-level data. The AVR ports are bidirectional, allowing you to set them for input or output on a pin-by-pin basis.
Many of the AVRs include additional hardware peripherals, such as UARTs for serial communication and calibrated RC oscillators used as internal system clocks. The external pins often serve two or more purposes, and how they are used depends on how you've configured the microcontroller. For instance, Figure 1 shows that certain I/O lines from both ports can be used with the multiplexed A/D converter.
The set of tools described here isn't the only one available, but it allows you to do basically anything, and the tools function well together. The toolkit is comprised of Binutils, GCC, AVR Libc and our Makefile template to write and build programs for the AVR microcontrollers; GDB and simulavr to debug your software; and avrdude as well as a hardware programmer to transfer your software to the microcontrollers. See the on-line Resources for download URLs for all software.
Fortunately, the recent versions of all these tools include support for the AVR platform, so installation is straightforward. We assume you've chosen to install everything under /usr/local/AVR.
Download a fresh copy of the current binutils source by following the link in the Resources. Untar the source, move into the binutils-X.XX directory and run:
$ ./configure --prefix=/usr/local/AVR --target=avr $ make # make install
The /usr/local/AVR/bin directory now contains AVR versions of ld, as, ar and the other binutils executables. Add the /usr/local/AVR/bin directory to your PATH now. You can apply the modification system-wide by adding:
PATH="$PATH:/usr/local/AVR/bin"
to the /etc/profile file. Make sure the directory is in your PATH and that the change has taken effect before proceeding.
After retrieving a recent release of the Gnu Compiler Collection from a mirror, run the following commands from within the unpacked top-level source directory:
$ ./configure --prefix=/usr/local/AVR \
--target=avr --enable-languages="c,c++" \
--disable-nls
$ make
# make install
This builds C and C++ compilers for AVR targets and installs avr-gcc and avr-g++ in /usr/local/AVR/bin.
The AVR Libc package provides a subset of the standard C library for AVR microcontrollers, including math, I/O and string processing utilities. It also takes care of basic AVR startup procedures, such as initializing the interrupt vector table, stack pointer and so forth. To install, get the latest release of the library and run the following from the top-level source directory:
$ unset CC $ PREFIX=/usr/local/AVR ./doconf $ ./domake # ./domake install
The Psychogenic team has created a standard Makefile template that simplifies AVR project management. You can customize it easily for all your assembly, C and C++ AVR projects. It provides everything for a host of make targets, from compilation and upload to the microcontroller to debugging aids, such as source code intermixed with disassembly, and helpful gdbinit files. A detailed discussion of the template is available, and the Makefile template is available as Listing 1 on the Linux Journal FTP site (see Resources). Store the template with the other AVR tools, moving it to /usr/local/AVR/Makefile.tpl.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Validate an E-Mail Address with PHP, the Right Way
- New Products
- Tech Tip: Really Simple HTTP Server with Python
- Developer Poll
- git-annex assistant
2 min 14 sec ago - direct cable connection
24 min 44 sec ago - Agreed on AirDroid. With my
35 min ago - I just learned this
39 min 10 sec ago - enterprise
1 hour 9 min ago - not living upto the mobile revolution
4 hours 33 sec ago - Deceptive Advertising and
4 hours 36 min ago - Let\'s declare that you have
4 hours 37 min ago - Alterations in Contest Due
4 hours 38 min ago - At a numbers mindset, your
4 hours 39 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




Comments
AVR microcontrollers
AVR microcontrollers is definitely user friendly since the combination of onboard reprogrammable Flash program memory and the in-system programming interface keeps the process of transferring software to the microcontroller simple and cheap.
______
texas criminal defense lawyer
Hi I run Ubuntu 8.10 but got
Hi
I run Ubuntu 8.10 but got troubles when making bin utilities. Giving message "format not a string literal and no format arguments"
Tried to google but one of the thread said it would be dificult to omit. I guess they are wrong but how to solve it is out of my mind. I understand it have something to do with 8.10 using -Wformat=2 and that this flag may give false positives. Any sugestions???
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.././opcodes -I. -I. -I.././opcodes -I../bfd -I.././opcodes/../include -I.././opcodes/../bfd -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror -g -O2 -c avr-dis.c -o avr-dis.o
cc1: warnings being treated as errors
avr-dis.c: In function 'avr_operand':
avr-dis.c:112: error: format not a string literal and no format arguments
avr-dis.c:152: error: format not a string literal and no format arguments
avr-dis.c:161: error: format not a string literal and no format arguments
avr-dis.c:172: error: format not a string literal and no format arguments
make[4]: *** [avr-dis.lo] Error 1
make[4]: Leaving directory `/home/zainka/Downloads/binutils-2.19.1/opcodes'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/zainka/Downloads/binutils-2.19.1/opcodes'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/zainka/Downloads/binutils-2.19.1/opcodes'
make[1]: *** [all-opcodes] Error 2
make[1]: Leaving directory `/home/zainka/Downloads/binutils-2.19.1'
make: *** [all] Error 2
AVR libc
Maybe the configure process for AVR Libc has changed since this was written; "./doconf" is not present in the archive I downloaded.
The INSTALL file tells me to:
./configure --build=`./config.guess` --host=avr
To follow the directory conventions in this article, append that with a "--prefix" option like this:
./configure --build=`./config.guess` \
--host=avr --pref \
--prefix="/usr/local/AVR"
Then make it with:
make
make install
AVR STK500
I have an AVR STK500 and I am using Ubuntu8.04. I am trying to download the update necessary to run the my AVR STK500 but I can't. Are these packages free?
Problem with optimization in the sample file kr.c from psychogen
I had a problem with gcc just skipping the busywait() function until i switched off optimization in the Makefile.
This resulted in all LEDs glowing since they were each turned on with approximately 30 clock cycles in between.
Lovely guide anyway!
Wrinkle (& resolution) using gcc-4.2.2 sources to build avr-gcc
I ran into a problem with the above instructions, using the gcc-4.2.2 sources. The build died with a long string of errors, starting with:
A little research showed this popping up for a few other folks trying to build cross-compilers with gcc 4.x. This message on the gcc-help list suggests that libssp is not likely to be needed when compiling for embedded systems, and suggests the expedient of disabling it during
configure. The following worked for me:$ ./configure --prefix=/usr/local/AVR \ --target=avr --enable-languages="c,c++" \ --disable-nls --disable-libssp $ make # make installSimulavr
Hi,
I am using simulavr version 0.1.2.2 in current Debian testing. In the article you stated, regarding output from simulavr, that "You should see a message to that effect, for example, writing 0xff to 0x0038." I don't get that output from simulavr, I only get the following message for each time through line 71:
Breakpoint 2, main () at kr.c:71
71 PORTB = ~currentValue;
(gdb) c
Continuing.
decoder.c:737: MESSAGE: BREAK POINT: PC = 0x00000045: clock = 194
Am I doing something wrong or could it be different versions of simulavr causing the problem?
Re: Simulavr
Ok,
I figured it out. I had to use the following changes to the simulavr command in one terminal:
simulavr --gdbserver --device at90s8515 -X -P simulavr-disp
Before I ran this command in another terminal:
The -X -P simulavr-disp invokes the display program, that shows all the register info for simulavr, and puts it in a normal terminal window instead of an xterm.
Re: Simulavr
The command I ran in the other terminal that I forgot to put above is the same as the one in the article:
avr-gdb -x gdbinit-helloavr