The Atmel datasheet says the bootloader section starts at 0xF000 on pg. 286
AVR Studio has a fuse bit to start the boot loader at 0xF000
I've seen several posts here on the site that says 0x1E000
In bootloader.h I have the following line of code:
void bootloader(void) __attribute__ ((section (".bootloader")));
In bootloader.c I have the following function:
void bootloader( void )
DDRF = 0xFF;
PORTF = 0x00;
I'm using JTAG ICE to program and debug so I expect to see bits 0-3 on the STK500 light up and don't care about bits 4-7.
With BOOTSZ = 00 and BOOTRST = 0 (both of the boxes checked) and using the makefile line:
LDFLAGS = -Wl,--section-start=.bootloader=0x1E000 -Wl,-Map=$(TARGET).map,--cref
It works even though the fuse setting says 0xF000 and this places the code at 0x1E000. (can't simulate though, just program with JTAG and unplug it) Does it just "fall through" the unprogrammed space until it gets to valid code?
If I change the makefile line to what I would expect it should be from looking at the datasheet and fuse settings to:
LDFLAGS = -Wl,--section-start=.bootloader=0xF000 -Wl,-Map=$(TARGET).map,--cref
It doesn't work.
I've read that the JTAG ICE can't simulate the bootloader section and that I should place the code in something lower, perhaps 0xC000 and just call the bootloader function (bootrst fuse unchecked) to see if the lights turn on and debug from there. Get the actual function working (have to follow a specific protocol thats already been implemented on the host so a generic bootloader would have to be modified... might as well make my own and learn something instead right?) and then move it back to the proper location.
I would expect the bootloader area of the mega128 to be around 1E000 as thats near the end of the 128k of flash, and the mega64 bootloader to be at F000, as thats near the end of the 64k flash. But why does the datasheet and the AVR Studio seem to say that its at 0xF000 instead?
Compiling with GCC 3.3.1 from AVR Studio 3.56
Programming with JTAG ICE in AVR Studio 4.08 or 3.56
Simulating with JTAG ICE in AVR Studio 4.08
Can someone explain away my confusion?