I made a bootloader for the ATtiny2313. It is written in C. There is only one thing I can't manage to do. I want that the first instruction (so on address 0x00), is jump to bootloader. I wasn't able to do this, so far. My knowledge of Makefiles, linkerscripts etc. is very limited. And as far as I know now, I have to change some things overthere.
What I want:
0x00 rjump to bootloader
0x02 interrupt vector
...... interrupt vector
0x24 interrupt vector
0x26 start of normal program
What I managed to do:
My first thougt was doing this:
void __rjmpBoot (void) __attribute__ ((naked)) __attribute__ ((section (".init0"))); void __rjmpBoot( void ) { asm volatile ( "rjmp bootloader"); // jump to bootloader() }
In the Makefile I set the bootloader address. But what happens, after compiling is on address 0x00 the compiler jumps to the first address after the interrupt vector table (0x26, byte address). On that address, the jump to the bootloader is done. So:
0x00 rjump to 0x26
0x02 interrupt vector
...... interrupt vector
0x24 interrupt vector
0x26 rjump to bootloader
0x28 start of normal program
At the end of the bootloader, the program jumps back to the start of the normal program. This works fine.
To test if the first jump is always the same, I declarde a string wich was store in flash (with PROGMEM). It is stored directly behind the interrupt vector. The first instruction jumped a little further now. So it is depending on something. But I don't know how I can change this.
The example bootloaders of the ATtiny2313 I could find, where in assambly. But writing the complete bootloader in assambly isn't an option.
So my question is, how is it possible to make the first instruction, jumping to the bootloader. Or is there an example how to manage this in C?
I'm using WinAVR 20060125. With avr-gcc version 3.4.5
Hope some could help me, thanks in advance
Thijs