I just get tower whit K60 TWR-K60N512 processor and i succesfully compiled and run code, but I am unable to make dhcp IP retival.
It even does not send antyhing out (checking whit wireshark)
error is maked in source
error = RTCS_create(); if(error) { printf("RTCS_create Error %08x!\n", error); return; } IPCFG_default_enet_device = DEMOCFG_DEFAULT_DEVICE; IPCFG_default_ip_address = ENET_IPADDR; IPCFG_default_ip_mask = ENET_IPMASK; IPCFG_default_ip_gateway = ENET_IPGATEWAY; LWDNS_server_ipaddr = ENET_IPGATEWAY; ip_data.ip = IPCFG_default_ip_address; ip_data.mask = IPCFG_default_ip_mask; ip_data.gateway = IPCFG_default_ip_gateway; ENET_get_mac_address (IPCFG_default_enet_device, IPCFG_default_ip_address, IPCFG_default_enet_address); error = ipcfg_init_device (IPCFG_default_enet_device, IPCFG_default_enet_address); if (error != IPCFG_ERROR_OK) { printf("Device init Error %08x!\n", error); return; } error = ipcfg_bind_dhcp_wait(IPCFG_default_enet_device, 0, NULL); if (error != IPCFG_ERROR_OK) { printf("DHCP Error %08x!\n", error); //well here fails whit IPCFG_ERROR_BIND }
已解决! 转到解答。
This is my Ethernet initialization code:
void initialize_networking(_ip_address ip, _ip_address mask, _ip_address gateway, _ip_address dns, uint_32 pcbs, uint_32 msgs,
uint_32 sockets, boolean dhcp)
{
int_32 error;
IPCFG_IP_ADDRESS_DATA ip_data;
_enet_address serverAddress =
{ 0x00, 0xcf, 0x52, 0x53, 0x54, 0xcc };
/* runtime RTCS configuration */
_RTCSPCB_init = pcbs;
_RTCS_msgpool_init = msgs;
_RTCS_socket_part_init = sockets;
error = RTCS_create();
if (error == RTCS_OK)
{
error = ipcfg_init_device(BSP_DEFAULT_ENET_DEVICE, serverAddress);
#if RTCSCFG_ENABLE_LWDNS
LWDNS_server_ipaddr = dns;
ipcfg_add_dns_ip(BSP_DEFAULT_ENET_DEVICE, LWDNS_server_ipaddr);
#endif
// check link status
printf("\nWaiting for ethernet cable plug in ... ");
while (!ipcfg_get_link_active(BSP_DEFAULT_ENET_DEVICE))
{
};
printf("Cable connected\n");
/* If DHCP Enabled, get IP address from DHCP server */
if (dhcp)
{
printf("\nDHCP bind ... ");
error = ipcfg_bind_dhcp_wait(BSP_DEFAULT_ENET_DEVICE, 1, &ip_data);
if (error != IPCFG_ERROR_OK)
{
printf("Error %08x!\n", error);
}
else
{
printf("Successful!\n");
}
}
else
{
ip_data.ip = ip;
ip_data.mask = mask;
ip_data.gateway = gateway;
/* Else bind with static IP */
printf("\nStatic IP bind ... ");
error = ipcfg_bind_staticip(BSP_DEFAULT_ENET_DEVICE, &ip_data);
if (error != IPCFG_ERROR_OK)
{
printf("Error %08x!\n", error);
}
else
{
printf("Successful!\n");
}
}
if (error == IPCFG_ERROR_OK)
{
ipcfg_get_ip(BSP_DEFAULT_ENET_DEVICE, &ip_data);
printf("\nIP Address : %d.%d.%d.%d\n", IPBYTES(ip_data.ip));
printf("\nIP Address HEX : %x", ip_data.ip);
printf("\nSubnet Address : %d.%d.%d.%d\n", IPBYTES(ip_data.mask));
printf("\nGateway Address : %d.%d.%d.%d\n", IPBYTES(ip_data.gateway));
printf("\nDNS Address : %d.%d.%d.%d\n", IPBYTES(ipcfg_get_dns_ip(BSP_DEFAULT_ENET_DEVICE,0)));
}
}
else
{
printf("\nRTCS_Create failed !\n");
_task_block();
}
}
Hope this will be useful to you.