https://toitlang.org/ logo
Ethernet esp32 board question
# help
a
Hello, I have a board: LilyGo T-Internet-COM https://lilygo.cc/products/t-internet-com It has a ESP32 WROVER-E chip and PSRAM (8 MB) ======================= So I tried the available generated envelope (I have installed version 168): https://github.com/toitlang/envelopes/releases/download/v2.0.0-alpha.168/firmware-esp32-eth-clk-out0-spiram.envelope.gz jag flash firmware-esp32-eth-clk-out0-spiram.envelope.gz This ^^^ seems to be good at first sight, but not working (and not work the others too: firmware-esp32-eth-clk-out0.envelope.gz, firmware-esp32-eth-clk-out17-spiram.envelope.gz, firmware-esp32-eth-clk-out17.envelope.gz) ======================= So if I check the board github repo, linked from the official product page (link above): https://github.com/Xinyuan-LilyGO/T-Internet-COM/blob/main/example/ESP-IDF/eth2ap/sdkconfig From this sdkconfig file these lines seems to be relevant: (2000 char limit ...)
# # Example Configuration # CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y # CONFIG_EXAMPLE_USE_DM9051 is not set # CONFIG_EXAMPLE_USE_W5500 is not set # CONFIG_EXAMPLE_ETH_PHY_IP101 is not set # CONFIG_EXAMPLE_ETH_PHY_RTL8201 is not set CONFIG_EXAMPLE_ETH_PHY_LAN8720=y # CONFIG_EXAMPLE_ETH_PHY_DP83848 is not set # CONFIG_EXAMPLE_ETH_PHY_KSZ8041 is not set CONFIG_EXAMPLE_ETH_MDC_GPIO=23 CONFIG_EXAMPLE_ETH_MDIO_GPIO=18 CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5 CONFIG_EXAMPLE_ETH_PHY_ADDR=0 CONFIG_EXAMPLE_WIFI_SSID="LilyGo-AP" CONFIG_EXAMPLE_WIFI_PASSWORD="12345678" CONFIG_EXAMPLE_WIFI_CHANNEL=1 CONFIG_EXAMPLE_MAX_STA_CONN=4 # end of Example Configuration # # Ethernet # CONFIG_ETH_ENABLED=y CONFIG_ETH_USE_ESP32_EMAC=y CONFIG_ETH_PHY_INTERFACE_RMII=y # CONFIG_ETH_PHY_INTERFACE_MII is not set # CONFIG_ETH_RMII_CLK_INPUT is not set CONFIG_ETH_RMII_CLK_OUTPUT=y CONFIG_ETH_RMII_CLK_OUTPUT_GPIO0=y CONFIG_ETH_DMA_BUFFER_SIZE=512 CONFIG_ETH_DMA_RX_BUFFER_NUM=10 CONFIG_ETH_DMA_TX_BUFFER_NUM=10 CONFIG_ETH_USE_SPI_ETHERNET=y # CONFIG_ETH_SPI_ETHERNET_DM9051 is not set # CONFIG_ETH_SPI_ETHERNET_W5500 is not set # CONFIG_ETH_USE_OPENETH is not set # end of Ethernet ======================= I can figure out things to this point only. I'm a very beginner, please bear with me. My goal to use a buyable esp32 board with built-in ethernet and maybe disable wifi (at boot). Can you give me any guidance where to go from here? May be I have to create a custom envelope variant with some of the sdkconfig settings above? Or buy an another board that works with the available variants here (https://github.com/toitlang/envelopes/tree/main/variants), if so, where/what to buy? Thanks, Adam
f
Let's see if we can get the board working. As you said; we might need a new envelope.
CONFIG_ETH_RMII_CLK_OUTPUT_GPIO0=y
That indicates that the
esp32-eth-clk-out0-spiram
is a better starting point. Still looking at what other changes we might need.
From what I can see, the board uses a lan8720. From the schematics I'm reading: - mdc = 23 - mdio = 18 - power = 4 Could you try with these settings (an the
esp32-eth-clk-out0-spiram
envelope) the code on https://libs.toit.io/esp32/net/ethernet/class-EthernetServiceProvider Basically:
Copy code
import gpio
import net.ethernet
import esp32.net.ethernet as esp32

main:
  power := gpio.Pin --output 4
  power.set 1
  provider := esp32.EthernetServiceProvider.mac-esp32
      --phy-chip=esp32.PHY-CHIP-LAN8720
      --phy-address=0
      --mac-mdc=gpio.Pin 23
      --mac-mdio=gpio.Pin 18
  provider.install
  network := ethernet.open
  try:
    // use network
    print "if we reach here the network opened"
  finally:
    network.close
    provider.uninstall
    power.close
If that doesn't work we might need to debug a bit more, but I would be surprised if we can't get the board working.
a
Wow, works perfectly. Thanks. For some reason I thought that if wifi is in firmware then ethernet should be too. I thought that working with containers (with jag) need working network established by the firmware. This is more simpler for me as beginner.
f
Great news. It could be that Jaguar is still trying to open the WiFi, though. Note that Artemis is fine with just ethernet.
Not important but maybe interesting: Jaguar itself is just a container and is responsible for opening the WiFi connection. So fundamentally there isn't any "firmware establishes the connection". It's just that
jag flash
automatically install the Jaguar container for you. It is, however, just a normal container.
a
Thanks for the clarification! https://docs.toit.io/getstarted Architecture diagram "The containers are developed and maintained independently from each other and the virtual machine provides the capabilities for safely running your platform-independent applications, services, and drivers side-by-side." For some reaseon I thought that virtual machine can not work with internet -> so firmware establish the net connection. I will check Artemis.
f
In general we recommend Jaguar for development (and experimentation) and Artemis for deployment. That means that Artemis is a more powerful but also a bit more "inconvenient".
@Adam I just noticed that the lilygo has PSRAM. As such you want to use the
esp32-eth-clk-out17-spiram
envelope.
esp32-eth-clk-out0 and esp32-eth-clk-out17 A variant for ESP32 boards with Ethernet and a clock output on pin 0/17. Olimex boards with Ethernet should use this variant. The WROOM versions need esp32-eth-clk-out17 and the WROVER versions need esp32-eth-clk-out0.
f
Ooh. Interesting. So it's the out0 with spiram that works?
a
My board lilygo (not olimex) has ESP32-WROVER-E
out0 works
f
Try the one with spiram then
You should see at startup if the external memory is recognized
a
I used this: esp32-eth-clk-out0-spiram ethernet works I not tried to use RAM
f
Perfect. You are using the envelope I wanted you to use.
a
Yes. Works like a charm.
k
The Toit platform automatically uses the SPIRAM so you just have more memory available 🎉