Wiznet makers

mark

Published March 13, 2026 ©

90 UCC

8 WCC

42 VAR

0 Contests

0 Followers

0 Following

Original Link

How to Port a W5500 TCP Server to AG32VF407 for Embedded Ethernet Education?

This project shows how to bring up the W5500 as a TCP server on an AG32VF407 board by transplanting a simple W5500 socket example, adding board-specific GPIO an

COMPONENTS
PROJECT DESCRIPTION

How to Port a W5500 TCP Server to AG32VF407 for Embedded Ethernet Education?

Summary

This project shows how to bring up the W5500 as a TCP server on an AG32VF407 board by transplanting a simple W5500 socket example, adding board-specific GPIO and SPI routines, and adapting the main loop to the target MCU. In this architecture, the W5500 is the hardwired Ethernet endpoint that handles socket-level networking, while the AG32VF407 provides reset control, SPI transfers, and application flow.

What the Project Does

The article is a practical porting note rather than a full product write-up. Its stated goal is to configure the W5500 as a server for communication testing without DHCP, using an AG32VF407 development target, VS Code, and a transplanted TCP Server example. The workflow is straightforward: find a reference example, copy the core W5500 files, add a custom SPI/GPIO layer, adapt data types and naming conflicts, and then replace the example loop with a board-specific task loop.

From a network-stack perspective, this is a classic hardwired-TCP/IP split. The MCU does not implement a full software TCP/IP stack. Instead, the W5500 supplies the TCP server socket behavior, and the firmware mainly handles board initialization, SPI byte movement, reset timing, and application control flow. For education, that is useful because it exposes the boundary between transport offload and MCU-side logic without hiding everything behind a heavy middleware layer.

Architecturally, the visible pieces are small but clear: socket.c/.h and w5500.c/.h are imported from the example, a custom w5500_gpio layer is added for hardware access, and the main runtime loop is modified to fit the AG32 platform. That makes the article more about firmware integration than about protocol theory, but it still shows the minimum structure needed to move from a generic example to a board-specific TCP server.

Where WIZnet Fits

The exact WIZnet product here is the W5500. Its role is the embedded Ethernet controller and hardwired TCP/IP engine sitting between the AG32VF407 and the network. WIZnet’s documentation describes the W5500 as a single-chip controller with an embedded TCP/IP stack, integrated 10/100 Ethernet MAC and PHY, 32 KB internal packet buffer memory, support for eight independent hardware sockets, and an SPI interface that can run up to 80 MHz. Those features are why a small MCU can act as a TCP server without carrying the full protocol burden in firmware.

In this project, the W5500 is not a generic PHY companion. It owns the socket endpoint. The AG32VF407 only has to provide reset control, chip-level integration, and data movement over SPI. That is a good educational fit because students can see the firmware flow clearly: initialize pins, reset the chip, exchange bytes over SPI, call into the socket layer, and then run the server loop.

Implementation Notes

This project does use WIZnet products, and the article includes real code snippets, but it does not expose a public repository with line-addressable source files. I am therefore quoting only what is visible in the article.

Snippet 1 — custom SPI/GPIO board layer (w5500_gpio)
The article shows the added board-support initialization:

void W5500_spio_Init(void)
{
SYS_EnableAPBClock(W5500_GPIO_MASK);
GPIO_SetInput(W5500_GPIO, W5500_Input_GPIO_BITS);
GPIO_SetOutput(W5500_GPIO, W5500_Output_GPIO_BITS);
GPIO_SetHigh(W5500_GPIO, W5500_Output_GPIO_BITS);
}

Why it matters: this is the platform boundary. It shows that the port is not abstract; the author had to define concrete GPIO ownership and default signal states before the W5500 driver could run on AG32VF407.

Snippet 2 — byte-level SPI transfer and reset path (w5500_gpio)
The article also shows a software-driven byte transfer and reset routine:

uint8_t W5500_ReadWriteByte(uint8_t bety)
{ ... W5500_SCK_L(); ... bety & 0x80 ? W5500_OUT_H() : W5500_OUT_L(); ... if (W5500_IN()) { data |= (1 << (7 - i)); } ... }

void W5500_Reset(void)
{
W5500_RST_L();
delay_us(2);
W5500_RST_H();
delay_us(1500e3);
}

Why it matters: this code reveals the real firmware flow of the port. The transport stack may be offloaded into the W5500, but the MCU still owns the physical transaction timing and reset sequence. That is the essential lesson in this article: porting W5500 is mostly about getting the hardware access layer right, then letting the socket example sit on top.

