It's a simulator for AVR in Linux that can take your ELF or HEX code and run it as if it's actually on-chip, but gives you hooks and the possibility of dumping trace files. I'll go through a simple example.
Remove these ads by
Signing UpStep 1: Git it
sudo apt-get install avr-libc libelf-dev \ libglut3-dev gtkwave git build-essentialI had to remove some crappy Mesa symlink for OpenGL in 10.10. Only do this if you have problems compiling related to -lGL,
sudo rm /usr/lib/libGL.so cd /usr/lib sudo ln -s libGL.so.1 libGL.so cdFinally, use git to download the source code:
git clone git://gitorious.org/simavr/simavr.gitNow, build it.
cd simavr makeIf you get any errors, leave me a comment. I'd be happy to help. You should have a new program called run_avr in the simavr subdirectory once that completes.








































Visit Our Store »
Go Pro Today »




[adam@deathstar simavr]$ ./simavr/run_avr tests/atmega48_disabled_timer.axf
Loaded 152 .text
Loaded 0 .data
avr_make_mcu_by_name: AVR 'atmega48' not known
./simavr/run_avr: AVR 'atmega48' not known
This error happens on each test that I try to run, and on my own .hex files as well.
Do you have any suggestions?
I do have a question though. How did you specify what you want to trace? I am assuming that you had to wrap your original .hex/.elf file in some sort of wrapper code that was linked against simavr? Did you have to do something like this?
#include "avr_mcu_section.h"
AVR_MCU(F_CPU, "atmega88");
/*
* This small section tells simavr to generate a VCD trace dump with changes to these
* registers.
* Opening it with gtkwave will show you the data being pumped out into the data register
* UDR0, and the UDRE0 bit being set, then cleared
*/
const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = {
{ AVR_MCU_VCD_SYMBOL("UDR0"), .what = (void*)&UDR0, },
{ AVR_MCU_VCD_SYMBOL("UDRE0"), .mask = (1 << UDRE0), .what = (void*)&UCSR0A, },
};
I am assuming that some sort of wrapper is required, since when I use run_avr on my plain .elf file, I just get:
Loaded 1892 .text
Loaded 6 .data
Starting attiny85 - flashend 1fff ramend 025f e2end 01ff
attiny85 init
and simavr just sits there.
https://github.com/hank/life/blob/master/code/avr/tutorials/ctc_ledblink.c
It's commented out in that code, but I apparently had it there specifically for SIMAVR. Cheers!
Thanks!