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

Support wifi as default network interface #373

Closed

Conversation

ccli8
Copy link

@ccli8 ccli8 commented Oct 15, 2024

Summary of changes

This supports configuring WiFi as default network interface. This support requires overriding weak symbol WiFiInterface::get_default_instance when e.g. "esp8266.provide-default: true" is specified in mbed_app.json. The override will fail because WiFi objects are archived in static library libmbed-wifi.a and don't participate in linking as expected, dependent on linker and library link order. To fix this, the override objects are extracted and passed to linker command line so that they always participate in the linking.


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)

@ccli8 ccli8 force-pushed the support_wifi_as_default_network_interface branch 4 times, most recently from 2597b53 to 7c2d892 Compare October 16, 2024 07:47
This fixes WiFi doesn't get linked in when configued as default network
interface.
The location where the 'mbed-wifi' target is created is now fixed to the
top directory. CMake commands e.g. add_custom_command are required to
invoke in the same directory as where the 'mbed-wifi' target is created.
This requires support for weak symbol override. Object files arcived in
static library don't always participate in linking, dependent on linker
and link order. To fix this, the object files which will override weak
symbols are extracted and passed to linker command line separately to
actively participate in linking.
@ccli8 ccli8 force-pushed the support_wifi_as_default_network_interface branch from 7c2d892 to 67b6fd9 Compare October 17, 2024 02:36
@multiplemonomials
Copy link
Collaborator

Hmm, I'm confused why this is needed... I have successfully used Arduino boards with Mbed CE that use Cypress WHD wifi modules, and I do not believe those needed anything special to get the default network interface to work

@multiplemonomials
Copy link
Collaborator

Actually no, you're right, this is an issue as the weak symbol override is defined in a .a file. How the heck did this work before?

Anyway, I guess we either need to do this, or we need to do something like move the definitions of WiFiInterface::get_target_default_instance() from the wifi drivers into NetworkInterfaceDefaults.cpp.

@ccli8
Copy link
Author

ccli8 commented Oct 18, 2024

Actually no, you're right, this is an issue as the weak symbol override is defined in a .a file. How the heck did this work before?

In Mbed CLI 2, mbed-wifi is interface library, not static library. It is e.g. ESP8266Interface.cpp.obj for ESP8266 WiFi not libmbed-wifi.a which appears in the linker command line. ESP8266Interface.cpp.obj can override weak symbol anyway.

or we need to do something like move the definitions of WiFiInterface::get_target_default_instance() from the wifi drivers into NetworkInterfaceDefaults.cpp.

This would be more concise. But if the override comes from another wifi library out of mbed-os tree, then it also cannot override unless it can apply either of above approaches.

@ccli8
Copy link
Author

ccli8 commented Oct 28, 2024

Fixed via #377

@ccli8 ccli8 closed this Oct 28, 2024
@ccli8 ccli8 deleted the support_wifi_as_default_network_interface branch October 28, 2024 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants