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.

Interfacing NDK to SPI Ethernet Controller

Other Parts Discussed in Thread: TM4C123GH6PGE, EK-TM4C123GXL

Hi,

I own a TM4C123GH6PGE evaluation kit.
I have installed CCS5.5  and TI-RTOS 1.10.

I want to use TI-RTOS and the NDK to create a sockets based application.
TM4C123GH6PGE does not have an EMAC on it.
I want to interface the TM4C123GH6PGE  with a SPI based Ethernet Controller.
This controller can receive ethernet frames over SPI and forward it to the actual physical medium and whenever it receives a frame via the physical medium, it can interrupt the TM4C123GH6PGE and forward the ethernet frame to it over SPI.


I want to know how I should go about adding this as an EMAC device to NDK. I went through " TMS320C6000 Network Developer's Kit  (NDK) Support Package Ethernet Driver Design Guide" and http://processors.wiki.ti.com/index.php/Guidelines_when_porting_NDK_to_different_PHYs but still have lots of doubts. 
While browsing the TI-RTOS, I found EMACTiva.c and EMACTiva.c  at the location C:\ti\tirtos_1_10_00_23\packages\ti\drivers\emac

1. Can I go on and modify these files and replace the body of the EMAC functions contained in them with my own code to interface to my ethernet controller over SPI?

2. If yes, how would I integrate those two files in my CCS project? do i need to enable EMAC in my RTOS.cfg file? When do I call NIMURegister? Are these functions (The ones in EMACTiva.c) all that are needed to interface an ethernet controller to NDK or are there other things that I have to do? 

Functions in EMACTiva.c

EMACTiva_emacStart
EMACTiva_emacStop
EMACTiva_emacPoll
EMACTiva_emacSend
EMACTiva_emacServicePacket
EMACTiva_emacioctl

 

