ESP32-S3-WROOM-1 loses CDC serial port when starting SPI

mathijs
Posts: 1
Joined: Mon May 15, 2023 6:37 pm

ESP32-S3-WROOM-1 loses CDC serial port when starting SPI

Postby mathijs » Mon May 15, 2023 7:04 pm

Hi,

I've created a custom board using an ESP32-S3-WROOM-1 which is connected to a Wiznet W6100 chip over SPI. The ESP32S3 is connected to USB over pins 13/14 (GPIO19/GPIO20). I can flash the chip without problems.

The W6100 in SPI mode is connected to the following pins:
18 (GPIO10): chip select
19 (GPIO11): MOSI
20 (GPIO12): SCLK
21 (GPIO13): MISO

Every time I try to connect to the SPI device, the ESP32S3 loses its serial connection. Rebooting in the bootloader restores the connection. Changing the pins to input / output manually gives the same result.

Simplest version which crashes right after
  1. Serial.println("Setting VSPI_SCK"):
  1. #include <Arduino.h>
  2. #include <SPI.h>
  3.  
  4. #define VSPI_SCK 19
  5. #define VSPI_MISO 21
  6. #define VSPI_MOSI 20
  7. #define VSPI_SS 18
  8.  
  9. void setup() {
  10.   Serial.begin(115200);
  11.   Serial.println("Starting");
  12.  
  13.   Serial.println("Setting VSPI_SS");
  14.   pinMode(VSPI_SS, OUTPUT); //HSPI SS
  15.   Serial.println("Setting VSPI_SCK");
  16.   delay(1000);
  17.   pinMode(VSPI_SCK, OUTPUT); //HSPI SS
  18.   Serial.println("Setting VSPI_MISO");
  19.   delay(1000);
  20.   pinMode(VSPI_MISO, INPUT); //HSPI SS
  21.   Serial.println("Setting SS");
  22.   delay(1000);
  23.   pinMode(VSPI_MISO, OUTPUT); //HSPI SS
  24.   Serial.println("Init ethernet");
  25. }
  26.  
  27. void loop() {}
My platformio project:
  1. [env:esp32-s3-custom]
  2. platform = espressif32
  3. board = custom_pcb
  4. board_build.arduino.memory_type = dio_opi
  5. framework = arduino
  6. monitor_speed = 115200
  7. build_flags =
  8.     -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
  9.     -D USBCON
  10.     -DCORE_DEBUG_LEVEL=5
  11.     -DBOARD_HAS_PSRAM
  12.     -mfix-esp32-psram-cache-issue
  13. lib_ldf_mode = deep+
  14. lib_deps =
  15.     https://github.com/WIZnet-ArduinoEthernet/Ethernet.git
  16.     adafruit/Adafruit NeoPixel@^1.11.0
and the board definition:
  1. {
  2.   "build": {
  3.     "arduino": {
  4.       "ldscript": "esp32s3_out.ld",
  5.       "partitions": "default_8MB.csv",
  6.       "memory_type": "qio_opi"
  7.     },
  8.     "core": "esp32",
  9.     "extra_flags": [
  10.       "-DBOARD_HAS_PSRAM",
  11.       "-DARDUINO_USB_MODE=1",
  12.       "-DARDUINO_USB_CDC_ON_BOOT=1"
  13.     ],
  14.     "f_cpu": "240000000L",
  15.     "f_flash": "80000000L",
  16.     "flash_mode": "qio",
  17.     "hwids": [
  18.       [
  19.         "0x303A",
  20.         "0x1001"
  21.       ]
  22.     ],
  23.     "mcu": "esp32s3",
  24.     "variant": "esp32s3"
  25.   },
  26.   "connectivity": [
  27.     "wifi"
  28.   ],
  29.   "debug": {
  30.     "openocd_target": "esp32s3.cfg"
  31.   },
  32.   "frameworks": [
  33.     "arduino",
  34.     "espidf"
  35.   ],
  36.   "name": "custom_pcb",
  37.   "upload": {
  38.     "flash_size": "8MB",
  39.     "maximum_ram_size": 327680,
  40.     "maximum_size": 16777216,    
  41.     "use_1200bps_touch": true,
  42.     "wait_for_upload_port": true,
  43.     "require_upload_port": true,
  44.     "speed": 460800
  45.   },
  46.   "url": "https://www.google.nl",
  47.   "vendor": "ME"
  48. }
Does anyone have a clue what could cause this?

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3-WROOM-1 loses CDC serial port when starting SPI

Postby ESP_Sprite » Tue May 16, 2023 8:31 am

pinMode and friends take the GPIO number, not the pin number. In other words, you're reconfiguring GPIO 19 and 20 and as such losing USB.

Who is online

Users browsing this forum: No registered users and 64 guests