I've got two issues with the Serial0 (pins D0/RX0 and D1/TX1), not necessarily related, but kinda...
#1 - Panic Dump
It seems that when the CPU panics, it sends the details to this port. In my project, I happen to have a small thermal printer, so when the CPU panics the printer spits out a long ribbon of crap.
I discovered that the Arduino API provides a setDebugOutput() method for serial ports, so I tried this:
// Set the USB serial port to send the panics
Serial.setDebugOutput( true );
// Disable panic dumps on the printer port
Serial0.setDebugOutput( false );
...but this seems to have no effect.
If I understand correctly, any digital pin on the ESP32 can host the hardware serial, so it's just a matter of using:
#define UART_ID 0
#define RX_PIN D12
#define TX_PIN D11
HardwareSerial mySerialPort( UART_ID );
mySerialPort.setPins( RX_PIN, TX_PIN );
But since that specifies UART 0, I'm betting the problem will just move with it.
I know I could also use SoftwareSerial, but I'd like to learn more about this situation and see if there's a real solution that stops panic dumps from being sent to UART 0.
#2 - Data sent to UART 0 at boot-up
As I mentioned above, I have a small thermal printer connected to Serial0. Every time the ESP32 boots, a small amount of data is being sent to that port (I can't tell what, as the printer is set to 9600 baud, and whatever is sending the data is set to a different speed, so the printer just spits out a few characters of garbage).
Somewhere, I can't remember where (maybe a GitHub issue), I found out that the boot ROM has something hard-coded in it that sends some little chunk of data at boot-up. They said that if you bring GPIO15 low, the bootloader will see this and not send any output to UART 0. Well, Arduino's implementation of the ESP32 seems to not have GPIO15 exposed anywhere, so this is not an option.
There's nothing I can really do in software to stop this, since it's in the bootloader. Unless I compile and load a custom bootloader?