Fab Academy at AS220 Labs

Tutorials

August 12, 2010 8:47 PM

Very Basic Beginner Assembly Tutorial III: How to Use Avrdude

by Anna Kaziunas France

First - If you have not already compiled your program

See the Very Basic Beginner Assembly Tutorial: How to Use Gavrasm to compile an .asm flie

If you have compiled your program (created a .hex file)

Note: If you do not yet have avrdude installed or if you are a windows user and need avr studio - see Lady Ada’s tutorials for detailed information on how to download, setup, configure and use these programs. Lady Ada’s AVR software installation tutorial:

Once your AVR software tools are installed:

Again - Lady Ada has excellent detailed tutorials on how to use avrdude check the out for details on what the all the commands are and what they do - I will just give the very basics here to help you program a chip.

  1. Open your command line interface and navigate to the directory that contains the file you want to flash to the microcontroller.

  2. Connect your AVR programmer to your computer - I prefer the usbtiny (also created by Lady Ada and available at a reasonable price from adafruit studios).

  3. If your board has an resonator / external clock you will need to set the fuses first before attempting to program the microcontroller. You must do this first. However, once the fuses are set - you do not have to do it again. The fuses are set only once. You can reprogram the microcontroller as many times as you want after the fuses are set.

example to set fuses:

parts used in this example:

  • 20 MHz clock
  • bsd cable programmer
  • microcontroller - attiny44
avrdude -p t44 -c bsd -U lfuse:w:0x7E:m

You need to change the parts in the code above to match the parts you are using in order for it to work. Ask you instructor if you are confused.

example to set fuses: parts used in this example:

  • 10 MHz clock
  • usbtiny programmer
  • microcontroller - attiny45
avrdude -p t45 -c usbtiny -U lfuse:w:0x7E:m

4. If you have set the fuses already or if your board does not have an external clock - here is how to flash / program the microcontroller.

generic example to flash microcontroller:

avrdude -p microcontroller -c programmer -U flash:w:program.hex

example with actual data:

parts used in this example:

  • usbtiny programmer
  • microcontroller - attiny44
avrdude -p t44 -c usbtiny -U flash:w:freqrx3.hex

August 12, 2010 8:21 PM

Very Basic Beginner Assembly Tutorial II: How to Use Gavrasm to compile an .asm flie

by Anna Kaziunas France

This tutorial instructs you on how to compile an assembly language file (.asm) into a .hex flie using Gavrasm (Gerd’s AVR Assembler). the .hex file can then be uploaded to a AVR microntroller using Avrdude (or another program.)

1. Check to see if you have Gavrasm installed.

Open your command line interface and type:

gavrasm

If Gavrasm is installed you will see (your version number may vary):

+------------------------------------------------------------+
| gavrasm gerd's AVR assembler Version 2.5 (C)2010 by DG4FAC |
+------------------------------------------------------------+

2. If Gavrasm is not installed you will get an error.

You can download and install Gavrasm from here: http://www.avr-asm-tutorial.net/gavrasm/index_en.html.

*Note: if you are running a Mac OS (especially a pre-intel / PPC - Power PC Mac see my tutorial on where to get the compiled Gavrasm for PPC Macs or how to compile it yourself. *

3. If Gavrasm is installed — or once you get it installed:

A. navigate to the directory where the file that you want to compile is located.

- if you are unfamilar with unix commands: s To list the files in your current directory type:

ls

To change directory / navigate into a specific listed directory type (where directory name is the name of the directory you want to move to):

cd directoryname

To move upwards in the directory tree structure type”

cd ..

If you know the pathname of the directory that you want - type in the pathname of the directory preceded by “cd”

ex:

cd  /Desktop/mydirectory/mydirectory2

you can find more about general unix commands b doing a general internet search.

B. After navigating the correct directory - type:

gavrasm filename.asm

where “filename.asm” is the name of the assembly file you want to compile.

4. Gavrasm will compile the file for you and produce a .hex file of the same name as the .asm file.

Warnings:

Gavrasm will inform you if there are warnings. For the most part you can ignore the warnings. Ask your Fab Academy instructor if they are something you should be concerned about.

Errors:

If there are errors in compiling your file - Gavrasm will refuse to create a .hex file and will throw a bunch of error messages at you. Use these error messages to fix the problem.

If you don’t understand them - google the error or look at the datasheet for the microcontroller that you are using. See my tutorial on “Datasheet Tips”. Ask your instructor if you are confused - odds are they have encountered this many times. You must fix the errors in the program before it will compile.

5. You can now use your AVR programmer and Avrdude to flash your microcontroller with the .hex file you just created.

August 11, 2010 8:30 PM

Very Basic Assembly Tutorial I: Where to Get Gavrasm for the Mac OS

by Anna Kaziunas France

Having problems compiling Gavrasm on your Mac? Here is where to get Gavrasm (Gerd’s AVR Assembler) pre-compiled binaries for the Mac OS.

OS X 10.4.11 - Tiger (Power PC)

Download Anna Kaziunas France’s compiled version

OS X 10.5.x - Leopard

Download Kelly Snook’s compiled version

OS X 10.6.x - Snow Leopard

Download David Mellis’ compiled version

Windows & Linux

Pre-compiled binaries for Windows and Linux are available from the Gavrasm homepage. http://www.avr-asm-tutorial.net/gavrasm/index_en.html

January 11, 2010 5:21 PM

Intro to Bazaar

by Noah Bedford

Creating a bzr repository:

First, inform bazaar as to your personage:

bzr whoami "Mr. Foo <mrfoo@as220.org>"

Then, make a directory for your repository: mkdir repository

Initialize the repository:

bzr init

Add the current directory:

bzr add *

Make the first commit:

bzr commit -m "Hello World"

Now, every time you want to add files, run

bzr add <files>

again, and

bzr commit -m "Message".

To check out your repository

start an ssh server (openssh-server in ubuntu, check the box in the preferences window in OSX), and run

bzr branch  sftp://user@ip-address/path/to/directory

Then

bzr pull

To update the repository, bzr commit again and then

bzr push

Have fun!

-\n

November 13, 2009 2:10 PM

Standard software on the AS220 fab machines + hairy.cad

by Noah Bedford

These packages are all in the Ubuntu repositories, so it's reasonable and sane to run:

aptitude install inkscape blender qcad python-scipy python-numpy python-tk python-imaging-tk eagle curl

We mirror http://fab.cba.mit.edu/about/fab/ using Curlmirror. (a perl script that spiders webpages)

Some of the boards were coming out a bit hairy due to our initial use of the wrong drill bit (we were using series 1 when we need 1b), so I made a hairy hello world .cad file: hairy.button.45.cad

All attempts to create a working board without ripping off the traces or shorting out important pins have thus far been nonexistent, however, this may change shortly as Elliot's just milled a fresh batch.

October 21, 2009 10:46 AM

Fetchdeps.sh and gik.svg

by Noah Bedford

There wasn't a script to fetch the dependencies required by cad.py under ubuntu, so here's one: fetchdeps.sh And there wasn't an SVG of GIK, so I ran it through trace bitmap: gik.svg

Return to front

Older articles