Here is some code I implemented to start up Firmata. It waits for u-boot to complete:
void setup()
{
Serial1.begin(115200); // Set the baud.
while (!Serial1) {}
// Wait for U-boot to finish startup. Consume all bytes until we are done.
do {
while (Serial1.available() > 0) {
Serial1.read();
}
delay(1000);
} while (Serial1.available()>0);
... and some other stuff.
}
I really wish they used a semaphore, but that would have made our lives easy. XD