본문 바로가기

RaspberryPi/RP2040_W6100

[RP2040_W6100] Arduino IDE에서 Iperf TCP Throughput 측정 테스트 (Ethernet_Generic 라이브러리 수정)

 

W6100을 이용하여 제작한 보드의 네트웍 전송속도를 테스트 해보자

[RP2040_W5500]  보드에서 테스트한 Iperf TCP Throughput 측정 테스트를 참고 하여 Arsuino의 기본 예제를 이용하여 전송률을 테스트 해보자.

4Mbps 정도로 측정이 된다. 역시 W5500의 수준으로 느리다.

 

 

전송율을 높이려면 Ethernet_Generic 라이브러리의 w5100_Impl.h 파일에서  write(), read() 함수를  수정하여 DMA로 전송하도록 수정해야 한다.

\Documents\Arduino\libraries\Ethernet_Generic\src\utility\w5100_Impl.h

 

uint16_t W5100Class::write(uint16_t addr, const uint8_t *buf, uint16_t len)
{
:
#if USING_W6100
  else if (chip == w6100)
  {
    // chip == w6100
    setSS();
 :
    else
    {
      //pCUR_SPI->transfer(cmd, 3);

#ifdef SPI_HAS_TRANSFER_BUF

#if ETHERNET_USE_RPIPICO
		//pCUR_SPI->transfer((uint8_t*)buf, len);
        
		#if ETHERNET_USE_RPIPICO_DMA
		spi_write_DMA(SPI_X, cmd, 3);
		spi_write_DAM(SPI_X, (uint8_t*)buf, len);
  		#else
		pCUR_SPI->transfer(cmd, 3);
		pCUR_SPI->transfer((uint8_t*)buf, len);  
		#endif

#elif ETHERNET_USE_GD32	
		pCUR_SPI->transfer(cmd, 3);
		pCUR_SPI->transfer((uint8_t*)buf, len);
#else
	  pCUR_SPI->transfer(cmd, 3);
      pCUR_SPI->transfer(buf, NULL, len);
#endif	  
#else

      // TODO: copy 8 bytes at a time to cmd[] and block transfer
      for (uint16_t i = 0; i < len; i++)
      {
        pCUR_SPI->transfer(buf[i]);
      }

#endif
    }

    resetSS();
  }

#endif    // W6100

 

 

 

uint16_t W5100Class::read(uint16_t addr, uint8_t *buf, uint16_t len)
{
  uint8_t cmd[4];
:

#if USING_W6100

  else if (chip == w6100)
  {
    // chip == w6100
    setSS();
:

/*
    pCUR_SPI->transfer(cmd, 3);
    memset(buf, 0, len);
    pCUR_SPI->transfer(buf, len);
*/

		#if ETHERNET_USE_RPIPICO_DMA
		spi_write_DMA(SPI_X, cmd, 3);
		memset(buf, 0, len);
		spi_read_DMA(SPI_X, 0, buf, len);  		
		#else
		pCUR_SPI->transfer(cmd, 3);
		memset(buf, 0, len);
		pCUR_SPI->transfer(buf, len);
		#endif
		

    resetSS();
  }

#endif    // USING_W6100
:
    resetSS();
  }

  return len;
}

 

 

 

 

#include <SPI.h>

#define USE_ETHERNET_GENERIC  true 
#define USE_THIS_SS_PIN                       17    //RP2040 EXP

#define USE_UIP_ETHERNET   false

#define SPI_ETHERNET_SETTINGS SPISettings(33000000, MSBFIRST, SPI_MODE0)

#define USE_W5100                           false
#define USING_W6100                         true
#define USING_SPI2                          false 
#define ETHERNET_USE_RPIPICO      true
#define SPI_HAS_TRANSFER_BUF      true

#define SPI_X spi0
#define ETHERNET_USE_RPIPICO_DMA  true

#include "Ethernet_Generic.h"

byte mac[] = {
  0x00, 0x08, 0xDC, 0x00, 0x00, 0x00
};

EthernetServer server(5001);

int led_toggle = 0;
void setup() {

 pinMode(25, OUTPUT);
 digitalWrite(25, 0);

  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
    led_toggle ^= 1;
    digitalWrite(25, led_toggle);  
    delay(200);
  }

  digitalWrite(25, 1);

  Serial.println("SPI INIT");

  pinMode(USE_THIS_SS_PIN, OUTPUT);
  digitalWrite(USE_THIS_SS_PIN, 1);

  // initialize the ethernet device
  Ethernet.init (USE_THIS_SS_PIN);

  Ethernet.begin(mac);

  server.begin();
   Serial.print("Iperf server address : ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  byte buf[2048];
  unsigned int len = 0;
  
  // wait for a new client:
  EthernetClient client = server.available();

    if (client) {
    Serial.println("Here is new client for check arduino performance");
  while (client.connected())
    {
      len = client.available();
      if (len)
      {
       client.read(buf, 2048);
      }
   }
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}

 

 

RP2040에서 W6100 을 SPI DMA를 사용해서 전송율을 테스트 해보면 11Mbps 정도 측정이 된다.

 

반응형