Arduino 101 Serial.print() to monitor fails, except after sketch upload

(MacBook Pro; MacOS 10.11.6; IDE 1.8.2; Curie core 1.0.5)

My project is required to print parameters and settings to the serial monitor. This works correctly once, immediately following code upload, but then fails on subsequent restarts (e.g., master reset or power cycle). The " while(!Serial) " hack described elsewhere appears to hang the sketch indefinitely in such instances.

Problem can be reproduced by adding the following lines to setup() in your example "Blink.ino". It is independent of the chosen baud rate (except 1200, which recursively triggers USB reset).

Serial.begin(115200);
while(!Serial);
Serial.println(" -- TEST --");
Serial.println(" 1 2 3 ");
Serial.end();

Any cogent advice appreciated. It's looking like we will otherwise have to abandon this board and go back to the AVR, despite its limitations.

Remove the "while serial" and "serial end" sections.

It is not needed in most cases.

the serial begin just waits until it senses a USB connection and triggers the serial.

The "serial end" will probably be ignored as the USB itself will trigger serial when the computer is polling USB devices.

Thats not a sketch BTW !
And my suggestion only covers you example.

For your real issue you would have to post a schematic and the sketch being used as without them anything else is just a stab in the dark.

BTW if you do post code then make sure you use CODE TAGS ( </> )

Thanks! I am new to this, did not know about code tags. Will do so in future.

It is just the stock "blink.ino" example as supplied, with the given lines inserted, and as indicated the while() has no effect on the observed failure (except that this line also causes the board to hang, i.e., no blink). In other words, the following sketch fails to write to a serial monitor except once, when it is first loaded.

This differs from the observed behavior of the same code with an AVR board.

Thank you again for having a look,

Mike

/*
 Blink
 Turns on an LED on for one second, then off for one second, repeatedly.

 Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO 
 it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
 the correct LED pin independent of which board is used.
 If you want to know what pin the on-board LED is connected to on your Arduino model, check
 the Technical Specs of your board  at https://www.arduino.cc/en/Main/Products
 
 This example code is in the public domain.

 modified 8 May 2014
 by Scott Fitzgerald
 
 modified 2 Sep 2016
 by Arturo Guadalupi
 
 modified 8 Sep 2016
 by Colby Newman
*/

// the setup function runs once when you press reset or power the board
void setup() {
 // initialize digital pin LED_BUILTIN as an output.
 pinMode(LED_BUILTIN, OUTPUT);
 
 Serial.begin(9600);
 Serial.println(" --- TEST ----");
}

// the loop function runs over and over again forever
void loop() {
 digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(1000);                       // wait for a second
 digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
 delay(1000);  // wait for a second
}