Hi @ptillisch
TLDR: @sterretje seems to have been 100% correct, and closing the serial monitor appears to have fixed it. I would open it after one successful upload each time above and didn't think of that. But sure enough, closing it now and it seems to work perfect. Regarding the old stock.. While that makes sense.. since there are reported issues with the old bootloader as far as I have read, when buying something in 2023 brand new from arduino themselves (even if shipped from amazon warehouses), I would have hoped that they would have patched their old stock. I was lucky to have another device to use as a programmer to reflash it.
...............
The long of it: Here is the code you asked for, Not sure if there are any hints or help to see why it crashes with the serial monitor open:
Arduino IDE 2.1.0
FQBN: arduino:avr:nano
Using board 'nano' from platform in folder: C:\Users\semitone3d\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\semitone3d\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
...
...
snip
Sketch uses 4528 bytes (14%) of program storage space. Maximum is 30720 bytes.
Global variables use 348 bytes (16%) of dynamic memory, leaving 1700 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\semitone3d\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\semitone3d\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -patmega328p -carduino "-PCOM5" -b115200 -D "-Uflash:w:C:\Users\semitone3d\AppData\Local\Temp\arduino\sketches\2DF4692FA8BC9115AD1E7E09F97B6342/Color_Organ.ino.hex:i"
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Users\semitone3d\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM5
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can't open device "\\.\COM5": Access is denied.
avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
Arduino 1.8.19
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\semitone3d\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\semitone3d\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\semitone3d\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -vid-pid=0403_6001 -ide-version=10819 -build-path C:\Users\semitone3d\AppData\Local\Temp\arduino_build_880896 -warnings=none -build-cache
...
...
snip
Sketch uses 4528 bytes (14%) of program storage space. Maximum is 30720 bytes.
Global variables use 348 bytes (16%) of dynamic memory, leaving 1700 bytes for local variables. Maximum is 2048 bytes.
C:\Users\semitone3d\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\semitone3d\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -PCOM5 -b115200 -D -Uflash:w:C:\Users\semitone3d\AppData\Local\Temp\arduino_build_880896/Color_Organ.ino.hex:i
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Users\semitone3d\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM5
Using Programmer : arduino
Overriding Baud Rate : 115200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 4.4
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\semitone3d\AppData\Local\Temp\arduino_build_880896/Color_Organ.ino.hex"
avrdude: writing flash (4528 bytes):
Writing | ################################################## | 100% 1.72s
avrdude: 4528 bytes of flash written
avrdude: verifying flash memory against C:\Users\semitone3d\AppData\Local\Temp\arduino_build_880896/Color_Organ.ino.hex:
avrdude: load data flash data from input file C:\Users\semitone3d\AppData\Local\Temp\arduino_build_880896/Color_Organ.ino.hex:
avrdude: input file C:\Users\semitone3d\AppData\Local\Temp\arduino_build_880896/Color_Organ.ino.hex contains 4528 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 1.55s
avrdude: verifying ...
avrdude: 4528 bytes of flash verified
avrdude done. Thank you.
I have now noticed that if I have the serial monitor open on v1.8.x everything still works ok.
BUT. if I have v2.x and v1.8.x open, and the serial monitor on v2.x is open.. v1.8.x also gives a similar error.
I haven't posted the code for when using the WebUI, but it appears to crash if the serial monitor is open on any of the local IDE's
Thanks so much