Sunday 2 January 2022

WIZnet W5100S-EVB-Pico Ethernet microcontroller

 The W5100S-EVB-Pico microcontroller board is pin compatible with the Raspberry Pi Pico and uses the same RP2040 microcontroller. It is integrated with the WIZnet W5100S ethernet controller.


It has a built in RJ45 ethernet socket.

There are examples in Circuit Python and C/C++.

As an exercise I decided to first try using C/C++ as the development language and a Windows 10 machine as the development machine (cross compiling to the ARM based RP2040).

I followed the instructions to install CMAKE, however there is an ongoing issue with CMAKE version 3.21+ that causes a 

AR10B2~1.EXE: error: n++CMakeFiles/blink.dir/blink.c.obj: No such file or directory

error when executing the nmake line of the instructions.

It is suggested that an earlier version of the CMAKE tool is installed. Version 3.20 seems to work. 

I tested the basic operation of the board by using the Blink example from the Raspberry Pi Pico examples.

WIZnet examples

The instructions for retrieving the examples from WIZnet are not quite as clear.
Eventually I managed to GIT clone the files. However it was quite difficult to get it to actually compile because of the folder structure.

In the end I started from scratch with a new folder structure and copied the files as required.

The default compiler for CMake needs to have been set (I ended up setting it via Visual Studio Code).

Initially the Blink example was included as I knew that worked. Once that worked, the CMakeLists.txt file was edited to include all the components required (see example below).

This included the patches files. Unfortunately that failed with an incorrect version error.

Compiling without the patches lead to pages of missing methods errors.
Examining the first patch file highlighted the change being made, selection of the Ethernet device chip set. The supplied code selects the W5500 chip set - the rest of the code only contains the W5100S chip set code, it is not selected and so methods are missing.

Manually updating the chip selection (as shown in the patch file) to the W5100S chip set solved the issue with the missing methods.

Once compiled, the EVB was put into bootloader mode and the UF2 was copied over.

Attempting to browse to the machine based on the default IP address failed.

The default IP address {192, 168, 11, 2} is outside the usual "local" range of a domestic router (192.168.1.X). This was changed in the w5x00_http_server.c file to a suitable number.
For my system I chose 192.168.1.234. 
Note: for a permanent solution, the IP address should be generated by the DHCP of the network or the selected IP address should be excluded from the range available to the DHCP server.
message("Start from scratch")
cmake_minimum_required(VERSION 3.10)
#include(rp2040_hat_c-patch.cmake)
include(pico_sdk_import.cmake)
include(rp2040_hat_c_sdk_version.cmake)
project(blink C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

set(PICO_EXAMPLES_PATH ${PROJECT_SOURCE_DIR})
pico_sdk_init()
if(NOT DEFINED WIZNET_DIR)
    set(WIZNET_DIR ${CMAKE_SOURCE_DIR}/libraries/ioLibrary_Driver)
    message(STATUS "WIZNET_DIR = ${WIZNET_DIR}")
endif()

if(NOT DEFINED MBEDTLS_LIB_DIR)
    set(MBEDTLS_LIB_DIR ${CMAKE_SOURCE_DIR}/libraries/mbedtls)
    message(STATUS "MBEDTLS_LIB_DIR = ${MBEDTLS_LIB_DIR}")
endif()

if(NOT DEFINED PORT_DIR)
    set(PORT_DIR ${CMAKE_SOURCE_DIR}/port)
    message(STATUS "PORT_DIR = ${PORT_DIR}")
endif()
# Turn off mbedtls test mode 
set(ENABLE_PROGRAMS OFF CACHE BOOL "Build mbedtls programs")
set(ENABLE_TESTING OFF CACHE BOOL "Build mbedtls testing")
add_definitions(-DMBEDTLS_CONFIG_FILE="${PORT_DIR}/mbedtls/inc/ssl_config.h")
add_definitions(-DSET_TRUSTED_CERT_IN_SAMPLES)

add_subdirectory(server)

# Add libraries in subdirectories
add_subdirectory(${CMAKE_SOURCE_DIR}/libraries)
add_subdirectory(${MBEDTLS_LIB_DIR})
add_subdirectory(${PORT_DIR})
include(example_auto_set_url.cmake)

add_compile_options(-Wall
        -Wno-format          # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
        -Wno-unused-function # we have some for the docs that aren't called
        -Wno-maybe-uninitialized
        )
message("PICO SDK: ${PICO_SDK_VERSION_STRING}")