introduce new feature: BOOTLOADERENTRY_FROMSOFTWARE
An USBaspLoader supporting this feature is able to be called
(and bootLoaderConditioned) from user firmware.
You can check MCUCSR watchdog-flag to check for success.
(If USBaspLoader starts up, all MCUCSR are removed...)
You can use something like this code to switch to the
bootloader:
#define BOOTLOADER_WORDADDRESS (BOOTLOADER_ADDRESS>>1)
wdt_enable(WDTO_15MS);
asm volatile (
"ldi r29 , %[ramendhi] \n\t"
"ldi r28 , %[ramendlo] \n\t"
"ldi r16 , %[boothi] \n\t"
"st Y+ , r16 \n\t"
"ldi r16 , %[bootme] \n\t"
"st Y+ , r16 \n\t"
"ldi r16 , %[bootlo] \n\t"
"st Y+ , r16 \n\t"
"resetloop%=: \n\t"
"rjmp resetloop%= \n\t"
:
: [ramendhi] "M" (((RAMEND - 2) >> 8) & 0xff),
[ramendlo] "M" (((RAMEND - 2) >> 0) & 0xff),
[boothi] "M" (((BOOTLOADER_WORDADDRESS) >>16) & 0xff),
[bootme] "M" (((BOOTLOADER_WORDADDRESS) >> 8) & 0xff),
[bootlo] "M" (((BOOTLOADER_WORDADDRESS) >> 0) & 0xff)
);
Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>