cpu/stm32: Fix & cleanup periph_eth#15193
Conversation
|
@JannesVolkens: You have a Nucleo-F207ZG if I recall correctly. Could you test this PR on this board? @bergzand: You have a Nucleo-F746ZG if I recall correctly. Could you test this PR? @aabadie: Care to confirm my test results on the Nucleo-F767ZI? |
|
BTW: Now that I know what is causing #13490 I should come up with a fix swiftly. But first let me split out the MII definitions from |
|
Fixed typo in commit message |
|
Everything is working correctly on the nucleo-f207zg! Output:
|
|
Will this need a backport? |
Wouldn't hurt :-) |
I agree that this fixes a bug. I'm fine with a backport for this. Thanks! |
|
Hmm, I think I should use |
The methods to read from / write to MII registers had an address argument to allow specifying the PHY to communicate with. However, only a single PHY is available on all boards supported and the driver is not able to operate with multiple PHYs anyway - thus, drop this parameter for ease of use. This fixes a bug in the _get_link_status() function, which used hard coded the address 0; which might not be correct for all boards.
Fix PHY address in eth_config. It should be 0 for these boards, not 1. This is why previously the link status read out worked with an hard code PHY address 0 before. Some dubious references for 0 being the correct PHY address and not 1 (in absence of proper references): https://www.carminenoviello.com/2016/01/22/getting-started-stm32-nucleo-f746zg/ https://community.st.com/s/question/0D50X00009XkgfISAR/stm32f767-nucleo-ethernet-not-working
Fixed. Test results remain valid: Due to integer promotion of
I propose to only backport the second commit and keep the hard coded phy address of 0 for the link status. All Nucleos supported by that branch use 0 as phy address (so the hard coded value is correct for all of them) and no new board support is going to be back-ported. Otherwise I would have to decide on whether to also backport the clean-up, or fix it completely differently in the stable branch. |
benpicco
left a comment
There was a problem hiding this comment.
Pretty straightforward and @JannesVolkens confirmed it's working.
|
Thanks! |
Contribution description
The function to check the link status of the STM32 Ethernet peripheral used the hard coded PHY address 0, rather than the configured address. This made me realize that the API of the MII register access functions sucks, as only one PHY is supported anyway.
Testing procedure
E.g. flash
examples/gnrc_networkingifconfigshould still properly see the link statusping6 <addr>should work, unless the issue in cpu/stm32/eth, board/nucleo-f767z1: ethernet initialisation fails sometimes #13490 hits (roughly one out of three boots)Issues/PRs references
None