in order to include FreeRTOS+TCP in my project, I followed the guide “Porting FreeRTOS+TCP to a Different Microcontroller” as no complete examples were available for my platform.
I’m using FreeRTOS 10.2.1.
The example reported on the porting guide contains the following example for vNetworkInterfaceAllocateRAMToBuffers(…) function:
for( x = 0; x < ipconfigNUM_NETWORK_BUFFERS; x++ )
{
…
/* The following line is also required, but will not be required in future versions. */ ( ( uint32_t * ) &ucBuffers[ x ][ 0 ] ) = ( uint32_t ) &( pxNetworkBuffers[ x ] );
}
The Network Buffer Descriptors contain a reference to the pucEthernetBuffer while this operation generate a cross-reference from the pucEthernetBuffer back to its Network Buffer Descriptor.
I verified that this is leveraged by the UDP Zero Copy flow.
It looks a temporary shortcut to get the descriptor reference from the data buffer itself. Can you clarify what “future versions” means ?
If it won’t be removed in the future, is it possible to make it more explicit ?
The 2 bytes (of ipconfigPACKET_FILLER_SIZE) are needed to get a correct alignment of the IP-header. The 8 bytes serve to get a good alignment for DMA.
All EMACs that I have seen until now, understand the 2-byte offset.
The routine that you point at is used by BufferAllocation_1.c only. BufferAllocation_1.2 uses pvPortMalloc() to allocate each buffer.
/* The following line is also required, but will not be required in future versions. */
This comment is outdated and has disappeared from all drivers. Drivers are still responsible to set the pointer. It is not recommended to change the 2 macros here above.
Here you find the latest Network Interfaces for FreeRTOS+TCP.
If you are writing a new Network Interface, you can always ask questions here in this post.
Good examples of network interfaces are e.g. STM32Fxx and DriverSAM. Note that they use a PHY-driver (Common/phyHandling.c) that recognises most 100 Mbps Ethernet PHY’s.