Unable to load any sketch in a MKRWAN1300

Hi,
I'm not able to load any sketch (i.e blink) in a MKRWAN1300, the IDE try to load the skecth but after some minutes it give me a loading error.
A second MKRWAN1300 is instead working fine in the same environment.
The device seems recognized by Windows, because I can see the related COM and also the device information when I request it by the IDE.
When I power it, only the green led is activated while the yellow one is always off, even if I double click the reset button.
Any idea about this issue ?
Thanks

Please do this:

  • (In the Arduino IDE) File > Preferences
  • Uncheck the checkbox next to "Show verbose output during: compilation"
  • Check the checkbox next to "Show verbose output during: upload
  • Click "OK"
  • Sketch > Upload
  • After the upload fails, you'll see a button on the right side of the orange bar "Copy error messages" (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the upload output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

Many thanks for your quick answer, here are the info you request:

Arduino:1.8.12 (Windows 10), Scheda:"Arduino MKR WAN 1300"

Lo sketch usa 11308 byte (4%) dello spazio disponibile per i programmi. Il massimo è 262144 byte.
Le variabili globali usano 2936 byte di memoria dinamica.
Forzo il reset aprendo e chiudendo a 1200bps la porta COM5
PORTS {COM1, COM5, } / {COM1, } => {}
PORTS {COM1, } / {COM1, COM5, } => {COM5, }
Found upload port: COM5
C:\Users\utente\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0-arduino3/bossac.exe -i -d --port=COM5 -U true -i -e -w -v C:\Users\utente\AppData\Local\Temp\arduino_build_724507/Blink.ino.bin -R 
Errore durante il caricamento dello sketch

There are two things that make me think the bootloader is missing or corrupted:

  • The "L" LED doesn't pulse after you do a double reset. The pulsing LED is an indicator that the bootloader is running.
  • The COM port number doesn't change during the upload. Normally, Windows enumerates the bootloader's COM port to a different port number than the port number it has while your sketch is running.

The common cause of losing the bootloader on the SAMD boards is to do an upload while you have Tools > Board > Arduino Nano 33 BLE selected. I've already managed to make that mistake once myself.


I'm going to share the process I use to restore the bootloader on my MKR boards:

