module wiznet5k

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
bananajoe
Posts: 2
Joined: Fri Oct 31, 2014 11:36 am

module wiznet5k

Post by bananajoe » Fri Oct 31, 2014 12:16 pm

Hi,
did anyone succeed in getting use the wiznet5k module?
I build the pyboard firmware by using:

Code: Select all

$ make MICROPY_PY_WIZNET5K=1
The build output loocks like:

Code: Select all

...
CC modwizenet5k.c
CC ../drivers/wiznet5k/ethernet/w5200/w5200.c
CC ../drivers/wiznet5k/ethernet/wizchip_conf.c
CC ../drivers/wiznet5k/ethernet/socket.c
CC ../drivers/wiznet5k/internet/dns/dns.c
...
So it seems to includ the modul. But if i try to import the wiznet5k module with pyboard, there is no module named wiznet5k.
(Example usage: http://micropython.org/doc/module/wiznet5k/)

Is there any other configuration needed to include the wiznet5k module?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: module wiznet5k

Post by dhylands » Fri Oct 31, 2014 3:06 pm

It looks like the module is called WIZnet5k and maybe you just need to import network ? I haven't used the networking stuff myself yet.

This thread (which I dug up looking through git history): https://github.com/micropython/micropython/issues/876 should have some clues.

I raised a github issue: https://github.com/micropython/micropython/issues/951

bananajoe
Posts: 2
Joined: Fri Oct 31, 2014 11:36 am

Re: module wiznet5k

Post by bananajoe » Mon Nov 03, 2014 2:25 pm

Thanks for your response.
In the network.WIZnet5k module, it should be possible to edit the ip address.
I tried it with:

Code: Select all

>>>import network
>>>wiz = network.WIZnet5k(pyb.SPI(2), pyb.Pin.board.Y5, pyb.Pin.board.Y6)
>>>wiz.ipaddr()
('0.0.0.0', '255.255.255.0'. '0.0.0.0', '8.8.8.8')
>>>wiz.ipaddr('192.168.1.2', '255.255.255.0'. '192.168.1.1', '8.8.8.8')
>>>wiz.ipaddr()
('0.0.0.0', '255.255.255.0'. '0.0.0.0', '8.8.8.8')
So the ip set function cannot be used, too.

I am not really adept at using socket and bind. But it seems to be the right way for connecting the network adapter into a network.

wdluo
Posts: 2
Joined: Tue Nov 11, 2014 5:43 am

Re: module wiznet5k

Post by wdluo » Tue Dec 02, 2014 7:35 am

i have the same problem

manitou
Posts: 73
Joined: Wed Feb 25, 2015 12:15 am

Re: module wiznet5k

Post by manitou » Fri Jul 03, 2015 9:13 pm

reviving this thread, as I try some pyboard experiments with SPI and wiz820io (W5200). I just did some teensy tests with the wiznet module, and all was well. so I enabled wiznet stuff in pyboard firmware and hooked up the SPI1 jumpers and reset jumper and common ground (seperate 3.3v power for wiz820io)

make BOARD=PYBV10 clean
make BOARD=PYBV10 MICROPY_PY_WIZNET5K=1
sudo dfu-util --alt 0 -d 0483:df11 -D build-PYBV10/firmware.dfu
Micro Python v1.4.3-36-g3c4b5d4-dirty

from REPL
import network
dir(network)
['__name__', 'WIZNET5K', 'route'] looks good

nic = network.WIZNET5K(pyb.SPI(1), pyb.Pin.board.X5, pyb.Pin.board.X4)

nic.ifconfig()
('222.252.10.80', '255.255.255.0', '255.2.160.0', '8.8.8.8') default stuff

nic.ifconfig(('192.168.1.15', '255.255.255.0', '192.168.1.1', '75.75.75.75'))
nic.ifconfig()
('0.0.0.0', '255.255.255.0', '0.0.0.0', '75.75.75.75') not good

but nic.regs() shows that somethings have been altered on wiz chip, but doesn't have my assigned ip address, mask, or gateway ????
Wiz CREG:
0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0010: 00 00 00 00 00 00 00 00 00 00 00 00 ff 08 df 00
0020: d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c0

any hints or incantations or working examples?

and then there is the documentation on the wiznet5k module ?? how does that fit in with network and socket???

over the years, i've exercised the wiz820io on various MCUs, see
https://github.com/manitou48/DUEZoo/blo ... izperf.txt
Last edited by manitou on Sat Jul 04, 2015 9:59 pm, edited 1 time in total.

manitou
Posts: 73
Joined: Wed Feb 25, 2015 12:15 am

Re: module wiznet5k

Post by manitou » Sat Jul 04, 2015 1:39 pm

well, since ifconfig() didn't seem to be working, I instead modified the defaults (ip, gateway) in the firmware's modnwwiznet5k.c, and re-flashed the firmware. Now CREGs looks OK and I could ping the wiznet module .... more tests coming.

Code: Select all

Wiz CREG:
  0000: 00 c0 a8 01 01 ff ff ff 00 00 08 dc ab cd ef c0
  0010: a8 01 10 00 00 00 00 07 d0 08 00 00 00 00 00 03
  0020: 00 00 00 00 00 00 00 00 28 00 00 00 00 00 00 00
  0030: 00 00 00 00 00 17 00 00 00 00 00 00 00 00 00 00
  0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Wiz SREG[0]:
  0000: 00 00 00 00 00 00 ff ff ff ff ff ff 00 00 00 00
  0010: 00 00 00 00 00 00 80 00 00 00 00 00 00 00 02 02
  0020: 08 00 00 00 00 00 00 00 00 00 00 00 ff 40 00 00
read/write speeds to wiznet RAM (1024 bytes) is 15.8 mbs @ 21mhz (default SPI CLK), 25.4 mbs @ 42mhz

UDP tests were OK, 8-byte RTT latency 562us (@21mhz) and 548us (@42mhz),
UDP 1000-byte send rate 7.98 mbs (21 or 42 mhz),
UDP receive lossless receive rate of 20 1000-byte packets, 5.4 mbs (21 or 42 mhz). nonblocking socket IO would have been handy for this, but the firmware lists it as a TODO ....

TCP tests were problematic:
pyboard TCP send of 100 1000-byte packets didn't "finish" at the linux receiver, because the socket.close() on the pyboard apparently shutdown the TCP flow before the last packets got out of the wiznet ?? tcpdump shows pyboard/wiznet emitting TCP RESET flag instead of FIN flag. TCP close() probably should invoke wiznet5k_socket_disconnect()

having the linux host send 100 1000-byte packets to the pyboard, resulted in OSError: 5 after receiving a packet or so. looking at packet trace (tcpdump), can see that wiznet has received some packets (ACK's), but then wiznet advertised window goes to 0 (presumably because OSError has stopped python from receiving), so linux sender is stalled waiting for window to open ....


-----------------------
EDIT:
1. to try and fix ifconfig() I noted that firmware modnwwiznet5k.c does a HAL_Delay(250) after the initial ifconfig. the python call to ifconfig() has no such delay in the firmware, so in my python code, I added a pyb.delay(300) after the ifconfig(). that seemed to work. CREGs looked good.

2. sample UDP progam that uses NTP to set RTC date/time, see
https://github.com/manitou48/pyboard/bl ... /wizntp.py

3. 7/10/15, with latest micropython, plus I added disconnect before close in modnwwiznet5k.c
TCP transmit from pyboard still has problems, but linux receiver is not aborted, but only shows 34000 bytes recvd (should be 100,000 bytes) @ 11.6mbs, though pyboard says it sent data at 35mbs ?? (send()'s getting dropped ?) Checked return value from send(), every other one is 0 -- so added retry in send-loop. OK that worked, pyboard transmitting at 10.8mbs

TCP receive on pyboard, seems ok at 5.7mbs

ayyoubzadeh
Posts: 3
Joined: Sun Aug 14, 2022 6:03 pm

Re: module wiznet5k

Post by ayyoubzadeh » Sun Aug 14, 2022 6:04 pm


Post Reply