WIZnet Developer Forum

W6100-EVB , UDP, Loopback example

Very strange problem.
I use the loopback example and W6100-EVB for the test. Nothing has changed.
Just start example and everything works OK.
I tried different sized packages. When sending a packet of 1300 -1460 bytes to the UDP 50000 /IP4/, the board blocks.
The strangest thing is that it blocks at row in which it tries to move the pointers to the new value. loopback_udps > recvfrom
….
if (len < sock_remained_size[sn]) pack_len = len;
else pack_len = sock_remained_size[sn];
wiz_recv_data(sn, buf, pack_len);
setSn_CR(sn,Sn_CR_RECV);
/* wait to process the command… */
while(getSn_CR(sn)) ;

void wiz_recv_data(uint8_t sn, uint8_t *wizdata, datasize_t len)
{
datasize_t ptr = 0;
uint32_t addrsel = 0;
if(len == 0) return;
ptr = getSn_RX_RD(sn);
addrsel = ((uint32_t)ptr << 8) + WIZCHIP_RXBUF_BLOCK(sn);
WIZCHIP_READ_BUF(addrsel, wizdata, len);
ptr += len;
setSn_RX_RD(sn,ptr);
}

void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb )
{
uint8_t tAD[4];
tAD[0] = (uint8_t)((AddrSel & 0x00FF0000) >> 16);
tAD[1] = (uint8_t)((AddrSel & 0x0000FF00) >> 8);
tAD[2] = (uint8_t)(AddrSel & 0x000000ff);
tAD[3] = wb;

WIZCHIP_CRITICAL_ENTER();
WIZCHIP.CS.s_e_l_e_c_t();

#if( (WIZCHIP_IO_MODE == WIZCHIP_IO_MODE_SPI_VDM))
tAD[2] |= (W6100_SPI_WRITE | W6100_SPI_OP);
WIZCHIP.IF.SPI._write_byte_buf(tAD, 4);

#elif ( (WIZCHIP_IO_MODE == WIZCHIP_IO_MODE_BUS_INDIR) )
WIZCHIP.IF.BUS._write_data_buf(IDM_AR0, tAD, 4, 1);
#else
#error “Unknown WIZCHIP_IO_MODE in W5100. !!!”
#endif

WIZCHIP.CS.d_e_s_e_l_e_c_t();
WIZCHIP_CRITICAL_EXIT();
}

Blocks SPI transfers. I don’t even know what to think.

It must be using some other test program, not a ScriptCommunicator, because it divides the packets into 512 bytes. A single packet must be sent.

In the W6100-EVB loopback example code, the UDP socket is fixed as IPv4 communication as below.
loopback_udps (0, ethBuf0,50000, AS_IPV4);

Have you modified this?
Please modify as below. In DUAL mode, both IPv4 and IPv6 communication is possible.
loopback_udps (0, ethBuf0,50000, AS_IPDUAL);

I started the example without changing anything. I changed it to a dual, there is no difference, it blocks again.

I use my program to send the package (only IP4), and I can set whatever length I want. For example, at 1200 it works normally. I don’t know exactly what the problem is. I watch it all with Wareshark.
When I opened the topic I thought there was a bug in W6100. Thank God there is none.

There is no problem for me personally. I use your software to find out how the W6100 works. Not everything is explained in his documentation. I guess a lot of things and do experiments. From your software I use only the principle and ideas. My software runs on PIC32, and everything works fine there, no problems with any length within the buffer in the chip.

In principle, it is good to fix your libraries so that they can be used by people who need them. I would highly recommend that you add some code that will allow the work to continue if an error occurs. Now as it is written everything, at the first mistake, and everything blocks. For example, when you receive an invalid UDP data packet (ip/port =0), you exit the function, with the Sn_RX_RD still pointing somewhere in the middle of the packet in the buffer, and everything falls apart. It is not possible to continue.

It’s just that a lot of people use libraries as a black box without understanding how they work, but they expect to always work.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.