guild icon
Toit
#Ethernet esp32 board question
Thread channel in help
Adam
Adam 12/06/2024 09:28 AM
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 ...)
LILYGO® TTGO T-Internet-COM ESP32 Wifi Bluetooth Board For T-PCIE Ethernet IOT Module With SIM TF Card Slot Type-C Connector Specification MCU  ESP32 FLASH 16MB PSRAM 8MB Bus Interfaces UART, SPI, I2C, CAN, I2S, SDIO Wireless Connectivity Wi-Fi 802.11 b/g/n/, BLE V4.2 Onboard Buttons RST+BOOT WS2812 RGB GPIO12 USB to T
Contribute to Xinyuan-LilyGO/T-Internet-COM development by creating an account on GitHub.
Adam
Adam 12/06/2024 09:29 AM
#
# 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
AdamOPAdam
# # 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 no...
floitsch
floitsch 12/06/2024 02:55 PM
Let's see if we can get the board working.
As you said; we might need a new envelope.
floitsch
floitsch 12/06/2024 03:01 PM
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.
floitsch
floitsch 12/06/2024 03:27 PM
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:
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
(edited)
floitsch
floitsch 12/06/2024 03:27 PM
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.
Adam
Adam 12/06/2024 04:23 PM
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.
floitsch
floitsch 12/06/2024 04:27 PM
Great news.
It could be that Jaguar is still trying to open the WiFi, though.

Note that Artemis is fine with just ethernet.
AdamOPAdam
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 net...
floitsch
floitsch 12/06/2024 04:29 PM
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.(edited)
Adam
Adam 12/06/2024 04:35 PM
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.
floitsch
floitsch 12/06/2024 04:36 PM
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".
floitsch
floitsch 12/09/2024 05:31 PM
@Adam I just noticed that the lilygo has PSRAM. As such you want to use the esp32-eth-clk-out17-spiram envelope.
Adam
Adam 12/10/2024 03:10 PM
Toit envelopes for different configurations. Contribute to toitlang/envelopes development by creating an account on GitHub.
Adam
Adam 12/10/2024 03:11 PM
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.
floitsch
floitsch 12/10/2024 03:13 PM
Ooh. Interesting. So it's the out0 with spiram that works?
Adam
Adam 12/10/2024 03:13 PM
My board lilygo (not olimex) has ESP32-WROVER-E
Adam
Adam 12/10/2024 03:14 PM
out0 works
floitsch
floitsch 12/10/2024 03:14 PM
Try the one with spiram then
floitsch
floitsch 12/10/2024 03:14 PM
You should see at startup if the external memory is recognized
Adam
Adam 12/10/2024 03:15 PM
I used this: esp32-eth-clk-out0-spiram
ethernet works
I not tried to use RAM
floitsch
floitsch 12/10/2024 03:15 PM
Perfect. You are using the envelope I wanted you to use.
Adam
Adam 12/10/2024 03:15 PM
Yes. Works like a charm.
👍1
bitphlipphar
bitphlipphar 12/12/2024 05:46 PM
The Toit platform automatically uses the SPIRAM so you just have more memory available :🎉:
23 messages in total