This is about series of projects that will be focusing on software porting to various application and microcontrollers.
In this first port of the series, I will be focusing on porting MicroPython to Wiznet5K from Raspberry pi (RP2040).
I have confirmed that wiznet5k doesn't support #DHCP on docs.micropython website.
The #iolibrary provided by WIZnet was updated a lot and a chip was added, and this part was applied. (added W5105(#w5100s), w5200, w5100 and w5300)
diff --git a/drivers/wiznet5k/ethernet/wizchip_conf.c b/drivers/wiznet5k/ethernet/wizchip_conf.c
index 3e54d2c90..9f6182f98 100644
--- a/drivers/wiznet5k/ethernet/wizchip_conf.c
+++ b/drivers/wiznet5k/ethernet/wizchip_conf.c
@@ -5,8 +5,12 @@
//! \version 1.0.1
//! \date 2013/10/21
//! \par Revision history
+//! <2015/02/05> Notice
+//! The version history is not updated after this point.
+//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary.
+//! >> https://github.com/Wiznet/ioLibrary_Driver
//! <2014/05/01> V1.0.1 Refer to M20140501
-//! 1. Explicit type casting in wizchip_bus_readbyte() & wizchip_bus_writebyte()
+//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata()
// Issued by Mathias ClauBen.
//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t*
//! For remove the warning when pointer type size is not 32bit.
@@ -49,66 +53,101 @@
//
#include "wizchip_conf.h"
-#include "socket.h"
+
+/////////////
+//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc.
+/////////////
/**
* @brief Default function to enable interrupt.
* @note This function help not to access wrong address. If you do not describe this function or register any functions,
* null function is called.
*/
-void wizchip_cris_enter(void) {};
+//void wizchip_cris_enter(void) {};
+void wizchip_cris_enter(void) {}
+
STEP 2. Modified DHCP timeout HandlerAs the interrupter method was missing in the code, the Handler function was modified.
STEP 3. Modified CMakeLists.txt and Makefileof rp2in ports/rp2/CMakeLists.txt
I added SSL library and wiznet5k library
if (MICROPY_PY_WIZNET5K)
INCLUDE_DIRECTORIES(${MICROPY_DIR}/drivers/wiznet5k/ ${MICROPY_DIR}/drivers/wiznet5k/ethernet/w${MICROPY_PY_WIZNET5K})
endif()
# axtls
${MICROPY_DIR}/lib/axtls/ssl/loader.c
${MICROPY_DIR}/lib/axtls/ssl/tls1.c
${MICROPY_DIR}/lib/axtls/ssl/tls1_svr.c
${MICROPY_DIR}/lib/axtls/ssl/tls1_clnt.c
${MICROPY_DIR}/lib/axtls/ssl/x509.c
${MICROPY_DIR}/lib/axtls/ssl/openssl.c
${MICROPY_DIR}/lib/axtls/ssl/os_port.c
${MICROPY_DIR}/lib/axtls/ssl/asn1.c
${MICROPY_DIR}/lib/axtls/crypto/aes.c
${MICROPY_DIR}/lib/axtls/crypto/bigint.c
${MICROPY_DIR}/lib/axtls/crypto/crypto_misc.c
${MICROPY_DIR}/lib/axtls/crypto/md5.c
${MICROPY_DIR}/lib/axtls/crypto/rsa.c
${MICROPY_DIR}/lib/axtls/crypto/sha1.c
${MICROPY_DIR}/lib/axtls/crypto/hmac.c
)
if (MICROPY_PY_WIZNET5K)
set(MICROPY_SOURCE_DRIVERS
${MICROPY_DIR}/drivers/bus/softspi.c
${MICROPY_DIR}/drivers/wiznet5k/ethernet/w${MICROPY_PY_WIZNET5K}/w${MICROPY_PY_WIZNET5K}.c
${MICROPY_DIR}/drivers/wiznet5k/ethernet/socket.c
${MICROPY_DIR}/drivers/wiznet5k/ethernet/wizchip_conf.c
${MICROPY_DIR}/drivers/wiznet5k/internet/dns/dns.c
${MICROPY_DIR}/drivers/wiznet5k/internet/dhcp/dhcp.c
${MICROPY_DIR}/extmod/modnetwork.c
${MICROPY_DIR}/extmod/modusocket.c
${PROJECT_SOURCE_DIR}/modnwwiznet5k.c
)
endif()
in ports/rp2/makefile
If you want to know the modifications of the Ethernet-related library, check 0001-Added-WIZnet-Chip-library.patch(Github : https://github.com/Wiznet/RP2040-HAT-MicroPython )
STEP 4. DownloadTo start, we’ll need to load a special firmware onto the Pico.Connect one end of a USB micro B cable into your computer. Push and hold the BOOTSEL button on your Pico. While holding the button, plug the other end of the USB cable into the Pico board(the hardware revision version add the reset button(run)). This will cause the Pico to load its bootloader.
I have sent a pull request to the micropython repository but it is not being applied.
(~Nov 23, 2021)
I don't know why it doesn't work.
So, I made a patch file using diff and apply among git commands and also I used the cmake.
In the case of patch, it is posted in Korean, but there is no problem in seeing the git command or the cmake command used.
https://blog.naver.com/roruca/222659759055
STEP 7. Add Patch file and complete projectIf you just use wiznet5k library on rp2040, please visit to website and download the firmware
Maybe Next project will be upip library porting
Comments
Please log in or sign up to comment.