본문 바로가기

IT

WIZnet Ethernet HAT[RP2040] Loopback Test 진행하기

Loopback

이 Ethernet HAT 모듈이 서버가 되고 클라이언트가 접속하여 데이터를 보내면 받은 데이터를 다시 리턴하게 된다.
CircuitPython 환경아래에서 제작했으며 Python 코드로 구성되어 있다.

 

Overview

W5100S은 Ethernet Controller 칩의 하나로 TCP/IP 프로토콜이 하드웨어 로직으로 구현되어 있어 칩 레벨에서 프로토콜 처리를 할 수 있다. W5100S를 라즈베리 파이 피코와 호환하는 보드이며 3.3V 5V와 8개 GND 핀을 지원한다.

 

W5100S에 대한 자세한 내용은 이 링크를 참조.

 

  • Raspberry Pi Pico Pin-Compatible
  • Ethernet (W5100S Hardwired TCP/IP CHIP)
  • Product page : https://docs.wiznet.io/Product/iEthernet/W5100S/overview
  • Support 4 Independent Hardware SOCKETs simultaneously
  • Support SOCKET-less new Command: ARP-Request, PING-Request
  • Support Auto-MDIX only when Auto-Negotiation mode

W5100S Chip
WIZnet Ethernet HAT

 

RP2040 Datasheet - https://www.raspberrypi.org/documentation/microcontrollers/raspberry-pi-pico.html
 

Raspberry Pi Documentation - Raspberry Pi Pico

The official documentation for Raspberry Pi computers and microcontrollers

www.raspberrypi.com

RP2040

 

준비하기

Prepare Hardware

1. 라즈베리피코와 WIZNet Ethernet HAT을 결합한다.

 

2. Micro 5 pin 케이블을 이용하여 Raspberry Pi Pico와 PC를 연결하여준다.

 

3. Ethernet cable을 Ethernet HAT에 있는 포트에 연결하여 링크 LED가 들어오는 지 확인한다.

 

 - W5100S-EVB-PICO 보드를 사용하게 된다면 (1.내용을 생략하면 된다.)

Ethernet HAT with Raspberry pi pico
WIZnet Ethernet HAT Pinout

 

Prepare Software

1.Installing CircuitPython

아래 링크를 참조하여 Raspberry pi Pico에 CircuitPython을 설치하여 준다.

https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/circuitpython

 

Getting Started with Raspberry Pi Pico and CircuitPython

The Raspberry Pi foundation changed single-board computing when they released the Raspberry Pi computer, now they're ready to do the same for microcontrollers with the release of the brand new Raspberry Pi Pico.

learn.adafruit.com

 

  • Download the below uf2 file link on your computer

CircuitPython 7.0.0 - https://downloads.circuitpython.org/bin/raspberry_pi_pico/en_US/adafruit-circuitpython-raspberry_pi_pico-en_US-7.0.0.uf2

CircuitPython

2.Setup WIZnet Ethernet wiznet5k Library

wiznet5k 라이브러리를 가져와 Pico 내부에 있는 lib폴더에 복사하여 준다. 자세한 환경설정은 CircuitPython에서 설명하고있다. 시작하기 전 lib 폴더에 다음 사진과 같은 폴더가 있는 지 확인하면 환경설정은 끝이다.

https://github.com/Wiznet/RP2040-HAT-CircuitPython

 

GitHub - Wiznet/RP2040-HAT-CircuitPython

Contribute to Wiznet/RP2040-HAT-CircuitPython development by creating an account on GitHub.

github.com

adafruit_bus_device
adafruit_wiznet5k

CIRCUITPY/lib

 

시작하기

1.Install Programs

Teraterm은 터미널 콘솔프로그램이며 PC와 사용자가 통신할 수 있게 도와주는 인터페이스이다. 주목적은 시리얼 통신 목적으로 사용하게 된다.

Tera Term

 

Download File List - Tera Term - OSDN

Download File List - Tera Term #osdn

osdn.net

 

RS232 시리얼 통신, TCP 통신, UDP 통신을 위한 Hercules SETUP utility 프로그램을 프리웨어로 제공하고 있다. 특정 장치와 통신 테스트를 하기에 아주 유용한 프로그램이다.

Hercules

 

Hercules SETUP utility | HW-group.com

 

www.hw-group.com

 

"장치관리자"를 열어 해당 포트가 몇번포트로 열려있는 지 확인한다. 이후 해당 COM포트로 Teraterm을 통해 라즈베이파이 피코와 연결한다. 

2. How to Loopback Example

 

WIZnet github에 접속하여 CircuitPython Loopback 소스를 가져와 피코 내부에 있는 code.py에 복사한다. 

 

Setup Loopback Example

download - https://github.com/Wiznet/RP2040-HAT-CircuitPython/tree/master/examples/Loopback

 

터미널창에서 "Ctrl+D" 를 누르게 되면 피코가 실행된다. 터미널에서 실행되는 메세지는 다음과 같다. 반대로 "Ctrl+C"를 누르게 되면 실행 중인 소스가 멈추게 된다.

IP 주소는 192.168.1.100와 PORT 5000 소켓으로 서버가 열려 있다.  Hercules 프로그램 열어 해당 포트와 IP주소를 넣어주고 Connect 버튼을 누르게 되면 서버로 접속하게 된다.

Hercules에서 Connect버튼을 누르면 서버에 접속하게 된다. PC는 192.168.1.10 IP 주소를 사용하고 있다. 접속된 후에는 아래 그림과 같은 화면으로 접속된 것을 확인할 수 있다.

메세지에 LoopBack Test 라는 Text를 입력하고 Send를 누르면 서버로 패킷이 전송된다. 받은 데이터를 리턴하여 다시 클라이언트가 같은 메세지를 받게된다.

 

WIZnet/RP2040 gitub source

이밖에 다른 예제를 확인하려면 아래 링크에 있는 WIZnet github에 접속하여 다양한 프로토콜 예제를 확인할 수 있다.

https://github.com/Wiznet/RP2040-HAT-CircuitPython

 

GitHub - Wiznet/RP2040-HAT-CircuitPython

Contribute to Wiznet/RP2040-HAT-CircuitPython development by creating an account on GitHub.

github.com