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.

NDK - Socket not created

Hi all,

I'm attempting to copy the "tcpEcho" example given in the TI-RTOS download.

The code is almost identical to that of the tcpEcho example, but I'm doing my own configurations in the .cfg file.

My problem currently is that the server socket is not being created, namely in the line:

server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

The return value is -1

I have attached my project with the .cfg file included.

What could the problem be? Any help would be much appreciated. Thanks

P.S. There are some ADC, uDMA code in the project, but I've disabled them so they shouldn't be interfering with anything.

4555.test_adc.rar

  • I don't know the level of detail of the socket interface implementation you are using.

    The "default" way (e.g. under BSD or Linux) is to read the errno variable, which gives you more specific error information.

  • It would be helpful and save a lot of time if you can tell us what has been changed from the original "tcpEcho" example.

    Thanks,
    Sai
  • I hope this will be helpful:

    In TI-RTOS > Products > NDK > Networking - All Options, the only changes are:

    tcpEcho:

    lowTaskStackSize = 1024
    normTaskStackSize = 1024
    highTaskStackSize = 1024
    ndkThreadStackSize = 1536
    memRawPageSize = 3072
    memRawPageCount = 6

    test_adc:

    lowTaskStackSize = 2048
    normTaskStackSize = 2048
    highTaskStackSize = 2048
    ndkThreadStackSize = 2048
    memRawPageSize = 1200
    memRawPageCount = 7

  • Sorry I just realized that I've already fixed the socket problem, however I'm having issues accepting connections now. Namely, accept() is not returning anything.

    The updated code is given below. And my previous comment about the .cfg changes are the latest changes of the code given below.

    2860.test_adc.rar

  • In the .cfg file, I have noticed the following lines. Are you trying to configure a static IP address? If yes, then I would recommend, that you modify the "tcpecho" example and get it to work with static IP address before incorporating other changes.

    Ip.autoIp = false;
    Ip.address = "192.168.137.8";

    Thanks,
    Sai
  • I did have the tcpEcho example working with a static IP address.

    I also had trouble with test_adc using non-static IP address (Getting an IP from DHCP server)

    The only changes I have made between the two are only stack sizes, but there seems to be some procedure unknown to me which allows a project to accept TCP connections.

    I guess my question is: how to I make a "tcpEcho" example from scratch using an empty project?

    Thanks in advance. Any help would be much appreciated

  • Why do you want to build a project from the scratch when a similar example is available and working?

    I have never tried to create a TI-RTOS project from scratch, so cannot directly address your question. I always try to use a existing example and modify it to my needs.

    I would solve this issue by using the working "tcpEcho" project and start adding one code block at a time, making sure all the while that the application is still working. When it stops working, I would immediately know (in most cases) what the problem is, reducing the debug time.

    If you still believe that creating a project from scratch is the fastest way to solve the problem then I can move this post to TI-RTOS forum. Maybe they have a better solution.

    Thanks,
    Sai
  • If you could move this post to Ti-RTOS forums, that would be great, thanks.

    My original problem:
    I was having some issues having a uDMA channel in ping pong mode when used with the tcpEcho example. For some reason, my uDMA application performs normally when using an empty project, but crashes when using the tcpEcho example.

    So to begin debugging I tried to add NDK into the working uDMA project, but that didn't break the program, so I proceeded in that direction, attempting to create a "tcpEcho" from an empty project.

  • I moved this post to TI-RTOS forum.

    Thanks,
    Sai
  • I did a quick compare between test_adc.cfg and a copy of tcpEcho.cfg I have on my PC.  Some important differences I see:

    BIOS.heapSize is 10240 in your app, but 20480 in tcpEcho
    Program.stack is 768 in your app, but 2048 in tcpEcho
    Task.idleTaskStackSize is 512 in your app, but 768 in tcpEcho

    I only spot checked, but these are some very important sizes to get right for tcpEcho to function properly.  Also, I don’t know which version of TI-RTOS you are using, so the differences I’m seeing might be different from yours.

    Also you said earlier you’d set:
     

    user4633873 said:

    test_adc:
    lowTaskStackSize = 2048
    normTaskStackSize = 2048
    highTaskStackSize = 2048
    ndkThreadStackSize = 2048
    memRawPageSize = 1200
    memRawPageCount = 7

    These aren’t in the test_adc.cfg file you attached.

    I know it is going backwards, but I think it would be much better to start with a working tcpEcho example, and then slowly add in your code to see when things fail, and debug that.  

    If you want to proceed with this app, I think you need to do a very detailed compare of the .cfg files, and make sure the equivalent settings for tcpEcho are set in your test_adc.cfg file.

    And… was your ADC app working in an empty TI-RTOS project to start with?  Or was it a completely non-TIRTOS project?  Looking briefly at the sources, I see lots of usage of driverlib APIs for configuring interrupts and GPIOs.  In the TI-RTOS empty project (as well as tcpEcho) there is separate configuration of interrupts using the kernel’s Hwi module, and GPIOs using the GPIO driver (see EK_TM4C1294XL.c).  I’m thinking there might be some collisions there, that will have to be resolved as you port your code…

    Regards,
    Scott