I’m starting this thread to reinvigorate discussion about development of an Ethernet port for the STM32H7xx series.
For a bit of history: I’ve used FreeRTOS+TCP on an STM32F7 with good success and it was relatively painless. There are things I learned while doing that, however, that I think might be of value when developing the driver/port for the H7.
- I modified the STM32F7 HAL files to minimize the dependency chain, ending up with the following files:
- stm32_hal_legacy.h
- stm32F7xx_hal.h
- stm32F7xx_hal_conf.h
- stm32F7xx_hal_def.h
- stm32F7xx_hal_eth.c
- stm32F7xx_hal_eth.h
What would be ideal is to reduce these further to a single .C and .H file, which would greatly improve project archiving. I think elimination of the STM HAL dependency chain in this area is quite possible as A) the Ethernet peripheral is quite stand-alone, and B) the STM HAL dependency chain can add a lot of unnecessary clutter to a project.
-
ST’s HAL_ETH_Init(.) function is abysmal. It should be a threaded process that invokes a hookable callback when complete, passing the success of the operation. Making it threaded implies dependency on FreeRTOS, which IMO would be OK. After all, this is a FreeRTOS TCP stack intended to run alongside FreeRTOS.
-
Phy initialization could be broken out such that an additional phy-device-specific implementation file could provide phy device initialization and control, adhering to an API contract. That way, community members could submit, if desired, their implementation of the file for a specific phy device. The reason I mention this is because I’m not convinced there is a comm “standard” (yet) that phy device OEMs adhere to for initializing the device. Efforts have been made over the years, but they’re still not there yet and tweaking code in the Ethernet driver init function breaks module abstraction.
Somewhat related is some of the FreeRTOS+TCP stack improvements I made while getting the F7 +TCP port running.
-
DHCP: Some routers don’t seem to remember IPAddr-to-MACAddr associations when granting an IP lease. Because of this, I noticed the FreeRTOS+TCP stack leasing an incrementing address each time the stack was initialized. The DHCP discover packet has an option field the client can use to specify the desired IP address. I modified the prvSendDHCPDiscover() function to invoke a callback that would return the desired IP address for the option field. This way, the application can hook this callback and it’s then up to the application to provide non-volatile storage of the “lastDhcpIpAddr”, or the callback hook can return {0,0,0,0} to bypass use of the option field.
-
I added two socket options to set the IP header’s TLL and DSCP value for any specific socket. Perhaps not a Berkley standard, but it provides tighter control over TTL and QoS.
-
In its current state, the FreeRTOS+TCP stack can in fact act as a Multicast level 1 server, without the need for IGMP (see RFC-1112, Section 3). This, however, requires a modification to the FreeRTOS+TCP function eARPGetCacheEntry(…) that bypasses MAC lookup and instead builds the proper Multicast MAC address if the input IP address falls in the Multicast range. Granted, full IGMP support would be preferable, but that’s quite an undertaking.
-
It would be nice if a socket provided a callback that could be hooked to indicate when the socket is truly closed and freed from memory. I attempted this but could not get it working.