fixing "avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20"

Just thought someone else is having the same issue, here is one solution for the elusive "avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20".

Environment: Windows 10 64bits, 16G RAM, FTDI USB-to-Serial adapter. IDE 1.8.2

Target: Atmega 328P board with Uno autoloader installed via SPI, running at 16M.

Other Hardware: MPU9150 wired to 328P's I2C pins

Symptom: Occasionally, there is no problem uploading software to the board described above, however, after the first successful upload, subsequent uploads will most likely fail with "avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20" type of error.

Fix: I happen to have a built-in COM port, namely COM1, it is on the modther board and there is no physical port associated with it, so nothing is selected. The upload USB-to-Serial adapter is COM9, when there is a problem, simply select COM1, wait a few seconds, select COM9 back as PORT under Tools->Port. After doing this, Uploading code is always successful.

Comments: I know this type of error is very elusive and error message is very "generic", but this fix seems to suggest the PORT configuration seem to be lost or the IDE does not keep it. I have been using the same USB-to-Serial adapter for a long time, under IDE 1.5.x, there is no such problem.

Anyways, just thought someone else can benefit from this.