You don't have a variable called Msg1 declared.
If it can't be compiled, it will not be uploaded and hence can't freeze your MKR
But your output indicates that you can compile but not upload.
I don't have a MKR1010 WiFi so can't verify; your statement that it does not accept Serial.read() is strange. Serial.parseInt() uses Serial.read() under the hood. Your MKR1010 WiFi has a native USB port; below is a test sketch that possibly fixes the Serial.read() issue. It does not fix your upload problem.
char d;
String Msg;
void setup() {
Serial.begin(57600);
while(!Serial);
}
void loop()
{
while ((d = Serial.read()) > '\n')
{
Msg += (char) d;
Serial.println(d);
}
if (d == '\n')
{
Serial.println(Msg);
}
}
Please note the additional line in the setup() function. Be aware that that line will cause the MKR1010 WiFi to hang forever if you don't open the serial port; if your final sketch does not have a need for serial output, that can be fixed (but that's for later).
Notes:
- The compiled code (that is uploaded) for boards with native USB contains specific code to reset the board; it's not part of your sketch. If your sketch is incorrectly written, it might overwrite variables used by this specific code and that will often result in being unable to upload code. This was already explained earlier.
- Observe the behaviour of this reset in Windows device manager. During a reset, the port should change.