[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] simulator issues

From: ken
Subject: [avr-gcc-list] simulator issues
Date: Thu, 15 Nov 2001 23:56:06 -0800
User-agent: Mutt/1.2.5i

i apologize if simulator issues are off-topic; if there is a simulavr list i'd 
be glad to join it and post there.

that said, here goes:
i was able to successfully download, compile, and run simulavr on a redhat 7.1 
system with gcc 3.01. the test assembly programs and the test c program worked 
just fine, in both simulavr mode and gdbserver mode. i'm using the 8515 
personality for my testing.

however, trying to load any program larger than a few hundred bytes crashes 
simulavr. i get this:

file storage.c: line 93: address out of boundsAborted (core dumped)

with this detail:
#0  0x40055801 in __kill () from /lib/i686/libc.so.6
(gdb) bt
#0  0x40055801 in __kill () from /lib/i686/libc.so.6
#1  0x400555da in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x40056d82 in abort () at ../sysdeps/generic/abort.c:88
#3  0x0804b4c8 in _avr_error () at avrerror.c:74
#4  0x08055268 in storage_readw (stor=0x8058c20, addr=-3006) at storage.c:93
#5  0x080526f7 in flash_read (flash=0x8058c20, addr=-1503) at flash.c:51
#6  0x0804a688 in exec_next_instruction (core=0x8058b90) at avrcore.c:414
#7  0x0804a925 in avr_core_step (core=0x8058b90) at avrcore.c:536
#8  0x0804aa0d in avr_core_run (core=0x8058b90) at avrcore.c:586
#9  0x0804916b in main (argc=3, argv=0xbffff94c) at main.c:267
#10 0x40044177 in __libc_start_main (main=0x8049050 <main>, argc=3, 
    ubp_av=0xbffff94c, init=0x8048880 <_init>, fini=0x8055fc0 <_fini>, 
    rtld_fini=0x4000e184 <_dl_fini>, stack_end=0xbffff93c)
    at ../sysdeps/generic/libc-start.c:129

the -1503 address in flash_read looks to me like the problem.

in stepping through this, i noticed that storage_readw is called by this:
        inline word flash_read  ( Flash *flash, int addr)
        { return storage_readw( (Storage *)flash, addr*2 ); }

and was very confused as to why addr is being multiplied by 2 before being 
passed to storage_readw. it looks to me like a macro expansion problem, or some 
magick i don't understand, and i just didn't have time or the skill to chase it 
down any further than this.

i duplicated the problem with a slight modification of demo.c that uses a long 
PSTR to simulate filling up about 5K of flash ram.

#include <io.h>
#include <progmem.h>

int main(void)
    unsigned char cnt;
    char * uglystring;
    uglystring = PSTR(" <long string of about 5k bytes> \n");

    outp( 0xff, DDRB );         /* enable port b for output */

    for ( cnt=0; cnt < strlen_P(uglystring); cnt++)
        outp( PRG_RDB(&uglystring[cnt]), PORTB );

    for (;;)
        ;                       /* loop forever */

    return 0;

the above test program works just fine with a very short strings (10bytes) but 
fails with larger ones.

and what i ended up with was:
        text    data     bss     dec     hex filename
        5356       0       0    5356    14ec demo.elf

the simulator otherwise looks very solid and easily extensible (i'm looking 
forward to being able to simulate a mega163!) and i'm sure this out-of-bounds 
error is either simple to fix or pilot error on my part.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]