Networking-for-Arduino / ESPHost-EMAC

Arduino library. Mbed Core EMAC over ESPHost library
GNU Lesser General Public License v2.1
1 stars 0 forks source link

WiFiWebClient sketch from Mbed WiFi library does not connect to AP with Pico and ESP-Host #1

Open lyusupov opened 6 months ago

lyusupov commented 6 months ago

Board: Raspberry Pico Core: ArduinoCore-Mbed 4.1.1 Sketch: WiFiWebClient

I can see numerous messages in a loop:

Attempting to connect to SSID: TestSSID
Attempting to connect to SSID: TestSSID
Attempting to connect to SSID: TestSSID
Attempting to connect to SSID: TestSSID
Attempting to connect to SSID: TestSSID

When I monitor UART messages from ESP-C3 Host - the log is empty.

My boards,local.txt file contains the following:

pico.build.extra_flags=-DESPHOST_RESET=9 -DESPHOST_HANDSHAKE=7 -DESPHOST_DATA_READY=6 -DESPHOST_CS=17 -DESPHOSTSPI=SPI

This issue happens with ESPHost-EMAC and Arduino-Mbed Core only.

The same hardware works fine with ESPHost driver integrated into Arduino PRP2040 Core developed by Earle Philhower (3.8.0).

boards,local.txt file for Earle's Core contains the following:

rpipico.build.extra_flags=-DESPHOST_RESET=D9 -DESPHOST_HANDSHAKE=D7 -DESPHOST_DATA_READY=D6 -DESPHOST_CS=D17 -DESPHOSTSPI=SPI

When I monitor UART messages from ESP-C3 Host connected to the Pico with Earle's Core - I can see regular boot log messages and connection session.

JAndrassy commented 6 months ago

default SPI in Mbed Core uses pins 16, 18, 19 for Pico.

https://github.com/arduino/ArduinoCore-mbed/blob/2d27acf719a2092f161c0e521c7521fb4dd1a0b7/variants/RASPBERRY_PI_PICO/pins_arduino.h#L44

lyusupov commented 6 months ago

They both match to me -

Mbed SPI

https://github.com/arduino/ArduinoCore-mbed/blob/main/variants/RASPBERRY_PI_PICO/pins_arduino.h#L44-L48

image

Pico SPI

https://github.com/earlephilhower/arduino-pico/blob/master/variants/rpipico/pins_arduino.h#L17-L21

image
JAndrassy commented 6 months ago

right sorry. did you do this from README?

In WiFi.cpp add this line at the end of the file. arduino::WiFiClass WiFi(WiFiInterface::get_default_instance());

lyusupov commented 6 months ago

Sure, I did:

$ tail -10 libraries/WiFi/src/WiFi.cpp
arduino::WiFiClass WiFi(WiFiInterface::get_default_instance());
#endif

// every specialization library should declare its own WiFI object: eg
//
// static ESP8266Interface wifi_if(PD_8, PD_9);
// arduino::WiFiClass WiFi(&wifi_if);

arduino::WiFiClass WiFi(WiFiInterface::get_default_instance());

As well as the header file:

#if 1 // defined(COMPONENT_4343W_FS)
#include "WhdSoftAPInterface.h"
#endif
JAndrassy commented 6 months ago

the C3 version of the firmware uses 30 MHz SPI. I wonder that with Pico Core it worked without -DESPHOSTSPI_MHZ=30

lyusupov commented 6 months ago

Adding -DESPHOSTSPI_MHZ=30 to boards,local.txt file gives no positive effect to me.

$ tail -2 ~/.arduino15/packages/arduino/hardware/mbed_rp2040/4.1.1/boards.local.txt
pico.build.extra_flags=-DESPHOST_RESET=9 -DESPHOST_HANDSHAKE=7 -DESPHOST_DATA_READY=6 -DESPHOST_CS=17 -DESPHOSTSPI=SPI -DESPHOSTSPI_MHZ=30

I wonder why the ESPHost-EMAC does not apply RESET _( ESPHOSTRESET=9 ) to the ESP32-C3 every time the sketch boots up, like the Pico Core does.

JAndrassy commented 6 months ago

did you restart the IDE after changing boards.local.txt?

reset is done by the ESPHost library so that should be the same

lyusupov commented 6 months ago

did you restart the IDE after changing boards.local.txt?

I use arduino-cli. It senses all the dependencies and makes a complete rebuild when necessary. It did the complete sketch rebuild after boards.local.txt update as well.

reset is done by the ESPHost library so that should be the same

I wonder if the Mbed Core uses the same PinName-to-GPIO mapping as the Pico Core does... If it does not - it may cause a lot of troubles.

JAndrassy commented 6 months ago

for Pico in Mbed Core pins mapping is simple. pins 0 to 29 are p0 to p29.

last time I wired the Pico to C3 I didn't test with Mbed Core only with the Pico Core so now I wired them together again. I will test it tomorrow.

lyusupov commented 6 months ago

last time I wired the Pico to C3 I didn't test with Mbed Core only with the Pico Core so now I wired them together again. I will test it tomorrow.

I guessed that by noticing "can work" words in the statement below:

Works with Nano RP2040 Connect and can work with Nano 33 BLE and Raspberry PI Pico with esp32 wired on SPI.

JAndrassy commented 6 months ago

that is because Nano RP2040 has ESP32 on board and the other two require to wire an ESP32 to them

JAndrassy commented 6 months ago

I tested it and it works. Maybe Mbed Core or the WiFi library has some problem with your WiFi? Is it WPA?