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

stm32: Add support for ETH RMII peripheral #3808

Open
wants to merge 19 commits into
base: master
from

Conversation

Projects
None yet
6 participants
@dpgeorge
Contributor

dpgeorge commented May 22, 2018

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

NUCLEO_F767ZI and STM32F7DISC boards have Ethernet enabled.

@boochow

This comment has been minimized.

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 some commits Dec 9, 2017

add ethernetif.c from STM32CubeMX sample (STM32Cube_FW_F7_V1.8.0/Proj…
…ects/STM32F767ZI-Nucleo/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS/Src)
stm32: STM32 ethernet driver integrated.
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
stm32/boards/STM32F7DISC: Enable ETH peripheral.
- add RMII_* pin definitions
- uncomment HAL_ETH_MODULE_ENABLED
- add pin definitions for Ethernet RII Interface
- Enable ETH_RMII.
@ziadelmolla

This comment has been minimized.

ziadelmolla commented Jun 21, 2018

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

This comment has been minimized.

Contributor

dpgeorge commented Jun 22, 2018

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

Please see also #3878

@boochow

This comment has been minimized.

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

This comment has been minimized.

Contributor

dpgeorge commented Jun 23, 2018

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

This comment has been minimized.

ziadelmolla commented Jun 25, 2018

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

@forester3

This comment has been minimized.

Contributor

forester3 commented Jun 28, 2018

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

@dpgeorge dpgeorge referenced this pull request Jul 17, 2018

Closed

stm32: add sdram support #3940

@volodink

This comment has been minimized.

volodink commented Aug 15, 2018

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

This comment has been minimized.

bilbolodz commented Nov 11, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment