VIRTUAL_BOOT_PARTITION (VBP in short) is a hack for implementing a bootloader on parts that don't have "start at the bootloader address after reset" support. Sometimes it could be useful for normal chips when changing or messing with fuses is impossible or not desired.
During programming bootloader "cleverly substitutes" start vector of application (located at address 0) by jump to bootloader. This way bootloader is always run after reset.
Bootloader assumes that start of application is typical vector table generated by most compilers. When Optiboot change start vector, it saves original jump to another free vector. Typically it uses SPM_RDY vector, or WDT if SPM_RDY is unavailable.
It's possible to assign arbitrary vector using additional option to CFLAGS: -Dsave_vect_num=xxx
where xxx could be name of vector like EE_RDY_vect_num
(see virboot8 target in Makefile) or even just number (see attiny84 target in Makefile.extras). In fact, any number could be used, even outside vector table. There is only one limitation: it MUST be located in first flash page!
Yes, as long as first instruction is jmp on chips with more than 8KB memory or rjmp on smaller memory devices. You must also provide another jump to store old jump by Optiboot.
It could be done for example by adding -Dsave_vect_num=1
to CFLAGS during compiling bootloader, and making beginning of application like this:
rjmp app
rjmp nowhere
app:
... ;your code here
Check Makefile targets virboot8, virboot328 or attiny84 for examples.
There are 2 things required:
-DVIRTUAL_BOOT_PARTITION
to CFLAGSadjust (decrease) address in .text part of LDSECTIONS (for example in --section-start=.text=0x1c00
) to fit larger bootloader in memory
Sadly, there are 2 of them: