NetworkInterface.c for TMS320F2838x?

I am attempting to use FreeRTOS Plus TCP on the CM side of a TMS320F28384S chip. I haven’t seen any implementations for the NetworkInterface.c file. I was wondering if

  1. Does such a thing already exist?
  2. If not, is there an existing NetworkInterface.c file that would be a good one to work off from aside form the blank one in the board_family directory?
  3. Is there some reason that this may be a bad idea?


Once I looked up “how to write a device driver in Linux”. The best answer that I found was: “Don’t”.
The author recommended to start with a well-developed driver that comes close to what you need.

I recommend to have a look at the NetworkInterface.c of either STM32Fxx or DriverSAM

The TMS32 Ethernet also has a speed of 100/10, which means that you can use the generic phyHandling.c.

And beside that, you will need a library from Texas Instruments with the following functionalities:

  • Read settings from PHY
  • Write settings to the PHY
  • Initialise and configure the EMAC
  • Enqueue a packet for sending, callback (ISR) when sent
  • Get callback (ISR) when receiving a packet

I recommend to do as little as possible during an ISR, just set a flag and unblock the the “EMAC deferred handler task” prvEMACHandlerTask(). That task has a higher priority than the IP-task, and also higher than the tasks that make use of TCP/IP.

Please feel always free to ask more questions in this FreeRTOS forum.

Thanks for the advice.

While trying to bring up the network interface I am running into problems between the TI driver library and the struct packing in FreeRTOS. I have complex TI-defined structs that become misaligned when passed by reference. So for example an unsigned char is given a 4-byte word when declared, but when passed by reference it is given just a byte with everything afterwards off by three bytes. (Or perhaps I have that backwards, either way, you get the idea.)

This misalignment is related to the pack_struct_start.h and pack_struct_end.h files that seem to be required for the TCP stack, as when I comment out their contents, the misalignment disappears.

What are the ramifications of not including this packing on the TCP stack? Or is there a workaround for restricting which structs are packed?

Hi @laurabattle,

Which compiler are you using? Did you verify that the implementation of pack_struct_start.h and pack_struct_end.h that you have included in the project conforms to the attribute syntax that is needed to correctly pack the structures for your compiler? Are you using an implementation of pack_struct_start.h and pack_struct_end.h already provided in the source/portable/Compiler folder?

What are the ramifications of not including this packing on the TCP stack?

The pack_struct_start.h and pack_struct_end.h are used before and after structure definitions that define network packets, where the compiler shouldn’t add any padding between the struct fields, so that packets can be received and transmitted exactly as per the standard packet definitions.

Or is there a workaround for restricting which structs are packed?

It should by default only be restricted to the structures which are defined in between the pack_struct_start.h and pack_struct_end.h provided that you are using the right definitions for pack_struct_start.h and pack_struct_end.h.

Thanks for the quick response. I am using TI v20.2.7.LTS for compiling

So after taking another look at these files I changed to the GCC version of them, which seems to have removed the misalignment in the circumstance where I was seeing the error.