Unbrick Nano 33 IoT

I own both a Nano 33 BLE Sense and a Nano 33 IoT.
After using my 33 BLE for a while, I've connected the Nano 33 IoT, loaded the Blink example sketch and clicked the compile and flash button. Unfortunately I forgot to change the board from BLE to IoT.

My Nano 33 IoT seems to be bricked now. The LED is constantly on. Double tapping the Reset button doesn't help and it is not recognized by Windows when connected through USB.

Does anyone have any ideas what else I can try? Do I need to manually re-flash the bootloader? How would I do that given that the USB-connection doesn't work?

Thanks,
Michael.

Note: alternative methods are described at the end of the post.

Using an Arduino board as the programmer

You'll need

  • An extra Arduino board that runs at 3.3 V to use as the programmer.
    • Note: certain Arduino boards can't be used with the sketch that converts it to a programmer.
      • Working: SAMD architecture boards (e.g., MKR boards, Nano 33 IoT, Zero).
      • Untested: AVR architecture boards (e.g., Mega), but the sketch does compile for them.
      • Not working: Nano 33 BLE
    • 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.
  • 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 Nano 33 IoT and the MKR Boards other than MKR1000, I like to use a 0.1" pitch 2x3 POGO adapter. You could also 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). On the MKR1000, it is a 0.05" pitch 2x5 male header on the top of the board, which you will need an adapter and cable for.

Instructions

  1. Connect an SD card to your computer.

  2. Open this link in your browser: https://github.com/arduino/ArduinoCore-samd/tree/master/bootloaders

  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. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE's menus.

  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. Select File > Examples > Adafruit DAP library > samd21 > flash_from_SD from the Arduino IDE's menus.

  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 from the Arduino IDE's menus.

  21. Select the correct port from the Tools > Port from the Arduino IDE's menus.

  22. Select Sketch > Upload from the Arduino IDE's menus.

  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

    SWD pads on MKR boards other than MKR 1000):


    MKR1000 SWD header pinout:

    Nano 33 IoT SWD pads:

  27. Plug the USB cable of the programmer Arduino board into your computer.

  28. Select Tools > Serial Monitor from the Arduino IDE's menus. You should now see the Serial Monitor output showing 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.


Alternatives

These are some alternatives to the "Adafruit DAP" method I described above.

Using a CMSIS-DAP debug probe as the programmer

If you have a CMSIS-DAP compliant debug probe, you can just do this instead:

  1. Connect the debug probe to your Arduino board.
  2. Select Tools > Programmer > Atmel EDBG from the Arduino IDE's menus.
  3. Select Tools > Burn Bootloader from the Arduino IDE's menus. - The "Burn Bootloader" process should now finish successfully.

I use this little open source debugger.


Using a J-Link as the programmer

Segger J-Link debug probes (e.g., J-Link EDU Mini) can be used with the Adalink software:
https://github.com/adafruit/Adafruit_Adalink

This is a fairly complex procedure, so I recommend against this option unless you already own a J-Link and don't have the supplies on hand for one of the other options.

Many thanks. I will try that.

You're welcome. Let me know if anything is unclear or you run into any problems.

Hello, I have bricked my Nano 33 IoT as well. The only other boards that I have for bootloader include UNO R3 SMD EDITION with ADAFRUIT Music Maker MP3 Shield with SD card slot. AND a MKR WAN 1310 but no SD Card.

When I try the solution above, at the burn bootloader command, I get an error

Please select a programmer from Tools->Programmer menu

I had already selected Arduino as ISP.

Not sure what other options I have.

Thanks in advance.

wstewart:
When I try the solution above, at the burn bootloader command, I get an error

Please read my instructions above very carefully. Note that I never said anything about using the Arduino IDE's Tools > Burn Bootloader option.

Thank you Pert for sharing your knowledge !

Has anyone tried this method to flash a bootloader in a ATsamd21? I have a few Arduino Nano clones but SWD pins are not available and same thing with my Teensy 3.5. I guess I will need to buy a real Nano !

