STM32H723 run TCP can not connect to server

Now I am using STM32H723 to run freertos-plus-tcp, and get the result as follow, I don’t understand why it occurs-===-, I don’t use MPU and do not enable I/D cache too.

FreeRTOS_IPInit
FreeRTOS_AddEndPoint: MAC: 00-00 IPv4: c0a8326cip
prvIPTask started
PHY ID 7C0F0
xPhyReset: phyBMCR_RESET [0] ready
+TCP: advertise: 01E1 config 3100
Autonego ready: 00000004: full duplex 100 mbit high status
eNetworkUp
IP Address: 192.168.50.108
Subnet Mask: 255.255.255.0
Gateway Address: 192.168.50.1
DNS Server Address: 192.168.50.1
FreeRTOS_connect: 9999 to c0a8320cip:9000
Socket 9999 -> [192.168.50.12]:9000 State eCLOSED->eCONNECT_SYN
ARP c0a8320cip miss using c0a8320cip
ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00
Connect[c0a8320cip:9000]: next timeout 1: 500 ms
ARP c0a8320cip miss using c0a8320cip
ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00
Connect[c0a8320cip:9000]: next timeout 2: 500 ms
ARP c0a8320cip miss using c0a8320cip
ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00
Connect[c0a8320cip:9000]: next timeout 3: 500 ms
Connect: giving up c0a8320cip:9000
Move from eCONNECT_SYN to eCLOSE_WAIT
vTCPStateChange: Closing (Queued 0, Accept 0 Reuse 0)
vTCPStateChange: me 24004708 parent 24004708 peer 00000000 clear 0
vTCPStateChange: xHasCleared = 0
Socket 9999 -> [192.168.50.12]:9000 State eCONNECT_SYN->eCLOSE_WAIT
FreeRTOS_connect() stopped due to an error
FreeRTOS_connect: 9999 to c0a8320cip:9000
Socket 9999 -> [192.168.50.12]:9000 State eCLOSE_WAIT->eCONNECT_SYN
ARP c0a8320cip miss using c0a8320cip
ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00
Connect[c0a8320cip:9000]: next timeout 1: 500 ms
ARP c0a8320cip miss using c0a8320cip
ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00
Connect[c0a8320cip:9000]: next timeout 2: 500 ms
ARP c0a8320cip miss using c0a8320cip
ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00
Connect[c0a8320cip:9000]: next timeout 3: 500 ms
Connect: giving up c0a8320cip:9000
Move from eCONNECT_SYN to eCLOSE_WAIT
vTCPStateChange: Closing (Queued 0, Accept 0 Reuse 0)
vTCPStateChange: me 24004708 parent 24004708 peer 00000000 clear 0
vTCPStateChange: xHasCleared = 0
Socket 9999 -> [192.168.50.12]:9000 State eCONNECT_SYN->eCLOSE_WAIT
FreeRTOS_connect() stopped due to an error
FreeRTOS_connect: 9999 to c0a8320cip:9000
Socket 9999 -> [192.168.50.12]:9000 State eCLOSE_WAIT->eCONNECT_SYN
ARP c0a8320cip miss using c0a8320cip
ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00
Connect[c0a8320cip:9000]: next timeout 1: 500 ms
ARP c0a8320cip miss using c0a8320cip
ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00
Connect[c0a8320cip:9000]: next timeout 2: 500 ms
ARP c0a8320cip miss using c0a8320cip
ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00
Connect[c0a8320cip:9000]: next timeout 3: 500 ms
Connect: giving up c0a8320cip:9000
Move from eCONNECT_SYN to eCLOSE_WAIT
vTCPStateChange: Closing (Queued 0, Accept 0 Reuse 0)
vTCPStateChange: me 24004708 parent 24004708 peer 00000000 clear 0
vTCPStateChange: xHasCleared = 0
Socket 9999 -> [192.168.50.12]:9000 State eCONNECT_SYN->eCLOSE_WAIT
FreeRTOS_connect() stopped due to an error

This is my config file.
FreeRTOSConfig.h (11.0 KB)
FreeRTOSIPConfig.h (17.3 KB)

@slhuan

Seems like the TCP connection is not succeeding after the eCONNECT_SYN state.

What version of FreeRTOS+TCP are you using? Is it possible for you to share the TCP client code?

Also, please take a look at the sample TCP client demo code here.

It looks like V4.2.2. This is my project.
stm32h723-ad-collector.zip (3.3 MB)

From the logs, it seems like your device is not able to get a SYN_ACK packet from the server even after 3 attempts at sending SYN packets:

            if( pxSocket->u.xTCP.ucRepCount >= 3U )
            {
                /* The connection is in the SYN status. The packet will be repeated
                 * to most 3 times.  When there is no response, the socket get the
                 * status 'eCLOSE_WAIT'. */
                FreeRTOS_debug_printf( ( "Connect: giving up %xip:%u\n",
                                         ( unsigned ) pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4, /* IP address of remote machine. */
                                         pxSocket->u.xTCP.usRemotePort ) );                 /* Port on remote machine. */
                vTCPStateChange( pxSocket, eCLOSE_WAIT );
            }

After the 3 tries, it stops and sets the state to eCLOSE_WAIT.

Are you sure your server is working fine and is reachable? Maybe you try connecting to it with netcat or a small Python script to make sure the server is fine.

Yes, I am sure TCP-Server is running.


I can use LwIP to connect to it, running on stm32h723 too. But I want to use freertos tcp rather than lwip.

