Forum Discussion
15 Replies
- Altera_Forum
Honored Contributor
I use two ports with tse and sgdma.
I use one of them with tcp/ip (Nichestack) and the other with raw ethernet frames. I don't know if this is your case but I suppose it is even easier if you need to use both in the same way. I assume you have already built your sopc. Then all you need to do is: - call twice (or multiple times) alt_tse_system_add_sys() in the beginning of your application, to initialize all your devices - provide the required callback functions for assigning mac and ip addresses, get_board_mac_addr() and get_ip_addr() Then, the actual use of the ethernet interface, as I said above, depends on what you need them for. Cris - Altera_Forum
Honored Contributor
Hi, Cris:
Thanks for your reply. I am trying to build a simple telnet application demo with two Ethernet ports first. Then I will develop a more complex system to realize multiple UDP/IP transmissions. What confused me is that at the sopc builder, I connected four DMA controllers (For one Ethernet port, it has one DMA for transmission and the other for receiving. Two Ethernet ports are needed, therefore I have four DMA controllers) at the same DDR memory module. It turns out the top level verilog file can not pass the synthesis. Here is the Error: Net"DE3_Referenceup_SOPC:DE3_Referenceup_SOPC_Instance|mem_dqs_to_and_from_the_altmemddr[2]", which fans out to "DE3_Referenceup_SOPC:DE3_Referenceup_SOPC_Instance|altmemddr:the_altmemddr|mem_dqs[2]", cannot be assigned more than one value So I am just wandering if it is necessary to allocate a separate DDR memory module for each pair of DMA controllers. The other problem is about socket programming. I have no experience about that before. Am I supposed to allocate one IP address and one port number for each Ethernet port? Each Ethernet port need to be managed by one individual socket? - Altera_Forum
Honored Contributor
You don't need a separate DDR: all dma share the same memory. My system is the same as yours: 2 tse, 4 dma a single dram; the only difference being I'm using sdram controller, not ddr.
I can't tell you what that error is due to. Try check in sopc builder: - connections between dma and ddr - interrupts, arbitration,base addresses - ddr module configuration Then in Quartus, if you use top level schematic, check if any connection is missing or if a couple of them has been wrongly connected together. About socket programming. One ip address for each Ethernet port (you must define the get_ip_addr() function which will be called by interniche upon initialization) One socket for each tcp/udp connection you need. The tcp/ip stack will take care to move data to and from the correct physical Ethernet port. - Altera_Forum
Honored Contributor
The sopc builder problem has been solved.
Unfortunately, I am still got stuck by the initialization steps of Ethernet MAC and IP address. I knew that I should use get_ip_addr and get_board_mac_addr twice to get the correct parameters for each Ethernet port. However, I can not find where these two functions have been used in the simple socket server example. Are they used by the alt_iniche_init()? - Altera_Forum
Honored Contributor
More precisely, I think I should ask are those two Ethernet interfaces should be initialized simultaneously during the calling of alt_iniche_init() and net_main(), or one Ethernet port can acquire the IP and MAC after the initialization.
- Altera_Forum
Honored Contributor
I can't understand exactly what is your problem.
Maybe you are missing a point: you don't have to call get_ip_addr and get_board_mac_addr functions; you'd rather have to define them into your project. iniche will call them during alt_iniche init or net_main (now I can't remember which) in order to know from you which ip and mac you want to assign to every network interface you have. If instead your problem is to reassign ip and mac AFTER initialization, this is possible, although I think it is not recommended. You need to change some fields in the device data structure (so, making nothing less than a re-initialization of the device). You can place a breakpoint into the above init functions and step with debugger in order to find where ip and mac data are stored. Cris - Altera_Forum
Honored Contributor
Hi, Cris
My problem is I can not figure out the way that iniche assign the IP address and MAC address to the Ethernet port. I went through the targnios.c, which define the alt_iniche_init function, and net_main.c. I did not find that the alt_iniche_init and net_main call the get_ip_addr and get_board_mac_addr directly. That's why I am so confused. I am not quite sure about your "define" means. Do you mean like that:# define GETIP get_ip_addr(), Then put GETIP twice in the alt_iniche or net_main to get the IP address for two Ethernet ports? Or you mean rewrite these two functions for support multiple Ethernet ports? - Altera_Forum
Honored Contributor
With "define" I didn't mean# define, but I meant you must provide in your code the two functions. These will be called by iniche upon initialization.
Here are two simple templates:int get_ip_addr(alt_iniche_dev *p_dev, ip_addr* ipaddr, ip_addr* netmask, ip_addr* gw, int* use_dhcp) { IP4_ADDR(*ipaddr, 192, 168, 101, 100); IP4_ADDR(*gw, 192, 168, 101, 1); IP4_ADDR(*netmask, 255, 255, 255, 0); # ifdef DHCP_CLIENT *use_dhcp = 1;# else /* not DHCP_CLIENT */ *use_dhcp = 0; printf("TCP/IP port\n"); printf("Static IP Address is %d.%d.%d.%d\n", ip4_addr1(*ipaddr), ip4_addr2(*ipaddr), ip4_addr3(*ipaddr), ip4_addr4(*ipaddr) );# endif /* not DHCP_CLIENT */ /* Non-standard API: return 1 for success */ return 1; }
get_ip_address() is called by iniche_devices_init(), which is in file alt_iniche_dev.c get_mac_address() is called by your MAC initialization function; if you use TSE is prep_tse_mac() in ins_tse_mac.c file Regards Crisint get_mac_addr(NET net, unsigned char mac_addr) { mac_addr = MAC_BYTE1; mac_addr = MAC_BYTE2; mac_addr = MAC_BYTE3; mac_addr = MAC_BYTE4; mac_addr = MAC_BYTE5; mac_addr = MAC_BYTE6; printf("Default Ethernet MAC address is %02x:%02x:%02x:%02x:%02x:%02x\n", mac_addr, mac_addr, mac_addr, mac_addr, mac_addr, mac_addr); } - Altera_Forum
Honored Contributor
TO_BE_DONE
- Altera_Forum
Honored Contributor
Hi Cris72,
I am debugging my simple socket server project and I have found that my Target MAC address: 00:00:00_00:00:00 (00:00:00:00:00:00) I have modified the get_mac_addr() in network_utilities.c int get_mac_addr(NET net, unsigned char mac_addr[6]) { mac_addr[0]=0x00; mac_addr[1]=0x07; mac_addr[2]=0xED; mac_addr[3]=0x0E; mac_addr[4]=0xD3; mac_addr[5]=0xA2; return 0; } In my design I am using TSE and as you said get_mac_address() should be called by prep_tse_mac() in ins_tse_mac.c file. I can't find ins_tse_mac.c Where can I find that? Thank you very much in advance --- Quote Start --- With "define" I didn't mean# define, but I meant you must provide in your code the two functions. These will be called by iniche upon initialization. Here are two simple templates:int get_ip_addr(alt_iniche_dev *p_dev, ip_addr* ipaddr, ip_addr* netmask, ip_addr* gw, int* use_dhcp) { IP4_ADDR(*ipaddr, 192, 168, 101, 100); IP4_ADDR(*gw, 192, 168, 101, 1); IP4_ADDR(*netmask, 255, 255, 255, 0); # ifdef DHCP_CLIENT *use_dhcp = 1;# else /* not DHCP_CLIENT */ *use_dhcp = 0; printf("TCP/IP port\n"); printf("Static IP Address is %d.%d.%d.%d\n", ip4_addr1(*ipaddr), ip4_addr2(*ipaddr), ip4_addr3(*ipaddr), ip4_addr4(*ipaddr) );# endif /* not DHCP_CLIENT */ /* Non-standard API: return 1 for success */ return 1; }
get_ip_address() is called by iniche_devices_init(), which is in file alt_iniche_dev.c get_mac_address() is called by your MAC initialization function; if you use TSE is prep_tse_mac() in ins_tse_mac.c file Regards Cris --- Quote End ---int get_mac_addr(NET net, unsigned char mac_addr) { mac_addr = MAC_BYTE1; mac_addr = MAC_BYTE2; mac_addr = MAC_BYTE3; mac_addr = MAC_BYTE4; mac_addr = MAC_BYTE5; mac_addr = MAC_BYTE6; printf("Default Ethernet MAC address is %02x:%02x:%02x:%02x:%02x:%02x\n", mac_addr, mac_addr, mac_addr, mac_addr, mac_addr, mac_addr); }