Pyboard + W5500/W5200 Ethernet - Cant get it to work - MicroPython v1.11-422-g98c2eabaf

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
MCHobby
Posts: 17
Joined: Mon Jan 26, 2015 2:05 pm

Pyboard + W5500/W5200 Ethernet - Cant get it to work - MicroPython v1.11-422-g98c2eabaf

Post by MCHobby » Fri Oct 11, 2019 4:59 pm

Hi, I'm trying to finish a book about MicroPython and surprisingly I'm getting in trouble with the Ethernet W5500 driver on the Pyboard.

EDIT 2019 oct 13: Since this thread was opened, a solution was found. See the Wiring and additional information along this thread.

I can't get ETHERNET W5500 module to get working on PYBV1.1 with the Network firmware.
This is getting me completely crazy and screwing up my brain.

A check over my triple check would be kindly welcome.
If someone have a serious suggestion, it would be really welcome.

=== The firmware applied is ===
pybv11-network-20191011-v1.11-422-g98c2eabaf.dfu

Properly applied, I can read the WIZNET5K class

EDIT 2019 oct 13: the network firmware available at micropython.org is not complete. By chance, Robert did share a dirty build for W5500 on Pyboard V1.1 and MicroPython v1.11. I shared that test firmware here https://github.com/mchobby/pyboard-driv ... cs/_static but you will have to compile your own MicroPython firmware.

=== The W5500 module ===
It is a Feather Ethernet Wing (EDIT 2019 oct 13: tested with success)
https://www.adafruit.com/product/3201

The board Schematic is available there
https://cdn-learn.adafruit.com/assets/a ... 1469652554

=== W5500 Wiring ===
See the link below, it is how did wired the W5500 to my Pyboard V1.1 (wiring revised on 2019 oct 13).
Image

I double checked every pins on my Pyboard... they are all working properly.
I also checked the signals with a scope... I do see them clocking. I even check the MISO_MCU and MISO over the 74AHC1G025 and signal is visible.

=== network ===
The network is the same as for my computer. Up And working.
Ethernet cable to W5500 is good (LEDs are blinking on the W5500 Ethernet socket)

=== Code ====
I did used the initial example coming from

http://docs.micropython.org/en/latest/l ... NET5K.html

EDIT 2019 oct 13: The nic must be activated with nic.active( True ) . If you can't then you do not have the right firmware. Ig you has bus communication issue then the active(True) method will never returns. The nic request an IP address via DHCP with nic.ifconfig( 'dhcp' ) .

Code: Select all

nic = network.WIZNET5K(pyb.SPI(1), pyb.Pin.board.X5, pyb.Pin.board.X4)
nic.active( True )
nic.ifconfig( 'dhcp' ) 
print(nic.ifconfig())
print(nic.isconnected())
always got

Code: Select all

('0.0.0.0', '255.255.255.0', '0.0.0.0', '8.8.8.8')
False
EDIT 2019 oct 13: Now its working and I can get the IP Address.
('192.168.1.60', '255.255.255.0', '192.168.1.1', '192.168.1.1')

== W5200 also fails! ==
I did tried it out with an WIZ820io module (based on W5200 chipset).
Image
I still got the result
('0.0.0.0', '255.255.255.0', '0.0.0.0', '8.8.8.8')
False

I also make check with network Firmware v1.9.4, v1.9.3, v1.9.2, v1.9 and the WIZ820io.
They all fails to return an ifconfig without assigned IP.

EDIT 2019 oct 13: Not retested tge WIZ820io. But W5500 based Ethernet is now running.

== Any suggestion? ... please? ==
Is the WIZNET5K in the network firmware is reliable ? EDIT 2019 oct 13: Yes, only if you configure and compile properly the MicroPython firmware.
Did I made something stupidly wrong? EDIT 2019 oct 13: yes, but the wiring is now fixed.
Any suggestion would be really welcome.
Last edited by MCHobby on Sun Oct 13, 2019 6:44 pm, edited 3 times in total.

MCHobby
Posts: 17
Joined: Mon Jan 26, 2015 2:05 pm

Re: Pyboard + W5500 Ethernet - Cant get it to work - MicroPython v1.11-422-g98c2eabaf

Post by MCHobby » Fri Oct 11, 2019 7:42 pm

@roberthh
Robert, sorry to bother you but it seems that you are very skilled with the Ethernet support on the Pyboard.
On this current thread (see initial message), I'm trying to use a W5200 et W5500 modules that never get connected to the network.
I even tested the W5200 modules down to network firmware version v1.9.4, V1.9.3, V1.9.2, V1.9.

Would you be open to give me some help? I have to finish a book and I'm completely by now.
Kind regards,
Dominique

User avatar
Roberthh
Posts: 1642
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pyboard + W5500/W5200 Ethernet - Cant get it to work - MicroPython v1.11-422-g98c2eabaf

Post by Roberthh » Sat Oct 12, 2019 2:25 pm

