Can't upload code to Arduino boards after changing settings

I’ve recently fiddled with the settings under Tools in the IDE, to upload code to a Daisy Seed board, following these instructions. This required changing the board to STM32 MCU based boards, after which a bunch of other choices appear in the IDE that are not there when the chosen board is an Arduino UNO. After switching back to choosing an Arduino UNO, the IDE shows the board’s port (/dev/ttyACM0 on my Debian system), but when I try to upload code to it, I get the following error:

avrdude: ser_open(): can't open device "/dev/ttyACM0": Device or resource busy
Failed uploading: uploading error: exit status 1

I tried a few different programmers like Arduino as ISP, ArduinoISP, or AVRISP mkII from the Tools -> Programmer menu, but no luck.

Anyone knows how I can reset the IDE to be able to upload code to my Arduino boards again?

My IDE is 2.3.5 on a Debian 13 system.

Thanks.

P.S. I checked a bunch of other similar posts, but none seemed to provide an answer to my problem.

Answering to myself, hopefully anyone in the future having the same issue will read this. I had several IDE windows open, and one of the had the serial monitor open, which was blocking the IDE from uploading code to my board. Since I’m on Linux, I read this from Arduino’s website and did a lsof /dev/ttyACM0 in the terminal, which gave this:

COMMAND    PID USER FD   TYPE DEVICE SIZE/OFF NODE NAME
serial-mo 7307 alex 3u   CHR  166,0      0t0  719 /dev/ttyACM0

and then did ps 7307 (the PID of the process), which returned this:

    PID TTY      STAT   TIME COMMAND
   7307 ?        Sl     0:00 /home/alex/.arduino15/packages/builtin/tools/serial-monitor/0.15.0/serial-monitor

telling me that the IDE’s serial monitor was using the port. I found the IDE window with the open serial monitor, closed the monitor and was finally able to upload code.

BTW, the programmer I have chosen is AVRISP mkII. I think this is the correct one, right?

Thanks for taking the time to post an update with your findings @alexandros301!

The Arduino IDE developers are tracking the bug where Serial Monitor interferes with the upload here:

The Tools > Programmer menu selection is only used when you are doing Tools > Burn Bootloader or "Upload Using Programmer". When you're doing a standard "Upload", the Tools > Programmer menu selection is completely ignored. So it makes no difference at all what you have selected from the Tools > Programmer menu.