# Strugling with porting Eth drivers for STM32H563ZI

**URL:** <https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918>\
**Category:** Libraries\
**Created:** [April 30, 2024, 8:37am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918 "2024-04-30T08:37:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [April 30, 2024, 8:37am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/1 "2024-04-30T08:37:23Z")

</div>

My current project can be found here - [GitHub - BjornArend/FreeRTOS-PLUS-TCP-H563: Attempt at porting Eth drivers for FreeRTOS-plus to work on STM32H563ZI](https://github.com/BjornArend/FreeRTOS-PLUS-TCP-H563/tree/main) (I have excluded most of the general code that stm32cubeide generates)

My project currently builds fine and runs without any errors being reached.

-My problem is that when using a static IP the function vApplicationIPNetworkEventHook is called with eNetworkUp which creates the client socket and attempts to send data to it but this does not happen. The board does not show up on the network and I am unable to ping it.

- When using DHCP it creates the DHCP socket and reaches the DHCP state of eWaitingOffer (never gets further than this) but I haven’t seen the DHCP request on Wireshark. Eventually DHCP fails and reverts back to static IP yet never calls vApplicationIPNetworkEventHook with eNetworkUp so sockets task never gets created.

I fear that when porting the H7 drivers for the H5 I may have used the wrong registers and am now stuck on what other debugging I could do to see what I did wrong.

---

<div class="post-metadata">

**Author:** ![tony-josi-aws](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@tony-josi-aws](https://forums.freertos.org/u/tony-josi-aws)\
**Post date:** [April 30, 2024, 10:05am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/2 "2024-04-30T10:05:06Z")

</div>

@arend

Where is the network interface implemented in your project? This should interface the +TCP stack with your ethernet drivers. [Example](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c)

---

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [April 30, 2024, 10:13am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/3 "2024-04-30T10:13:55Z")

</div>

Hey there,

Its currently under - Middlewares/Third\_Party/FreeRTOS-Plus-TCP/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c - in the github repository its in the same path just remove Middlewares and Third\_Party.

The ethernet drivers I tried to port are under STM32H5xx\_Hal\_Driver.

Just to add to my original comment once vApplicationIPNetworkEventHook with eNetworkUp is called (only happens with static IP) i print out the addresses and they all look correct yet my board still doesn’t show up on the network.

The phy is LAN8742a which i see is supported.

---

<div class="post-metadata">

**Author:** ![tony-josi-aws](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@tony-josi-aws](https://forums.freertos.org/u/tony-josi-aws)\
**Post date:** [April 30, 2024, 10:19am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/4 "2024-04-30T10:19:52Z")

</div>

Your [protable folder](https://github.com/BjornArend/FreeRTOS-PLUS-TCP-H563/tree/main/FreeRTOS-Plus-TCP/source/portable) doesn’t contain NetworkInterface folder.

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [April 30, 2024, 10:26am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/5 "2024-04-30T10:26:14Z")

</div>

Apparently you do not have network connctivity at all. If your PHY and MCU is generally supported, check the variable network paramters ie RMII vs. MII wiring and PHY address.

---

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [April 30, 2024, 10:39am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/6 "2024-04-30T10:39:39Z")

</div>

I see that now, sorry about that I must have uploaded the incorrect folder, however, in my project I have the NetworkInterface.c file that you shared earlier. I have updated the repository to the correct folder.

---

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [April 30, 2024, 10:41am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/7 "2024-04-30T10:41:51Z")

</div>

I will have a look at that now,

Also just to add on I have tested this hardware with an LWIP application that ran perfectly, i now just need an RTOS and well LWIP doesn’t work well.

---

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [April 30, 2024, 1:01pm UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/8 "2024-04-30T13:01:26Z")

</div>

I have solved one of the problems which was that my TX buffers were too large and causing a timeout. However this has not solved my over all problem of no network connectivity. when using Debug printf this is what comes out of the terminal.

prvIPTask started  
PHY ID 7C130  
xPhyReset: phyBMCR\_RESET 0 ready  
+TCP: advertise: 01E1 config 3100  
prvEthernetUpdateConfig: LS mask 00 Force 1  
Its working  
prvIPTask started  
PHY ID 7C130  
xPhyReset: phyBMCR\_RESET 0 ready  
+TCP: advertise: 01E1 config 3100  
prvEthernetUpdateConfig: LS mask 00 Force 1  
Autonego ready: 00000004: full duplex 100 mbit high status  
Link Status is high  
IP Address: 192.168.0.80rn  
Subnet Mask: 255.255.255.0rn  
Gateway IP Address: 192.168.0.1rn  
DNS server IP Address: 8.8.4.4rn  
FreeRTOS\_connect: 1024 to c0a800ebip:12345  
Socket 1024 → c0a800ebip:12345 State eCLOSED-\>eCONNECT\_SYN  
ARP for c0a800ebip (using c0a800ebip): rc=0 00:00:00 00:00:00  
Connect[c0a800ebip:12345]: next timeout 1: 500 ms  
Network buffers: 60 lowest 59  
Heap: current 3176 lowest 3080  
TX descriptors 1/8  
ARP for c0a800ebip (using c0a800ebip): rc=0 00:00:00 00:00:00  
Connect[c0a800ebip:12345]: next timeout 2: 500 ms  
TX descriptors 2/8  
ARP for c0a800ebip (using c0a800ebip): rc=0 00:00:00 00:00:00  
Connect[c0a800ebip:12345]: next timeout 3: 500 ms  
TX descriptors 3/8  
Connect: giving up c0a800ebip:12345  
Move from eCONNECT\_SYN to eCLOSE\_WAIT  
Socket 1024 → c0a800ebip:12345 State eCONNECT\_SYN-\>eCLOSE\_WAIT  
FreeRTOS\_connect() stopped due to an error  
FreeRTOS\_closesocket[1024 to c0a800ebip:12345]: buffers 60 socks 0

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [May 6, 2024, 6:22am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/9 "2024-05-06T06:22:54Z")

</div>

Does [xNetworkInterfaceOutput](https://github.com/BjornArend/FreeRTOS-PLUS-TCP-H563/blob/main/FreeRTOS-Plus-TCP/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c#L345C12-L345C35) get called to send data on the wire? If yes, do you see any data going out on the wire in the Wireshark capture?

---

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [May 17, 2024, 9:14am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/10 "2024-05-17T09:14:42Z")

</div>

Hi there,  
sorry I have been busy with another project. Yes xNetworkInterfaceOutput does get called. I don’t see anything on wireshark however that is because the function gets stuck at:

configASSERT( pxDescriptor-\>xDataLength \<= sizeof( Tx\_Buff[0] ) );

Can you suggest how large to make my RX and TX buffers?  
The buffer does populate but the code does not pass that point.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [May 17, 2024, 11:03am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/11 "2024-05-17T11:03:14Z")

</div>

I see that [the value 1536](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/source/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.h#L464) is used in the existing NetworkInterface. Can you try that?

---

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [May 17, 2024, 11:30am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/12 "2024-05-17T11:30:42Z")

</div>

I gave that a try, this now caused a new issue where the TX buffers timeout printing this to the terminal.

emacps\_send\_message: Time-out waiting for TX buffer

---

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [May 17, 2024, 12:03pm UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/13 "2024-05-17T12:03:12Z")

</div>

I am going to re-port the drivers on Monday most likely. I rushed through it because our custom board was arriving and I needed to write test software on it.

If I make any progress or need some more help I will let you know…

---

<div class="post-metadata">

**Author:** ![HTRamsey](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htramsey/32/4136_2.png) [@HTRamsey](https://forums.freertos.org/u/HTRamsey)\
**Post date:** [May 19, 2024, 4:49am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/14 "2024-05-19T04:49:41Z")

</div>

You can look at my [draft](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/pull/804) here if you want help. I tried to include just about every currently available capability of HAL drivers. Haven’t yet decided if it’s worth finishing entirely though.

---

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [May 20, 2024, 7:36am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/15 "2024-05-20T07:36:37Z")

</div>

Thank you so much, Ill get to testing this now. Quick question, am I understanding correctly that your code uses the standard ST generated ethernet drivers while the NetworkInterface.c integrates them with FreeRTOS\_Plus\_TCP?

---

<div class="post-metadata">

**Author:** ![kanherea](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/kanherea/32/4106_2.png) [@kanherea](https://forums.freertos.org/u/kanherea)\
**Post date:** [May 20, 2024, 11:15am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/16 "2024-05-20T11:15:14Z")

</div>

> [@arend](#):
>
> Quick question, am I understanding correctly that your code uses the standard ST generated ethernet drivers while the NetworkInterface.c integrates them with FreeRTOS\_Plus\_TCP?

That is what I generally do. I don’t take on the problem of writing the ethernet drivers too. You should try and use the drivers to talk to the hardware while you use the NetworkInterface.c to:

1. Setup the driver correctly using APIs.
2. Move data to and from the vendor driver to the +TCP stack.

We will keep an eye out on this thread - let us know if you face any issues.

- Aniruddha

---

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [May 20, 2024, 1:48pm UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/17 "2024-05-20T13:48:54Z")

</div>

Sorry for not getting quick responses back to you. I still seem to be having issues with connectivity using FreeRTOS\_Plus. While the code given by @HTRamsey seems to work ALOT better than my attempt, I still see no transmissions on wireshark. I have connected my pc, router and board to a switch, this setup has been working to monitor packets when using LWIP.

Here are my current terminal logs:  
With DHCP enabled:

FreeRTOS\_AddEndPoint: MAC: 00-10-c0-b0-63 IPv4: c4ip  
prvIPTask started  
vIPSetDHCP\_RATimerEnableState: Off  
prvCloseDHCPSocket[63-c4]: closed, user count 0  
PHY ID 7C130  
xPhyReset: phyBMCR\_RESET 0 ready  
+TCP: advertise: 01E1 config 3100  
Autonego ready: 00000004: full duplex 100 mbit high status  
HAL\_ETH\_RxAllocateCallback: failed  
vDHCPProcessEndPoint: enter 0  
DHCP-socket[63-c4]: DHCP Socket Create  
prvCreateDHCPSocket[63-c4]: 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\_RxAllocateCallback: failed  
pxEasyFit: ARP c0a80001ip → c0a800f2ip  
HAL\_ETH\_RxAllocateCallback: failed  
HAL\_ETH\_RxAllocateCallback: failed  
ipARP\_REQUEST from c0a80001ip to c0a800f2ip end-point 0ip  
vDHCPProcessEndPoint: enter 2  
vDHCPProcess: discover  
vDHCPProcess: timeout 10000 ticks  
vDHCPProcess: discover  
vDHCPProcess: timeout 20000 ticks

after this it timesout and the board is not seen on the network

With DHCP disabled:

FreeRTOS\_AddEndPoint: MAC: 00-10-c0-b0-63 IPv4: c4ip  
prvIPTask started  
PHY ID 7C130  
xPhyReset: phyBMCR\_RESET 0 ready  
+TCP: advertise: 01E1 config 3100  
Autonego ready: 00000004: full duplex 100 mbit high status  
HAL\_ETH\_RxAllocateCallback: failed  
HAL\_ETH\_RxAllocateCallback: failed  
pxEasyFit: ARP c0a80065ip → c0a8006fip  
HAL\_ETH\_RxAllocateCallback: failed  
HAL\_ETH\_RxAllocateCallback: failed  
ipARP\_REQUEST from c0a80065ip to c0a8006fip end-point a0a0ac8ip

Again the board is not seen on the network.

The RxAllocateCallback function does complete 4 times before it starts failing and giving that error.

Any idea where I went wrong?

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [May 20, 2024, 2:46pm UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/18 "2024-05-20T14:46:58Z")

</div>

Again, have you made sure that the communication between your MCU and the PHY works? Is the PHY address and the protocol type (MII vs RMII) matching your hardware? You can hook into the PHY interface and try to determine if you see anything meaningful.

---

<div class="post-metadata">

**Author:** ![HTRamsey](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htramsey/32/4136_2.png) [@HTRamsey](https://forums.freertos.org/u/HTRamsey)\
**Post date:** [May 21, 2024, 4:16am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/19 "2024-05-21T04:16:52Z")

</div>

Here are some more [examples](https://github.com/HTRamsey/STM32_ETH_Test). Check out the H7 as the registers are identical to H5, although the H5 and H7 HAL drivers are out of sync so there are some small differences. Ignore the H5 as I never got around to buying an H5 unfortunately. Additionally, there are a couple people in the comment section of my draft PR that have gotten H5 to work, maybe their repos are public and you can check them out. Also, make sure your memory map is set up correctly and prefer to use BufferAllocation1. I have a modified BufferAllocation that you can use in my ETH\_Test repo.

---

<div class="post-metadata">

**Author:** ![arend](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@arend](https://forums.freertos.org/u/arend)\
**Post date:** [May 21, 2024, 6:46am UTC](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918/20 "2024-05-21T06:46:55Z")

</div>

Morning, I have have just implemented your version of the buffer management and well I somehow managed to turn my serial terminal into a very basic wireshare that shows every ARP sent on the network. Im fairly certain I know how I messed this up and should be able to fix it.

[Next page](https://forums.freertos.org/t/strugling-with-porting-eth-drivers-for-stm32h563zi/19918.md?page=2)
