I have project that use VDK + lwIP. One device that sends data and 50 devices that receives data.
My receiver code is:
#include "MulticastReceiverThread.h"
#include <new>
#include <defBF518.h>
#include <services/services.h>
#include <drivers/adi_dev.h>
#include <stdio.h>
#include <string.h>
#include "adi_ssl_init.h"
#include <lwip/sockets.h>
#include "MultiBuffer.h"
#define RECEIVER_PORT_NUM 12345
#pragma file_attr("OS_Component=Threads")
#pragma file_attr("Threads")
unsigned char* ReceivePacket;
void MulticastReceiverThread::Run()
{
int socket_fd;
struct sockaddr_in sa,ra;
int recv_data;
socket_fd = socket(PF_INET, SOCK_DGRAM, 0);
if ( socket_fd < 0 ) {
printf("socket call failed");
exit(0);
}
memset(&sa, 0, sizeof(struct sockaddr_in));
ra.sin_family = AF_INET;
ra.sin_port = htons(RECEIVER_PORT_NUM);
if (bind(socket_fd, (struct sockaddr *)&ra, sizeof(struct sockaddr_in)) == -1) {
exit(1);
}
// data length = 50 bytes
// header size = 3 bytes
ReceivePacket=new unsigned char[DATALENGTH+PACKET_HEADER_SIZE] ;
while(1) {
recv_data = recv(socket_fd,ReceivePacket,DATALENGTH+PACKET_HEADER_SIZE,0);
//processData(ReceivePacket);
VDK::Sleep(10);
}
//close(socket_fd);
}
I run receiver device and after 10min (sometimes 20min, 40min, 1 hour, 5 hours) dsp stops. I tried to connect to dsp with JTAG ICE100B, but i can't and have error like JTAG can't find target.
Also i tried run program on receiver device with loading it to SDRAM with ICE100B. But after several minutes i have error in IDDE that says:
target is disconnected! After this error i cant connect to device. I must turn off device and turn on. Only after this i can again connect to it.
9 devices from 50 works like this. other 41 devices works perfectly without problems.
if i comment recv(..) function all works fine.
Devices are custom boards with BF518F dsp .(but sdram and ethernet driver the same as on BF518 EZBoard).
in ldf settings i have:
external memory 32MB,
partition default,
system heap L3 external 4MB,
user heap L1 8KB
network configuration:
user_net_config_info[0].imask = 0
user_net_config_info[0].rx_buffs = 60;
user_net_config_info[0].tx_buffs = 40;
user_net_config_info[0].rx_buff_datalen = 1600;
user_net_config_info[0].tx_buff_datalen = 1548;
user_net_config_info[0].buff_area = 0;
user_net_config_info[0].buff_area_size = 0;
user_net_config_info[0].use_dhcp = 0;
user_net_config_info[0].mac_addr[0] = 0x1C;
user_net_config_info[0].mac_addr[1] = 0xC1;
user_net_config_info[0].mac_addr[2] = 0xDE;
user_net_config_info[0].mac_addr[3] = 0xB4;
user_net_config_info[0].mac_addr[4] = 0x79;
user_net_config_info[0].mac_addr[5] = DeviceNum;
user_net_config_info[0].ipaddr = (0xC0A801<<8) | DeviceNum;
user_net_config_info[0].netmask = 0xFFFFFF00;
user_net_config_info[0].gateway = 0x0;