# FreeRTOS+UDP port to STM32F429

**URL:** <https://forums.freertos.org/t/freertos-udp-port-to-stm32f429/506>\
**Category:** Kernel\
**Created:** [January 28, 2015, 9:27am UTC](https://forums.freertos.org/t/freertos-udp-port-to-stm32f429/506 "2015-01-28T09:27:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 28, 2015, 9:27am UTC](https://forums.freertos.org/t/freertos-udp-port-to-stm32f429/506/1 "2015-01-28T09:27:15Z")

</div>

**[beaker1969](https://sourceforge.net/u/beaker1969/)** wrote on [Wednesday, January 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/1906b1e1/#2955):

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

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [January 28, 2015, 11:06am UTC](https://forums.freertos.org/t/freertos-udp-port-to-stm32f429/506/2 "2015-01-28T11:06:54Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, January 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/1906b1e1/#83ab):

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](http://interactive.freertos.org)).

We are currently porting [FreeRTOS+TCP](http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/index.html) 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.

---

<div class="post-metadata">

**Author:** ![RealtimeRik](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/realtimerik/32/581_2.png) [@RealtimeRik](https://forums.freertos.org/u/RealtimeRik)\
**Post date:** [November 17, 2020, 7:01pm UTC](https://forums.freertos.org/t/freertos-udp-port-to-stm32f429/506/3 "2020-11-17T19:01:25Z")

</div>

Has this been resolved somehow as I have the same issue on a different processor?

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [November 17, 2020, 7:18pm UTC](https://forums.freertos.org/t/freertos-udp-port-to-stm32f429/506/4 "2020-11-17T19:18:01Z")

</div>

@RealtimeRik - which library and version are you using? The +UDP product (only supports UDP) was deprecated some time back. You should be able to build the latest +TCP product (supports both TCP and UDP) in UDP only mode.

---

<div class="post-metadata">

**Author:** ![RealtimeRik](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/realtimerik/32/581_2.png) [@RealtimeRik](https://forums.freertos.org/u/RealtimeRik)\
**Post date:** [November 17, 2020, 7:29pm UTC](https://forums.freertos.org/t/freertos-udp-port-to-stm32f429/506/5 "2020-11-17T19:29:25Z")

</div>

v2.2.0. Perhaps I am using it wrong? Although I think I have just replied to a message that was for the UDP only stack without realizing.

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [November 18, 2020, 7:41am UTC](https://forums.freertos.org/t/freertos-udp-port-to-stm32f429/506/6 "2020-11-18T07:41:06Z")

</div>

> replied to a message that was for the UDP only stack without realizing

No problem, but do you encounter checksum problems when using [FreeRTOS+TCP](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP) on an STM32F429?

Note that this driver ignores the macro’s`ipconfigHAS_RX_CRC_OFFLOADING` and `ipconfigHAS_TX_CRC_OFFLOADING`.  
When the driver is responsible for checksum calculations, it will use offloading unconditionally.
