Flash erase failed in Arduino Nano 33 IoT

Hello,
I just got an Arduino Nano 33 IoT.
The only things I have done is installing the libraries: WiFiNINA, Arduino LSM6DS3, Arduino RTCZero and ArduinoBLE.
When I try to upload through File>Examples>01Basic>Blink I get this error:

Arduino: 1.8.19 (Windows 10), Board: "Arduino Nano 33 BLE"
Sketch uses 83568 bytes (8%) of program storage space. Maximum is 983040 bytes.
Global variables use 43920 bytes (16%) of dynamic memory, leaving 218224 bytes for local variables. Maximum is 262144 bytes.
Forcing reset using 1200bps open/close on port COM5
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
PORTS {COM5, } / {COM5, } => {}
Uploading using selected port: COM5
C:\Users\ob.lux\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.9.1-arduino2/bossac.exe -d --port=COM5 -U -i -e -w C:\Users\OB~1.LUX\AppData\Local\Temp\arduino_build_477061/Blink.ino.bin -R

Set binary mode
Flash erase failed
version()=v2.0 [Arduino:XYZ] Apr 19 2019 14:38:48
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
write(addr=0x20004000,size=0x34)
An error occurred while uploading the sketch
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
version()=v2.0 [Arduino:XYZ] Apr 19 2019 14:38:48
readWord(addr=0x41004018)=0
readByte(addr=0x804001)=0xc7
readByte(addr=0x804001)=0xc7
readByte(addr=0x804006)=0xff
readByte(addr=0x804007)=0xff
Device : ATSAMD21x18
Version : v2.0 [Arduino:XYZ] Apr 19 2019 14:38:48
Address : 0x0
Pages : 4096
Page Size : 64 bytes
Total Size : 256KB
Planes : 1
Lock Regions : 16
Locked : none
Security : false
BOD : true
BOR : true
Erase flash

Does anyone have any idea about what could be going on?

Hi @ob_lux. You have the wrong board selected from the Tools > Board menu of the Arduino IDE. Despite the similar names, the Nano 33 IoT and Nano 33 BLE are very different boards, so you must make sure to select the right one in order to be able to upload successfully.

So select Tools > Board > Arduino SAMD (32-bits ARM Cortex-M0+) Boards > Arduino Nano 33 IoT from the Arduino IDE menus and then try uploading again.

If you don't have that option in the menu, it means that you haven't installed the "Arduino SAMD (32-bits ARM Cortex-M0+) Boards" platform yet. You can do that via the Arduino IDE Boards Manager, just like you did it for the Nano 33 BLE's platform;

  1. Select Tools > Board > Boards Manager from the Arduino IDE menus.
  2. Wait for the updates to finish.
  3. Scroll down through the list of boards platforms until you see "Arduino SAMD Boards (32-bits ARM Cortex-M0+) by Arduino". Click on it.
  4. Click the Install button.
  5. Wait for the installation to finish.
  6. Click the Close button.

You should now see the "Arduino Nano 33 IoT" board under the Tools > Board menu of the Arduino IDE.

Thanks, I had the same problem and this worked perfectly. much appreciated.