From 1fe978fcfffa7605c8c179960c85672cf8047d07 Mon Sep 17 00:00:00 2001
From: Louiswiz <75520034+min-hs@users.noreply.github.com>
Date: Fri, 9 Aug 2024 13:52:20 +0900
Subject: [PATCH 1/6] Update README.md
---
README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index 0636507..ad8f1f0 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,8 @@ The LwIP examples use **Raspberry Pi Pico** and **WIZnet Ethernet HAT** - ethern
- [**W5100S-EVB-Pico**][link-w5100s-evb-pico]
- [**W5500-EVB-Pico**][link-w5500-evb-pico]
- [**W55RP20-EVB-Pico**][link-w55rp20-evb-pico]
+- [**W5100S-EVB-Pico2**][link-w5100s-evb-pico2]
+- [**W5500-EVB-Pico2**][link-w5500-evb-pico2]
@@ -387,6 +389,8 @@ Link
[link-w5100s-evb-pico_main]: https://github.com/Wiznet/RP2040-HAT-LWIP-C/blob/main/static/images/getting_started/w5100s-evb-pico_main.png
[link-w5500-evb-pico]: https://docs.wiznet.io/Product/iEthernet/W5500/w5500-evb-pico
[link-w5500-evb-pico_main]: https://github.com/Wiznet/RP2040-HAT-LWIP-C/blob/main/static/images/getting_started/w5500-evb-pico_main.png
+[link-w5100s-evb-pico2]:https://docs.wiznet.io/Product/iEthernet/W5100S/w5100s-evb-pico2
+[link-w5500-evb-pico2]:https://docs.wiznet.io/Product/iEthernet/W5500/w5500-evb-pico2
[link-w5500-evb-pico]: https://docs.wiznet.io/Product/iEthernet/W5500/w5500-evb-pico
[link-w55rp20-evb-pico]: https://docs.wiznet.io/Product/ioNIC/W55RP20/w55rp20-evb-pico
[link-dhcp_dns]: https://github.com/Wiznet/RP2040-HAT-LWIP-C/tree/main/examples/dhcp_dns
From 79efad6d4a83f0718f51ea84f1a507a29c15a236 Mon Sep 17 00:00:00 2001
From: Louiswiz <75520034+min-hs@users.noreply.github.com>
Date: Fri, 9 Aug 2024 13:54:50 +0900
Subject: [PATCH 2/6] Update README.md
---
README.md | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/README.md b/README.md
index ad8f1f0..8af57ce 100644
--- a/README.md
+++ b/README.md
@@ -96,6 +96,8 @@ Setup the board in '**CMakeLists.txt**' in '**WIZnet-PICO-LWIP-C/**' directory a
- W5100S-EVB-Pico
- W5500-EVB-Pico
- W55RP20-EVB-Pico
+- W5100S-EVB-Pico2
+- W5500-EVB-Pico2
For example, when using WIZnet Ethernet HAT or W5100S-EVB-Pico :
@@ -118,6 +120,18 @@ When using W55RP20-EVB-Pico :
set(BOARD_NAME W55RP20_EVB_PICO)
```
+When using W5100S_EVB_PICO2 :
+```cpp
+# Set board
+set(BOARD_NAME W5100S_EVB_PICO2)
+```
+
+When using W5500_EVB_PICO2 :
+```cpp
+# Set board
+set(BOARD_NAME W5500_EVB_PICO2)
+```
+
3. Test
Please refer to 'README.md' in each example directory to find detail guide for testing LwIP examples.
From 53fbeabe5bd4b2e65a8ffb6d5d8b5841122d8050 Mon Sep 17 00:00:00 2001
From: Louiswiz <75520034+min-hs@users.noreply.github.com>
Date: Fri, 9 Aug 2024 13:57:47 +0900
Subject: [PATCH 3/6] Update README.md
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 8af57ce..fae0f65 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ The LwIP examples were tested by configuring the development environment for **W
The LwIP examples use **Raspberry Pi Pico** and **WIZnet Ethernet HAT** - ethernet I/O module built on WIZnet's [**W5100S**][link-w5100s] ethernet chip, **W5100S-EVB-Pico** - ethernet I/O module built on [**RP2040**][link-rp2040] and WIZnet's [**W5100S**][link-w5100s] ethernet chip or **W5500-EVB-Pico** and **W55RP20-EVB-Pico** - ethernet I/O module built on [**RP2040**][link-rp2040] and WIZnet's [**W5500**][link-w5500] ethernet chip.
-- [**Raspberry Pi Pico**][link-raspberry_pi_pico] & - [**WIZnet Ethernet HAT**][link-wiznet_ethernet_hat]
+- [**Raspberry Pi Pico**][link-raspberry_pi_pico] or [**Raspberry Pi Pico2**][link-raspberry_pi_pico2]& [**WIZnet Ethernet HAT**][link-wiznet_ethernet_hat]
- [**W5100S-EVB-Pico**][link-w5100s-evb-pico]
- [**W5500-EVB-Pico**][link-w5500-evb-pico]
- [**W55RP20-EVB-Pico**][link-w55rp20-evb-pico]
@@ -396,6 +396,7 @@ Link
[link-w5100s]: https://docs.wiznet.io/Product/iEthernet/W5100S/overview
[link-w5500]: https://docs.wiznet.io/Product/iEthernet/W5500/overview
[link-raspberry_pi_pico]: https://www.raspberrypi.org/products/raspberry-pi-pico/
+[link-raspberry_pi_pico2]: https://www.raspberrypi.com/products/raspberry-pi-pico-2/
[link-raspberry_pi_pico_main]: https://github.com/Wiznet/RP2040-HAT-LWIP-C/blob/main/static/images/getting_started/raspberry_pi_pico_main.png
[link-wiznet_ethernet_hat]: https://docs.wiznet.io/Product/Open-Source-Hardware/wiznet_ethernet_hat
[link-wiznet_ethernet_hat_main]: https://github.com/Wiznet/RP2040-HAT-LWIP-C/blob/main/static/images/getting_started/wiznet_ethernet_hat_main.png
From dd89febe539caab415cf0a0ccda17c8f37a34f6d Mon Sep 17 00:00:00 2001
From: wizhannah
Date: Mon, 12 Aug 2024 11:11:25 +0900
Subject: [PATCH 4/6] Update 5x00_spi.c, clean up code
---
port/ioLibrary_Driver/src/w5x00_spi.c | 10 +++
port/ioLibrary_Driver/src/wiznet_spi_pio.c | 75 +---------------------
2 files changed, 11 insertions(+), 74 deletions(-)
diff --git a/port/ioLibrary_Driver/src/w5x00_spi.c b/port/ioLibrary_Driver/src/w5x00_spi.c
index f2ea572..e10200a 100644
--- a/port/ioLibrary_Driver/src/w5x00_spi.c
+++ b/port/ioLibrary_Driver/src/w5x00_spi.c
@@ -56,6 +56,16 @@ wiznet_spi_handle_t spi_handle;
* Functions
* ----------------------------------------------------------------------------------------------------
*/
+static inline void wizchip_select(void)
+{
+ gpio_put(PIN_CS, 0);
+}
+
+static inline void wizchip_deselect(void)
+{
+ gpio_put(PIN_CS, 1);
+}
+
void wizchip_reset()
{
gpio_init(PIN_RST);
diff --git a/port/ioLibrary_Driver/src/wiznet_spi_pio.c b/port/ioLibrary_Driver/src/wiznet_spi_pio.c
index 52d658e..3cb812b 100644
--- a/port/ioLibrary_Driver/src/wiznet_spi_pio.c
+++ b/port/ioLibrary_Driver/src/wiznet_spi_pio.c
@@ -17,8 +17,6 @@
#include "wiznet_spi_pio.pio.h"
-
-
#ifndef PIO_SPI_PREFERRED_PIO
#define PIO_SPI_PREFERRED_PIO 1
#endif
@@ -33,17 +31,6 @@
#define SPI_OFFSET_WRITE_END __CONCAT(SPI_PROGRAM_NAME, _offset_write_end)
#define SPI_OFFSET_READ_END __CONCAT(SPI_PROGRAM_NAME, _offset_read_end)
-//#define ENABLE_SPI_DUMPING 1
-#define ENABLE_SPI_DUMPING 0
-
-#if ENABLE_SPI_DUMPING
-static uint32_t counter = 0;
-#define DUMP_SPI_TRANSACTIONS(A) A
-#else
-#define DUMP_SPI_TRANSACTIONS(A)
-#endif
-
-
// All wiznet spi operations must start with writing a 3 byte header
#define SPI_HEADER_LEN 3
@@ -222,22 +209,6 @@ static void wiznet_spi_pio_frame_end(void) {
#endif
}
-#if ENABLE_SPI_DUMPING
-static void dump_bytes(const uint8_t *bptr, uint32_t len) {
- unsigned int i = 0;
-
- for (i = 0; i < len;) {
- if ((i & 0x0f) == 0) {
- printf("\n");
- } else if ((i & 0x07) == 0) {
- printf(" ");
- }
- printf("%02x ", bptr[i++]);
- }
- printf("\n");
-}
-#endif
-
// send tx then receive rx
// rx can be null if you just want to send, but tx and tx_length must be valid
static bool pio_spi_transfer(spi_pio_state_t *state, const uint8_t *tx, size_t tx_length, uint8_t *rx, size_t rx_length) {
@@ -248,10 +219,6 @@ static bool pio_spi_transfer(spi_pio_state_t *state, const uint8_t *tx, size_t t
if (rx != NULL && tx != NULL) {
assert(tx && tx_length && rx_length);
- DUMP_SPI_TRANSACTIONS(
- printf("[%lu] bus TX/RX %u bytes rx %u:", counter++, tx_length, rx_length);
- dump_bytes(tx, tx_length);
- )
pio_sm_set_enabled(state->pio, state->pio_sm, false); // disable sm
pio_sm_set_wrap(state->pio, state->pio_sm, state->pio_offset + SPI_OFFSET_WRITE_BITS, state->pio_offset + SPI_OFFSET_READ_END - 1);
@@ -288,10 +255,7 @@ static bool pio_spi_transfer(spi_pio_state_t *state, const uint8_t *tx, size_t t
__compiler_memory_barrier();
} else if (tx != NULL) {
assert(tx_length);
- DUMP_SPI_TRANSACTIONS(
- printf("[%lu] bus TX only %u bytes:", counter++, tx_length);
- dump_bytes(tx, tx_length);
- )
+
pio_sm_set_enabled(state->pio, state->pio_sm, false);
pio_sm_set_wrap(state->pio, state->pio_sm, state->pio_offset + SPI_OFFSET_WRITE_BITS, state->pio_offset + SPI_OFFSET_WRITE_END - 1);
pio_sm_clear_fifos(state->pio, state->pio_sm);
@@ -323,46 +287,9 @@ static bool pio_spi_transfer(spi_pio_state_t *state, const uint8_t *tx, size_t t
pio_sm_set_consecutive_pindirs(state->pio, state->pio_sm, state->spi_config->data_in_pin, 1, false);
} else if (rx != NULL) {
panic_unsupported(); // shouldn't be used
-#if 0
- assert(rx_length);
- DUMP_SPI_TRANSACTIONS(
- printf("[%lu] bus RX only %u bytes:\n", counter++, rx_length);
- )
- pio_sm_set_enabled(state->pio, state->pio_sm, false); // disable sm
- pio_sm_set_wrap(state->pio, state->pio_sm, state->pio_offset + SPI_OFFSET_WRITE_BITS, state->pio_offset + SPI_OFFSET_READ_END - 1); // stall on write at the end of the read
- pio_sm_clear_fifos(state->pio, state->pio_sm); // clear fifos from previous run
- pio_sm_restart(state->pio, state->pio_sm);
- pio_sm_clkdiv_restart(state->pio, state->pio_sm);
- pio_sm_put(state->pio, state->pio_sm, rx_length - 1);
- pio_sm_exec(state->pio, state->pio_sm, pio_encode_out(pio_y, 32)); // y is bytes to be read
- pio_sm_exec(state->pio, state->pio_sm, pio_encode_jmp(state->pio_offset + SPI_OFFSET_READ_BYTE)); // setup pc
- dma_channel_abort(state->dma_in);
-
- dma_channel_config in_config = dma_channel_get_default_config(state->dma_in);
- channel_config_set_dreq(&in_config, pio_get_dreq(state->pio, state->pio_sm, false));
- channel_config_set_write_increment(&in_config, true);
- channel_config_set_read_increment(&in_config, false);
- channel_config_set_transfer_data_size(&in_config, DMA_SIZE_8);
- dma_channel_configure(state->dma_in, &in_config, rx, &state->pio->rxf[state->pio_sm], rx_length, true);
-
- pio_sm_set_enabled(state->pio, state->pio_sm, true);
- __compiler_memory_barrier();
-
- dma_channel_wait_for_finish_blocking(state->dma_in);
-
- __compiler_memory_barrier();
-#endif
}
pio_sm_exec(state->pio, state->pio_sm, pio_encode_mov(pio_pins, pio_null)); // for next time we turn output on
- DUMP_SPI_TRANSACTIONS(
- if (rx_length > 0) {
- printf("RXed:");
- dump_bytes(rx, rx_length);
- printf("\n");
- }
- )
-
return true;
}
From 4cccca524c66dc9a9301a3566376f6e0b8491a58 Mon Sep 17 00:00:00 2001
From: wizhannah
Date: Mon, 12 Aug 2024 11:11:43 +0900
Subject: [PATCH 5/6] Support RP2350
---
CMakeLists.txt | 61 +++++++++++++++++-----------
port/CMakeLists.txt | 1 +
port/board_list.h | 2 +
wiznet_pico_lwip_c_sdk_version.cmake | 4 +-
4 files changed, 43 insertions(+), 25 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e9d9c8..035884f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,34 +1,16 @@
# CMake minimum required version
cmake_minimum_required(VERSION 3.12)
-# Pull in SDK (must be before project)
-if(NOT DEFINED PICO_SDK_PATH)
- set(PICO_SDK_PATH ${CMAKE_SOURCE_DIR}/libraries/pico-sdk)
- message(STATUS "PICO_SDK_PATH = ${PICO_SDK_PATH}")
-endif()
-
-include(pico_sdk_import.cmake)
-include(wiznet_pico_lwip_c_sdk_version.cmake)
-
-# Set project name
-set(PROJECT_NAME WIZnet-PICO-LWIP-C)
-
-# Set project informations
-project(${PROJECT_NAME} C CXX ASM)
-
-set(CMAKE_C_STANDARD 11)
-set(CMAKE_CXX_STANDARD 17)
-
-# Initialize the SDK
-pico_sdk_init()
-
# Set board
#set(BOARD_NAME WIZnet_Ethernet_HAT)
#set(BOARD_NAME W5100S_EVB_PICO)
#set(BOARD_NAME W5500_EVB_PICO)
-set(BOARD_NAME W55RP20_EVB_PICO)
-
+#set(BOARD_NAME W55RP20_EVB_PICO)
+set(BOARD_NAME W5100S_EVB_PICO2)
+#set(BOARD_NAME W5500_EVB_PICO2)
+
if(${BOARD_NAME} STREQUAL WIZnet_Ethernet_HAT)
+ #set(PICO_PLATFORM rp2350) #If you are using WIZnet_ethernet_HAT with Pico2, uncomment it.
set(WIZNET_CHIP W5100S)
add_definitions(-D_WIZCHIP_=W5100S)
add_definitions(-DDEVICE_BOARD_NAME=WIZnet_Ethernet_HAT)
@@ -40,14 +22,47 @@ elseif(${BOARD_NAME} STREQUAL W5500_EVB_PICO)
set(WIZNET_CHIP W5500)
add_definitions(-D_WIZCHIP_=W5500)
add_definitions(-DDEVICE_BOARD_NAME=W5500_EVB_PICO)
+
elseif(${BOARD_NAME} STREQUAL W55RP20_EVB_PICO)
set(WIZNET_CHIP W5500)
add_definitions(-D_WIZCHIP_=W5500)
add_definitions(-DDEVICE_BOARD_NAME=W55RP20_EVB_PICO)
+
+elseif(${BOARD_NAME} STREQUAL W5100S_EVB_PICO2)
+ set(PICO_PLATFORM rp2350)
+ set(WIZNET_CHIP W5100S)
+ add_definitions(-D_WIZCHIP_=W5100S)
+ add_definitions(-DDEVICE_BOARD_NAME=W5100S_EVB_PICO2)
+elseif(${BOARD_NAME} STREQUAL W5500_EVB_PICO2)
+ set(PICO_PLATFORM rp2350)
+ set(WIZNET_CHIP W5500)
+ add_definitions(-D_WIZCHIP_=W5500)
+ add_definitions(-DDEVICE_BOARD_NAME=W5500_EVB_PICO2)
else()
message(FATAL_ERROR "BOARD_NAME is wrong = ${BOARD_NAME}")
endif()
+# Pull in SDK (must be before project)
+if(NOT DEFINED PICO_SDK_PATH)
+ set(PICO_SDK_PATH ${CMAKE_SOURCE_DIR}/libraries/pico-sdk)
+ message(STATUS "PICO_SDK_PATH = ${PICO_SDK_PATH}")
+endif()
+
+include(pico_sdk_import.cmake)
+include(wiznet_pico_lwip_c_sdk_version.cmake)
+
+# Set project name
+set(PROJECT_NAME WIZnet-PICO-LWIP-C)
+
+# Set project informations
+project(${PROJECT_NAME} C CXX ASM)
+
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_CXX_STANDARD 17)
+
+# Initialize the SDK
+pico_sdk_init()
+
# Set the project root directory if it's not already defined, as may happen if
# the tests folder is included directly by a parent project, without including
# the top level CMakeLists.txt.
diff --git a/port/CMakeLists.txt b/port/CMakeLists.txt
index f6db3a1..5bbfb35 100644
--- a/port/CMakeLists.txt
+++ b/port/CMakeLists.txt
@@ -43,6 +43,7 @@ target_include_directories(LWIP_FILES PUBLIC
target_link_libraries(LWIP_FILES PUBLIC
ETHERNET_FILES
+ pico_stdlib
pico_lwip
pico_lwip_nosys
)
diff --git a/port/board_list.h b/port/board_list.h
index b14108e..5c9b961 100644
--- a/port/board_list.h
+++ b/port/board_list.h
@@ -3,3 +3,5 @@
#define W5100S_EVB_PICO 1
#define W5500_EVB_PICO 2
#define W55RP20_EVB_PICO 3
+#define W5100S_EVB_PICO2 4
+#define W5500_EVB_PICO2 5
\ No newline at end of file
diff --git a/wiznet_pico_lwip_c_sdk_version.cmake b/wiznet_pico_lwip_c_sdk_version.cmake
index 2111cb3..5ac2a00 100644
--- a/wiznet_pico_lwip_c_sdk_version.cmake
+++ b/wiznet_pico_lwip_c_sdk_version.cmake
@@ -1,7 +1,7 @@
# WIZnet-PICO-LWIP-C_BUILD_DEFINE: WIZnet-PICO-LWIP-C_SDK_VERSION_MAJOR, SDK major version number
-set(WIZnet-PICO-LWIP-C_SDK_VERSION_MAJOR 1)
+set(WIZnet-PICO-LWIP-C_SDK_VERSION_MAJOR 2)
# WIZnet-PICO-LWIP-C_BUILD_DEFINE: WIZnet-PICO-LWIP-C_SDK_VERSION_MINOR, SDK minor version number
-set(WIZnet-PICO-LWIP-C_SDK_VERSION_MINOR 1)
+set(WIZnet-PICO-LWIP-C_SDK_VERSION_MINOR 0)
# WIZnet-PICO-LWIP-C_BUILD_DEFINE: WIZnet-PICO-LWIP-C_SDK_VERSION_REVISION, SDK version revision
set(WIZnet-PICO-LWIP-C_SDK_VERSION_REVISION 0)
# WIZnet-PICO-LWIP-C_BUILD_DEFINE: WIZnet-PICO-LWIP-C_SDK_VERSION_STRING, SDK version
From be54693e8f36608d19b43cd1add606ec7f88584b Mon Sep 17 00:00:00 2001
From: wizhannah <143767394+wizhannah@users.noreply.github.com>
Date: Mon, 12 Aug 2024 11:14:11 +0900
Subject: [PATCH 6/6] Change dafault board to W5500-EVB-Pico
---
CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 035884f..40a3d76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,9 +4,9 @@ cmake_minimum_required(VERSION 3.12)
# Set board
#set(BOARD_NAME WIZnet_Ethernet_HAT)
#set(BOARD_NAME W5100S_EVB_PICO)
-#set(BOARD_NAME W5500_EVB_PICO)
+set(BOARD_NAME W5500_EVB_PICO)
#set(BOARD_NAME W55RP20_EVB_PICO)
-set(BOARD_NAME W5100S_EVB_PICO2)
+#set(BOARD_NAME W5100S_EVB_PICO2)
#set(BOARD_NAME W5500_EVB_PICO2)
if(${BOARD_NAME} STREQUAL WIZnet_Ethernet_HAT)