ei, my project code seem like delete some header files error.This one can complie successfully.
stm32h723-ad-collector.zip (3.2 MB)

Did you make sure your device’s network interface is up? Is it responding to pings?
Maybe enable ipconfigUSE_DHCP and see if your device is able to get the IP assigned.

Yes I can not ping my device at all. It seems that network interface doesn’t work up.
But the same config it can work up on STM32F470VGT6. So I don’t unstand that why it can’t work on STM32H723

when I enable DHCP, the log as follows:

FreeRTOS_IPInit
FreeRTOS_AddEndPoint: MAC: 00-00 IPv4: c0a8326cip
prvIPTask started
vIPSetDHCP_RATimerEnableState: Off
prvCloseDHCPSocket[00-00]: closed, user count 0
PHY ID 7C0F0
xPhyReset: phyBMCR_RESET [0] ready
+TCP: advertise: 01E1 config 3100
Autonego ready: 00000004: full duplex 100 mbit high status
vDHCPProcessEndPoint: enter 0
DHCP-socket[00-00]: DHCP Socket Create
prvCreateDHCPSocket[00-00]: open, user count 1
prvInitialiseDHCP: start after 250 ticks
vDHCP_RATimerReload: 250
vDHCPProcessEndPoint: exit 1
vDHCPProcessEndPoint: enter 1
vDHCPProcess: discover
vDHCPProcessEndPoint: exit 2
vDHCPProcessEndPoint: enter 2
HAL_ETH_RxLinkCallback: Buffer Dropped
HAL_ETH_RxLinkCallback: Buffer Dropped
HAL_ETH_RxLinkCallback: Buffer Dropped
HAL_ETH_RxLinkCallback: Buffer Dropped
vDHCPProcess: discover
vDHCPProcess: timeout 10000 ticks
vDHCPProcess: discover
vDHCPProcess: timeout 20000 ticks

But the same config it can work up on STM32F470VGT6

Config should be fine, there should be issues with setting up the GPIOs and interrrupts while interfacing with the drivers for STM32H723.

Are you using STM32 Cube to generate the init files? ( HAL_ETH_MspInit )

No, I write it in stm32h7xx_hal_msp.c myself. I am sure the RMII GPIOs is all the same as the board schematic.

Now I do not use the ram from 0x20000000-0x20020000. DHCP seems worked

FreeRTOS_IPInit
FreeRTOS_AddEndPoint: MAC: 00-00 IPv4: c0a8326cip
prvIPTask started
vIPSetDHCP_RATimerEnableState: Off
prvCloseDHCPSocket[00-00]: closed, user count 0
PHY ID 7C0F0
xPhyReset: phyBMCR_RESET [0] ready
+TCP: advertise: 01E1 config 3100
Autonego ready: 00000004: full duplex 100 mbit high status
vDHCPProcessEndPoint: enter 0
DHCP-socket[00-00]: DHCP Socket Create
prvCreateDHCPSocket[00-00]: open, user count 1
prvInitialiseDHCP: start after 250 ticks
vDHCP_RATimerReload: 250
vDHCPProcessEndPoint: exit 1
vDHCPProcessEndPoint: enter 1
vDHCPProcess: discover
vDHCPProcessEndPoint: exit 2
HAL_ETH_RxLinkCallback: Buffer Dropped
vDHCPProcessEndPoint: enter 2
vDHCPProcess: offer c0a83219ip for MAC address 00-00
vDHCPProcess: reply c0a83219ip
vDHCPProcessEndPoint: exit 3
vDHCPProcessEndPoint: enter 3
vDHCPProcess: offer c0a83219ip for MAC address 00-00
vDHCPProcess: acked c0a83219ip
eNetworkUp
IP Address: 192.168.50.25
Subnet Mask: 255.255.255.0
Gateway Address: 192.168.50.1
DNS Server Address: 192.168.50.1
prvCloseDHCPSocket[00-00]: closed, user count 0
vDHCP_RATimerReload: 43200000
vDHCPProcessEndPoint: exit 6
FreeRTOS_connect: 9999 to c0a8320cip:9000
Socket 9999 -> [192.168.50.12]:9000 State eCLOSED->eCONNECT_SYN
ARP c0a8320cip miss using c0a8320cip
ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00
Connect[c0a8320cip:9000]: next timeout 1: 500 ms
ARP c0a8320cip miss using c0a8320cip

but still can not connect to my tcp-server and also can not ping to 192.168.50.25

The MAC address does not make sense.

HAL_ETH_RxLinkCallback: Buffer Dropped

Can you try disabling ipconfigETHERNET_DRIVER_FILTERS_PACKETS?

aha, I tried to disable it, and then it worked, device can connect to my tcp-server~
Thanks~~

thank you.The MAC address which I used is ST’s cubemx generated.
The key is not the MAC, my problem has been resolved~

Thanks for reporting back.

The latest STM32 network interface compared to legacy doesn’t fully support ipconfigETHERNET_DRIVER_FILTERS_PACKETS yet.

The MAC address does not make sense.

@RAc That’s probably because while logging the MAC address, its only printing the last 2 bytes.

so that logging is incorrect?

I meant this:

FreeRTOS_AddEndPoint: MAC: 00-00 IPv4: c0a8326cip

where the endpoint is added.

ARP for c0a8320cip (using c0a8320cip): rc=0 00-00-00-00-00-00

This logging is for the case when ARP lookup is performed and it wasn’t a cache hit (in this case ARP miss), where its supposed to zero.