PIO giving errors for previously functioning sketches

I am not sure if I am doing anything wrong or if this is normal behaviour for PIO.

I have now three ESP boards that I am using for learning this family of microcontrollers. Previously I have used Arduino and teensy.
I have an ESP-01, an ESP32-C3 and an ESP32-S3.
I have had all sort of issues at start, for example PIO not compiling and giving [this error]:frowning:freertos/FreeRTOS.h: No such file or directory) - which i resolved by completely uninstalling PIO and reinstalling it. However I was eventually able to upload very simple sketches (ie blink sketches) on all three boards. For the esp32s3 I used a premade sketch to light up the onboard LED -using the Adafruit neopixel library- and it worked fine at this point.
I saved the projects. Then I attempted to upload a more complex project for the esp32s3 when I got a new error. At this point I tried to reload the previously functioning simple sketch on the same board but now itā€™s not working anymore.
I am sort of starting to despair. I knew that PIO has a steeper learning curve than Arduino IDE but it is discouraging that a previously functioning sketch is not working after I get an error for another project. Now the question is: am I causing some sort of corruption to the program anytime I do something wrong, and can this affects other sketches ?

I just paste the error below maybe that can help to explain?

Traceback (most recent call last):
  File "C:\Users\inhk\.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py", line 3969, in <module>
    _main()
  File "C:\Users\inhk\.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py", line 3962, in _main
    main()
  File "C:\Users\inhk\.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py", line 3552, in main
    esp.connect(args.before, args.connect_attempts)
  File "C:\Users\inhk\.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py", line 519, in connect
    last_error = self._connect_attempt(mode=mode, esp32r0_delay=False)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inhk\.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py", line 499, in _connect_attempt
    self.sync()
  File "C:\Users\inhk\.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py", line 437, in sync
    self.command(self.ESP_SYNC, b'\x07\x07\x12\x20' + 32 * b'\x55',
  File "C:\Users\inhk\.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py", line 376, in command
    self.write(pkt)
  File "C:\Users\inhk\.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py", line 339, in write
    self._port.write(buf)
  File "C:\Users\inhk\.platformio\penv\Lib\site-packages\serial\serialwin32.py", line 325, in write
    raise SerialTimeoutException('Write timeout')
serial.serialutil.SerialTimeoutException: Write timeout
*** [upload] Error 1

It appears that it does not communicate with the board anymore, but I checked the port number and it seems correctā€¦

even the blink sktech with the esp32C3 does not upload anymore. it gets stuck here:

Serial port COM8
Connectingā€¦

the port number is correct again but it wont uploadā€¦

The ESP32-S3 and ESP32-C3 are even more complex than an ESP8266 and ESP32. This is partly due to the native USB interface. This must be configured correctly. Nevertheless, it behaves differently to a USB to serial chip. So there is a lot to keep in mind (and to learn).

Proceed step by step. Firstly, stick to one model and one sketch. Name the exact model and show us the sketch and the platformio.ini and name the problem.

@sivar2311 thank you,
I was trying to do just what you said. Proceeding slowly and step by step. I started with very simple sketches, even sketches with just empty setup and loop folders, to ensure that the board is uploading (an empty sketch). I will need to send an update as soon as I am able to -working tonight unfortunatelyā€¦ But the issue that I found yesterday was baffling as why would platformio suddenly stopped communicating with all the three boards. Including the esp01 after the issue encountered with the esp32s3ā€¦
Will try again tomorrow and post an update, thank you for now :blush:

I found out that the problem was that I was uploading the sketches on the wrong board, this is because I was selecting the project on the main page rather than reopening the project. Silly mistakeā€¦

Thank you guys for share this information.

Hii All
I have made a few web searches to find out more about selecting the active project (ie:

https://community.platformio.org/t/how-to-select-project-to-build/18681

) but I am still not clear on whether there is a quick way to switch between projects and select the one that I want to compile and upload. Opening another project does work, however sometimes I had to restart VS. Is this the quickest or most efficient way?

this seems to be the answer:

from a previous post :slightly_smiling_face:

https://community.platformio.org/t/platformio-vscode-how-to-select-the-project-to-be-build/4993/13

Multiple projects in a single VS Code workspace will probably lead to errors in the near future that will be difficult to analyze or whose cause will be difficult to find. Do yourself a favor and avoid this by just having ONE project open at a time in VS Code.

This is very easy to achieve. On Windows: Right-click on the project directory you want to open. Then select ā€œOpen with Codeā€.

I donā€™t see ā€œopen with codeā€ option when I do that (I see from another post that I may need to reinstall VC) but honestly I can just stick to opening the file from PlatformIO home section.
Thanks for the heads up about possible problems.

If the option is missing, you have to reinstall VS code and select the option.
17348675523485854593676146673926