-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Closed
Labels
Status: Awaiting triageIssue is waiting for triageIssue is waiting for triage
Description
Board
Closed source product with ESP32-Wrover-IE.N16R8
Device Description
It is an unique designed acquisition device. The following ESP32 functionalities are used (so far):
- Ethernet / Webserver function, RTL8201 phy, 50MHz clock connected to GPIO0 and inverted signal connected to REF clock of the PHY
- SPI - connected to ADC 20MHz SCLK, MISO/MOSI lines used, 16bit data, CS streched x4 burst transfer, period of 20us
- x2 channel PWM with MCPWM
Hardware Configuration
<style> </style>GPIO | Notes | Assigment |
---|---|---|
35 | input only | MISO |
32 | MOSI | |
33 | SCLK | |
25 | EMAC_RXD0 | MAC_RXD0(RMII) |
26 | EMAC_RXD1 | MAC_RXD1(RMII) |
27 | EMAC_RX_DV | MAC_RX_CRS_DV |
14 | EMAC_TXD2 | I2C_SDA |
12 | EMAC_TXD3 | I2C_SCL |
13 | EMAC_RX_ER | CS |
15 | Strapping pin, EMAC_RXD3 | PWM1 |
2 | Strapping pin, bootloader low | PWM2 |
0 | Strapping pin, bootloader low | MAC_CLK_IN |
18 | DIO(RMII) | DIO(RMII) |
19 | EMAC_TXD0 | MAC_TXD0(RMII) |
21 | EMAC_TX_EN | MAC_TX_EN(RMII) |
RXD0 | SerialRXD | |
TXD0 | EMAC_RXD2 | SerialTXD |
22 | EMAC_TXD1 | MAC_TXD1(RMII) |
23 | MDC(RMII) |
Version
v2.0.6
IDE Name
PlatformIO
Operating System
Windows 10
Flash frequency
40
PSRAM enabled
yes
Upload speed
115200
Description
If the MCPWM is configured and started (pwm_init() called) the ethernet stops working. Events are not generated. If the MCPWM does not configured (pwm_init() does not called) the ethernet works properly. I have issues ethernet + SPI as well but I could not strip down the closed source firmware to share a test code.
Sketch
/*
This sketch shows the Ethernet event usage
*/
#include <Arduino.h>
#include <ETH.h>
#include "esp_log.h"
#include "esp_check.h"
#include "soc/mcpwm_periph.h" //for mcpwm_periph_signals
#include "driver/mcpwm.h"
#include "soc/mcpwm_struct.h"
#include "esp_rom_gpio.h" //for esp_rom_gpio_connect_out_signal
static bool eth_connected = false;
const int PS_PHY_EN = 4;
const int START_DELAY_MS = 5000; //miliseconds
void WiFiEvent(WiFiEvent_t event)
{
switch (event) {
case ARDUINO_EVENT_ETH_START:
Serial.println("ETH Started");
//set eth hostname here
ETH.setHostname("esp32-ethernet");
break;
case ARDUINO_EVENT_ETH_CONNECTED:
Serial.println("ETH Connected");
break;
case ARDUINO_EVENT_ETH_GOT_IP:
Serial.print("ETH MAC: ");
Serial.print(ETH.macAddress());
Serial.print(", IPv4: ");
Serial.print(ETH.localIP());
if (ETH.fullDuplex()) {
Serial.print(", FULL_DUPLEX");
}
Serial.print(", ");
Serial.print(ETH.linkSpeed());
Serial.println("Mbps");
eth_connected = true;
break;
case ARDUINO_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
eth_connected = false;
break;
default:
break;
}
}
void testClient(const char * host, uint16_t port)
{
Serial.print("\nconnecting to ");
Serial.println(host);
WiFiClient client;
if (!client.connect(host, port)) {
Serial.println("connection failed");
return;
}
client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
while (client.connected() && !client.available());
while (client.available()) {
Serial.write(client.read());
}
Serial.println("closing connection\n");
client.stop();
}
void pwm_init()
{
mcpwm_config_t pwm_config;
pwm_config.frequency = 12500; //20; //frequency = 110Hz
pwm_config.cmpr_a = 0; //duty cycle of PWMxA = 60.0%
pwm_config.cmpr_b = 0; //duty cycle of PWMxA = 60.0%
pwm_config.counter_mode = MCPWM_UP_COUNTER;
pwm_config.duty_mode = MCPWM_DUTY_MODE_0;
//REF1
mcpwm_init(MCPWM_UNIT_0, MCPWM_TIMER_0, &pwm_config); //Configure PWM0A & PWM0B with above settings
mcpwm_set_duty(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_OPR_A,50);
mcpwm_set_duty_type(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_OPR_A, MCPWM_DUTY_MODE_0);
mcpwm_set_duty(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_OPR_B,50);
mcpwm_set_duty_type(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_OPR_B, MCPWM_DUTY_MODE_0);
//configure GPIO
gpio_set_direction((gpio_num_t) 15, GPIO_MODE_INPUT_OUTPUT);
gpio_set_direction((gpio_num_t) 2, GPIO_MODE_INPUT_OUTPUT);
gpio_set_direction((gpio_num_t) 20, GPIO_MODE_INPUT_OUTPUT);
esp_rom_gpio_connect_out_signal((gpio_num_t)15, mcpwm_periph_signals.groups[MCPWM_UNIT_0].operators[MCPWM0B / 2].generators[MCPWM0B % 2].pwm_sig, 0, 0);
esp_rom_gpio_connect_out_signal((gpio_num_t)2, mcpwm_periph_signals.groups[MCPWM_UNIT_0].operators[MCPWM0B / 2].generators[MCPWM0A % 2].pwm_sig, 0, 0);
esp_rom_gpio_connect_out_signal((gpio_num_t)20, mcpwm_periph_signals.groups[MCPWM_UNIT_0].operators[MCPWM0A / 2].generators[MCPWM0A % 2].pwm_sig, 0, 0);
mcpwm_start(MCPWM_UNIT_0, MCPWM_TIMER_0);
}
void setup()
{
Serial.begin(115200);
log_e("Initialization is starting");
delay(START_DELAY_MS);
pinMode(PS_PHY_EN, OUTPUT);
digitalWrite(PS_PHY_EN, LOW);
delay(200);
digitalWrite(PS_PHY_EN, HIGH);
delay(200);
pwm_init();
WiFi.onEvent(WiFiEvent);
ETH.begin(ETH_PHY_ADDR, PS_PHY_EN, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_RTL8201, ETH_CLOCK_GPIO0_IN, false);
}
void loop()
{
if (eth_connected) {
testClient("google.com", 80);
}
delay(10000);
}
Debug Message
Log message from normal operation:
rst:0x1 (POWERON_RESET),boot:0x23 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13104
load:0x40080400,len:3036
entry 0x400805e4
[ 6][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[ 29][E][main.cpp:76] setup(): Initialization is starting
[ 8367][V][WiFiGeneric.cpp:437] _arduino_event_cb(): Ethernet Started
[ 8367][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 18 - ETH_START
ETH Started[ 8370][V][WiFiGeneric.cpp:430] _arduino_event_cb(): Ethernet Link Up
[ 8380][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 20 - ETH_CONNECTED
ETH Connected
[ 10371][V][WiFiGeneric.cpp:434] _arduino_event_cb(): Ethernet Link Down
[ 10371][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 21 - ETH_DISCONNECTED
ETH Disconnected
[ 14371][V][WiFiGeneric.cpp:430] _arduino_event_cb(): Ethernet Link Up
[ 14371][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 20 - ETH_CONNECTED
ETH Connected[ 14381][V][WiFiGeneric.cpp:445] _arduino_event_cb(): Ethernet got newip:192.168.0.16
[ 14384][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 22 - ETH_GOT_IP
[ 14389][D][WiFiGeneric.cpp:1032] _eventCallback(): ETH IP: 192.168.0.16, MASK: 255.255.255.0, GW: 192.168.0.1
ETH MAC: 90:38:0C:B0:7A:5F, IPv4: 192.168.0.16, FULL_DUPLEX, 100Mbps
connecting to google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Cross-Origin-Opener-Policy-Report-Only: same-origin-allow-popups; report-to="gws"
Report-To: {"group":"gws","max_age":2592000,"endpoints":[{"url":"https://csp.withgoogle.com/csp/report-to/gws/other"}]}
Date: Fri, 06 Jan 2023 09:04:05 GMT
Expires: Sun, 05 Feb 2023 09:04:05 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
closing connection
Bad operation:
rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13104
load:0x40080400,len:3036
entry 0x400805e4
[ 6][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[ 29][E][main.cpp:111] setup(): Initialization is starting
[ 9468][V][WiFiGeneric.cpp:437] _arduino_event_cb(): Ethernet Started
[ 9468][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 18 - ETH_START
ETH Started
Other Steps to Reproduce
Platformio configuration:
[env:esp-wrover-kit]
platform = espressif32@^5.3.0
board = esp-wrover-kit
framework = arduino
monitor_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=5
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.
Metadata
Metadata
Assignees
Labels
Status: Awaiting triageIssue is waiting for triageIssue is waiting for triage