QS-IOT project LWIP1.4.1 (lwipopt.h) Checksum testing is disabled and configuration in (lwiplib.c) offloads IP Chksum and CRC to the EMAC.
Questions: Why is checksum during Stack writes disabled and to enable any LWIP checksums during (tcp_write) copy_data_flag the CHKSUM_GEN_TCP must be enabled?
Seemingly off loading CRC Chksum to EMAC0 is good idea until (tcp_write) performs a copy larger than the remaining stack space.
9.30.15 That was the assumption made from reading text describing LWIP function details. Seems author left out a word in the sentence (TCP) stack. After all from all the issues involved around the PBUF heap pool is seemed plausible a checksum on writes to SRAM stack space (who knew).
ASSERT_DEBUG last_unsent->oversize_left >= oversize_used line:639 C:/lwip-1.4.1/src/core/tcp_out.c ASSERT_DEBUG unsent_oversize mismatch (pcb vs. last_unsent) line:445 C:/lwip-1.4.1/src/core/tcp_out.c #if TCP_OVERSIZE //(MSS= 850 bytes) u16_t oversize = 0; u16_t oversize_used = 0; #endif /* TCP_OVERSIZE */ #if TCP_CHECKSUM_ON_COPY u16_t concat_chksum = 0; u8_t concat_chksum_swapped = 0; u16_t concat_chksummed = 0; #endif /* TCP_CHECKSUM_ON_COPY */
/* don't allocate segments bigger than half the maximum window we ever received */ u16_t mss_local = LWIP_MIN(pcb->mss, pcb->snd_wnd_max/2); Disabling all LWIP Chksum often ends badly in random crash dumps with a full TCP stack regiment. We found the minimal set works best to protect the Stack during (tcp_write) and the Heap PBUF appears to benefit from the Chksum test during copy packet data. Likewise when RX CRC off-loading: The receive checksum feature can be enabled by setting the IPC bit of the Ethernet MAC Configuration (EMACCFG) register. EMAC_CONFIG_CHECKSUM_OFFLOAD Below minimal project Stack protection is enabled for (tcp_write): //***************************************************************************** // // ---------- checksum options ---------- // //***************************************************************************** #define CHECKSUM_GEN_IP 0 #define CHECKSUM_GEN_ICMP 0 #define CHECKSUM_GEN_UDP 0 #define CHECKSUM_GEN_TCP 0 #define CHECKSUM_CHECK_IP 0 #define CHECKSUM_CHECK_UDP 0 #define CHECKSUM_CHECK_TCP 0 #define LWIP_CHECKSUM_ON_COPY 1 (tcp_impl.h) /** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */ #define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY)// && CHECKSUM_GEN_TCP 20.3.8.1 Transmit Checksum Offload Engine The checksum for TCP, UDP, or ICMP is calculated over a complete frame, and then inserted into its corresponding header field. Because of this requirement this function is enabled only when the TX FIFO is configured for the store-and-forward mode (the TSF bit is set in the EMACDMAOPMODE register). Note: The TX FIFO must be deep enough to store a complete frame before the frame is transferred to the MAC when the checksum offload is being used. If space is not available to accept the programmed burst length of data, the TX/RX Controller starts reading to avoid deadlock. When reading starts, the checksum offload fails and the consequently all succeeding frames may be corrupted because of improper recovery. Therefore, checksum insertion must only be enabled in frames that are less than [2048-((PBL+3)*4)] bytes in size, where PBL is the Programmable Burst Length field in the EMACDMABUSMOD register