This is based on a post from: https://forum.arduino.cc/index.php?topic=718128.0
- A working Arduino MKR WiFi 1010 (or another 3.3V Arduino with at least 35K of flash)
- Soldering iron
- Some wires to solder onto the target Arduino
(In the Arduino IDE) Sketch > Include Library > Manage Libraries
Wait for the download to finish.
In the "Filter your search..." field, type "Adafruit DAP library".
Press "Enter".
Click on "Adafruit DAP library by Adafruit".
Click the "Install" button.
Wait for the installation to finish.
Click the "Close" button.
Alternatively, the code for the library is at: https://github.com/adafruit/Adafruit_DAP
Plug the USB cable of the Arduino board you will be using as a programmer into your computer.
Load flash_from_header_mkrwifi1010.ino into the Arduino IDE.
Select the correct board from the Tools > Board menu.
Select the correct port from the Tools > Port menu.
Sketch > Upload
Wait for the upload to finish successfully.
Unplug the programmer Arduino board from your computer.
Connect the programmer Arduino board to the target Arduino board as follows:
Programmer | Target |
---|---|
VCC | +3V3 |
9 | SWDIO |
8 | SWCLK |
GND | GND |
7 | RESETN |
For the target board these connections are solder pads on the underside of the Arduino. There are six pads laid out as follows, assuming you are looking at the underside of the Arduino with the USB socket pointing up...
(not used) | GND
SWCLK | RESET
SWDIO | +3V3
Plug the USB cable of the programmer Arduino board into your computer.
Tools > Serial Monitor. You should now see the target board detected, and the bootloader file flashed to it successfully.
For reference, when it works correctly the serial output should be...
Connecting...Adafruit Generic CMSIS-DAP Adapter 123456 v0.1 (S)
Found Target: SAM D21G18A (Rev D) Flash size: 262144 Flash pages: 4096
done.
Erasing... done.
Programming... 46
Done!
If you instead have an invalid response writing to reg
error and the CHRG LED on the programmer Arduino is flashing rapidly (for more than a few seconds after first connecting to USB) then maybe there is not enough power from your computer for both Arduinos. You may be able to get around it by pressing the reset button on the programmer, or you may need an external power source instead of USB. If you decide you need to use an external power supply then remember to remove the while(!Serial)
line from the sketch, otherwise the programmer won't proceed without a serial/USB connection.
Unplug the programmer Arduino board from your computer.
Disconnect the programmer Arduino board from the target Arduino board.