Skip to main content
Explorer II
October 7, 2024
Solved

HAL MDIO on Nucleo-H7A3ZI-Q

  • October 7, 2024
  • 9 replies
  • 3283 views

Hello everyone,

 

I would like to know if the Nucleo-H7A3ZI-Q supports the MDIO to external Ethernet PHY control via SMI (MDC and MDIO). I have the setup connected, and I have programmed it accordingly but the MDC and MDIO Lines are always LOW, not even a hint of toggling or any thing on the PINS when viewed on a logic analyser.

This brings me to my question. Does the Nucleo-H7A3ZI-Q support control on an external PHY.

 

Best regards

    This topic has been closed for replies.
    Best answer by STea

    Hello @Promise_Conti ,

    MDIOS can't communicate with an external PHY because the PHY will behave as a slave also so no one will initiate the communication.
    you need to have a master communicating with MDIOS providing its clock so normally you will not see any traffic on the MDIO /MDC lines as a clock and a command to the address programmed in the slave should be provided.

    otherwise MDIO/MDC are quite simple to emulate using normal GPIO if you are constrained to use this product series, or you can switch to a product supporting master MDIO/MDC communication.
    please refer to sections 59.3.3 and 59.3.5 of RM.
    Regards

    9 replies

    Graduate II
    October 7, 2024

    I don't see any ethernet components (RJ45, transformer, PHY) on this photo:

    https://www.st.com/en/evaluation-tools/nucleo-h7a3zi-q.html

    Edit: H7A / H7B do NOT have ethernet peripheral!

     

    Before that, I wrote:

    I don't know.

    But to find out:

    - check the Nucleo schematics and find the SMI pins

    - search the source code for GPIO init of these pins (could be in ../lwip/target/ethernetif.c)

    - compare to datasheet / GPIO alternate functions

    - ...

    Explorer II
    October 8, 2024

    Hi LCE,

    I do not need the On board PHY or any of the Analogue Front End circuitry, I only need the MDC and MDIO pins (on PC1 and PA2) to communicate with an external PHY on another board.

    - check the Nucleo schematics and find the SMI pins

            Response: Pins are on PC1 and PA2

     

    - search the source code for GPIO init of these pins (could be in ../lwip/target/ethernetif.c)

           This might be what I am missing. Can you please elaborate more, I have the PINS initilized as  "static void MX_MDIOS_Init(void);". I did not bother with the Ethernet communication since I only need the SMI.

    Do I necessarily need to initialize the ETH?

    Technical Moderator
    October 7, 2024

    Hello @Promise_Conti and welcome to the community,

    By defaults, Nucleo-H7A3ZI-Q does not have the PHY nor the transformer for the ethernet function.

    See the schematics. All the components related to the ETH are not fitted:

    SofLit_0-1728311563820.png

     

     

    Explorer II
    October 8, 2024

    Hello SofLit,

     

    I do not need the onboard Ethernet PHY on the Evaluation board, I only need the SMI (MDC and MDIO) pins, I have an Ethernet PHY on an external board with I would like to communicate with.

     

    According to DS the PA2 and PC1 should support this function, but this does not respond and are always LOW

    Promise_Conti_0-1728365678200.png

     

    ST Employee
    October 7, 2024

    As LCE wrote, the STM32H7A3 series don't have Ethernet . In particular, no ethernet MAC component.

    There is a STM32 peripheral called "MDIOS" ("Management data input/output") that could be used for very basic serial interface, but the Ethernet MAC component is missing in this specific STM32H7 to do real Ethernet communication with an external PHY.

    Ethernet MACs are present in other STM32H7s.

    Explorer II
    October 8, 2024

    Hi Guillaume K,

     

    I do not need an onboard PHY, I have a PHY on an external Board which I would like to communicate with.

    The STM32H7A3 seems to have the MDIO interface, my problem is that it seems responsive even when called via HAL_MDIO 

    Promise_Conti_1-1728365800476.png

     

    Graduate II
    October 8, 2024

    Get a Nucleo H723, it's a "simple" (ha!) single core H7 with ethernet and PHY on the board.

    Explorer II
    October 8, 2024

    Hello LCE, 

    I have no need for an On-the-Board PHY, I already have an external PHY with I would like to communicate with

    Graduate II
    October 8, 2024

    Interesting, I never saw the MDIO interface on ICs without ethernet before.

    If there's no ETH peripheral, you cannot init it.

    But then you probably have to init the MDIO peripheral (it looks like it is an extra peripheral), starting with the clock etcpp.

    And init the GPIOs with the MDIO alternate functions (check datasheet), which you probably do in  "static void MX_MDIOS_Init(void);" ?

     

    Explorer II
    October 8, 2024

    Hi LCE,

     

    for my use case, I do not care about the actual Ethernet Traffic, therefore I pay not attention to the RMII interfaces. I only to have access to the external PHY registers via SMI. 

    Can you expand more on the init the MDIO peripheral, I think I am definitely missing a step that's why the SMI lines are LOW, Where can I find the clock.cpp?

    Graduate II
    October 8, 2024

    clock.cpp?

    I don't know the H7A, but from the screenshot it looks like the H7A has an MDIO peripheral, very similar to other peripherals, like SPI, I2C, ADC...

    So only guessing from here (no time to download and check datasheet / ref manual -> your job), if MDIO is a peripheral, it is usually set up / initialized by:

    - starting the peripheral clock (some HAL function like HAL_CLK_ENABLE_MDIO() or so)
    - configuring the GPIO pins
    - setting some MDIO registers

    Is there a function like "MX_MDIO_init()" or so?

    Explorer II
    October 8, 2024

    Hi LCE, 

     

    These are the functions I have on the Initilization:

     HAL_MDIOS_Init(&hmdios);

    MDIOS_HandleTypeDef hmdios;

    static void MX_MDIOS_Init(void)
    {
    
     /* USER CODE BEGIN MDIOS_Init 0 */
    
     /* USER CODE END MDIOS_Init 0 */
    
     /* USER CODE BEGIN MDIOS_Init 1 */
    
     /* USER CODE END MDIOS_Init 1 */
     hmdios.Instance = MDIOS;
     hmdios.Init.PortAddress = 0x09; // User defined address
     hmdios.Init.PreambleCheck = MDIOS_PREAMBLE_CHECK_ENABLE;
     if (HAL_MDIOS_Init(&hmdios) != HAL_OK)
     {
     Error_Handler();
     }
     /* USER CODE BEGIN MDIOS_Init 2 */
    
     /* USER CODE END MDIOS_Init 2 */
    
    }
    Explorer II
    October 8, 2024

    But the issue still persists.

    Graduate II
    October 8, 2024

    HAL_xyz_Init() usually calls a function named like HAL_xyz_MspInit(), which should be in the same xyz.c file.

    That one usually enables the peripheral clock and sets up the GPIOs.

    STeaAnswer
    ST Employee
    October 9, 2024

    Hello @Promise_Conti ,

    MDIOS can't communicate with an external PHY because the PHY will behave as a slave also so no one will initiate the communication.
    you need to have a master communicating with MDIOS providing its clock so normally you will not see any traffic on the MDIO /MDC lines as a clock and a command to the address programmed in the slave should be provided.

    otherwise MDIO/MDC are quite simple to emulate using normal GPIO if you are constrained to use this product series, or you can switch to a product supporting master MDIO/MDC communication.
    please refer to sections 59.3.3 and 59.3.5 of RM.
    Regards

    Explorer II
    October 10, 2024

    Hello @STea ,

     

    You are right, the Nucleo-H7A3ZI-Q cannot initiate the SMI communication because it is also a SLAVE ( I found this choice of architecture really fascinating as I would have expected MCUs to serve as ETH MAC Master and definately not as SLAVE to another MCU).

    This issue seems to also have been treated here How to generate MDC 

     

    Thanks for your support, I will switch to another Product

    Graduate II
    October 10, 2024

    @STea just curious, what's that MDIO slave-only interface for?

    ST Employee
    October 10, 2024

    Hello @LCE ,

    a usecase that I imagine is possible for this Periph is to control switch ports VIA gpios by receiving commands form to manage network stations for example. it can be set to communicate networking configuration Data as well.
    Regards