I have developed my own board based on the mkrzero schematics but with smaller SAMD21 device (ATSAMD21E1) that I need to flash with the bootloader, through the USB port.
I don't want to say money's no object(!!!), but if I need to spend to get a programmer, then so be it.
I have a read of the articles on this forum (eg. Programming Custom SAMD21 board through Native USB ) but the advice peters out so I am left none the wiser as to how to proceed!
I am hoping to flash an appropriate bootloader so I can then plug my board's USB into the PC and just upload a sketch from the arduino IDE as I can on the mkrzero board.
Thanks in advance!
Juraj
January 30, 2024, 9:23pm
2
it is not possible if there is no bootloader
westfw
February 3, 2024, 7:40am
3
Once you have loaded a bootloader, you can upload applications via USB.
But to load the bootloader, you need "SWD" connectivity and and SWD programmer. I somewhat recommend the Microchip SNAP programmer as a good compromise between price and capabilities.
SWD programming will require access to Vcc (for voltage level, not for power), GND, SWDIO (PA31), SWCLK (PA30), and perhaps RESET.
1 Like
Thanks! I have also found this guide to using a mkrzero -
If you shot the bootlader on a MKR Board, here's the remedy:
First of all, check if the bootloader is realy dead: Double tap the reset fast (Like a double click on a mouse). If the led dimms on and off, everything is fine, upload your sketch.
If there is no reaction to double tap, continue:
You need a second MKR board to heal the bricked up. This can be another type of MKR, you can heal a MKR 1500 with a MKR 1400 for example.
Solder 5 cables with pinheads to the bricked up MKR :
[MK…
although this fails for me with errors like invalid response writing to reg 5 (count = 0, value = 7).
I am unsure if this is because my SAMD device is a SAMD21E and I am selecting a MKRZERO to bootload, or if it implies (say) SWDIO is stuck-at 1 (hence 7?).
Ok I haven't had any luck with the method below, so I have ordered the Microchip SNAP and downloaded the IDE. I'll give it a go! Thanks
Hi - I have the MPLAB SNAP now and think I know which pin is which for SWCLK etc. I have soldered leads to the bottom of the mkrzero to give me the SWD pins, but I'm not having much luck finding out how to actually do the flash operation. Any advice gratefully received!!
Thanks
I am having the same problems with my custom board.
Trying to burn the mkrwifi1010 bootloader on my board which has SAMD21 CPU but without success.
I literally tried every single method possible. Using RPI + openocd, J-link, SAM-ICE, through other mkr board etc.. The best I got was with RPI + openocd where it burns the bootloader, but the PC COM doesn't recognize the board and if I do the double RST tap it recognizes the board (adds always new com Port on ide, got like 10 different com ports now) but it can't flash the firmware.
Therefore I'm bumping this thread since I'm also interested in a solution.
Regards.
Hi @d4v3l3cc
Which variant of the SAMD21 are you using for your custom board?
Hey @MartinL
I am using the standard one: ATSAMD21G18.
Is that the ATSAMD21G18A? The 'A' suffix denoting the default variant.
Also, does your custom board use an external 32.768kHz crystal?
I ended up using an MPLAB SNAP and exposing the SAMD debug interface pins and that worked
@MartinL
Yeah it is the A version, more precisely: ATSAMD21G18A-AUT. It does use yes. Here is the schematic snippet.
32KHz Crystal.
SWD Debug.
Connector Im using for flashing afterwards (USB 2.0):
@mackerel
I might order MPLAB Snap as well. Even though I tried with like 5 different programmers..
Hi @d4v3l3cc
I noticed that your board's SWD connections on J5 differ from the MKR WiFi 1010's, as on the MKR the SWDIO and SWCLK are swapped on pins 2 and 4 respectively. I presume that this has been accounted for, as you mentined that you managed to flash the bootloader?
Regarding the USB adapter, are D+ and D- connected to J3 on your schematic? Is there also a pin connection for the USB's ground?
Hey @MartinL
nice catch, but this has been accounted for and is properly visible on the pcb as well.
D+ and D- are on the J5 pin header yeah. Since I forgot to put GND on the same pin header I am using the one on the J2 pin header. Not the closest connection but should do the job since this is the same reference point.
Hi @d4v3l3cc
Do you get any particular error messages when you attempt to upload a simple sketch, such as "blink"?
Hey @MartinL
sorry for the late reply.
This si the log I get after doing Tools -> Burn Bootloader (Programmer is ATMEL-ICE (SAM Pinout)).
Blockquote
"C:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.10.0-arduino7/bin/openocd.exe" -d2 -s "C:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.10.0-arduino7/share/openocd/scripts/" -f "interface/cmsis-dap.cfg" -c "set telnet_port 0" -f "target/at91samdXX.cfg" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {C:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14/bootloaders/mkrwifi1010/samd21_sam_ba_arduino_mkrwifi1010.bin} verify reset; shutdown"
Open On-Chip Debugger 0.10.0+dev-gf0767a31 (2018-06-11-13:36)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
debug_level: 2
0
Info : auto-selecting first available session transport "swd". To override use 'transport select '.
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x000002d8 msp: 0x20007f9c
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x00000b78 msp: 0x20007ffc
** Programming Started **
auto erase enabled
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
wrote 8192 bytes from file C:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14/bootloaders/mkrwifi1010/samd21_sam_ba_arduino_mkrwifi1010.bin in 0.732987s (10.914 KiB/s)
** Programming Finished **
** Verify Started **
verified 7984 bytes in 0.684426s (11.392 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked
Blockquote
but also at the same time notification to the right says burning bootloader and it never finishes and it spits out port monitor error.
Also it is unable to recognize the USB COM Port (with two reset to gnd taps as well) of the "burned" custom device.
This specific error is only saying that the Arduino IDE Serial Monitor was not able to connect to the selected port at the end of the "Burn Bootloader" operation.
In order to avoid it possibly interfering with a "Burn Bootloader" operation (which might need access to the port), Arduino IDE automatically disconnects Serial Monitor from the selected port when you start a "Burn Bootloader" operation, then connects Serial Monitor to the port again at the end of the operation.
In some cases, such as when the selected port is unavailable, or when the selected port has a protocol other than serial, it is expected that Serial Monitor would fail to reconnect.
You might not even notice that you have Serial Monitor open since the bottom panel of the Arduino IDE window that is the container for the "Serial Monitor " view is also the container for the "Output " view. If the "Output " view is selected then the "Serial Monitor " view is not visible and the only indication you have of it being open is the presence of the tab in the bottom panel tab bar. You can close Serial Monitor by clicking the X icon on that tab.
Hey @ptillisch
Yeah, makes sense I closed the serial monitor tab and now it said burning bootloader done, so I assume that is correct now.
But it still cant recognize the device when I want to flash now after burning the bootloader.
Also for if I try to upload the code via programmer ATMEL-ICE
it spits out following as if it correctly uploads, but it doesn't upload the code and COM port is still not visible:
FQBN: arduino:samd:mkrwifi1010
Using board 'mkrwifi1010' from platform in folder: C:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14
Using core 'arduino' from platform in folder: C:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14
Detecting libraries used...
C:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_MKRWIFI1010 -DARDUINO_ARCH_SAMD -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x8054 -DUSBCON -DUSB_MANUFACTURER="Arduino LLC" -DUSB_PRODUCT="Arduino MKR WiFi 1010" -DUSE_BQ24195L_PMIC -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/deprecated -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/deprecated-avr-comp -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\cores\arduino -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\variants\mkrwifi1010 C:\Users\david\AppData\Local\Temp\arduino\sketches\5C536C5F117D02BEACB393E7B63406D1\sketch\BareMinimum.ino.cpp -o nul
Generating function prototypes...
C:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_MKRWIFI1010 -DARDUINO_ARCH_SAMD -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x8054 -DUSBCON -DUSB_MANUFACTURER="Arduino LLC" -DUSB_PRODUCT="Arduino MKR WiFi 1010" -DUSE_BQ24195L_PMIC -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/deprecated -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/deprecated-avr-comp -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\cores\arduino -IC:\Users\david\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\variants\mkrwifi1010 C:\Users\david\AppData\Local\Temp\arduino\sketches\5C536C5F117D02BEACB393E7B63406D1\sketch\BareMinimum.ino.cpp -o C:\Users\david\AppData\Local\Temp\2105439480\sketch_merged.cpp
C:\Users\david\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\david\AppData\Local\Temp\2105439480\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_MKRWIFI1010 -DARDUINO_ARCH_SAMD -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x8054 -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino MKR WiFi 1010\"" -DUSE_BQ24195L_PMIC "-IC:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/" "-IC:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.14\\cores\\arduino/api/deprecated" "-IC:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.14\\cores\\arduino/api/deprecated-avr-comp" "-IC:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.14\\cores\\arduino" "-IC:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.14\\variants\\mkrwifi1010" "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1\\sketch\\BareMinimum.ino.cpp" -o "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1\\sketch\\BareMinimum.ino.cpp.o"
Compiling libraries...
Compiling core...
Using previously compiled file: C:\Users\david\AppData\Local\Temp\arduino\sketches\5C536C5F117D02BEACB393E7B63406D1\core\variant.cpp.o
Using precompiled core: C:\Users\david\AppData\Local\Temp\arduino\cores\arduino_samd_mkrwifi1010_0d8c8072db521d950eb18eb481d72d12\core.a
Linking everything together...
"C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" "-LC:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1" -Os -Wl,--gc-sections -save-temps "-TC:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.14\\variants\\mkrwifi1010/linker_scripts/gcc/flash_with_bootloader.ld" "-Wl,-Map,C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1/BareMinimum.ino.map" --specs=nano.specs --specs=nosys.specs -mcpu=cortex-m0plus -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -o "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1/BareMinimum.ino.elf" "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1\\sketch\\BareMinimum.ino.cpp.o" "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1\\core\\variant.cpp.o" -Wl,--start-group "-LC:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Lib/GCC/" -larm_cortexM0l_math -lm "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1/..\\..\\cores\\arduino_samd_mkrwifi1010_0d8c8072db521d950eb18eb481d72d12\\core.a" -Wl,--end-group
"C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-objcopy" -O binary "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1/BareMinimum.ino.elf" "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1/BareMinimum.ino.bin"
"C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-objcopy" -O ihex -R .eeprom "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1/BareMinimum.ino.elf" "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1/BareMinimum.ino.hex"
"C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-size" -A "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\5C536C5F117D02BEACB393E7B63406D1/BareMinimum.ino.elf"
Sketch uses 12244 bytes (4%) of program storage space. Maximum is 262144 bytes.
Global variables use 2988 bytes (9%) of dynamic memory, leaving 29780 bytes for local variables. Maximum is 32768 bytes.
"C:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.10.0-arduino7/bin/openocd.exe" -d2 -s "C:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.10.0-arduino7/share/openocd/scripts/" -f "interface/cmsis-dap.cfg" -c "set telnet_port 0" -f "target/at91samdXX.cfg" -c "telnet_port disabled; program {C:\Users\david\AppData\Local\Temp\arduino\sketches\5C536C5F117D02BEACB393E7B63406D1/BareMinimum.ino.hex} verify reset; shutdown"
Open On-Chip Debugger 0.10.0+dev-gf0767a31 (2018-06-11-13:36)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
0
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x21000000 pc: 0x00000b78 msp: 0x20007ffc
** Programming Started **
auto erase enabled
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
wrote 12288 bytes from file C:\Users\david\AppData\Local\Temp\arduino\sketches\5C536C5F117D02BEACB393E7B63406D1/BareMinimum.ino.hex in 1.086115s (11.049 KiB/s)
** Programming Finished **
** Verify Started **
verified 12244 bytes in 1.028284s (11.628 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked
I also measured the external crystal oscillator:
it has:
frequency: ~ 32.6kHz
Vmax: ~ 780mV
*Vmin: ~ 112mV
DC OFFSET: 336mV