Fix build issues with cellular (#397)

* Cellular: Add back weak CellularInterface::get_default_instance

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.

* Cellular: Fix overriding CellularDevice::get_default_instance failure

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

* Cellular: Fix ThisThread::sleep_until link error

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.
pull/15531/head
ccli8 2024-12-04 16:29:33 +08:00 committed by GitHub
parent 2564b2c1bf
commit df28d42a77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 246 additions and 4 deletions

View File

@ -39,5 +39,6 @@ target_link_libraries(mbed-cellular
PUBLIC PUBLIC
mbed-netsocket-api mbed-netsocket-api
mbed-core-flags mbed-core-flags
mbed-rtos-flags
mbed-randlib mbed-randlib
) )

View File

@ -118,5 +118,19 @@ CellularDevice *CellularDevice::get_default_instance()
static ALT1250_PPP device(&serial, MBED_CONF_ALT1250_PPP_RST, PIN_OUTPUT, OpenDrainNoPull, 1); static ALT1250_PPP device(&serial, MBED_CONF_ALT1250_PPP_RST, PIN_OUTPUT, OpenDrainNoPull, 1);
return &device; return &device;
} }
/*
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
* object file 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
*
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
* <LINK_FOO> symbol correctly.
*/
extern "C"
void LINK_ALT1250_PPP_CPP(void)
{
}
#endif #endif

View File

@ -12,3 +12,15 @@ target_sources(mbed-cellular
ALT1250_PPP_CellularContext.cpp ALT1250_PPP_CellularContext.cpp
ALT1250_PPP_CellularNetwork.cpp ALT1250_PPP_CellularNetwork.cpp
) )
# Link override object file coming from static library anyway
#
# NOTE: This linker option is to pretend undefined symbol and won't cause
# undefined symbol error even though the override object file actually
# doesn't provide such symbol definition.
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_link_options(mbed-cellular
INTERFACE
LINKER:--undefined=LINK_ALT1250_PPP_CPP
)
endif()

View File

@ -10,3 +10,15 @@ target_sources(mbed-cellular
PRIVATE PRIVATE
STModCellular.cpp STModCellular.cpp
) )
# Link override object file coming from static library anyway
#
# NOTE: This linker option is to pretend undefined symbol and won't cause
# undefined symbol error even though the override object file actually
# doesn't provide such symbol definition.
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_link_options(mbed-cellular
INTERFACE
LINKER:--undefined=LINK_STMODCELLULAR_CPP
)
endif()

View File

@ -179,5 +179,19 @@ CellularDevice *CellularDevice::get_default_instance()
static STModCellular device(&serial); static STModCellular device(&serial);
return &device; return &device;
} }
/*
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
* object file 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
*
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
* <LINK_FOO> symbol correctly.
*/
extern "C"
void LINK_STMODCELLULAR_CPP(void)
{
}
#endif #endif

View File

@ -13,3 +13,15 @@ target_sources(mbed-cellular
GEMALTO_CINTERION_CellularInformation.cpp GEMALTO_CINTERION_CellularInformation.cpp
GEMALTO_CINTERION_CellularStack.cpp GEMALTO_CINTERION_CellularStack.cpp
) )
# Link override object file coming from static library anyway
#
# NOTE: This linker option is to pretend undefined symbol and won't cause
# undefined symbol error even though the override object file actually
# doesn't provide such symbol definition.
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_link_options(mbed-cellular
INTERFACE
LINKER:--undefined=LINK_GEMALTO_CINTERION_CPP
)
endif()

View File

@ -214,4 +214,18 @@ CellularDevice *CellularDevice::get_default_instance()
static GEMALTO_CINTERION device(&serial); static GEMALTO_CINTERION device(&serial);
return &device; return &device;
} }
/*
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
* object file 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
*
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
* <LINK_FOO> symbol correctly.
*/
extern "C"
void LINK_GEMALTO_CINTERION_CPP(void)
{
}
#endif #endif

View File

@ -10,3 +10,15 @@ target_sources(mbed-cellular
PRIVATE PRIVATE
GENERIC_AT3GPP.cpp GENERIC_AT3GPP.cpp
) )
# Link override object file coming from static library anyway
#
# NOTE: This linker option is to pretend undefined symbol and won't cause
# undefined symbol error even though the override object file actually
# doesn't provide such symbol definition.
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_link_options(mbed-cellular
INTERFACE
LINKER:--undefined=LINK_GENERIC_AT3GPP_CPP
)
endif()

View File

@ -61,4 +61,18 @@ CellularDevice *CellularDevice::get_default_instance()
static GENERIC_AT3GPP device(&serial); static GENERIC_AT3GPP device(&serial);
return &device; return &device;
} }
/*
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
* object file 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
*
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
* <LINK_FOO> symbol correctly.
*/
extern "C"
void LINK_GENERIC_AT3GPP_CPP(void)
{
}
#endif #endif

View File

@ -14,4 +14,16 @@ target_sources(mbed-cellular
if("MTS_DRAGONFLY_L471QG" IN_LIST MBED_TARGET_LABELS) if("MTS_DRAGONFLY_L471QG" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_MTS_DRAGONFLY_L471QG) add_subdirectory(TARGET_MTS_DRAGONFLY_L471QG)
endif() endif()
# Link override object file coming from static library anyway
#
# NOTE: This linker option is to pretend undefined symbol and won't cause
# undefined symbol error even though the override object file actually
# doesn't provide such symbol definition.
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_link_options(mbed-cellular
INTERFACE
LINKER:--undefined=LINK_SARA4_PPP_CPP
)
endif()

View File

@ -185,4 +185,18 @@ CellularDevice *CellularDevice::get_default_instance()
static SARA4_PPP device(&serial); static SARA4_PPP device(&serial);
return &device; return &device;
} }
/*
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
* object file 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
*
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
* <LINK_FOO> symbol correctly.
*/
extern "C"
void LINK_SARA4_PPP_CPP(void)
{
}
#endif #endif

