introduce new feature: BOOTLOADERENTRY_FROMSOFTWARE
authorStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Tue, 10 Sep 2013 13:35:11 +0000 (15:35 +0200)
committerStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Tue, 10 Sep 2013 13:57:01 +0000 (13:57 +0000)
commitfdd80449610db4cccc152e17b04cdb51de578a61
treed2ab2b44b71f33da8907afaca62432b85f69ad6f
parent46e5d78c08ff324cf95cc1a11ca2234feddb7713
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>
firmware/bootloaderconfig.h
firmware/main.c