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: 829
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
  1. #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
  2. #ifndef ARDUINO_USB_CDC_ON_BOOT
  3. #define ARDUINO_USB_CDC_ON_BOOT 0
  4. #endif
  5. #if ARDUINO_USB_CDC_ON_BOOT  //Serial used from Native_USB_CDC | HW_CDC_JTAG
  6. #if ARDUINO_USB_MODE         // Hardware CDC mode
  7. // Arduino Serial is the HW JTAG CDC device
  8. #define Serial HWCDCSerial
  9. #else  // !ARDUINO_USB_MODE -- Native USB Mode
  10. // Arduino Serial is the Native USB CDC device
  11. #define Serial USBSerial
  12. #endif  // ARDUINO_USB_MODE
  13. #else   // !ARDUINO_USB_CDC_ON_BOOT -- Serial is used from UART0
  14. // if not using CDC on Boot, Arduino Serial is the UART0 device
  15. #define Serial Serial0
  16. #endif  // ARDUINO_USB_CDC_ON_BOOT
  17. // There is always Seria0 for UART0
  18. extern HardwareSerial Serial0;
  19. #if SOC_UART_NUM > 1
  20. extern HardwareSerial Serial1;
  21. #endif
  22. #if SOC_UART_NUM > 2
  23. extern HardwareSerial Serial2;
  24. #endif
  25. #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: No registered users and 85 guests