Page 1 of 1

module wiznet5k

Posted: Fri Oct 31, 2014 12:16 pm
by bananajoe
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?

Re: module wiznet5k

Posted: Fri Oct 31, 2014 3:06 pm
by dhylands
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

Re: module wiznet5k

Posted: Mon Nov 03, 2014 2:25 pm
by bananajoe
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.

Re: module wiznet5k

Posted: Tue Dec 02, 2014 7:35 am
by wdluo
i have the same problem

Re: module wiznet5k

Posted: Fri Jul 03, 2015 9:13 pm
by manitou
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

Re: module wiznet5k

Posted: Sat Jul 04, 2015 1:39 pm
by manitou
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

Re: module wiznet5k

Posted: Sun Aug 14, 2022 6:04 pm
by ayyoubzadeh