STM32 Nucleo64 UART problem?

Hi all,
I want to test UART communication on Nucleo64 F303 board and I have a problem.
I send a message with another board to this Nucleo (to Serial 1 and Serial2).
In NUC I want to receive massages in Serial1 and Serial2, nad transfer it to Serial (USB).
such a simple quick test to see if the series are working (and pins are correct).
Unfortunately, only Serial1 works for me and it doesn't read anything from S2.
At the beginning I need to define the pins for Serial1 (without it I get an error when compiling).
If I also define Serial2, there is an error ‘multiple definition of `Serial2';’

What can I do to make this Serial2 work?

HardwareSerial Serial1(PA10, PA9);
//HardwareSerial Serial2(PA3, PA2);

void setup() {
Serial.begin(115200);    // USB ST-LINK
Serial1.begin(115200);     // PA9 (TX), PA10 (RX)
Serial2.begin(115200);     // PA2 (TX), PA3 (RX)
delay(1000);
Serial.println("Start test");
}

void loop() {
if (Serial1.available()) {
String received1 = Serial1.readStringUntil('\n');
Serial.print("Serial1: ");
Serial.println(received1);
}

if (Serial2.available()) {
String received2 = Serial2.readStringUntil('\n');
Serial.print("Serial2: ");
Serial.println(received2);
}
}

I'm assuming we're talking about the Nucleo-F303RE here.

The variant.h file of the core for that board defines "Serial" to be Serial2 at TX=PA2 and RX=PA3. Serial is a macro for Serial2.

It's wrong to try to create Serial2 again.

The definition of Serial1 is fine. Available UART TX/RX pins are also referenced in https://github.com/stm32duino/Arduino_Core_STM32/blob/main/variants/STM32F3xx/F303R(D-E)T/PeripheralPins.c#L199-L229.

Double check your pin mapping. You can't use Serial2 (USART2 perpiheral) at PA2 and PA3 since that's the serial connection to the ST-Link back to the computer. However, there are various other UARTs still available.

An overview if also given by

Okay, wait, so Serial2 is the same as Serial and what I have connected to my PC :open_mouth: .
I just checked it by connecting this test, and I'm receiving messages from Serial1 as before and I see it on the PC, BUT when I send something from the computer to the NUC, it sends it back as from Serial2 :open_mouth: :man_facepalming:
ok, I need to check this Nucleo Serial mapping more carefully (I assumed it works as in Pi Pico)