Ethernet LAN8720A does not work on MicroPython port for STM32 #13406
-
Hi! Whenever I try to use LAN on custom MPY port, when executing // ETHERNET
#define MICROPY_HW_ETH_MDC (pin_C1)
#define MICROPY_HW_ETH_MDIO (pin_A2)
#define MICROPY_HW_ETH_RMII_REF_CLK (pin_A1) // A8 nije ok, povezan i na A1
#define MICROPY_HW_ETH_RMII_CRS_DV (pin_A7)
#define MICROPY_HW_ETH_RMII_RXD0 (pin_C4)
#define MICROPY_HW_ETH_RMII_RXD1 (pin_C5)
#define MICROPY_HW_ETH_RMII_TX_EN (pin_B11)
#define MICROPY_HW_ETH_RMII_TXD0 (pin_B12)
#define MICROPY_HW_ETH_RMII_TXD1 (pin_B13) Specifically, I am using STM32F437ZG (MCU CARD with built-in LAN controller: link. I tested LAN communication in plain C using CycloneTCP, and I can confirm that LAN controller is working properly. Does anyone know what's happening here and what is first steps of troubleshooting this problem, because I cannot get at all LAN controller to work? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 91 replies
-
You should check whether there are proper control signals at the interface. Check with a logic analyzer/oscilloscope that there is I2C communication at MDC and MDIO, and you can check with an oscilloscope that you have a proper RMII ref clock at A1, which either is provided by the MCU or by the LAN8720 module. You have to verify what is configured. The ref clk is 50MHz for a 100 MBit Ethernet. |
Beta Was this translation helpful? Give feedback.
-
Conclusion
Another questionSo, after the LAN chip is fired up, I have problems with communication. Using simple MicroPython v1.23.0-preview.33.g2ed976f14.dirty on 2024-01-13; Fusion for ARM v8 with STM32F43xx
Type "help()" for more information.
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== # LAN priprema
=== import network
=== nic = network.LAN()
=== nic.active(True)
=== nic.ifconfig(('192.168.0.140', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
=== nic.isconnected()
===
=== # Socket test
=== import urequests
=== r = urequests.get("http://192.168.0.110:8080")
=== print(r.text)
=== r.close()
===
True
Traceback (most recent call last):
File "<stdin>", line 10, in <module>
File "requests/__init__.py", line 180, in get
File "requests/__init__.py", line 91, in request
OSError: [Errno 103] ECONNABORTED
>>> The chip is communicating with MCU, now for sure. But I get that error unexpectedly. On router, it shows that the MCU is connected via LAN. I set up the |
Beta Was this translation helpful? Give feedback.
-
stdout is just the terminal output of the device, the same as sys.stdout of python. |
Beta Was this translation helpful? Give feedback.
-
I do not know if you continued your work on the topic. I restarted yesterday evening by connecting a LAN8720 to a PYBD_SF6 (STM32F767). I took that approach since this device has ETH defines in the mpconfigboard.h, indicating that Ethernet worked with a different PHY. I can log communication at the MDIO interface between the PYBD and the LAN8720, but startup stops when attempting to reset the ETH DMA unit. It simply does never indicate of being ready and runs in a timeout. That looks like a clock is missing, but the ETH clocks are enabled. That's strange because that is not linked to the PHY. So I wonder if it ever worked. |
Beta Was this translation helpful? Give feedback.
-
About the F437 and the LAN8720. Just reading the LAN8720 data sheet about the refclk. To have the LAN8720 provide the REFCLK, the RefClk Pin must be strapped low at the time of Power on or when the LAN8720 is reset. I do not know what the status or the strapping is on your board. For the LAN8720 I used this does not matter since it has an external 50MHz oscillator. |
Beta Was this translation helpful? Give feedback.
-
Conclusion
|
Beta Was this translation helpful? Give feedback.
Conclusion
MICROPY_HW_ETH_RMII_CLK_OUT
.