I’m trying to get freertos plus TCP working on a stm32f4. Everything seems to be working at the driver level but when I wireshark it I find this error.
Pic
What I’m seeing in wireshark is exactly what I can see if I view the memory of the chip. So at least I know my driver is working.
Here is the code I send with. Huge thanks in advance.
uint8_t sn = 0;
// Wait for space in the transmit buffer
while(1)
{
uint16_t freesize = getSn_TX_FSR(sn);
if(getSn_SR(sn) == SOCK_CLOSED) {
return -1;
}
if (pxDescriptor->xDataLength <= freesize) break;
};
wiz_send_data(sn, pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength);
setSn_CR(sn, Sn_CR_SEND);
The code you have posted is very specific to your device, so you would probably get more knowledgeable information about the behaviour at this low level driver level from the vendor of the chip and/or driver itself. It would be interesting to know though if the packet being send using the code you posted matches what you are seeing on the wire in Wireshark. If the packet sent to that while loop matches what is on the wire then it is likely to be a configuration issue - on the other hand if the packet sent to the while loop is correct and only corrupt on the wire then it is likely to be something in the driver that is the issue.
Can’t use it because I’m using an external PHY. All the drivers I can find are for the internal Ethernet of the f4 series. I don’t think it’s the driver though because wireshark is seeing the exact thing that is generated in “pxDescriptor->pucEthernetBuffer”. The PHY is in RAW mode which means it sends out exactly what it receives from freeRTOS and it seems to be working as such.
Thanks for everyone having a punt so far. Very appreciated. Here is a side by side of the broken DHCP request and a proper one. I’m 100% sure the driver is not at fault. It’s transmitting exactly what is generated by Plus TCP/FreeRTOS+TCP V2.2.1.
I probably have a error in the config file somewhere. Any one else use Plus TCP.
If I am not mistaken, the 2 zero’s you see are at offset 24, which is the 2-byte IP checksum.
I can not see a reason why 2 bytes are inserted at that place.
I already asked you before, can you please send PCAP files in a ZIP file, in stead of showing pictures of WireShark?
Here are 2 packets from my STM32F407, using the internal EMAC: dhcp_by_stm32f4.zip (342 Bytes)
I don’t see a reason why the contents of the DHCP packets would be erroneous on a different system.
If you have doubts about your configuration, please send your FreeRTOSConfig.h and FreeRTOSIPConfig.h files.
Using https://www.mikroe.com/eth-wiz-click
Communication is via SPI. I’d be suspicious of my driver implementation if i wasn’t able to read the memory of the STM chip and see that it is an accurate send of the data at that address. I think the problem apears at around line 146 of FreeRTOS_UDP_IP.c. If I put a watch on the heap address where the pucEthernetBuffer is placed I can see that is where the header is first placed into memory. At this line “pxIPHeader->ulDestinationIPAddress = pxNetworkBuffer->ulIPAddress;” i starts to form the rest of the buffer but it is all out by 2 bytes. Then when it drops in the checksum it’s out by 2 bytes also. Hope this helps. The codes a bit beyond me I’m afraid. I’m told freeRTOS is one of the easiest to read and i can dig into a little bit. But i get out of my depth pretty quick.
Yeah it does, but I’m using it in MACRAW mode so i can get the advantage of using the FreeRTOS features. Libraries for other freertos features are written to interface with the freertos TCP stack. I thought it would be better for future compatibility to go with the freertos stack instead. The problem is all my udp packets. as seen in this exchange.UDP_test.zip (444 Bytes)
Turning off DHCP doesn’t help because ARP packets are bugged as well.
Yes, I can see that in the code but i’m not sure how to test it’s length when the code is running sorry. I’m right at the edge of my understanding.
Yes ARP is not working either. I attached the test but here is a pic.
The two bytes in front of the are second mac address are where things get offset. Providing the opcode request is meant to be “00 01” then the problem in this case is byte 23 and 24.
I’ve updated all of the file to the latest versions on github. Except for the files in “CMSIS_RTOS_V2” Because the project was originally built with CubeIDE. I’m not sure where to get them from. Everything else i updated. I’ve also updates my freertosipconfig to look like this. FreeRTOSIPConfig.h (21.0 KB)
OK, I reckon i’ve made that many attempts to fix it i’ve made it worse. I’m regenerating the project and starting from scratch. I’ll let you know in 30 minutes if this fixes it.
Very good, glad to hear. Thanks for taking the effort to report back.
The lesson to learn: sometimes it can be good to start a project all over again
Thanks, Hein