# TCP/IP with STM32F745 / LAN8742A transmit gratuitous ARPs but no receive

**URL:** <https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959>\
**Category:** Libraries\
**Created:** [October 21, 2020, 8:01pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959 "2020-10-21T20:01:21Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdittmar](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mdittmar](https://forums.freertos.org/u/mdittmar)\
**Post date:** [October 21, 2020, 8:01pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/1 "2020-10-21T20:01:21Z")

</div>

I am trying to get the FreeRTOS TCP/IP stack going on a STM32F745 with a LAN874A phy on a custom board. I’m using the latest network interface drivers at:

> <https://github.com/htibosch/FreeRTOS-Plus-TCP/tree/main/source/portable/NetworkInterface/STM32Fxx>
>
> //github.com/htibosch/FreeRTOS-Plus-TCP/tree/main/source/portable/NetworkInterface/STM32Fxx

I’m going from my PC (192.168.1.33) through a switch (192.168.1.10) to the device (192.168.1.125).

Everything seems to come up OK to a point:

prvIPTask started  
PHY ID 7C130  
xPhyReset: phyBMCR\_RESET 0 ready  
+TCP: advertise: 01E1 config 1000  
prvEthernetUpdateConfig: LS mask 00 Force 1

> > Autonego ready: 00000004: full duplex 100 mbit high status  
> > PHY reg dump  
> > reg 0 1100  
> > reg 1 782D  
> > reg 2 0007  
> > reg 3 C131  
> > reg 4 01E1  
> > reg 5 C1E1  
> > reg 6 006F  
> > reg 7 2001  
> > reg 8 4000  
> > reg 9 FFFF  
> > reg 10 FFFF  
> > reg 11 FFFF  
> > reg 12 FFFF  
> > reg 13 0000  
> > reg 14 0000  
> > reg 15 0000  
> > reg 16 0041  
> > reg 17 0002  
> > reg 18 60E0  
> > reg 19 FFFF  
> > reg 20 0000  
> > reg 21 0000  
> > reg 22 0000  
> > reg 23 0000  
> > reg 24 9B9D  
> > reg 25 0000  
> > reg 26 0000  
> > reg 27 000A  
> > reg 28 4000  
> > reg 29 00C8  
> > reg 30 0000  
> > reg 31 1058  
> > Network buffers: 96 lowest 96  
> > Link Status is high  
> > IP Address: 192.168.1.125  
> > Subnet Mask: 255.255.255.0  
> > Gateway IP Address: 192.168.1.1  
> > DNS server IP Address: 208.67.222.222  
> > Network buffers: 96 lowest 95

and I am getting gratuitous ARPs being sent out every 20 seconds as seen via wireshark. I see that the transmit interrupt does get called when the ARP gets sent out, so interrupts running.

Now, when I try to ping the device from the PC I get no response. There is output from the PHY visible on the oscilloscope at the RXD0/RXD1 inputs to the STM32. I verified that the GPIO pins are setup correctly for the part for ethernet ( alternate function 11 ) and that the hardware is correct. I NEVER see a receive interrupt. It is enabled. Also, the MAC filter is set to receive broadcast messages.

I’m looking for ideas on what I could be missing here…I have run out of them !

Thanks ! Mark

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [October 21, 2020, 8:09pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/2 "2020-10-21T20:09:36Z")

</div>

And you enabled `ipconfigREPLY_TO_INCOMING_PINGS` in your `FreeRTOSIPConfig.h` ?

---

<div class="post-metadata">

**Author:** ![mdittmar](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mdittmar](https://forums.freertos.org/u/mdittmar)\
**Post date:** [October 21, 2020, 8:12pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/3 "2020-10-21T20:12:54Z")

</div>

Yes, it is enabled.

I’m mainly puzzled by the lack of any ethernet receive interrupts, when there is clearly data coming into RXd0/RXD1

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [October 21, 2020, 8:32pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/4 "2020-10-21T20:32:03Z")

</div>

Errm… yes. I’ve reread your post and noticed the _missing ETH RX_ interrupt 🙄  
And that you checked the MAC (filter) setup. RX DMA is surely also armed properly.  
Did you just try a TCP connection or sending UDP packets to the device ?  
This might start with an ARP request to the device which should then ARP reply.  
I think the provided drivers are pretty good and working but as far as I know they rely on HAL. Maybe post the (cube) version you’re using.  
I don’t use cube/HAL and can’t really help with it, unfortunately.

---

<div class="post-metadata">

**Author:** ![mdittmar](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mdittmar](https://forums.freertos.org/u/mdittmar)\
**Post date:** [October 22, 2020, 12:58pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/5 "2020-10-22T12:58:58Z")

</div>

Thanks Hartmut. Right now I’m just trying a TCP connection.

Binding socket to port 10000  
Socket 10000 -\> 0ip:0 State eCLOSED-\>eTCP\_LISTEN  
Heap: current 1128 lowest 1128  
Network buffers: 96 lowest 95

Although I don’t think it has anything to do with my present problem ( no DMA receive interrupts ), I’m wondering about the “heap” memory. is 1128 enough ?

Mark

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [October 22, 2020, 1:09pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/6 "2020-10-22T13:09:36Z")

</div>

Well, it depends 😉 Which heap is it and is (this) heap used for something.

---

<div class="post-metadata">

**Author:** ![mdittmar](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mdittmar](https://forums.freertos.org/u/mdittmar)\
**Post date:** [October 22, 2020, 1:28pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/7 "2020-10-22T13:28:44Z")

</div>

It’s the heap used by FreeRTOS. I have configTOTAL\_HEAP\_SIZE set to 46K in FreeRTOSConfig.h.

The funtion that calls this debug print of the current heap is in vPrintResourceStats() in FreeRTOS\_IP.

---

<div class="post-metadata">

**Author:** ![mdittmar](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mdittmar](https://forums.freertos.org/u/mdittmar)\
**Post date:** [October 22, 2020, 1:35pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/8 "2020-10-22T13:35:22Z")

</div>

I should also mention I’m using heap\_4

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [October 22, 2020, 2:29pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/9 "2020-10-22T14:29:59Z")

</div>

Then there is not much left to dynamically create FreeRTOS resources (tasks, queues, etc) in case you need that (later).  
Enabling/defining `configUSE_MALLOC_FAILED_HOOK` will easily show you if you run out of heap.

---

<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:** [October 23, 2020, 5:27am UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/10 "2020-10-23T05:27:56Z")

</div>

1128 bytes left sounds very minimal. I also suspect that your pvPortMalloc is failing. Like Hartmut said, have you enabled `configUSE_MALLOC_FAILED_HOOK` and defined `vApplicationMallocFailedHook()`?

It is possible to run the FreeRTOS+TCP stack on a CPU with 64 KB of RAM, but you will have to configure it to get a small RAM footprint. Like you might want to disable the use of TCP sliding windows (`#define ipconfigUSE_TCP_WIN 0`).

By the way, the **official repo** of FreeRTOS+TCP is here:

> **[FreeRTOS/FreeRTOS-Plus-TCP](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP)**
>
> FreeRTOS-Plus-TCP library repository. +TCP files only. Submoduled into https://github.com/FreeRTOS/FreeRTOS and various other repos. - FreeRTOS/FreeRTOS-Plus-TCP

  
That is where the pull requests are being done, and also a lot of testing.

If it helps, [here](https://github.com/htibosch/freertos_plus_projects/tree/master/plus/stm32F7) you find a STM32F7 project that works fine. You may want to compare the initialisation in [main.c](https://github.com/htibosch/freertos_plus_projects/blob/master/plus/stm32F7/Src/main.c).

---

<div class="post-metadata">

**Author:** ![mdittmar](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mdittmar](https://forums.freertos.org/u/mdittmar)\
**Post date:** [October 23, 2020, 12:55pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/11 "2020-10-23T12:55:05Z")

</div>

Thanks for all the information Hein. I have plenty of SRAM available, so I increased configTOTAL\_HEAP\_SIZE to 200K, and added the `vApplicationMallocFailedHook()` and enabled configUSE\_MALLOC\_FAILED\_HOOK.

Thanks for the code link. I will study that and see what I can learn.

It almost seems like the MAC is not transferring the received frames to the memory locations pointed to by the DMA descriptors. An examination of those memory locations show that nothing is being written there. The descriptors themselves are located in the DTCM RAM space.

I tried playing with the configurable threshold value but that did not affect anything.

Mark

---

<div class="post-metadata">

**Author:** ![mdittmar](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mdittmar](https://forums.freertos.org/u/mdittmar)\
**Post date:** [October 27, 2020, 7:41pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/12 "2020-10-27T19:41:47Z")

</div>

OK still no luck getting this to work. I’ve tried a number of different things…including disabling auto negotiation and just using fixed values of duplex mode and speed., physically swapping RXD0/RXD1 ( a long shot but I saw someone had that issue ), and varying configurable receive DMA FIFO threshold.

I have studied the code referenced above at

> **[htibosch/freertos\_plus\_projects](https://github.com/htibosch/freertos_plus_projects)**
>
> FreeRTOS sample projects using +TCP and/or +FAT. Contribute to htibosch/freertos\_plus\_projects development by creating an account on GitHub.

and examined the initialization. It looks basically the same as my initialization ( not surprising, since we are both using the same network interface driver ), except for the board specific items ( like ethernet pin numbers - which I have verified to be correct multiple times ). MAC and DMA configuration and interrupt registers appear to all be set correctly when I debug the running code. But the DMA buffers remain empty, and a receive interrupt never happens.

One difference between the aforementioned code and mine is that I am using FreeRTOS\_TCP version 2.3, and the other is 2.2.2. But I don’t see how that could be the problem. The network interface code is the same though.

---

<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:** [October 27, 2020, 11:58pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/13 "2020-10-27T23:58:14Z")

</div>

> except for the board specific items ( like ethernet pin numbers -  
> which I have verified to be correct multiple times )

Does you board have a MII or a RMII? Unless you define `ipconfigUSE_RMII`, for a `STM32F7xx` it will be assumed that you have a Reduced Media-Independent Interface:

```c
#ifndef ipconfigUSE_RMII
	#ifdef STM32F7xx
		#define ipconfigUSE_RMII	1
	#else
		#define ipconfigUSE_RMII	0
	#endif /* STM32F7xx */
#endif /* ipconfigUSE_RMII */

```

because that is how the evaluation boards are set-up.

---

<div class="post-metadata">

**Author:** ![mdittmar](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mdittmar](https://forums.freertos.org/u/mdittmar)\
**Post date:** [October 28, 2020, 12:15pm UTC](https://forums.freertos.org/t/tcp-ip-with-stm32f745-lan8742a-transmit-gratuitous-arps-but-no-receive/10959/14 "2020-10-28T12:15:12Z")

</div>

Yes, ipconfigUSE\_RMII is 1, I am using a Reduced Media-Independent Interface, and the GPIO pins are set accordingly for this ( AF11 ).
