Skip to content
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

[network] fixes Ethernet default config/validation, minor optimizations #2846

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

avtolstoy
Copy link
Member

@avtolstoy avtolstoy commented Dec 11, 2024

Problem

PIN_INVALID should not be used as a default pin setting for wiznet config. It's very easy to put ethernet driver into a not so performant mode due to lack of interrupt pin configuration.

Solution

PIN_INVALID should not be used to reset the settings, as currently calling

        if_wiznet_pin_remap remap = {};
        remap.base.type = IF_WIZNET_DRIVER_SPECIFIC_PIN_REMAP;

        remap.cs_pin = PIN_INVALID; // default
        remap.reset_pin = PIN_INVALID; // default
        remap.int_pin = PIN_INVALID; // default

        auto ret = if_request(nullptr, IF_REQ_DRIVER_SPECIFIC, &remap, sizeof(remap), nullptr);

will result in cs_pin being properly overridden to defaults, but not RESET or INT. This is not in public docs, but a couple of test apps are using this.

Reset to defaults should be:

        if_wiznet_pin_remap remap = {};
        remap.base.type = IF_WIZNET_DRIVER_SPECIFIC_PIN_REMAP;

        remap.cs_pin = HAL_PLATFORM_ETHERNET_WIZNETIF_CS_PIN_DEFAULT; // default
        remap.reset_pin = HAL_PLATFORM_ETHERNET_WIZNETIF_RESET_PIN_DEFAULT; // default
        remap.int_pin = HAL_PLATFORM_ETHERNET_WIZNETIF_INT_PIN_DEFAULT; // default

        auto ret = if_request(nullptr, IF_REQ_DRIVER_SPECIFIC, &remap, sizeof(remap), nullptr);

until we introduce a nicer API.

When loading the config from filesystem, if we see cs_pin = PIN_INVALID - invalidate the whole config to the defaults. This is NOT a valid configuration and it's better to just revert to defaults.

Setting reset_pin or int_pin to PIN_INVALID is still allowed.

This PR also includes some minor optimizations to ethernet driver itself.

Steps to Test

N/A

Example App

N/A

References

Links to the Community, Docs, Other Issues, etc..


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@technobly technobly removed the request for review from scott-brust December 11, 2024 16:53
@avtolstoy avtolstoy merged commit 6caead0 into develop Dec 11, 2024
13 checks passed
@avtolstoy avtolstoy deleted the fix/eth-config branch December 11, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants