0

I'm developing an application for STM32F4 with Azure RTOS Netx Duo. In particular I'm trying to adapt the example Nx_TCP_Echo_Server application for my board where is present the Ethernet Phy ADIN1200 produced by Analog Devices.

Note about example Nx_TCP_Echo_Server

The Nx_TCP_Echo_Server example application has been made for a STM32F429ZI-NUCLEO demo board (code of Nx_TCP_Echo_Server on github).
In the demo board STM32F429ZI-NUCLEO the Ethernet Phy is compatible with the lan8742 driver (see the lan8742 driver code on GitHub). Unfortunately the Ethernet PHY ADIN1200 present on my board is not compatible with that driver.

I have noted that the sixth parameter of the function nx_ip_create() is the pointer function nx_stm32_eth_driver. This pointer function points to lan8742 driver.
Below I show the invocation of the function nx_ip_create() present in the file app_netxduo.c (code of app_netxduo.c) of the Nx_TCP_Echo_Server example application:

/* Create the main NX_IP instance */
  ret = nx_ip_create(&IpInstance, "Main Ip instance", NULL_ADDRESS, NULL_ADDRESS, &AppPool, nx_stm32_eth_driver,
                     pointer, 2 * DEFAULT_MEMORY_SIZE, DEFAULT_PRIORITY);

The documentation of NetX Duo reports the following info:

The NX_IP structure contains everything to manage a single IP instance. This includes general TCP/IP protocol information as well as the application-specific physical network driver's entry routine. The driver's entry routine is defined during the nx_ip_create service. Additional devices may be added to the IP instance via the nx_ip_interface_attach service.

My development environment

My development environment is composed by:

  • STM32CubeMX version 6.7.0
  • In the STM32CubeMX I have installed the Package STM32F4 version 1.27.1
  • To use ThreadX I have added to CubeMX the software pack X-CUBE-AZRTOS-F4 version 1.1.0

By the previous environment I can find only the driver for LAN8742.

My question

How can I find other Ethernet PHY drivers for NetX Duo other than the one for lan8742?


EDIT

I have found this driver for ADIN1200 but it is very far from the driver lan8742.c provided by my development tool (see the code of lan8742).
In fact the API of the 2 drivers are very different; for example NetX Duo (and before it: LwIP) needs a function like LAN8742_RegisterBusIO() (present in the LAN8742 driver) to init a structure with pointer functions useful to write and read registers of the Ethernet PHY, but in this driver this function and its data structures are not present.

frankfalse
  • 1,553
  • 1
  • 4
  • 17
  • 1
    You try to do cargo-cult programming. The driver will help understand how the chip (but it will not replace the documentation) works. Having this knowledge you can port it to threadx. – 0___________ Feb 07 '23 at 22:50

1 Answers1

1

You can find different phy drivers from https://github.com/azure-rtos/samples.

  • mimxrt1060:KSZ8081RNB
  • same54:KSZ8091RNA 
  • stm32f746:LAN8742A-CZ-TR
  • rx65n rsk:DP83620SQE

For others, you will need to develop the driver by yourself, based on existing ones.

  • Thank you very much, I'll try to follow your indication as soon as possible.. Now I have to do an other task. My PHY is ADIN1200 so from Analog Device. I hope that one of the driver present in your link is suited for it. – frankfalse Feb 07 '23 at 07:56
  • I'm looking for the driver in the samples. I have downloaded some of the ZIP files but I can't find the driver code.. Are you sure that in the example is present the code of the Ethernet PHY driver. For example in the example for STMicroelectronics (`Azure_RTOS_6.2_Renesas_CK_RX65N_e2studio_CCRX_Sample_2022_12_28.zip`) I can't find the driver for LAN8742A-CZ-TR! Could you help me to find the code (if you can update your answer). – frankfalse Feb 07 '23 at 08:30
  • 1
    Take [STM32F746](https://github.com/azure-rtos/samples/releases/download/v6.1_rel/Azure_RTOS_6.1_STM32F746G-DISCO_IAR_Samples_2021_11_03.zip) for example, the logic of phy is mixed in HAL APIs. You can find phy initialization in stm32f7xx_hal_eth.c. In latest network driver, ST has separate the phy driver. You can take a look at the [nx_stm32_phy_driver.c](https://github.com/STMicroelectronics/x-cube-azrtos-h7/blob/main/Middlewares/ST/netxduo/common/drivers/ethernet/lan8742/nx_stm32_phy_driver.c). – Tiejun Zhou Feb 09 '23 at 01:34
  • Thank you very much. I'll try to put all the info together and write a driver for the PHY. ADIN1200. – frankfalse Feb 09 '23 at 08:20