I use the common watchdog timeout approach to perform a software reset of the 328P chip. I've received some reports from my users that this doesn't always have the desired effect and the board just hangs, requiring a power cycle.
#include <avr/wdt.h> wdt_disable(); wdt_enable(WDTO_15MS); while (1) {}
Any thoughts on why this might not always work ?
The use-case is part of a routine to set the board back to factory defaults - hold the pushbutton switch at power-on, release and hold for another 5 secs to avoid accidents, wait for the LED to flash, release the switch, write default values to EEPROM and then reset the processor. The values are written as expected, so it must be the final reset that is failing.
Clearly, I have no control over the user's Arduino IDE configuration or what dodgy hardware they may be using.
I could use the other approach, which would (for this specific purpose) have the same result:
asm volatile ("jmp 0");
or
void (*reboot_fptr)(void) = 0; // ... reboot_fptr();