I'm finishing an I2C bootloader for ATtiny85 written in C. What I'm missing is that when I compile it, the reset vector points to the bootloader address (located on the top of the flash).
So far, I have been doing it by hand by modifying the generated .hex file to add the rjmp instruction that points to the bootloader in the address 0. I was thinking about having a small asm code portion with the rjmp instruction that compiles with the bootloader, only to be part of the .hex, but not part of the bootloader itself. The address of the bootloader is set by a variable in the Makefile, so the asm source should also be able to take it from there.
The problem is that I do not know how to do what I describe ...
Below is the asm chunk I'm using and the .hex line that I'm cutting & pasting into the beginning of the bootloader's .hex. The "BOOTLOADER_ADDRESS" should come from the Makefile, this I don't know how to do it either.
Thank you in advance for your help.
; #define BOOTLOADER_ADDRESS 0x1980 .CSEG .ORG 0x0 /* Reset vector, it is modified to jump to the bootloader after POR */ reset: rjmp bootloader .ORG (BOOTLOADER_ADDRESS / 2) /* Bootloader start address = (1980 / 2) */ bootloader: nop
:020000020000FC :02000000BFCC73 :02198000000065 :00000001FF