Thanks
 

  • Anurag,

    This should be possible through a modified version of EMACTiva.c, but this software isn't something that the Tiva C team creates.  I'll try to answer your questions the best that I can.  If you need more help or details, I can move this post to the TI-RTOS forums for better assistance.

    If you look in the TI-RTOS User's Guide (1016.8726.spruhd4c.pdf), section 6.3.1 states that to use the EMAC module, the application needs to include the EMAC module in the .cfg file.  This can be done graphically or by using 

        var EMAC = xdc.useModule('ti.drivers.EMAC');
        EMAC.libType = EMAC.LibType_Instrumented;

    NIMURegister is in the EMACTiva_NIMUInit() function.  This init function should be visible and called by the stack.

    I also know there are some example projects using the EK-TM4C123GXL LaunchPad and the EK-LM4F232 (kind of equivalent to the DK-TM4C123G kit that you have) (details about the project can be found in the TI-RTOS Getting Started Guide (8306.4454.spruhd3e.pdf)) that may be a useful reference.

    Some additional information, if you are looking for a Tiva C part that can be used for Ethernet applications, we just released the TM4C129x family of devices that can do exactly that.  Maybe these would be worth looking into, depending on your end goal.

    -Rebecca

  • @ Rebecca,

    Far from my comfort zone - yet find your post both inspired & inventive - good job!  Demonstrates much, "out of/beyond the box" thinking, data search/harvesting & resulting, "dot-connections."

    Surely this writing provides you a pleasant escape from, "launchpad fails to (launch)."  Hope to see further, similar...

    Indeed - that TMC129x and its (more available) Eval Board provide a far eased - more straightforward path for poster...

  • Thanks for the reply,

    I did go through the TI RTOS Getting started guide and the NDK related projects are either for the ARM concerto series boards or using the CC3000 with LM4F232. The CC3000 based project are of no use to me as a reference because what I want to achieve is completely different.

    What I want is simply a TI-RTOS + NDK CCS project for the LM4F/TM4C series. I would use that as a reference.

    I was hoping to find such a demo app as a part of TM4C129x eval board but i havent be able to locate such code thus far. The Weather Station app for the TM4C129x seems to be based on lwip/freertos?

    Please do correct me if I am wrong. I am not only confused but clueless as to what documentation to refer to.

    Anurag

  • Anurag,

    Correct, the qs_weather app does not use TI-RTOS.  The TI-RTOS examples are not made by the Tiva C group, but let me move this post to the TI-RTOS forums.  They may have some more information and docs that I can't locate that would be useful to you.

    -Rebecca

  • Hi,

    The EMACTiva is for the Concerto family devices. The name is not the best and we'll be changing probably in the Dec or Jan timeframe.

    You can add the two files into your application and modify as needed. You do not need the EMAC configuration in your .cfg. You'll lose ROV support though and the ability to automatically grab the EMAC lib (which you don't need since the files will be part of your project!).

    The EMACTiva_NIMUInit() function calls NIMURegister(). EMACTiva_NIMUInit() function is called by the NDK. The NDK knows about the EMACTiva_NIMUInit() function via the NIMUDeviceTable. For example, in the TMDXDOCK28M36.c board file, there is the following line:

    NIMU_DEVICE_TABLE_ENTRY  NIMUDeviceTable[2] = {EMACTiva_NIMUInit, NULL};

    The functions you have listed are the ones you'll need to modify. You might need to change EMACTiva_init() also. This function initializes software items needed by the driver. So depending on your implementation, you might not need this.

    You might want to add EMAC.c and EMAC.h also. They define the EMAC_Config stucture. It really depends on how much you want to gut the current implementation within EMACTiva.c/.h.

    Todd

  • Hi Todd,

    Thanks for the details. I was able to get a bit further with the information you provided. Thanks for that.

    I work at Greenvity Communications. We have developed our own ASIC for power line communications. It appears as an Ethernet
    controller can can be interfaced to over SPI. We want to interface it to a TM4C part. We want to use TI-RTOS and NDK with
    our part. These are our unchangeable requirements.
    So even if we switch from TM4C123 to TM4C129, we will still not be using the latter's onboard EMAC because we have out own
    Ethernet controller.

    There are two gaps in my understanding that I need to fill in before I am able to successfully do this: one is to do with
    the use of CCS and the other regarding the incomplete understanding of the NDK/TI-RTOS Source Code. I am constantly jumping
    around the user manuals re-referring various things but I still need your help so that I don't waste time blindly
    performing an unnecessary large number of trials and errors to get a feel for whats really happening.

    So right now I have a TI-RTOS project for my TM4C123GH6PGE board. The problem I am facing is that the compiler is reporting
    a lack of space in SRAM. Here is what I did:

    1) Simple TI-RTOs project with just one (LED blinky) task and no unnecessary modules other than NDK and EMAC
    var Global = xdc.useModule('ti.ndk.config.Global');
    var Udp = xdc.useModule('ti.ndk.config.Udp');
    var Ip = xdc.useModule('ti.ndk.config.Ip');
    var Emac = xdc.useModule('ti.ndk.config.Emac');
    Emac.device = Emac.NONE;
    2) Copied the EMACTiva.C/.h into my project. Gutted all the Ethernet related calls from all the EMAC functions bodies.
    3) Removed the Frame Receive interrupt function for now...
    4) Added printfs in all the EMAC functions so that I know when they are called. Will add body to interface to my ASIC later
    5) added the following to the main.c

    EMAC_Config EMAC_config;
    EMACTiva_Object my_object;
    EMACTiva_HWAttrs my_hwAttrs;
    UInt8 macaddress[6] = {0x10,0x22,0x33,0x44,0x55,0x66};
    NIMU_DEVICE_TABLE_ENTRY NIMUDeviceTable[2] = {EMACTiva_NIMUInit, NULL};

    and the following as the init code in main(), just before BIOS Start.
    my_hwAttrs.macAddress = macaddress;
    EMAC_config.fxnTablePtr = &EMACTiva_fxnTable;
    EMAC_config.objects = &my_object;
    EMAC_config.hwAttrs = &my_hwAttrs;
    EMACTiva_init(0);

    6) Since TM4C123 has only 32KB SRAM (unlike TM4C129's 256 kB), here are the settings for the NDK buffers:
    Global.pktNumFrameBufs = 4;
    Global.memRawPageSize = 1536;
    Global.memRawPageCount = 4;
    Global.debugPrintLevel = Global.DBG_NONE;
    Global.highTaskStackSize = 1024;
    Global.normTaskStackSize = 1024;
    Global.lowTaskStackSize = 1024;
    Global.ndkThreadStackSize = 1024;

    7) Linker setting: --heap-size 1024, --stack-size 4096


    Compiling still gives me the error:
    "../EKS_LM4F232.cmd", line 66: error #10099-D: program will not fit into available memory. run placement with alignment fails for section ".data" size 0x100f . Available memory ranges:
    SRAM size: 0x8000 unused: 0xe28 max hole: 0xe08
    "../EKS_LM4F232.cmd", line 67: error #10099-D: program will not fit into available memory. run placement with alignment fails for section ".stack" size 0x1000 . Available memory ranges:
    SRAM size: 0x8000 unused: 0xe28 max hole: 0xe08

    8) Linker CMD file is unchanged from the one supplied by default for LM4F232/TM4C123

    So I guess I really need to move to TM4C129 part. Or am I missing something?

    How/where do I check the memory consumed by various variables - the map file I mean.


    Anurag

  • Anurag,

    First off, I noticed that you said:

    Anurag Chugh said:
    4) Added printfs in all the EMAC functions so that I know when they are called.

    You have to be careful here.  One reason is because printf is very expensive to call (it halts the processor).  Another reason is that you cannot call printf within ISR context, as this could result in unpredictable behavior that is hard to debug - best to avoid.

    I would recommend using System_printf with SysMin as the system provider.

    Anurag Chugh said:
    Since TM4C123 has only 32KB SRAM

    I have put together some sample applications for size benchmarking for the NDK with the intent of shrinking the footprint and I wanted to point these out to you.  I think you should be able to get your foot print reduced by looking at the configuration files for these benchmarks.

    Please have a look in the NDK product that came with your TI-RTOS installation.  For example, I see it here on my machine:

    C:\ti\TI-RTOS\tirtos_1_20_00_24_eng\products\ndk_2_23_00_00

    If you open the NDK's release notes (found in that directory), you will see a section titled "benchmarks" and under that, a link called "Timing and Size Benchmarks" - click on that link.

    From there, look at the sizing benchmarks for M3 and it will take you to a page like

    Here you will see some size stats for various NDK apps, including the total RAM footprint.  Each application name (that's in the left most column) is a link that will show you the configuration settings file that was used to obtain that foot print size.  It's also important to point out that the beginning of each of those configuration files has a description of the application.

    I think the one that may match your use case best is the 'tcpSocket' application.  Click on that link and check out the settings (as well as the description).

    Note that one specific "trick" I did with this app is to shrink the TCP send/receive buffers down to 512 bytes.  This is acceptable for an application that, for example, only sends some packets with small payloads and not super fast.  I don't know what the requirements of your network app are, but this could work for you.  However, the drawback with this approach is that if you need to send a packet that's greater than 512 bytes, then it could be problematic.

    You can find further details on NDK memory usage here: http://processors.wiki.ti.com/index.php/TI-RTOS_Networking_Stack_Memory_Usage

    Hope this helps.

    Steve

  • Hi,

    TI-RTOS 1.10 release notes have no mention of validation being done on Cortex M4 series.
    Also TI-RTOS comes with NDK 2.22 

    You mention TI-RTOS 1.20. Where can I download this latest version? It doesn't seem to be available for download. Although I see that the user manual for this new versions are available.

    I really need a sample application for the TM4C129x series which uses TI-RTOS and NDK and the onchip EMAC. 

    I really don't have time to put something together and validate it before beginning to modify it to use my own ethernet chip instead of the onchip emac. Our client has ordered a DK-TM4C129X for us. Its on our way. I was really expecting a TI-RTOS+NDK example project to be shipped with it. Would I really have to do this myself?

    Anurag 

  • Hi Anurag,

    You can get 1.20 from here:

    http://downloads.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/

    Todd

  • Thanks for the link!!! downloading it right away

    Also, I forgot to mention, I did use System_printf() instead of just printf(). I had incorrectly mentioned that I used printf().

    Now I am just waiting for the DK-TM4C129X board. Want to be as ready as possible before they arrive.

    Thanks

  • Found the TCP/IP (NDK +EMAC) sample projects (for DK_TM4C129X) that I was looking for in TI-RTOS 1.20!