1

I am trying to find out if it is possible to trigger programmatically the double-tap on reset button function, implemented in modified version of Atmel's SAM-BA bootloader. The board of interest is Arduino Zero. In case this is not possible using the stock board setup, if this can be achieved by hardware or bootloader modifications.

3

Theoretically it is quiet easy to fake that double-tap with software, but there might be some obstacles in practice.

The bootloader uses an unsigned long value in RAM memory to indicate if the double tap happend. The actual bootloader for the zero uses the following definitions.

// zero specific; but other boards use the same values AFAIK
// (in board_definitions_arduino_zero.h)
#define BOOT_DOUBLE_TAP_ADDRESS  (0x20007FFCul)
#define BOOT_DOUBLE_TAP_DATA  (*((volatile uint32_t *) BOOT_DOUBLE_TAP_ADDRESS))

// for all bootloader (in main.c)
#define DOUBLE_TAP_MAGIC 0x07738135

When the bootloader is started after a reset, it checks, if that was a power on reset (POR) or not. If it has been a POR, it sets the indicator value to 0 BOOT_DOUBLE_TAP_DATA = 0;.

If it does not detect a POR, the bootloader continues with checking the indicator value whether it is set to the tap magic.

If the magic can be found the indicator value is set back to 0 and the bootloader is started. Otherwise the value is set to the "double tap magic": BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC. The bootloader waits for 500 ms to let the user reset the zero a second time (double tap) and resets the indicator value after that time interval.


How to:

To simulate a double tap, you just need to set the indicator variable with the magic value from within you program. Use the definitions above. Then perform a software reset.


The caveats:

  • If the bootloader was changed, that could make you code useless.
  • I have not the time to test my ideas, so this is just an unverified method. It might fail for some reasons, I do not see actually.
  • You have to find a method to reset the zero with the program. Iknow some methods but I've not tried any of them so far.

Reset Methods: (as a starting point for your search)

I've read somewhere that the zero supports the CMSIS method NVIC_SystemReset.

This is a method often used for M0 ARM controllers (like SAMD11).

SCB_AIRCR = SCB_AIRCR_VECTKEY(0x5FA) | SCB_AIRCR_SYSRESETREQ_MASK;

Here is my code "idea" (untested):

#define BOOT_DOUBLE_TAP_ADDRESS  (0x20007FFCul)
#define BOOT_DOUBLE_TAP_DATA  (*((volatile uint32_t *) BOOT_DOUBLE_TAP_ADDRESS))
#define DOUBLE_TAP_MAGIC 0x07738135

// lots of code ....

void resetWithDoubleTap()
{
   BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC;
   NVIC_SystemReset();
}

I would be lucky, if you succeed with this. Please let us know your outcomes, either write your own answer or tell me what you've done and I will correct my answer if necessary. Good luck.

1
  • Thank you very much. I will have a board available for testing in a week or so. Anyway I will definitely post the results here. For now this is the accepted answer. – T81 Feb 13 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.