I am trying to learn how to develop an I2C bootloader for attiny85. What I have so far is a small interrupt-free "bootloader wannabe" that communicates with the master correctly. It is loaded in the upper part of the flash (--section-start = .text = 1B40). In the lower part of the memory, I have a test program that I'm flashing together with the bootloader by combining both .hex in one.
I've modified by hand the test program reset vector inside the .hex to jump to the bootloader after POR, and it works well. What I can not do is to jump from a bootloader C function to the start of the test program (0x1e). I do not know either how can I know the address of the rjpm instruction itself from C, to calculate later the jump to 0x1e from there. This is the original test program, without the reset mod.
Disassembly of section .sec1: 00000000 <.sec1>: 0: 0e c0 rjmp .+28 ; 0x1e 2: 28 c0 rjmp .+80 ; 0x54 4: 27 c0 rjmp .+78 ; 0x54 6: 26 c0 rjmp .+76 ; 0x54 8: 25 c0 rjmp .+74 ; 0x54 a: 24 c0 rjmp .+72 ; 0x54 c: 23 c0 rjmp .+70 ; 0x54 e: 22 c0 rjmp .+68 ; 0x54 10: 21 c0 rjmp .+66 ; 0x54 12: 20 c0 rjmp .+64 ; 0x54 14: 1f c0 rjmp .+62 ; 0x54 16: 1e c0 rjmp .+60 ; 0x54 18: 1d c0 rjmp .+58 ; 0x54 1a: 1c c0 rjmp .+56 ; 0x54 1c: 1b c0 rjmp .+54 ; 0x54 1e: 11 24 eor r1, r1
Can someone please help me with the C code to jump to the testing program? I have tried several things with no success, without knowing exactly what I'm doing:
asm volatile ("rjmp __ctors_end"); // --> Doesn't work! ((void (*)())0x1E)(); // --> Doesn't work!