Skip to content

EthernetInterface fix detecting change of connection status on ARCH_MAX #12405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

zhiyong-ft
Copy link

Summary of changes

Fixed bug that EthernetInterface doesn't detect change of connection status on ARCH_MAX boards, and also provided facility to change/override default Ethernet PHY address for STM32 based customized boards.

Bug was described in the following thread.
#12367

Impact of changes

None

Migration actions required

None

Documentation

To change default Ethernet PHY address, add the following entry into mbed_app.json:

 "ARCH_MAX": {
     "stm32-emac.eth-phyaddr": 1
 }

Pull request type

[X] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[X] Tests / results supplied as part of this PR

Bug on ARCH_MAX board was fixed by adding overriding entry described in documentation section. The same test code compiled for NUCLEO_F429ZI also works.


Reviewers


@eg-astrouka @toyowata @ARMmbed/mbed-os-ipcore

…status on ARCH_MAX board.

ARCH_MAX board uses 0x01 as PHY address, different from other NUCLEO STM32 boards. To faciliate change of PHY address of customized boards, a configuration entry eth-phyaddr was added and can be overriden as needed in mbed_app.json by adding "stm32-emac.eth-phyaddr": X. Macro ETH_ARCH_PHY_ADDRESS was also renamed to ETH_PHY_ADDRESS, because it is not only used by ARCH_MAX board but also other boards.
@ciarmcom
Copy link
Member

@zhiyong80, thank you for your changes.
@toyowata @ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-maintainers please review.

@ciarmcom ciarmcom requested review from toyowata and a team February 11, 2020 04:00
Copy link
Contributor

@michalpasztamobica michalpasztamobica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a smart fix to me, but let's improve the mbed_lib.json a little bit, please.

@@ -2,7 +2,8 @@
"name": "stm32-emac",
"config": {
"eth-rxbufnb": 4,
"eth-txbufnb": 4
"eth-txbufnb": 4,
"eth-phyaddr": 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be reasonable to add a target_override below for ARCH_MAX? Like this:

 "target_overrides": {
        ...
        "ARCH_MAX": {
            "eth-phyaddr": 0
        }
    }

This way user wouldn't have to figure things out on his/her own.
Also - Some documentation explaining what this option exactly stands for would be a good idea. For example:

"config": {
        "eth-rxbufnb": 4,
        "eth-phyaddr": {
            "help" : "Configures the expected value of PHYAD0 pin (0 for pulled-down or 1 for pulled-up",
            "options": [0, 1],
            "value" : 0
        }

Feel free to come up with a better description or remove the option limitation, if I misunderstood how this pin works.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, I would change the default for ARCH_MAX to 1 and options can be an array of different values depending on PHY used. DP83848 can use any value between 0 ~ 31. LAN8742 uses only 0 and 1 though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, ARCH_MAX should use 1 by default, not 0.
I am not sure if there is a way to define a range of numbers neatly in mbed_lib.json. I haven't found such configuration in any of the existing mbed_lib.jsons and from json docs I read that you'd have to set a "minimum" and "maximum" values. If you feel like experimenting with this, go ahead, but it's also fine to give up on the "options" field and just specify the valid values in the "help" message.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just took out the options line. If someone is adventurous enough to play with with PHYAD pins, he/she will figure out what value to put there:)

@zhiyong-ft
Copy link
Author

Can anyone test the status change bug on other STM32 based Ethernet boards? ODIN-W2 and u-blox C030 seem need to use 1 as well.

@michalpasztamobica
Copy link
Contributor

@zhiyong80 , to my understanding the PHYADDR stays the same (0) for all boards apart from ARCH_MAX? I don't think it is necessary to test them all, if nothing changed for them. Our CI will run quite some STM boards, once started, so we will be able to see any potential failures.

@michalpasztamobica
Copy link
Contributor

michalpasztamobica commented Feb 11, 2020

And one more thing - if the PHYADDR has a value dependent on a pull-up/pull-down configuration then how come it can have any value other than [0, 1] (up to 31, you said)? Is there something else influencing this value? Perhaps the "help" field needs a further update?

@zhiyong-ft
Copy link
Author

@michalpasztamobica Once the board is designed and manufactured, phy address will stay the same. But people may design their own boards and change the strapping of PHYAD pin(s), therefore need to override it.

Copy link
Contributor

@michalpasztamobica michalpasztamobica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current version looks good to me.

@zhiyong-ft
Copy link
Author

zhiyong-ft commented Feb 11, 2020

UBox boards seem to pullup PHYAD0 during initialization. But you are right all 144pin nucleo boards have PHYAD0 pulled down, and DISCO boards don't pullup/down PHYAD0 so default 0 will be used as well.

@michalpasztamobica
Copy link
Contributor

@zhiyong80 , I guess CI might not have a test which plugs the ethernet cable in and out ;-). I will test UBLOX_EVK_ODIN_W2 on my desk and come back to you with the results. Perhaps we need to add another "target_override" for Ublox.

Copy link
Collaborator

@jeromecoutant jeromecoutant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could remove ETH_PHY_ADDRESS definition,
and use /
EthHandle.Init.PhyAddress = MBED_CONF_STM32_EMAC_ETH_PHYADDR;

@michalpasztamobica
Copy link
Contributor

@zhiyong80 , regarding UBLOX_EVK_ODIN_W2, with the current master branch it works fine:

210: Network Status = 3
211: Network Status = 3
// Here I disconnected the network cable
212: Network Status = 1
213: Network Status = 1

So I guess it needs 0 in PHYADDR or perhaps this value gets overridden somewhere else in the code. Anyway - it should work with the current setting and no need to add a separate "target_override" for it.

@zhiyong-ft
Copy link
Author

zhiyong-ft commented Feb 11, 2020

And one more thing - if the PHYADDR has a value dependent on a pull-up/pull-down configuration then how come it can have any value other than [0, 1] (up to 31, you said)? Is there something else influencing this value? Perhaps the "help" field needs a further update?

Because some Phy have more than 1 PHYAD pin, DP83848 has 5, but other Phy used by STM32 based Ethernet boards do have only 1 PHYAD pin. Unfortunately pulling PHYAD0 on DP83848 has other implications.

@zhiyong-ft
Copy link
Author

You could remove ETH_PHY_ADDRESS definition,
and use /
EthHandle.Init.PhyAddress = MBED_CONF_STM32_EMAC_ETH_PHYADDR;

I would prefer to keep this extra line, otherwise it breaks the pattern of original code.

@mergify mergify bot added needs: CI and removed needs: review labels Feb 12, 2020
@0xc0170 0xc0170 added the release-version: 6.0.0-alpha-2 Second pre-release version of 6.0.0 label Feb 12, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Feb 12, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented Feb 13, 2020

Test run: FAILED

Summary: 1 of 11 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_dynamic-memory-usage

@mergify mergify bot removed the needs: CI label Feb 13, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Feb 13, 2020

Job restarted (internal fault)

@0xc0170 0xc0170 changed the title Fixed bug that EthernetInterface doesn't detect change of connection status on ARCH_MAX board EthernetInterface fix detecting change of connection status on ARCH_MAX Feb 13, 2020
@0xc0170 0xc0170 merged commit 667f8bb into ARMmbed:master Feb 13, 2020
@mergify mergify bot removed the ready for merge label Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-version: 6.0.0-alpha-2 Second pre-release version of 6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants