Re: STM32 Ethernet Demo
Posted: Thu Oct 06, 2011 10:05 pm
Hey santatanta,
I was curious how ST does it and basically they do the same thing:
Some further googling I found this PDF: http://www.st.com/internet/com/TECHNICA ... 255062.pdf
I was curious how ST does it and basically they do the same thing:
Code: Select all
diff -C 3 -b -w -B -E -d -t -r -N -- lwip-1.3.1/src/core/ipv4/icmp.c lwip-1.3.1-st/src/core/ipv4/icmp.c
*** lwip-1.3.1/src/core/ipv4/icmp.c Tue Aug 18 14:54:17 2009
--- lwip-1.3.1-st/src/core/ipv4/icmp.c Fri Nov 20 17:07:14 2009
***************
*** 189,200 ****
--- 189,209 ----
iphdr->src.addr = iphdr->dest.addr;
iphdr->dest.addr = tmpaddr.addr;
ICMPH_TYPE_SET(iecho, ICMP_ER);
+
+
+ /* This part of code has been modified by ST's MCD Application Team */
+ /* To use the Checksum Offload Engine for the putgoing ICMP packets,
+ the ICMP checksum field should be set to 0, this is required only for Tx ICMP*/
+ #ifdef CHECKSUM_BY_HARDWARE
+ iecho->chksum = 0;
+ #else
/* adjust the checksum */
if (iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {
iecho->chksum += htons(ICMP_ECHO << 8) + 1;
} else {
iecho->chksum += htons(ICMP_ECHO << 8);
}
+ #endif
/* Set the correct TTL and recalculate the header checksum. */
IPH_TTL_SET(iphdr, ICMP_TTL);
Some further googling I found this PDF: http://www.st.com/internet/com/TECHNICA ... 255062.pdf
With lwIP, you can disable software generation and checksum verification for the IP, UDP
and TCP protocols. In the current port, this is done in the lwipopts.h file. For the ICMP,
however, it is necessary to modify the icmp.c file to disable checksum calculation.