Wiznet makers

scarlet

Published October 04, 2023 ©

100 UCC

12 WCC

22 VAR

0 Contests

0 Followers

0 Following

Boost Your W5100S-EVB-PICO with HardWired TCP/IP!

Introducing a way to speed up the ethernet in the micropython you're using.

COMPONENTS Hardware components

WIZnet - W5100S-EVB-Pico

x 1


WIZnet - W5500-EVB-Pico

x 1

Software Apps and online services

thonny.org - Thonny

x 1


PROJECT DESCRIPTION

Boost Your W5100S-EVB-PICO with HardWired TCP!/IP 

Introducing a way to speed up the ethernet in the micropython you're using.

First off, such a speed enhancement is only possible with a pico equipped with a WIZnet chip. Did you know that the WIZnet ethernet chip (W5100S or W5500) has two modes? 

They are HardWired and LWIP. 

By running in HardWired mode, the network physical layer tasks are executed on the Ethernet Chip rather than the MCU, improving both network speed and MCU efficiency.

There are also many other ways to improve speed, and further enhancements can be made, 

but for now, let's just check out the hard wired mode setting .

looking at the results!

default F/W (747 Kbits/sec) => custom F/W (1.34 Mbits/sec) 

An improvement of approximately 74%!!  

Here, we introduce the method to create FW and test it using iperf3.


FW Build

The place to download the code is from the official micropython GitHub repository. 

https://github.com/micropython/micropython 

 

After downloading the code, configure it for HardWired mode. 

The only part we will modify is a single line in the make file. 

micropython/ports/rp2/boards/W5500_EVB_PICO/mpconfigboard.cmake 

On line 4, Disable the LWIP setting.

#set(MICROPY_PY_LWIP 1)
set(MICROPY_PY_LWIP 0)

Now, let's proceed with the build. 

The method to build is well-explained in the README.md.

https://github.com/micropython/micropython/blob/master/ports/rp2/README.md 

While the example uses the Pico W, since we are using the W5100S-EVB-PICO or W5500-EVB-PICO, we'll need to make a slight modification to the commands mentioned there.

#W5100S-EVB-PICO
$ make BOARD= W5100S_EVB_PICO submodules
$ make BOARD= W5100S_EVB_PICO clean
$ make BOARD= W5100S_EVB_PICO
# W5500-EVB-PICO
$ make BOARD= W5500-EVB-PICO submodules
$ make BOARD= W5500_EVB_PICO clean
$ make BOARD= W5500_EVB_PICO

 


Speed Test

We should verify if the improvement is real, right? I typically use iperf3.

First, add the iperf3 library and import it. You can download the library here: 

https://github.com/micropython/micropython-lib/blob/master/python-ecosys/iperf3/iperf3.py

Use the following example. 

You can download it from the following git repository.

https://github.com/wiznetmaker/Hard_wired_WIZNET5K-Micropython/tree/main/examples/iperf3_test

Modify the defined Network information and Server IP. The Server IP is the IP of the Test PC.

import machine
import network
import uiperf3

SERVER_IP= "192.168.11.100" #Test PC IP
DEVICE_IP = "192.168.11.101"
GATEWAY = "192.168.11.1"
NETMASK = "255.255.255.0"
DNS = "8.8.8.8"
def wiznet_init():
    spi = machine.SPI(0, baudrate=2000000, mosi=machine.Pin(19), miso=machine.Pin(16), sck=machine.Pin(18))
    nic = network.WIZNET5K(spi, machine.Pin(17), machine.Pin(20))
    nic.active(True)
    nic.ifconfig((DEVICE_IP, NETMASK, GATEWAY, DNS))
    
    print('IP address :', nic.ifconfig())
    
def main():
    wiznet_init()
    uiperf3.client(SERVER_IP)

 

Additionally, please set up iperf3 on your PC. 

Download iperf3 from here. (I used version 3.1.3.)

 https://iperf.fr/iperf-download.php 

After installing, open a command prompt from the installed directory and enter the Server operation command: 

iperf3.exe -s 

If it doesn't work, please check your firewall.

 

To verify whether LWIP is accurately enabled/disabled, I added logs. In the /extmod/network_wiznet5k.c file, there's a function to initialize the WIZnet Chip. 

(For reference, if you want to modify features related to WIZNET5K, you can modify this code.) 

 

The branching occurs based on the define value of WIZNET5K_WITH_LWIP_STACK. 

If LWIP_STACK is enabled, the code on the left (line 173) will run, and if disabled, the code on the right (line 351) will be executed.

I am planning to submit a pull request for this to the official MicroPython repository. 

I hope it gets accepted so everyone can benefit from a faster network.

 

Additionally, If you need basic MicroPython examples, try using the examples available on the WIZnet official git repository.

Documents
  • MakerGit

Comments Write