This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/EK-TM4C1294XL: TCP connection between Tiva Launchpad and Linux system not working

Part Number: EK-TM4C1294XL

Tool/software: Linux

I am using Tiva Connected Launchpad(EK-TM4C1294XL) to take some ADC data from a sensor and send it to another system(Beaglebone Black, PC) over ethernet using TCP. On the Tiva side, I am using LwIP for the connection and on the system(PC) side, socket programming in python. I have provided static ip on both sides. I am directly connecting the ethernet wires between the Tiva launchpad and the system. 

My relevant code for the Tiva board is shown below

typedef struct {
uint32_t pui32IPArray;
uint8_t pui8MACArray[8];
struct pbuf *p;
struct tcp_pcb *tpcb;
struct ip_addr server_ip, local_ip;
}Ethernet;

Ethernet eth0;

void tcp_initialize(void){
IP4_ADDR(&eth0.server_ip, 169,254,0,1);
IP4_ADDR(&eth0.local_ip, 169,254,0,2);
eth0.tpcb = tcp_new();
tcp_bind(eth0.tpcb, &eth0.local_ip, 5002);
tcp_arg(eth0.tpcb, 0);
tcp_recv(eth0.tpcb, tcp_recv_callback);
tcp_sent(eth0.tpcb, tcp_sent_callback);
tcp_nagle_disable(eth0.tpcb);
tcp_connect(eth0.tpcb, &eth0.server_ip, 5002, tcp_connected_callback);
}

int main(void){

lwIPInit(ui32SysClock, pui8MACArray, (169u<<24) | (254u<<16) | (0<<8) | 2, (255u<<24) | (255u<<16) | (0<<8) | 0, (0u<<24) | (0u<<16) | (0<<8) | 1, IPADDR_USE_STATIC);

tcp_initialize();

}

Even though it is working well for the Windows system(where I use Spyder to run python), it does not work for Ubuntu or Debian systems. The code does not go go beyond socket.accept(). The Python code at the PC side is shown below. My firewall is disabled on the Ubuntu system.

import socket
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

s.bind(('169.254.0.1',5002))
s.listen(1)
conn, addr = s.accept()

print "connection address :", addr

So it gets stuck at s.accept() and could not connect. Please help me if I have to do something more to connect it to Linux than Windows.

  • Hi,
    Let me try to understand. The Tiva board is working with the Windows PC on the network. But you have problem between the Tiva board and your Linux machine. Is that the correct understanding?

    Can you ping the Tiva board from your linux machine? What does it say?

    Is your linux machine on the same network, (same subnet) as the Tiva board?

    Please use WireShark to capture the network traffic and compare between the Windows PC vs the Linux machine.

    What if you use DHCP instead of static address? What result do you see?
  • Hi Charles,

    No, I am not connecting the Tiva board to any network or Router just connecting the Linux system directly to the board through ethernet cable to send and receive data. I have flashed my code in the Tiva board and just press the reset button to run the code and to power the board give external power to a 5V pin. The difference is when I try the same connection with Windows system it works fine.  

    Yes, I can ping the Tiva board from the Linux terminal. It replies back until I terminate it using Ctrl+C.

    Yes, I have set the subnet same for both the Linux machine and the Tiva board.

    I used  WireShark  when I connected the Tiva board to a Beaglebone Black(Debian O.S). The Wireshark was installed on the Beaglebone Black and it showed that a Texas Instrument was asking about an IP which had the same netmask but the IP was different from the one I set for Beaglebone. This was an ARP packet coming from the Texas Instrument source which I feel is the Tiva board. Other than it nothing relevant was being shown.

    For the Windows Wireshark , the TCP packets were being shown between the two IPs(Windows and Tiva board) as source and destination interchangeably. It was showing satisfying results.

    I have not tried with DHCP. So, will i keep both of the Tiva board and Linux machine on DHCP or just the Tiva board?

    Regards,

    Sourav

     

  • Hi,
    Can you try to put both the Tiva board and your linux machine on the LAN using DHCP address and later also try with static address?
  • Hi Charles,

    I tried with DHCP but it did not work. I can ping the Tiva launchpad from my Linux system but the socket program is not going beyond socket.accept().

    Regards,

    Sourav

  • Hi Sourav,
    I don't know if there is a network problem with your Linux machine. If the Tiva board works with the Windows PC then the Tiva board should be working both hardware and software wise. I'm not familiar with the Linux side. Not sure what to recommend. Can you show the Wireshark capture for the Tiva<->Windows PC and Tiva<->Linux machine?
  • Hi Charles,

    Sorry for the late reply but the problem got resolved yesterday. So, as per my code I was calling tcp_initialize() just after lwIPInit() as shown above in the my question. Every time the wired connection was getting disconnected for like 1 sec and then again connecting back. This was just happening in Linux machines and not in Windows. I do not know why.
    So, I delayed the tcp_initialize() a bit from the lwIPInit() line and now it is working fine.

    Regards,
    Sourav Bhattacharya