The article also states that the imported files are socket.c/.h and w5500.c/.h, that unnecessary headers were removed, that a naming conflict around IR may require renaming it to W5500_IR, and that the example main loop was modified into the target board’s loop task. Those details matter because they show the practical friction points in W5500 bring-up: board I/O, type compatibility, symbol conflicts, and runtime integration.

Practical Tips / Pitfalls

Keep the porting boundary clean. Import the W5500 driver and socket layer as-is where possible, and isolate AG32-specific code inside a board layer such as w5500_gpio.

Watch for symbol collisions. The article explicitly warns that IR may already exist in the target SDK and may need to be renamed to W5500_IR.

Validate reset behavior early. If reset timing is wrong, socket code will fail in ways that look like network bugs rather than bring-up faults. The article includes an explicit reset routine; WIZnet also documents chip-level reset and initialization requirements.

Do not overcomplicate the first test. This article intentionally skips DHCP and uses the W5500 as a fixed TCP server for communication testing, which is the right first milestone.

Performance on this kind of port is usually limited less by the W5500 than by the MCU-side SPI path and loop design. A software-bit-banged SPI path is fine for education and bring-up, but hardware SPI will usually scale better once the server is stable. This is an inference from the article’s shown transfer routine and W5500’s SPI capabilities.

Keep the server example simple before adding higher-level protocols. WIZnet’s own application materials separate TCP function examples from more advanced services for the same reason.

FAQ

Why use the W5500 here instead of implementing the stack in software on AG32VF407?
Because the article’s goal is a quick, practical TCP server bring-up. The W5500 already provides hardwired TCP/IP handling and socket-level operation, so the firmware effort shifts from full network-stack development to driver porting and server control flow. That is a much better educational path for learning embedded Ethernet integration.

How does the W5500 connect to the platform in this project?
Through a custom GPIO/SPI board layer. The article shows GPIO initialization, software-controlled SPI byte transfers, and a dedicated reset routine, which together form the hardware interface between AG32VF407 and the W5500.

What role does the W5500 play in this specific project?
It acts as the TCP server endpoint. The imported socket and w5500 files provide the server-side Ethernet functionality, while the AG32 firmware adapts them to the local board and loop structure.

Can beginners follow this project?
Yes, if they already understand basic GPIO, SPI, and build integration. The article is suitable for education because it focuses on concrete porting steps rather than abstract networking theory, but a complete beginner may still need help understanding reset timing, pin control, and symbol adaptation.

How does this compare with LwIP on the MCU?
LwIP gives more software control, but it also places much more stack integration, RAM management, and debugging burden on the MCU firmware. The W5500 approach shown here keeps the architecture simpler: the MCU ports the hardware interface and runs the application loop, while the W5500 handles TCP/IP and socket behavior.

Source

Original link: CSDN article “调试W5500(作为服务器).” The page states CC 4.0 BY-SA.
Additional product facts were verified against WIZnet’s official W5500 documentation and TCP application notes.

Tags

W5500, WIZnet, AG32VF407, TCP Server, Embedded Ethernet, SPI, Firmware Porting, Socket Offload, Education, Hardwired TCP/IP, Board Bring-up, MCU Networking

 

AG32VF407에서 W5500 TCP 서버를 어떻게 포팅할 수 있을까?

Summary

이 프로젝트는 간단한 W5500 소켓 예제를 이식하고, 보드 전용 GPIO 및 SPI 루틴을 추가한 뒤, 메인 루프를 대상 MCU에 맞게 수정하여 AG32VF407 보드에서 W5500을 TCP 서버로 구동하는 방법을 보여준다. 이 구조에서 W5500은 소켓 수준 네트워킹을 처리하는 하드와이어드 이더넷 종단이며, AG32VF407은 리셋 제어, SPI 전송, 애플리케이션 흐름을 담당한다.

What the Project Does

이 글은 완성형 제품 소개라기보다 실전 포팅 노트에 가깝다. 목표는 DHCP 없이 W5500을 서버로 설정해 통신 테스트를 수행하는 것이며, AG32VF407 개발 대상, VS Code, 그리고 이식한 TCP Server 예제를 사용한다. 전체 흐름은 단순하다. 먼저 기준이 되는 예제를 찾고, 핵심 W5500 파일을 복사한 뒤, 사용자 정의 SPI/GPIO 계층을 추가하고, 데이터 타입 및 이름 충돌을 조정한 다음, 예제의 메인 루프를 보드 전용 루프 태스크로 바꾼다.

