FreeRTOS+UDP port to STM32F429

beaker1969 wrote on Wednesday, January 28, 2015:

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_INCLUDED_TX_IP_CHECKSUM’ 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 ) - ( 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 ) ) );
}

 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 ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 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

rtel wrote on Wednesday, January 28, 2015:

Thanks for the very useful post - yes please do keep us updated, and once you are happy with the code please post it to the FreeRTOS Interactive site (http://interactive.freertos.org).

We are currently porting FreeRTOS+TCP to the STM32, although with all the other development work we are doing it will probably be a while before it is released… FreeRTOS+TCP has a few more options for checksum offloading.

Regards.