cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP157F-DK2 + Arduino Ethernet Shield + w5100-spi.c linux driver

mpu
Associate

I am attempting to implement a second ethernet interface on STM32MP157F-DK2 by using the Arduino Ethernet Shield, which is based on the Wiznet W5500 chip. The implementation aims to use SPI assigned to A7 core to communicate with the shield, which will then convert the SPI messages to be transferred over Ethernet. I have been unsuccessful in configuring this thus far and would like any help possible.

 

What I have tried so far:

- Modification of the kernel was done using the following page: 

https://wiki.st.com/stm32mpu/wiki/How_to_cross-compile_with_the_Distribution_Package 

1. Modified the distribution package using menuconfig to include W5500 support such that CONFIG_WIZNET_5100=y and CONFIG_WIZNET_5100_SPI=y. It is my intention to use linux/drivers/net/ethernet/wiznet/w5100-spi.c in order to achieve my goal of SPI->Ethernet.

 

Specific Problems:

- I am not sure how to configure SPI4 in the device tree for this application. I am hoping to follow https://github.com/torvalds/linux/commit/0114214eca21e85d66a5e206f803db42d1d07960.

- I am using STM32CubeIDE to create and deploy the user applications. The application was created within the CA7 project as referenced by https://wiki.st.com/stm32mpu/wiki/How_to_manage_OpenSTLinux_projects_in_STM32CubeIDE.  Unfortunately, STM32CubeIDE has no knowledge of the changes made by menuconfig and the SDK (4.2.1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sysroots/cortexa7t2hf-neon-vfph4-ostl-linux-gnueabi/usr/include) does not include certain files that are needed to compile linux/drivers/net/ethernet/wiznet/w5100-spi.c and linux/drivers/net/ethernet/wiznet/w5100.c/h, even though the necessary files are in the adjacent sources folder of the CA7 project, "linux-6.1.28/include/linux". How could I go about adding the support for this driver so that I can use it in STM32CubeIDE?

- It is my understanding that linux/drivers/net/ethernet/wiznet/w5100-spi.c requires configuring a net device. Is it sufficient to simply write:

struct net_device *dev;

w5500_spi_init(dev);

and then assume the configuration is complete since SPI4 is assigned the .compatible="wiznet,w5500"?

I do have access to the ethernet configuration for the only other device on the bus.

 

I am open to modifying any part of the implementation.

For example, I have been able to successfully use spidev on SPI4 to send and receive messages to/from itself, but I was unsuccessful in getting the Arduino Ethernet Shield to work in response to the SPI4 messages. 

If need be, I would be willing to use the rj45 connector on board for this ethernet to send and receive packets using tcp, but I do not know how to do this and I would still need to solve the problem of adding another ethernet port in the future.

3 REPLIES 3
Erwan SZYMANSKI
ST Employee

Hello @mpu ,
Well, a lot of different information are given in your first message, so I will try to take points one by one based on what I understood.

1) You seems to well activate the Kernel configuration needed to make the driver of your module working, it is a first good point. 

2) Based on the example given by Linux documentation, you took inspiration from this last one to complete the stm32mp157f-dk2.dts file, adding a subnode under &spi4 one. Once again, good point, that is exactly the step. However, can you copy here this part of device tree ? I would like to double check that you took the right pinctrl configuration. The good pinctrl configuration is already defined in stm32mp15-pinctrl.dsti file, and for arduino connector it should be spi4_pins_b. The property is by default like this, defined in stm32mp15xx-dkx.dsti.

3) What about the boot ? Did you check that your driver is well probed ? You can check in "dmesg" if you have specific SPI logs, and also a /dev/spixxx device should have been created. Moreover, as this driver is made for ethernet, I would not be surprised that if you enter "ifconfig -a", you should see another ethernet interface (I do not know which name it will take).

4) Finaly, to test, I imagine that you need to configure the Ethernet interface the same way you could do on Linux with a standard interface (I imagine that the w5100 driver is like an interface, and so transparent for you), and see if you can UP the interface, set IP address and so on ...

I hope that my message will help you to go forward and that I well understood your setup. Please if I misunderstood something, let me know. Moreover, if there is a blocker point in the 4 mentioned above, let me know too.

Kind regards,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Erwan,

 

 

Thank you for your reply.

The spi4 node defined in stm32mp15xx-dkx.dtsi is as follows:

&spi4 { 
        pinctrl-names = “default”, “sleep”; 
        pinctrl-0 = <&spi4_pins_b>; 
        pinctrl-1 = <&spi4_sleep_pins_b>;	 
        status = “okay”; 

        w5500@0{ 
	        compatible = “wiznet,w5500”; 
	        reg = <0>;
            interrupt-parent = <&pinctrl>; 
            interrupts = <25 IRQ_TYPE_EDGE_FALLING>; 
          	spi-max-frequency = <10000000>; 
        }; 
}; 

In order to update the device tree, I did not follow the wiki document to cross compile with the distribution package. Instead, I sourced the SDK in a new terminal window and used "make stm32mp157f-dk2.dtb". The result of the make command appears to be successful, but the output generates the following warning:

arch/arm/boot/dts/stm32mp151.dtsi:1953.29-2083.5: Warning (interrupts_property): /soc/pinctrl@50002000: Missing interrupt-controller or interrupt-map property

        also defined at arch/arm/boot/dts/stm32mp15-pinctrl.dtsi:8.10-2531.3

        also defined at arch/arm/boot/dts/stm32mp15xxac-pinctrl.dtsi:7.10-63.3

        also defined at arch/arm/boot/dts/stm32mp15-m4-srm-pinctrl.dtsi:7.10-507.3

 

After using scp to overwrite the .dtb file on the running target, I note that there is no /dev/spixxx device and the only ethernet interfaces according to "ifconfig -a" are the default "end0, wlan0, lo, and usb0." By utilizing dmesg, I was able to find that the spi driver was initialized:

[15.364764] spi_stm32 44005000.spi: driver initialized (master mode)

 

I was not able to find any device or dmesg statement that pointed towards the existence of w5500@0.

 

I have attempted multiple placements and omissions of the various assignments in &spi4 and the aforementioned code has produced the best results (spi driver initialized). Removing the interrupt-parent and interrupts assignment entirely still produce the same results, but there is no error when executing the make command.

Hi @mpu ,
I am a little bit surprised to not see dmsg logs related to your shield driver. But I have not a relevant setup to replicate on my side unfortunately .

Did you already try to probe your shield driver manualy, with an "insmod" command to see the ouput ?

Kind regards,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.