네트워크 스택 관점에서 보면 이것은 전형적인 하드와이어드 TCP/IP 분리 구조다. MCU가 전체 소프트웨어 TCP/IP 스택을 직접 구현하지 않는다. 대신 W5500이 TCP 서버 소켓 동작을 제공하고, 펌웨어는 주로 보드 초기화, SPI 바이트 전송, 리셋 타이밍, 애플리케이션 제어 흐름을 담당한다. 교육용으로는 이 점이 유용하다. 복잡한 미들웨어 뒤로 숨기지 않고도 전송 계층 오프로딩과 MCU 측 로직의 경계를 분명하게 보여주기 때문이다.

아키텍처 측면에서 보이는 구성은 작지만 명확하다. socket.c/.hw5500.c/.h를 예제에서 가져오고, 하드웨어 접근을 위한 사용자 정의 w5500_gpio 계층을 추가하며, 메인 런타임 루프를 AG32 플랫폼에 맞게 수정한다. 그래서 이 글은 프로토콜 이론보다 펌웨어 통합에 더 가깝지만, 범용 예제를 보드 전용 TCP 서버로 바꾸는 데 필요한 최소 구조를 잘 보여준다.

Where WIZnet Fits

여기서 사용된 정확한 WIZnet 제품은 W5500이다. 이 칩은 AG32VF407과 네트워크 사이에 위치하는 임베디드 이더넷 컨트롤러이자 하드와이어드 TCP/IP 엔진이다. WIZnet 문서에 따르면 W5500은 내장 TCP/IP 스택, 통합 10/100 Ethernet MAC 및 PHY, 32 KB 내부 패킷 버퍼 메모리, 8개의 독립 하드웨어 소켓, 최대 80 MHz SPI 인터페이스를 제공한다. 이런 특성 때문에 소형 MCU도 전체 프로토콜 부담을 펌웨어에 지지 않고 TCP 서버 역할을 수행할 수 있다.

이 프로젝트에서 W5500은 단순한 PHY 보조 칩이 아니다. 실제 소켓 엔드포인트를 맡는다. AG32VF407은 리셋 제어, 칩 통합, SPI를 통한 데이터 이동만 제공하면 된다. 교육 목적에 잘 맞는 이유도 여기에 있다. 학생은 핀 초기화, 칩 리셋, SPI 바이트 교환, 소켓 계층 호출, 서버 루프 실행이라는 펌웨어 흐름을 명확하게 볼 수 있다.

Implementation Notes

이 프로젝트는 실제로 WIZnet 제품을 사용하며, 글 안에 실제 코드 조각도 포함되어 있다. 다만 줄 번호를 가진 공개 저장소는 제공되지 않으므로, 여기서는 글 안에서 확인 가능한 코드만 인용한다.

Snippet 1 — 사용자 정의 SPI/GPIO 보드 계층 (w5500_gpio)
글에는 다음과 같은 보드 지원 초기화 코드가 보인다.

void W5500_spio_Init(void)
{
SYS_EnableAPBClock(W5500_GPIO_MASK);
GPIO_SetInput(W5500_GPIO, W5500_Input_GPIO_BITS);
GPIO_SetOutput(W5500_GPIO, W5500_Output_GPIO_BITS);
GPIO_SetHigh(W5500_GPIO, W5500_Output_GPIO_BITS);
}

이 코드가 중요한 이유는 포팅 경계를 보여주기 때문이다. 즉, 이 포팅은 추상적인 설명이 아니라, AG32VF407에서 W5500 드라이버를 실행하기 전에 구체적인 GPIO 소유권과 기본 신호 상태를 먼저 정의해야 했음을 보여준다.

Snippet 2 — 바이트 단위 SPI 전송과 리셋 경로 (w5500_gpio)
글은 소프트웨어 기반 SPI 전송과 리셋 루틴도 보여준다.

uint8_t W5500_ReadWriteByte(uint8_t bety)
{ ... W5500_SCK_L(); ... bety & 0x80 ? W5500_OUT_H() : W5500_OUT_L(); ... if (W5500_IN()) { data |= (1 << (7 - i)); } ... }

void W5500_Reset(void)
{
W5500_RST_L();
delay_us(2);
W5500_RST_H();
delay_us(1500e3);
}

이 코드가 중요한 이유는 이식의 실제 펌웨어 흐름을 드러내기 때문이다. 전송 스택은 W5500에 오프로딩되어 있지만, 물리적인 트랜잭션 타이밍과 리셋 시퀀스는 여전히 MCU가 책임진다. 이 글의 핵심 교훈도 바로 이것이다. W5500 포팅은 결국 하드웨어 접근 계층을 정확하게 만들고, 그 위에 소켓 예제를 올리는 작업이다.

