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] postpone ethernet interface initialization to allow STARTUP() call to override pin configuration without a reset #2847

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

avtolstoy
Copy link
Member

PR is based on #2846

Description

As title says. Postpones Ethernet interface initialization until after power management is initialized for all the platforms (even without aux power support). This happens after global app constructors are called, so should allow STARTUP() to override pin configuration for W5500.

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)

…() call to override pin configuration without a reset
@avtolstoy avtolstoy added this to the 6.3.0 milestone Dec 11, 2024
Copy link
Member

@technobly technobly left a comment

Choose a reason for hiding this comment

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

LGTM, please also see comments 👍🏼

bool postpone_;
hal_pin_t cs_ = PIN_INVALID;
hal_pin_t reset_ = PIN_INVALID;
hal_pin_t interrupt_ = PIN_INVALID;
Copy link
Member

Choose a reason for hiding this comment

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

Use defaults?
HAL_PLATFORM_ETHERNET_WIZNETIF_CS_PIN_DEFAULT
HAL_PLATFORM_ETHERNET_WIZNETIF_RESET_PIN_DEFAULT
HAL_PLATFORM_ETHERNET_WIZNETIF_INT_PIN_DEFAULT

Copy link
Member Author

Choose a reason for hiding this comment

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

The defaults are in the WizNetConfig. I've left things as much as possible to how it was before: settings coming from network.cpp. Could set to defaults here too.

if (wizNetif->init(wizNetifConfigData) == 0) {
return 0;
}
LOG(INFO, "Remove Ethernet interface");
Copy link
Member

Choose a reason for hiding this comment

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

Should this be more like LOG(ERROR, "Error Initializing Ethernet");

I won't duplicate my comment for all of the rest of them ;-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, might be better to make it something like not detected

@@ -173,6 +169,28 @@ int if_init_platform(void*) {
return 0;
}

#if HAL_PLATFORM_IF_INIT_POSTPONE
Copy link
Member

Choose a reason for hiding this comment

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

Should the call to if_init_platform_postpone(nullptr); in main.cpp be wrapped in #if HAL_PLATFORM_IF_INIT_POSTPONE ... #endif as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably, but there is always a default weak empty function anyway and it was like that before.

@technobly
Copy link
Member

I think this may also require a documentation change to our example on how to setup the Wiznet Pin Config, simplifying it.

@technobly technobly removed the request for review from scott-brust December 11, 2024 16:53
@avtolstoy avtolstoy merged commit 24a2661 into fix/eth-config Dec 11, 2024
1 check passed
@avtolstoy avtolstoy deleted the feature/eth-config-startup branch December 11, 2024 17:27
@@ -318,7 +328,7 @@ bool WizNetif::isPresent(bool retry) {
cv = getVERSIONR();
/* VERSIONR always indicates the W5500 version as 0x04 */
if (cv != 0x04 && retry) {
HAL_Delay_Milliseconds(50);
HAL_Delay_Milliseconds(10);
Copy link
Member

Choose a reason for hiding this comment

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

@avtolstoy The delay is not enough to detect the W5500 on Muon. Cc. @artyLee

@avtolstoy avtolstoy mentioned this pull request Jan 21, 2025
6 tasks
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.

3 participants