Trying to read debug output of rock 3a using esp 32

i am using arduino ide, my plan is to keep the eps32 connected to rock3a, and access the debug logs from the browser,

this is the code i have used to see if the esp32 is able to read data form rock 3a,
#define RXD2 16

#define TXD2 17


void setup() {

  // Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);

  Serial.begin(115200);

  //Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2);

  Serial2.begin(15000000, SERIAL_8N1, RXD2, TXD2);

  Serial.println("Serial Txd is on pin: "+String(TX));

  Serial.println("Serial Rxd is on pin: "+String(RX));

}


void loop() { //Choose Serial1 or Serial2 as required

  while (Serial2.available()) {

Serial.print(char(Serial2.read()));

  }

}

on serial monitor i am getting the data but only able to see boxes you can see the same in the image attached

can esp32 read the serial debug uart messages?

what am i doing wrong?

my rock 3b keeps hanging after a while and i am unable to pinpoint the exact reason it hangs, so only trying to do this