Hi,
I’m trying to forward raw ethernet frames generated by an application. I have seen several examples using lwip to handle TCP and UDP packets, however I need to work at lower level. In linux kernel is possible to work with net_device structure and related functions to receive and send raw packets. Is it possible also in FreeRTOS?
Thanks, I just need to be able to receive ethernet frames and send them out. Actually I’m using FreeRTOS on top of the Xilinx Ultrascale. I imagine that lwip and the RTOS tcp stack is able to use such low level functionalities.
This support provides the Xilinx MAC interface to LWIP so perhaps you can use it as examples for your raw interface.
If there is a middle interface it will be in LWIP and not part of FreeRTOS.
FreeRTOS does include FreeRTOS+TCP and there is a port for the Xilinx MAC here:
that code could be used as an example for creating a raw interface. Taking a simplistic look at it, there are fewer files in the +TCP interface so perhaps it will be easier to extract an example.
FreeRTOS+TCP indeed has a port for Xilinx UltraScale. I uploaded a testing makefile project for UltraScale here.
FreeRTOS+TCP lets you send raw packets by doing a system call eNetworkTxEvent.
For reception there is an application hook that you can use, see ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES .
In case you decide to use FreeRTOS+TCP, you can ask any further questions in this thread.
Thanks to everyone for the replies. All considered I’m looking to use directly FreeRTOS+TCP and I’m trying to understand the examples to make the raw interface.
I have imported FreeRTOS in my Vitis project (I started with a new HelloWorld FreeRTOS application). However, when I try to compile it I get the following error (refers to this link)
…/src/FreeRTOS-Plus-TCP/source/portable/NetworkInterface/xilinx_ultrascale/uncached_memory.c:79:26: error: ‘XPAR_PS7_DDR_0_S_AXI_HIGHADDR’ undeclared (first use in this function); did you mean ‘XPAR_PSU_DDR_0_S_AXI_HIGHADDR’?
79 | #define DDR_MEMORY_END (XPAR_PS7_DDR_0_S_AXI_HIGHADDR+1)
Yes, I’ve had to change the bspconfig.h to work on top of an Hypervisor, the same change did not produced any issue when compiling without that library. With that configuration the TCP library cannot work?
I must admit that I know very little about the insides of the Xilinx BSP. So if you can not solve it, anyone else? Or post a message on the Xilinx forum?
I think I have fixed some issues regarding the use of the FreeRTOS+TCP in a Hypervisor.
Regarding the solution you proposed before:
FreeRTOS+TCP indeed has a port for Xilinx UltraScale. I uploaded a testing makefile project for UltraScale here.
FreeRTOS+TCP lets you send raw packets by doing a system call eNetworkTxEvent.
For reception there is an application hook that you can use, see ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES .
In case you decide to use FreeRTOS+TCP, you can ask any further questions in this thread.
If I understood correctly, once called the FreeRTOS_IPInit(…) I can send raw packets anytime by just using the eNetworkTxEvent() function, right? What arguments does it takes?
Regarding reception, where can I define the eApplicationProcessCustomFrameHook? And if I modify the code to call it for each packet I receive (for example by removing the first two cases of the switch, it could be a problem?
xEventMessage.eEventType = eNetworkTxEvent;
xEventMessage.pvData = pxNetworkBuffer;
xil_printf(“[SEND_FRAME] ready to add packet to queue\n”);
r = xSendEventStructToIPTask(&xEventMessage, xDontBlock); //Add packet to queue, xDontBlock makes it return immediately without blocking
if(r == pdTRUE){
xil_printf(“[SEND_FRAME] packet added to queue\n”);
}else{
xil_printf(“[SEND_FRAME] unable to add packet to queue. QUEUE FULL\n”);
}
}
However when I call the xSendEventStructToIPTask function, that function never returns. Debugging I found that it seems that there is an abort:
Mind you that you may not access pxNetworkBuffer when it is NULL.
Remember that it is important to give a higher task priority to the IP-task ( see ipconfigIP_TASK_PRIORITY ).
The function xNetworkInterfaceOutput() works directly with DMA buffers, and so you may never call it from the application. Only the IP-task can use it.
it runs out of buffers. Anyone knows which could be the cause?
Does none of the packets arrive at their destination?
Can you use other things like ICMP/ping, UDP, TCP?
Hi,
unfortunately I did not managed to make it work. However I successfully managed to send ethernet frames baremetal and now I’m trying to port that code into FreeRTOS, however when moving that application code to FreeRTOS, my callback functions are no more called by when the device raises an interrupt. Do you know if there is something particular that I need to take care of when dealing with interrupts in FreeRTOS?