I my Arduino Sktech I have as you suggested
uint8_t resetFlags __attribute__ ((section(".noinit")));
void resetFlagsInit(void) __attribute__ ((naked)) __attribute__ ((section (".init0")));
void resetFlagsInit(void)
{
// save the reset flags passed from the bootloader
__asm__ __volatile__ ("mov %0, r2\n" : "=r" (resetFlags)
;
}
so my global var resetFlags reflect the ch passed to me by bootloader. like this I know in my main program that I'm coming from bootloader and that this one (bootloader) done nothing else started us quickly if bit 7 = 1 (0x80).
my setup is as follow
void setup()
{
// Get reset flags
resetFlagsInit(); Serial.begin(115200);
Serial.print(F("I received from optiboot => "));
Serial.println(resetFlags, HEX);
}
testoval jsem i toto a vysledek byl stejny porad 8
a oni jeste vali tu funkci v setupu