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

Fix build issues with cellular #397

Conversation

ccli8
Copy link

@ccli8 ccli8 commented Nov 28, 2024

Summary of changes

This fixes cellular build issues, including:

  1. Add back weak CellularInterface::get_default_instance so that cellular driver can provide default just overriding CellularDevice::get_default_instance.
  2. Like Fix wifi cannot configure as default network interface #377, fix CellularDevice::get_default_instance coming from static library cannot participate in linking and so cannot override.
  3. Fix ThisThread::sleep_until link error, this is caused by mismatch on MBED_CONF_RTOS_PRESENT defined or not between executable and mbed-cellular targets.

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)

The enables the cellular call flow below:
1. Weak CellularInterface::get_default_instance (NetworkInterfaceDefaults.cpp)
2. Weak CellularInterface::get_target_default_instance (NetworkInterfaceDefaults.cpp)
3. Weak CellularContext::get_default_instance (CellularContext.cpp)
4. Weak CellularDevice::get_default_instance (CellularDevice.cpp)
5. Weak CellularDevice::get_target_default_instance (CellularDevice.cpp)

So that cellular modem driver can override CellularDevice::get_default_instance
or CellularDevice::get_target_default_instance to provide actual default
instance.
With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in the object
file implemening CellularDevice::get_default_instance anyway for being
able to override weak symbol successfully even though from static library.

See: https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
ATHandler::cmd_start (ATHandler.c) calls ThisThread::sleep_until, which
has parameter abs_time, whose type is Clock::time_point. Clock::time_point
type has different definitions dependent on MBED_CONF_RTOS_PRESENT defined
or not (rtos/Kernel.h). For cellular application whose executable cmake
target always links mbed-os rather than mbed-baremetal, mbed-cellular must
also link mbed-rtos-flags to be consistent with executable, so that both
have MBED_CONF_RTOS_PRESENT defined.
Copy link
Collaborator

@multiplemonomials multiplemonomials left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@multiplemonomials multiplemonomials merged commit df28d42 into mbed-ce:master Dec 4, 2024
52 checks passed
@ccli8 ccli8 deleted the cellular_default_instance_n_link_undefine branch December 5, 2024 01:15
@ccli8 ccli8 restored the cellular_default_instance_n_link_undefine branch December 6, 2024 08:41
@ccli8 ccli8 deleted the cellular_default_instance_n_link_undefine branch December 6, 2024 08:43
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