I have seen other posts about flashing the bootloader with an Arduino as ISP, but it means I would need to do it from a Arduino Zero (since Uno/Nano/... don't use a samd21) ?

Any recommendations are appreciated !

owartique:
Has anyone tried this method to flash a bootloader in a ATsamd21?

That's exactly what we're doing here. Unlike the classic Arduino Nano, which uses the ATmega328P microcontroller, the Nano 33 IoT uses the ATSAMD21G18 microcontroller.

owartique:
I have seen other posts about flashing the bootloader with an Arduino as ISP, but it means I would need to do it from a Arduino Zero (since Uno/Nano/... don't use a samd21) ?

From a hardware standpoint, it doesn't matter which microcontroller is on the board you are using as an Arduino as ISP. It's true that some board architectures aren't compatible with the Arduino as ISP sketch, but that's only a software problem. If someone made the effort, those boards could be made to work as Arduino as ISP programmers.

However, it's important to understand that, although you can use a board with any microcontroller for the Arduino as ISP Programmer board, the protocol of the Arduino as ISP programmer only works with target boards that use a microcontroller of the AVR archtecture (e.g., ATmega328P, ATmega32U4, ATmega2560). Even if you were to use an Arduino Zero as an Arduino as ISP programmer, you couldn't use it to program a Nano 33 IoT because the ATSAMD21G18 microcontroller on the Nano 33 IoT is not AVR architecture.

Alright thank you for your quick answer !

I am currently designing a custom board based on the ATsamd21 and I will certainly follow the steps you have carefully written. I just need to order a Nano33 IoT and use it as my programmer (much cheaper than Atmel-ICE!!).

You're welcome. I'm glad if I was able to be of assistance.

It sounds like you're doing a fun project! I always like the idea of being able to turn an Arduino board into a cool tool to assist me in my explorations of microcontrollers.

That said, I will add another think I learned since the time I wrote the instructions above, just for the sake of providing all the alternatives I've tried:

Note: if you have a CMSIS-DAP debugger, you can just do this instead:

  • Connect the debugger to your Arduino board.
  • (In the Arduino IDE) Tools > Programmer > Atmel EDBG
  • Tools > Burn Bootloader

I use this little open source debugger.

If you're interested in "ICE" debugging, that debugger is a useful tool to have. If not, maybe you'd prefer ending up with a spare Nano 33 IoT to play with. After all, you can never have too many Arduinos!

All the steps you have listed above can be replaced by those 3 steps with a CMSIS-DAP?

Tell me if I'm wrong but if I understood well :

I connect the SWD pins of my custom board to a CMSIS-DAP debugger (via JTAG or SWD connector) and then the CMSIS-DAP to my computer (via usb) and I should be able to burn the bootloader ?

If that's right then I'll probably choose this method over the other since it looks way easier !

That's correct.

The Arduino IDE's Tools > Burn Bootloader feature really makes the process convenient. On the other hand, many Arduino users already have a spare Arduino board on hand, and will only ever need to flash a bootloader to recover their board once or twice in their lives. So those users might prefer to do a little extra setting up the Adafruit DAP system with the tools they already have rather than be delayed on their project for some days waiting for a debugger to be delivered.

Hi pert,
thanks for this info, got me right out of the .....

I used a NANO 33 to do this to another NANO 33, so i used an SD card module,
one thing to not, especially with the modules i have , they have a 5 to 3.3v regulator on them. (AMS1117)
If you try to use 3.3v from the board it wont power up.
So i linked the Vusb pads on the base of the board to get the 5 volts working and connected to VCC.

I checked the signal levels in and out with my scope and they were 3.3V
also i had to move the RESETEN to pin 8 as , 11 is the MOSI pin and it stopped the sd card from reading
and adjust

#define SD_CS 4
#define SWDIO 10
#define SWCLK 9
#define SWRST 8 // was 11

.
Once i had that done, it worked straight off.
Thanks again

Yay! I'm glad to hear you brought your Nano 33 IoT back to life.

Thanks for taking the time to share your findings. That is very useful information.

Thank you!

Also recovered my NANO IOT 33 using an Arduino MRK VIDOR 4000.

I used File > Examples > Adafruit DAP library > flash_from_header

With The .bin file as a .hex list. No external SD needed.

Files attached. (modify pins according to your board).

2772cipy.h (31.3 KB)

flash_from_header.ino (2.58 KB)

Hi all,

I've tried to follow this but I am using a nano BLE sense as the Programmer board to flash the bootloader to a Nano 33 IOT. I am getting an error on compile. Do I need a different board to use as the programmer?

I get this warning
WARNING: library Adafruit_DAP_library claims to run on samd architecture(s) and may be incompatible with your current board which runs on mbed architecture(s).

and then an error when trying to compile. Any help would be appriciated.

Hi @ltortuya. Unfortunately, I think this library can only be used with the boards of the SAMD architecture like MKR boards, Nano 33 IoT, and Zero. I apologize if my instructions were misleading.

It's confusing because the documentation for Adafruit_DAP says this:

Tested with a Metro M0 / Arduino Zero as the 'host' and with ATSAMD21's as the client but in theory any 3.3V Arduino board will work as host (just slower)

This is the reason is why I didn't specify that the programmer board must be of the SAMD architecture in my instructions, but it seems clear that at least the Nano 33 BLE boards are not supported. I have now updated my instructions to prevent future confusion.

I'm sending you best wishes for eventual success with your bootloader burning endeavor.

Thanks for the Update Pert. I was able to use a j-link mini edu and the flash-lite function using your instructions and it worked out perfectly.

I just followed your wiring instructions and flashed the .bin file from the j-link programmer to the IOT board. Its working now.

Thanks for all the info!

I'm glad to hear you were able to burn the bootloader! Thank you for taking the time to post an update with your solution. I'm sure those who find this thread while searching for a solution to the same problem will be very grateful.

Regards, Per

Im getting the following error:

Card initialized
fw.bin opened!
Connecting...
Adafruit Generic CMSIS-DAP Adapter 123456 v0.1 (S)

Enter Reset with Extension mode... Target prepare...
invalid response writing to reg 0 (count = 0, value = 0)