1

I bought an Arduino Due, and I noticed unlike the other boards, the onboard LED does not flash after reset. I prefer this behavior, so I want to modify the bootloader to do this behavior when it starts. I have burnt bootloaders before, but I never modified one before.

How can I do this?

asked Feb 21, 2016 at 18:35

2 Answers 2

2

The Arduino Due bootloader is built-in. If you check the Arduino SAM core there are no bootloader files. There is a firmware file for the ATmega16u2 on the Programming Port. You might be able to modify this to do that (given that there is a LED to flash).

The alternative solution to a modified bootloader is modifing the init() of the Arduino SAM core. Please see https://github.com/arduino/Arduino/blob/master/hardware/arduino/sam/cores/arduino/main.cpp#L36 or https://github.com/arduino/Arduino/blob/master/hardware/arduino/sam/variants/arduino_due_x/variant.cpp#L372. Blink code as proposed by Majenko could be added there.

Cheers!

answered Feb 21, 2016 at 18:43
3
  • In my Arduino Folder, in /hardware/arduino I do not have a sam folder. Do I need to reinstall Arduino? Commented Feb 22, 2016 at 2:14
  • Nevermind, I found it in the AppData folder. Thanks! Commented Feb 22, 2016 at 2:28
  • The newer Arduino Boards Manager uses packages. They are typically installed in a "hidden" folder such as AppData, .arduino15, etc. Editing the files there is only a very temporary solution as they may "disappear" in the next update. A long term solution would be to get the code into the Due/SAM core by filing a github issue and a pull-request. Commented Feb 22, 2016 at 13:07
1

You cannot.

The SAM3X's bootloader is hard-coded into ROM and can never be changed.

Ever.

Yes, I know, it sucks, doesn't it?

However, the bootloader only executes if the flash is empty (bit of an odd choice if you ask me, but there you go) so you could "emulate" the operation by flashing an LED as the first thing in your sketch.

pinMode(13, OUTPUT);
for (int i = 0; i < 5; i++) {
 digitalWrite(13, HIGH);
 delay(100);
 digitalWrite(13, LOW);
 delay(100);
}
pinMode(13, INPUT); // This will "reset" the pin to default.
answered Feb 21, 2016 at 19:28
1

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.