글은 또한 가져온 파일이 socket.c/.hw5500.c/.h라고 밝히고, 불필요한 헤더를 제거했으며, IR 이름 충돌이 있을 경우 W5500_IR로 바꿔야 할 수 있다고 설명한다. 또 예제의 main 루프를 대상 보드의 루프 태스크 구조로 수정했다고 언급한다. 이런 내용은 W5500 구동에서 실제로 마주치는 문제를 잘 보여준다. 보드 I/O, 타입 호환성, 심볼 충돌, 런타임 통합이 바로 그런 지점이다.

Practical Tips / Pitfalls

포팅 경계를 깔끔하게 유지하는 편이 좋다. 가능한 한 W5500 드라이버와 소켓 계층은 그대로 가져오고, AG32 전용 코드는 w5500_gpio 같은 보드 계층에 격리하는 것이 낫다.

심볼 충돌을 주의해야 한다. 글에서도 IR이 대상 SDK에 이미 존재할 수 있으므로 W5500_IR로 이름을 바꿔야 할 수 있다고 경고한다.

리셋 동작은 초기에 반드시 검증해야 한다. 리셋 타이밍이 틀리면 소켓 코드가 네트워크 버그처럼 보이는 방식으로 실패할 수 있다.

첫 테스트를 지나치게 복잡하게 만들지 않는 것이 좋다. 이 글은 의도적으로 DHCP를 제외하고 고정 TCP 서버로 통신 테스트를 수행하는데, 이것이 올바른 첫 단계다.

이런 종류의 포팅에서 성능 한계는 대개 W5500보다 MCU 측 SPI 경로와 루프 설계에서 먼저 나타난다. 글에 나온 비트뱅잉 SPI는 교육과 초기 구동에는 충분하지만, 서버가 안정화된 뒤에는 하드웨어 SPI가 더 잘 확장되는 경우가 많다.

상위 프로토콜을 붙이기 전에 서버 예제를 단순하게 유지하는 편이 낫다. WIZnet 공식 문서도 같은 이유로 기본 TCP 예제와 고급 서비스를 분리해서 다룬다.

FAQ

왜 AG32VF407에서 소프트웨어 스택 대신 W5500을 쓰는가?
이 글의 목표는 빠르고 실용적인 TCP 서버 구동이다. W5500은 이미 하드와이어드 TCP/IP 처리와 소켓 수준 동작을 제공하므로, 펌웨어 작업은 전체 네트워크 스택 개발이 아니라 드라이버 포팅과 서버 제어 흐름으로 옮겨간다. 임베디드 이더넷 통합을 배우는 교육용 경로로는 이 방식이 훨씬 적절하다.

이 프로젝트에서 W5500은 플랫폼과 어떻게 연결되는가?
사용자 정의 GPIO/SPI 보드 계층을 통해 연결된다. 글에는 GPIO 초기화, 소프트웨어 제어 SPI 바이트 전송, 전용 리셋 루틴이 제시되어 있으며, 이 셋이 AG32VF407과 W5500 사이의 하드웨어 인터페이스를 이룬다.

이 프로젝트에서 W5500의 구체적인 역할은 무엇인가?
TCP 서버 엔드포인트 역할이다. 가져온 socketw5500 파일이 서버 측 이더넷 기능을 제공하고, AG32 펌웨어는 이를 로컬 보드와 루프 구조에 맞게 적응시킨다.

초보자도 이 프로젝트를 따라갈 수 있는가?
가능하다. 다만 기본적인 GPIO, SPI, 빌드 통합을 이해하고 있어야 한다. 이 글은 추상적인 네트워킹 이론보다 구체적인 포팅 절차에 집중하기 때문에 교육용으로 적합하지만, 완전 초보자라면 리셋 타이밍, 핀 제어, 심볼 조정 부분에서 약간의 도움이 필요할 수 있다.

MCU 위의 LwIP와 비교하면 어떤 차이가 있는가?
LwIP는 더 많은 소프트웨어 제어권을 주지만, 스택 통합, RAM 관리, 디버깅 부담도 MCU 쪽으로 더 많이 넘어간다. 반면 여기서 보이는 W5500 방식은 구조가 더 단순하다. MCU는 하드웨어 인터페이스를 포팅하고 애플리케이션 루프를 실행하며, W5500이 TCP/IP와 소켓 동작을 처리한다.

Source

원문 출처: CSDN 글 “调试W5500(作为服务器).”
페이지에는 CC 4.0 BY-SA가 표시되어 있다.
추가적인 제품 정보는 WIZnet 공식 W5500 문서와 TCP 애플리케이션 노트를 기준으로 확인했다.

Tags

W5500, WIZnet, AG32VF407, TCP Server, Embedded Ethernet, SPI, Firmware Porting, Socket Offload, Education, Hardwired TCP/IP, Board Bring-up, MCU Networking

 
 

 

Documents
Comments Write