Serial.print on Adafruit ESP32S3 Metro board

PCRiscV
Posts: 11
Joined: Thu Jan 04, 2024 3:57 pm

Serial.print on Adafruit ESP32S3 Metro board

Postby PCRiscV » Wed Apr 17, 2024 9:58 pm

I am using Arduino as an IDF component and I am able to run code on the Metro board. I can see the ESP_LOGx messages in the "idf.py monitor" window, but I am not seeing the Serial.print() output? Where is Serial configured. I would like the Serial.print to go to the USB out, same as ESP_LOG.

Thanks


PCRiscV
Posts: 11
Joined: Thu Jan 04, 2024 3:57 pm

Re: Serial.print on Adafruit ESP32S3 Metro board

Postby PCRiscV » Thu Apr 18, 2024 1:22 pm

Thanks, I see that but I am trying to build my app with the IDF tools (Arduino is installed as a component) but I cannot find the right setting. I get the expected result if I use the Arduino IDE, I get the expected results.

Thanks

lbernstone
Posts: 1131
Joined: Mon Jul 22, 2019 3:20 pm

Re: Serial.print on Adafruit ESP32S3 Metro board

Postby lbernstone » Fri Apr 19, 2024 8:11 am

That link also shows the define macros you should set before you call initArduino that match the settings from the tools menu.

PCRiscV
Posts: 11
Joined: Thu Jan 04, 2024 3:57 pm

Re: Serial.print on Adafruit ESP32S3 Metro board

Postby PCRiscV » Fri Apr 19, 2024 12:08 pm

Ok that's easy to do. Do I define the macro before the call to initArduino, or should the #define be used to compile the whole component? When looking at HardwareSerial.h it looks like the define are needed when compiling the components.

Thanks

Code: Untitled.c Select all


#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
#ifndef ARDUINO_USB_CDC_ON_BOOT
#define ARDUINO_USB_CDC_ON_BOOT 0
#endif
#if ARDUINO_USB_CDC_ON_BOOT //Serial used from Native_USB_CDC | HW_CDC_JTAG
#if ARDUINO_USB_MODE // Hardware CDC mode
// Arduino Serial is the HW JTAG CDC device
#define Serial HWCDCSerial
#else // !ARDUINO_USB_MODE -- Native USB Mode
// Arduino Serial is the Native USB CDC device
#define Serial USBSerial
#endif // ARDUINO_USB_MODE
#else // !ARDUINO_USB_CDC_ON_BOOT -- Serial is used from UART0
// if not using CDC on Boot, Arduino Serial is the UART0 device
#define Serial Serial0
#endif // ARDUINO_USB_CDC_ON_BOOT
// There is always Seria0 for UART0
extern HardwareSerial Serial0;
#if SOC_UART_NUM > 1
extern HardwareSerial Serial1;
#endif
#if SOC_UART_NUM > 2
extern HardwareSerial Serial2;
#endif
#endif //!defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)

PCRiscV
Posts: 11
Joined: Thu Jan 04, 2024 3:57 pm

Re: Serial.print on Adafruit ESP32S3 Metro board

Postby PCRiscV » Fri Apr 19, 2024 1:44 pm

If I define:

target_compile_options(${COMPONENT_TARGET} PUBLIC
-DARDUINO=10812
-DARDUINO_${idf_target_for_macro}_DEV
-DARDUINO_ARCH_ESP32
-DARDUINO_BOARD="${idf_target_caps}_DEV"
-DARDUINO_VARIANT="${CONFIG_ARDUINO_VARIANT}"
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=0
-DESP32)

Then I get compilation errors:

/HardwareSerial.h:350:16: error: 'USBSerial' was not declared in this scope; did you mean 'Serial'?
350 | #define Serial USBSerial

when compiling .../cores/esp32/chip-debug-report.cpp:290:3: note: in expansion of macro 'Serial'

Who is online

Users browsing this forum: Amazon [Bot], Qwantbot and 4 guests