Skip to content

stm32: Add support for ETH RMII peripheral #3808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from

Conversation

dpgeorge
Copy link
Member

This PR is based on #3671. It adapts that PR to work with current master.

NUCLEO_F767ZI and STM32F7DISC boards have Ethernet enabled.

@boochow
Copy link
Contributor

boochow commented May 28, 2018

This works fine on my Nucleo-F767ZI. Thank you a lot for integrating codes.
I believe that NUCLEO-F746ZG and NUCLEO-H743ZI also could run this same code when pin definitions file is provided since they have same RMII interface and PHY chip (LAN8742A).

boochow and others added 19 commits June 1, 2018 15:10
…ects/STM32F767ZI-Nucleo/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS/Src)
ethernetif.c --- low level driver mainly derived from STM example code
network_ethernet.c --- MicroPython module code
Makefile and mpconfigport.mk are modified to build these files
modnetwork.c added ethernet
- add RMII_* pin definitions
- uncomment HAL_ETH_MODULE_ENABLED
- add pin definitions for Ethernet RII Interface
- Enable ETH_RMII.
@ziadelmolla
Copy link

Hello boochow, i would like to ask you how did you test the Ethernet , as i am struggling to work with this topic ,would appreciate any help

@dpgeorge
Copy link
Member Author

i would like to ask you how did you test the Ethernet

Please see also #3878

@boochow
Copy link
Contributor

boochow commented Jun 23, 2018

@ziadelmolla to use this PR we have to cherry-pick a bug fix of modnetwork.c.
@dpgeorge nic.ifconfig() shows a wrong dns server address. in modnetwork.c, at line 136, we should use 'dns' instead of '&dns'.

building this PR for Nucleo-F767ZI:

git clone http://github.com/micropython/micropython.git
cd micropython/
git fetch origin pull/3808/head:local-branch-name
git checkout local-branch-name
git cherry-pick 309fe39dbb14b1f715ea09c4b9de235a099c01b0
git submodule update --init
make -C mpy-cross
make -C ports/stm32 MICROPY_HW_ENABLE_ETH_RMII=1 BOARD=NUCLEO_F767ZI
make -C ports/stm32 MICROPY_HW_ENABLE_ETH_RMII=1 BOARD=NUCLEO_F767ZI deploy-stlink

testing the ethernet and its results:

>>> import network
>>> nic = network.Ethernet()
>>> nic.active(True)
>>> nic.ifconfig('dhcp')
>>> print(nic.ifconfig())
('192.168.0.105', '255.255.255.0', '192.168.0.1', '192.168.0.1')
>>> import socket
>>> socket.getaddrinfo('micropython.org', 80)
[(2, 1, 0, '', ('176.58.119.26', 80))]
>>>

@dpgeorge
Copy link
Member Author

nic.ifconfig() shows a wrong dns server address. in modnetwork.c, at line 136, we should use 'dns' instead of '&dns'.

Thanks! I've now fixed this in 6fc84a7

@ziadelmolla
Copy link

@dpgeorge @boochow Thank u for your help. Everything is now working properly.

@forester3
Copy link
Contributor

Should I test this PR Code on STM32F746G-disco board?

@volodink
Copy link

Hi everyone!
Thanks to all contributed into ethernet on stm32.

Today i've ported ethernet feature (RMII) from STM32F7 to STM32F4DISC board.
I´m using STM32F4DISC with DM-STF4BB addon board to have out of the box ethernet experience.
LAN8720A and LAN8742A work perfect (they are direct pin compatible).
I've managed to run Telnet StarWars example running via serial REPL.

In order to test network performance i used iperf utility.
iperf -c board_ip -p 8080 -t 1000 -i 5

uPy code on the board (main.py):

import network
import socket

print('Ethernet init ...')
eth = network.Ethernet()
print('Ethernet init ... done')

eth.active(1)
eth.ifconfig('dhcp')

print(eth.ifconfig())

addr = socket.getaddrinfo(eth.ifconfig()[0], 8080)[0][-1]
s = socket.socket()
s.bind(addr)
s.listen(1)

while True:
    cl, addr = s.accept()
    print('client connected from', addr)
    cl_file = cl.makefile('rwb', 0)
    while True:
        line = cl_file.read(1024)
        if not line or line == b'\r\n':
            break
    cl.close()

and it showed appoximately 4.19-4.3MBit
BUT
after i ONLY just connected and didnt open any consoles or putty to use REPL, uUSB cable to the stm32f407 board port the speed bumped up to 6.5-7.9MBit.
and back if one pulls usb out of the port.
Very very wierd behavior indeed.

Any suggestions?
Thanks.

@bilbolodz
Copy link

I'm trying to run micropython on STM32F746G-DISCO. Using "above recipe" ethernet is working fine but SD card is now working: (PYB: can't mount SD card message during startup). Has anyone working SD card on theses board? And second question: are they any chances to include these patch into "main branch" of the project?

@Meekdai
Copy link

Meekdai commented Jan 3, 2019

I would like to ask if the Ethernet connection is supported with NUCLEO_H743ZI ?

@dpgeorge
Copy link
Member Author

This is superseded by #4541

@dpgeorge dpgeorge closed this Feb 22, 2019
@dpgeorge dpgeorge deleted the stm32-eth-rmii branch February 22, 2019 11:47
@rolandvs
Copy link
Contributor

👍👍

@@ -258,6 +258,8 @@ SRC_C = \
servo.c \
dac.c \
adc.c \
ethernetif.c \
network_ethernet.c \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did you obtain this file from?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, the network_ethernet.c file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, this PR was superseded by #4541 and network_ethernet.c was replaced by network_lan.c

tannewt added a commit to tannewt/circuitpython that referenced this pull request Dec 9, 2020
Enter safe mode after panic or brownout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants