Skip to main content
Visitor II
August 20, 2020
Question

PTP support in HAL drivers STM32H7

  • August 20, 2020
  • 9 replies
  • 7035 views

We have migrated our project from STM32F7 to STM32H7 MCU and found that there's no support for PTP IEEE 1588 protocol in MAC Ethernet driver (HAL).

Here is a message written in stm32h7xx_hal_eth.c file:

   -@- The PTP protocol offload APIs are not supported in this driver.

Is it ever going to be supported?

    This topic has been closed for replies.

    9 replies

    Technical Moderator
    August 27, 2020

    Hello @leshich-k​ ,

    For the moment, no plan to implement PTP feature in the STM32CubeH7 software package.

    The request is already raised internally to implement this feature, but Currently, not at the short term planning.

    Kind Regards,

    Imen

    Visitor II
    May 24, 2022

    Hello Any updates in this area? Is PTP feature available in STM32CubeH7 now? Is reference driver available for some other platform?

    Visitor II
    May 24, 2022

    Thanks for the quick response. Is there any examples using the PTP available too?

    Visitor II
    February 5, 2023

    @JMath.5​ im intresed in examples for ptp on stm32h7 and f7 cups aswell

    Graduate II
    February 6, 2023

    Somewhere on Github someone ported "PTPd" to H7, I just did the same - but without using the H7's "hardware" features, there's so much info in the descriptors which would really speed up the PTP stuff compared to PTPd.

    But I haven't had time yet for that, PTPd is working for now...

    And HAL... no thanks for the important stuff! ;)

    leshich-kAuthor
    Visitor II
    February 6, 2023

    Hardware feature is the main thing that PTP requires, otherwise PTP doesn't make sense since it cannot be as precise.

    H7 has some silicon bugs in ETH-MAC, so this is the reason of not supporting PTP in HAL. But theres are workarounds for those bugs.

    Visitor II
    February 6, 2023

    @Community member​ do you mean this repo https://github.com/hasseb/stm32h7_atsame70_ptpd ?

    For my application i want to use atleast the RMMI_PTP_synchro and then use the PPS puse to replace an GPS PPS Pulse in my application.

    I tryed something in cube MX but there seams to be an bug so i will create an question ragarding this topic and linking it here.

    Graduate II
    February 6, 2023

    Yes, that's what I meant. But it needs some further tuning, I think.

    To get the PPS working, you need to have lwIP and the ETH driver working, then PTP, then you can turn on the PPS output.

    I have it working here to sync multiple devices.

    Here's my HAL-less ETH driver, with the heavily modified PTPd stuff, mostly because it's blocking waiting for the TX timestamps, which I could not use without an OS.

    Graduate II
    February 6, 2023

    Oops, put in the wrong gpio file, not so difficult anyway... ;)

    /* PTP pulse output ON / OFF on GPIO B5 */
    void GPIO_PPS_OnOff(uint8_t u8PpsOn)
    {
    	GPIO_InitTypeDef GPIO_InitStruct = { 0 };
     
    	if( u8PpsOn )
    	{
    		/* GPIO B: 5-PPS_OUT */
    		GPIO_InitStruct.Pin 		= PTP_PPS_Pin;
    		GPIO_InitStruct.Mode 		= GPIO_MODE_AF_PP;
    		GPIO_InitStruct.Pull 		= GPIO_NOPULL;
    		GPIO_InitStruct.Speed 		= GPIO_SPEED_FREQ_HIGH;
    		GPIO_InitStruct.Alternate 	= GPIO_AF11_ETH;
    		HAL_GPIO_Init(PTP_PPS_GPIO_Port, &GPIO_InitStruct);
     
    		u8GpioPpsActive = 1;
    	}
    	else
    	{
    		HAL_GPIO_DeInit(PTP_PPS_GPIO_Port, PTP_PPS_Pin);
     
    		u8GpioPpsActive = 0;
    	}
    }

    Visitor II
    February 6, 2023

    @Community member​ tank you very mutch for sharing this code i will have a look.

    If there are silicon bug in the H7 i can use the stm767zi i used so far.

    Having a loock at you other questions i know u used the mcu as well have you managed to get freeRTOS+LWIP+DHCP+IEEE1588 PTP to run with an cubeMX project ?

    If yes cann you give me an ioc file or the source code.

    I need FreeRTOS and LWIP anaways so this dependecies are not a problem for me.

    https://github.com/BeSeeTek/STM32F767zi_PTP_FreeRTOS/tree/main/Firmware this is what if got as blank cube MX code so far.

    Is it normal that

    #define ETH_RX_BUF_SIZE /* buffer size for receive */

    in Core/Inc/stm32f7xx_hal_conf.h is empty an the code generated from cubeMX does not compile with out manualy patching that ?

    Graduate II
    February 6, 2023

    I am using CubeMX only for very basic IO and clock setup, maybe for UART or ADC when I'm lazy...

    And NOT using any OS.

    F767:

    I had some problems when TX streaming TCP, I had to set memory alignment to 8 (64 bit, makes sense for some parts), but still had problems when http / SSI / CGI worked with some short and odd-numbered pbufs.

    These problems are completely gone with the H723 and the adapted driver.