View File

@ -13,3 +13,15 @@ target_sources(mbed-cellular
RM1000_AT_CellularNetwork.cpp RM1000_AT_CellularNetwork.cpp
RM1000_AT_CellularStack.cpp RM1000_AT_CellularStack.cpp
) )
# Link override object file coming from static library anyway
#
# NOTE: This linker option is to pretend undefined symbol and won't cause
# undefined symbol error even though the override object file actually
# doesn't provide such symbol definition.
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_link_options(mbed-cellular
INTERFACE
LINKER:--undefined=LINK_RM1000_AT_CPP
)
endif()

View File

@ -103,5 +103,19 @@ CellularDevice *CellularDevice::get_default_instance()
static RM1000_AT device(&serial); static RM1000_AT device(&serial);
return &device; return &device;
} }
/*
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
* object file 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
*
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
* <LINK_FOO> symbol correctly.
*/
extern "C"
void LINK_RM1000_AT_CPP(void)
{
}
#endif #endif

View File

@ -17,4 +17,16 @@ endif()
if("TARGET_MTS_DRAGONFLY_F413RH" IN_LIST MBED_TARGET_LABELS) if("TARGET_MTS_DRAGONFLY_F413RH" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_MTS_DRAGONFLY_F413RH) add_subdirectory(TARGET_MTS_DRAGONFLY_F413RH)
endif() endif()
# Link override object file coming from static library anyway
#
# NOTE: This linker option is to pretend undefined symbol and won't cause
# undefined symbol error even though the override object file actually
# doesn't provide such symbol definition.
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_link_options(mbed-cellular
INTERFACE
LINKER:--undefined=LINK_TELIT_HE910_CPP
)
endif()

View File

@ -70,4 +70,18 @@ CellularDevice *CellularDevice::get_default_instance()
static TELIT_HE910 device(&serial); static TELIT_HE910 device(&serial);
return &device; return &device;
} }
/*
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
* object file 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
*
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
* <LINK_FOO> symbol correctly.
*/
extern "C"
void LINK_TELIT_HE910_CPP(void)
{
}
#endif #endif

View File

@ -16,4 +16,16 @@ target_sources(mbed-cellular
if("TARGET_EP_ATLAS" IN_LIST MBED_TARGET_LABELS) if("TARGET_EP_ATLAS" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_EP_ATLAS) add_subdirectory(TARGET_EP_ATLAS)
endif() endif()
# Link override object file coming from static library anyway
#
# NOTE: This linker option is to pretend undefined symbol and won't cause
# undefined symbol error even though the override object file actually
# doesn't provide such symbol definition.
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_link_options(mbed-cellular
INTERFACE
LINKER:--undefined=LINK_TELIT_ME310_CPP
)
endif()

View File

@ -153,6 +153,20 @@ CellularDevice *CellularDevice::get_default_instance()
MBED_CONF_TELIT_ME310_POLARITY); MBED_CONF_TELIT_ME310_POLARITY);
return &device; return &device;
} }
/*
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
* object file 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
*
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
* <LINK_FOO> symbol correctly.
*/
extern "C"
void LINK_TELIT_ME310_CPP(void)
{
}
#endif #endif
nsapi_error_t TELIT_ME310::hard_power_on() nsapi_error_t TELIT_ME310::hard_power_on()

View File

@ -15,4 +15,16 @@ target_sources(mbed-cellular
if("TARGET_EP_AGORA" IN_LIST MBED_TARGET_LABELS) if("TARGET_EP_AGORA" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_EP_AGORA) add_subdirectory(TARGET_EP_AGORA)
endif() endif()
# Link override object file coming from static library anyway
#
# NOTE: This linker option is to pretend undefined symbol and won't cause
# undefined symbol error even though the override object file actually
# doesn't provide such symbol definition.
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_link_options(mbed-cellular
INTERFACE
LINKER:--undefined=LINK_TELIT_ME910_CPP
)
endif()

View File

@ -152,6 +152,20 @@ CellularDevice *CellularDevice::get_default_instance()
MBED_CONF_TELIT_ME910_POLARITY); MBED_CONF_TELIT_ME910_POLARITY);
return &device; return &device;
} }
/*
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
* object file 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
*
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
* <LINK_FOO> symbol correctly.
*/
extern "C"
void LINK_TELIT_ME910_CPP(void)
{
}
#endif #endif
nsapi_error_t TELIT_ME910::hard_power_on() nsapi_error_t TELIT_ME910::hard_power_on()

View File

@ -43,6 +43,13 @@ MBED_WEAK MeshInterface *MeshInterface::get_default_instance()
return get_target_default_instance(); return get_target_default_instance();
} }
#if MBED_CONF_CELLULAR_PRESENT
MBED_WEAK CellularInterface *CellularInterface::get_default_instance()
{
return get_target_default_instance();
}
#endif // MBED_CONF_CELLULAR_PRESENT
/* For other types, we can provide a reasonable get_target_default_instance /* For other types, we can provide a reasonable get_target_default_instance
* in some cases. This is done in EthernetInterface.cpp, mbed-mesh-api and * in some cases. This is done in EthernetInterface.cpp, mbed-mesh-api and
* OnboardCellularInterface.cpp. We have no implementation for WiFi, so a * OnboardCellularInterface.cpp. We have no implementation for WiFi, so a