1

The Adafruit Feather SAMD21 takes about two seconds from power being supplied to when setup() starts running. How can I shorten that time so that setup() will run sooner? I measure this time using a power supply and others appear to measure similar times with their eyeballs.

I understand that 328 microcontrollers can be made to boot quicker (almost instantly from a human perspective) using different bootloaders for example, but I haven't found one for the M0 SAMD21 nor another method.

The code isn't relevant because the blink example shows the same timeframe, but here's another example:

//no libraries, global variables, nothing.
setup(){ 
digitalWrite(LED_BUILTIN, HIGH);
}

loop(){
}
2
  • I dont think that is relevant because other people observe the same start time. Anyway here it is, apologies for the formatting setup(){ digitalWrite(LED_BUILTIN,HIGH);} loop(){} There is nothing else before or after. The standard Blink example shows the same thing.
    – rfii
    Nov 14, 2021 at 19:45
  • Measured with a power supply. Other people observe about the same time.
    – rfii
    Nov 14, 2021 at 19:46

1 Answer 1

1

After consulting the datasheet for the SAMD21, I verified that the processor starts immediately once the internal clocks are stable. This happens quickly. The reset vector directs execution to the Arduino bootloader, which certainly spins while waiting for the Arduino programmer to connect. If that does not happen during that delay, the bootloader jumps to the resident application. The delay with no activity is how the bootloader determines that you want to start the application. You can eliminate that by programming the processor using a hardware programmer/debugger, and getting rid of the Arduino bootloader.

The hardware programmers also allow source level breakpoint debugging. You just have to learn to use a decent IDE programming environment. A good prgrammer will cost you around $160.

2
  • 1
    I have no idea why this would be "voted down" since it is a valid and appropriate solution to the op's question.
    – user81882
    Jan 13, 2022 at 13:49
  • Awesome idea and research! Thanks. Do you have link to the type of programmer and IDE or what you mean by removing the bootloader? Perhaps this? learn.adafruit.com/how-to-program-samd-bootloaders
    – rfii
    Jan 21, 2022 at 3:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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