Hello @McHobby. Thank you for the trust, although my knowledge in that topic is very sparse. Nevertheless I pulled the WIZNET5500 interface out of the drawer and connected it to a pyboard V1.1. The connection is identical to the one you showed above, except that I connected the 5V input of that adapter to the V+ pin. But that should not matter. When connected to the switch, the status LEDs of the adapter show activity. The Image I used was compiled with:
MICROPY_PY_WIZNET5K = 5500
in the GNUmakefile. I start the board with:

Code: Select all

import pyb
import network
nic = network.WIZNET5K(pyb.SPI(1), pyb.Pin.board.X5, pyb.Pin.board.X4)
nic.ifconfig(('10.0.0.77', '255.255.255.0', '10.0.0.240', '8.8.8.8'))
Note that different from your example I set the IP address here. After that, I can ping the device from my PC. There seemed to have been an option for dhcp, but that may be gone. So far, so good, but then the trouble starts. The code that I ran two years ago does not work any more. When compiled without LWIP, some basic socket methods are present and work. But many are missing. When compiled with LWIP, all methods are present, but refuse to work.
I'm not sure if I want to dig into that. The WiFi based board work flawlessly.

Edit: I use a 5$ Chinese board. But that should not make the difference.

User avatar
Roberthh
Posts: 1642
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pyboard + W5500/W5200 Ethernet - Cant get it to work - MicroPython v1.11-422-g98c2eabaf

Post by Roberthh » Sat Oct 12, 2019 3:49 pm

Update: It works with the lwip module included. All what I had to do was changing the nic init sequence to:

Code: Select all

import pyb
import network
nic = network.WIZNET5K(pyb.SPI(1), pyb.Pin.board.X5, pyb.Pin.board.X4)
nic.active(True)
nic.ifconfig(('10.0.0.77', '255.255.255.0', '10.0.0.240', '8.8.8.8'))
# for dhcp, use
# nic.ifconfig('dhcp')
IP-addresses to be chosen appropriately.

MCHobby
Posts: 17
Joined: Mon Jan 26, 2015 2:05 pm

Re: Pyboard + W5500/W5200 Ethernet - Cant get it to work - MicroPython v1.11-422-g98c2eabaf

Post by MCHobby » Sat Oct 12, 2019 10:48 pm

Thank @roberthh for you quick response and the efforts put in the triple checks.

I think that the compiled network firmware available on MicroPython.org is not complete.
I got the following error when I activates the nic.

Code: Select all

>>> nic.active(True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'WIZNET5K' object has no attribute 'active'
It seems obvious that I should compile MicroPython Firmware to get a running version.
Unfortunately I'm already 30 days off (too late) with the writing and still have to work on the last chapter.

Would it be possible to share your Pyboard compiled Firmware through WeTransfer? My email info (at) mchobby (dot) be .
That would really help me a lot in the meanwhile (before finding times to compile my first MicroPython firmware).

I Agree with the WiFi supremacy. However, wired connexion are still the best in noisy environment ;-)
Once again... thank you a lot for your response it already help a lot about what's happening here.

Kind regards,
Dominique

User avatar
Roberthh
Posts: 1642
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pyboard + W5500/W5200 Ethernet - Cant get it to work - MicroPython v1.11-422-g98c2eabaf

Post by Roberthh » Sun Oct 13, 2019 6:32 am

Done.
P.S:: I tried that adapter too with an PYBD, and it works well. Of course with a build that includes a setting for WIZNET5K devices.

MCHobby
Posts: 17
Joined: Mon Jan 26, 2015 2:05 pm

Re: Pyboard + W5500/W5200 Ethernet - getting it to work - MicroPython v1.11-422-g98c2eabaf

Post by MCHobby » Sun Oct 13, 2019 1:15 pm

@roberthh

I did finally get it to work with your firmware and many hour of labours:
1) I did trash all cables et use new ones (after continuity test)
2) replace the Ethernet cable and use one of a running computer... (being paranoiak is not excessive)
3) Change every pins used on the pyboard (so SPI(2) on the other pyboard's side and another reset pin)
4) fix a stupid error on the W5500 Feather Ethernet Wiring (from bottom to top, the pins are MOSI, MISO, SCK). I will shortly fix the online picture showed in this thread.

And BAM! now to rocks!


EDIT 2019 oct 13: Here is the wiring I used for this test
Image

Code: Select all

>>> import network
>>> from pyb import Pin, SPI
>>> nic = network.WIZNET5K( SPI(2), Pin.board.Y5, Pin.board.X3 )
>>> nic.active()
False
>>> nic.active(True)
>>> nic.ifconfig( 'dhcp' )
>>> nic.ifconfig()
('192.168.1.60', '255.255.255.0', '192.168.1.1', '192.168.1.1')
Thank a lot for support. The firmware it was definitively an important piece of software on which I could rely on.

Note: I also throw the Chinese W5500 which was (for sure) a faulty one.

Cheers,
Dominique

Post Reply