avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] ATmega128 Boot Loader Using AVR-GCC 3.2


From: Harald Kipp
Subject: [avr-gcc-list] ATmega128 Boot Loader Using AVR-GCC 3.2
Date: Mon, 29 Jul 2002 21:20:23 +0200

Warning: This is really weird. :-)

I'm trying to implement a boot loader, which should
use DHCP/TFTP. As you can imagine, it's hard to get
this done without data/bss segments. After several
trials, I gave up to move the GCC 3.2 init segments
to the boot area and take another approach:

--------- Start of booter.c ------------
#include <progmem.h>

/*
 * These variables are to test the init code.
 * Tey belong to the data segment.
 */
char what = '3';
char *str = "Any String";

/*
 * This variable is in bss.
 */
unsigned char *ptr;

extern unsigned char __data_start;
extern unsigned char __data_end;
extern unsigned char __data_load_start;

extern unsigned char __bss_start;
extern unsigned char __bss_end;

int main(void)
{
    unsigned char *bp;
    unsigned char *pp;

    /*
     * Initialize data
     */
    pp = &__data_load_start;
    for(bp = &__data_start; bp < &__data_end; bp++) {
        *bp = PRG_RDB(pp);
        pp++;
    }

    /*
     * Clear bss.
     */
    for(bp = &__bss_start; bp < &__bss_end; bp++)
        *bp = 0;

    for(;;);
    return 0;
}
--------- End of booter.c ------------

The first loop initializes the data segment, while the
second loop clears the bss. Both loops work in the low
64k program memory. But when moving it up into the
upper 64k (word address 0xF800) the data area get's
initialized with 0xFF. Probably the pointer pp points
to word address 0x78## instead of 0xF8##.

Here are the compiler/linker options I'm using:

avr-gcc -c -g -mmcu=atmega128 -O0 -Wall -Wstrict-prototypes -Wa,-ahlms=booter.lst -I. booter.c -o booter.o avr-gcc booter.o -mmcu=atmega128 -Wl,-Map=booter.map,--cref,--defsym,__stack=0x10FF -nostartfiles
  -nodefaultlibs -Ttext=0x1F000 -o booter.elf

Any idea?

Is there an easier way to get an ATmega 128 boot loader done?
(The one at AvrFreaks form Jaroslaw Karwik doesn't
work with AVR-GCC 3.2)

Many thanks for taking the time to study my bizarre code.

Harald Kipp

avr-gcc-list at http://avr1.org



reply via email to

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