You'll need:

  • An extra Arduino board that runs at 3.3 V (your other MKR WAN 1300 will work).
  • An SD slot. This could be built into your Arduino board (e.g., MKR Zero), a shield (e.g., MKR SD Proto Shield), or one of the common SD modules.
  • An SD card that fits your SD slot.
  • A way to connect the SD card to your computer.
  • A way to make the connections to the SWD pins on your target Arduino board. For the MKR boards other than MKR1000, I like to use a 0.1" pitch 2x3 POGO adapter. You could also carefully hold some pins in contact with the pads (you only need connections to the SWDIO and SWCLK pads, since the other connections are available on the normal pins) or solder wires to the test points if you prefer. On the MKR boards other than the MKR1000, the SWD header is on the bottom of the board and is the footprint for a 0.1" pitch 2x3 SMD header (e.g., https://www.digikey.com/short/z3dvdv).

It is possible to use an Arduino board that runs at 5 V as the programmer, but you'll need to use level shifting circuitry on the programming lines to avoid exposing the target board to 5 V logic levels, which would damage it.


Instructions:

  1. Connect an SD card to your computer.
  2. Open this link in your browser: ArduinoCore-samd/bootloaders at master · arduino/ArduinoCore-samd · GitHub
  3. Click the folder that matches the name of your target board.
  4. Click the file that ends in .bin.
  5. Click the "Download" button.
  6. Rename the downloaded file to fw.bin
  7. Move fw.bin to the SD card.
  8. Eject the SD card from your computer.
  9. Plug the USB cable of the Arduino board you will be using as a programmer into your computer.
  10. (In the Arduino IDE) Sketch > Include Library > Manage Libraries
  11. Wait for the download to finish.
  12. In the "Filter your search..." field, type "Adafruit DAP library".
  13. Press "Enter".
  14. Click on "Adafruit DAP library by Adafruit".
  15. Click the "Install" button.
  16. Wait for the installation to finish.
  17. Click the "Close" button.
  18. File > Examples > Adafruit DAP library > flash_from_SD
  19. Change this line:
    #define SD_CS 4
    
    according to the Arduino pin connected to the SD CS pin. If your board has a built-in SD slot (e.g., MKR Zero), then you can change this line:
    if (!SD.begin(SD_CS)) {
    
    to:
    if (!SD.begin()) {
    
  20. Select the correct board from the Tools > Board menu.
  21. Select the correct port from the Tools > Port menu.
  22. Sketch > Upload
  23. Wait for the upload to finish successfully.
  24. Unplug the programmer Arduino board from your computer.
  25. Plug the SD card into the SD slot connected to your Arduino board.
  26. Connect the programmer Arduino board to the target Arduino board as follows:
    Programmer Target
    VCC +3V3
    10 SWDIO
    9 SWCLK
    GND GND
    11 RESETN
    MKR board SWD pads:
    ![MKRZero_labeled.jpg 600x418](upload://8xFYxiBJDiIkqDyg6ulkRQDn5Je.jpeg)
  27. Plug the USB cable of the programmer Arduino board into your computer.
  28. Tools > Serial Monitor. You should now see the target board detected, and the bootloader file flashed to it successfully.
  29. Unplug the programmer Arduino board from your computer.
  30. Disconnect the programmer Arduino board from the target Arduino board.

Note: another alternative is to use a J-Link debug probe (J-Link EDU Mini and J-Link clones are available for a low price) with the Adalink software:

Hi pert,
thanks for your diagnosys and detailed procedure for recover the bootloader.
At the moment I haven't any SD slot connectable to the Arduino Programmer (the only one I have is the second 1300), so, if I well understand, I'm afraid I have to wait till I could go again outside home to buy something that could let me connect an SD slot (i.e. MKR SD Proto Shield), to the second 1300.
I'll come back to you asap.
Gianluigi

There is an alternative that doesn't require an SD card, shown here:
https://github.com/adafruit/Adafruit_DAP/tree/master/examples/flash_from_header
The contents of the bootloader file is stored as an array in the header file (2772cipy.h) in this example. The reason I didn't recommend this approach in my instructions is because a process is required to change the data from the bootloader file into the array, and I haven't had the time to investigate this, figure out the easiest way to accomplish it, and write the instructions. It's possible there is a nice tutorial for doing this already available somewhere.

you don't need any adapter for SD card with a 3.3 V MCU. here a normal card to micro SD adapter is used as slot

Hopefully that is a 3.3V processor card. SD cards get hot when powered from 5V.

The MKR WAN 1300 is 3.3 V, as is the ESP32 board in Juraj's picture.

Forum with great support, thanks.

@pert
I didn't found additional info about the alternative you suggest, so at the moment I'm not able to apply this way.

@Juraj
Unfortunaltely I'm currently not able to buy the SD adapter, but I will in the (hope near) future.
Anyway, could you give me some hints on where I can find info on the connection between the adapter and the board (possibly MKRWAN) ?

Gianluigi

gigi130358:
@Juraj
Unfortunaltely I'm currently not able to buy the SD adapter, but I will in the (hope near) future.
Anyway, could you give me some hints on where I can find info on the connection between the adapter and the board (possibly MKRWAN) ?

Gianluigi

it is SPI, so use SPI pins MISO, MOSI, SCK. one pin as CS and ground and VCC.

gigi130358:
I didn't found additional info about the alternative you suggest, so at the moment I'm not able to apply this way.

Maybe someone else here on the forum can provide some assistance on that. I know one of the people I helped to burn the bootloader on their board some weeks ago managed to do it, but I don't think they shared the script they used to generate the array.

gigi130358:
Unfortunaltely I'm currently not able to buy the SD adapter

It is possible to solder directly to the pads on the SD card. There is no magic in the adapters. It just has direct electrical connections between the pads. The problem with doing this is it will make the card no longer usable for normal usage. You will also need to be a bit careful not to damage the SD card with too much heat, but apparently they can handle a fair amount of heat:

Maybe someone else here on the forum can provide some assistance on that. I know one of the people I helped to burn the bootloader on their board some weeks ago managed to do it, but I don't think they shared the script they used to generate the array.

Ok, I hope so

It is possible to solder directly to the pads on the SD card...

This is a possible alternative, but at the moment I prefear to wait till I can buy an SD adapter.

on the photo I linked from StackExchange, the soldered pads are on an adapter for micro SD card for the large SD slot. so no direct soldering of SD card. most micro SD cards are sold with this adapter. I have a bunch of them.

on the photo I linked from StackExchange, the soldered pads are on an adapter for micro SD card for the large SD slot. so no direct soldering of SD card. most micro SD cards are sold with this adapter. I have a bunch of them.

Useful precisation,thanks