Hi
I have been working on porting the FreeRTOS+UDP to the stm32f429 and
have successfully got it to work with being able to get responses from
ping’s from a PC.
I have had to make a few changes as explained below.
The STM32F429 has the capability to generate the checksums required for
the sections in a packet.
when the FreeRTOS responds to an ICMP packet it does a quick
re-calculation of the ICMP checksum but this causes the STM32F429 auto
calculation of the checksum to fail as it MUST be 0000 when it enters
the calculation process.
for STM32F4 – see page 1125 of doc – DM00031020 Reference manual.
Note that: for ICMP-over-IPv4 packets, the checksum field in
the ICMP packet must
always be 0x0000 in both modes, because pseudo-headers are not
defined for such
packets. If it does not equal 0x0000, an incorrect checksum may
be inserted into the
packet.
in order to get round this problem i have used the existing setting
called ‘ipconfigDRIVER
INCLUDEDTX
IPCHECKSUM’ to decide if the ICMP
will be calculated in the routine ”prvProcessICMPEchoRequest’ located
in ‘FReeRTOS_IP.c’ as shown below.
original
if( pxICMPHeader->usChecksum >= FreeRTOS_htons( ( (
uint16
t ) 0xffffU ) – ( ipICMPECHO
REQUEST << ( ( uint16t ) 8U ) ) ) )
{
pxICMPHeader->usChecksum = ( uint16
t )
( ( ( uint32t ) pxICMPHeader->usChecksum ) +
FreeRTOS
htons( ipICMPECHO
REQUEST << ( (
uint16t ) 8U ) ) + 1U );
}
else
{
pxICMPHeader->usChecksum = ( uint16
t )
( ( ( uint32t ) pxICMPHeader->usChecksum ) +
FreeRTOS
htons( ipICMPECHO
REQUEST << ( (
uint16t ) 8U ) ) );
}
replaced by
//added by AW
#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 )
{
// for STM32F4 - see page 1125 of doc - DM00031020 Reference
manual.
/*
* Note that: for ICMP-over-IPv4 packets, the checksum field in
the ICMP packet must
always be 0x0000 in both modes, because pseudo-headers are not
defined for such
packets. If it does not equal 0x0000, an incorrect checksum may
be inserted into the
packet.
*/
if( pxICMPHeader->usChecksum >= FreeRTOS_htons( ( (
uint16_t ) 0xffffU ) – ( ipICMP_ECHO_REQUEST << ( ( uint16_t ) 8U ) ) ) )
{
pxICMPHeader->usChecksum = ( uint16_t )
( ( ( uint32_t ) pxICMPHeader->usChecksum ) +
FreeRTOS_htons( ipICMP_ECHO_REQUEST << ( (
uint16_t ) 8U ) ) + 1U );
}
else
{
pxICMPHeader->usChecksum = ( uint16_t )
( ( ( uint32_t ) pxICMPHeader->usChecksum ) +
FreeRTOS_htons( ipICMP_ECHO_REQUEST << ( (
uint16_t ) 8U ) ) );
}
} // added by AW
#else
{
pxICMPHeader->usChecksum = 0x0000;
}
#endif
if it hasn’t already been added the following needs to be added to the
FreeRTOSIPConfig.h
define ipconfigDRIVERINCLUDEDTXIPCHECKSUM 1
this allows all the checksums to be calculated by the hardware.
I will keep you updated on my progress in getting more of it working.
Alan