Hello again,
I have now tried making it work with my real application, which uses interrupts...
First thing I noticed was that the interrupts doesn't work.
Just because I tell PE to place the interrupts at another address, it still seems to jump to the default location at interrupt.
I have also realized that it is a bad idea to use different addresses for different versions.
Some users might skip over one update, and then it would delete the current version when updating
Instead I will use the same address as for a stand-alone application without the bootloader, and relocate both program and vectors with the bootloader before I write it to flash.
That way I don't have to keep track of changing the settings every time I complile a new version either.
I still have problems with relocating the intrerrupt vectors though :smileysad:
I've tried just writing over the default vectors for the bootloader with the content of the application vectors (after making a backup of the bootloader vectors, so I can change it back later).
And I keep track of which vectors are currently in use, with a byte in the eeprom.
But this doesn't seem to work.
Is there some security function that doesn't allow me to write to the default vector locations while the program is running.
I have not initialized any functions that uses interrupts before i try this.
And I don't get any error message when writing, it just doesn't write the correct data...
If it tries to write 0xE000 it ends up writing 0x2000 instead.
I tried looking at the project you posted Carlos, but I really suck at assembler, and there are some low level aspects of C I'm not so familiar with either, so I don't understand all of it :smileyblush:
I think I have found where you are doing this, but could you please explain what these line does:
uint8_t jmp_code @0x103D = 0xcc;
uint8_t jmp_addr[2] @0x103E = {0,0};
| #define INSTALL_VECTOR(n) | | interrupt n void vector_##n##_ISR(void) {__asm LDHX (RELOCATION_VERTOR_ADDR+(39-n)*2); __asm STHX jmp_addr; __asm PULH; __asm JMP jmp_code;} |
This part I understand about the new address for every single interrupt, but thats about it :smileyconfused:
(RELOCATION_VERTOR_ADDR+(39-n)*2)