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

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

RE: [avr-gcc-list] memory layout for bootloader


From: Larry Barello
Subject: RE: [avr-gcc-list] memory layout for bootloader
Date: Thu, 16 Jun 2005 07:43:22 -0700

-----Original Message-----
From:  Parthasaradhi Nayani
...
How does one avoid putting interrupt table and cleanup
code in the bootloader section? (this is what I am
looking for)

------------------------------------
-nostdlib on the linker command line will drop all library support and
rename "main" something else like "boot" will drop the startup support.

You need to clear R1 and set the stack and not have any initialized SRAM
variables.  That is easy to do. Just explicitly initialize stuff in your C
code.

Below are snippets of what I used.  I have a separate file for the reset
vector (start.c) since GCC aggressively reorganizes functions while the
linker will link in the order you specify.  My file "boot.c" has lots of
functions including replacements for eeprom_read_byte(), etc. and I could
never get GCC to keep the text order (even with -fno-reorder-functions)

I found that I could keep all variables needed in the register set, except
for the buffer receiving/transmitting blocks of code to the programmer.

Cheers!

---- file makefile ----
CFLAGS = -g -Wall -Os -mmcu=$(MCU) -gdwarf-2 -mshort-calls
LDFLAGS
= -Wl,-Map,$(TARGET).map,--section-start=.text=$(BOOT_START),--cref,-e,boot,
 -nostdlib -gdwarf-2

----- file start.c ----
void boot(void);
void start(void)
{
        asm volatile ("rjmp boot");
}
----- file boot.c -----
void boot(void)
{
// declare variables (don't initialize)
// Set up bare minimum for C to operate...

asm volatile(
"\tcli\n"
"\tclr  __zero_reg__\n"
);
SPL = (RAMEND-1)&0xFF;
SPH = (RAMEND-1)>>8;

// initialize variables, main code...

}

-





reply via email to

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