@@ -209,18 +209,27 @@ ifeq ($(CONFIG_UCFWHANDLER),y)
LDLIBS += gpiod
endif
+
+ifeq ($(CONFIG_BOOTLOADER_STATIC_LINKED),y)
ifeq ($(CONFIG_UBOOT),y)
+LDLIBS += ubootenv
+endif
+ifeq ($(CONFIG_BOOTLOADER_EBG),y)
+LDLIBS += ebgenv
+endif
+else
+ifeq ($(CONFIG_UBOOT),y)
+LDLIBS += dl
+endif
+ifeq ($(CONFIG_BOOTLOADER_EBG),y)
LDLIBS += dl
endif
+endif
ifeq ($(CONFIG_SYSTEMD),y)
LDLIBS += systemd
endif
-ifeq ($(CONFIG_BOOTLOADER_EBG),y)
-LDLIBS += dl
-endif
-
ifeq ($(CONFIG_BOOTLOADER_DEFAULT_NONE),y)
KBUILD_CPPFLAGS += -DBOOTLOADER_DEFAULT="none"
else ifeq ($(CONFIG_BOOTLOADER_DEFAULT_GRUB),y)
@@ -106,6 +106,16 @@ config BOOTLOADER_DEFAULT_NONE
endchoice
+config BOOTLOADER_STATIC_LINKED
+ bool "Bootloader interface static linked"
+ help
+ Link statically the interface to the bootloader. In case of distros,
+ more interfaces are available at the same time and SWUpdate checks
+ at runtime and loads the interface via dlopen(). This is available
+ with glibc and dlopen support. For other system, the interface can be linked
+ statically.
+
+
choice
prompt "Update Status Storage"
help
@@ -518,6 +518,18 @@ static bootloader *probe(void)
return NULL;
}
+#if defined(BOOTLOADER_STATIC_LINKED)
+ libebg.beverbose = ebg_beverbose;
+ libebg.env_create_new = ebg_env_create_new;
+ libebg.env_open_current = ebg_env_open_current;
+ libebg.env_get = ebg_env_get;
+ libebg.env_set = ebg_env_set;
+ libebg.env_set_ex = ebg_env_set_ex;
+ libebg.env_getglobalstate = ebg_env_getglobalstate;
+ libebg.env_setglobalstate = ebg_env_setglobalstate;
+ libebg.env_close = ebg_env_close;
+ libebg.env_finalize_update = ebg_env_finalize_update;
+#else
void *handle = dlopen("libebgenv.so.0", RTLD_NOW | RTLD_GLOBAL);
if (!handle) {
return NULL;
@@ -534,6 +546,7 @@ static bootloader *probe(void)
load_symbol(handle, &libebg.env_setglobalstate, "ebg_env_setglobalstate");
load_symbol(handle, &libebg.env_close, "ebg_env_close");
load_symbol(handle, &libebg.env_finalize_update, "ebg_env_finalize_update");
+#endif
return &ebg;
}
@@ -123,6 +123,17 @@ static bootloader uboot = {
static bootloader* probe(void)
{
+#if defined(BOOTLOADER_STATIC_LINKED)
+ libuboot.open = libuboot_open;
+ libuboot.close = libuboot_close;
+ libuboot.exit = libuboot_exit;
+ libuboot.initialize = libuboot_initialize;
+ libuboot.get_env = libuboot_get_env;
+ libuboot.read_config = libuboot_read_config;
+ libuboot.load_file = libuboot_load_file;
+ libuboot.set_env = libuboot_set_env;
+ libuboot.env_store = libuboot_env_store;
+#else
void* handle = dlopen("libubootenv.so.0", RTLD_NOW | RTLD_GLOBAL);
if (!handle) {
return NULL;
@@ -138,6 +149,7 @@ static bootloader* probe(void)
load_symbol(handle, &libuboot.load_file, "libuboot_load_file");
load_symbol(handle, &libuboot.set_env, "libuboot_set_env");
load_symbol(handle, &libuboot.env_store, "libuboot_env_store");
+#endif
return &uboot;
}
Commit 3a4e626b857 introduced dynamic linking for the bootloader interface. This helps with standard Linux distros, where SWUpdate is provided as package and it is not built from sources, and SWUpdate checks at startup if the chosen library can be loaded. However, this mechanism just works if dynamic linking is supported, and it fails on system where dlopen() is not available, like uclibc and musl. Add an option BOOTLOADER_STATIC_LINKED to reintroduce again static linking. Signed-off-by: Stefano Babic <sbabic@denx.de> --- Makefile.flags | 17 +++++++++++++---- bootloader/Config.in | 10 ++++++++++ bootloader/ebg.c | 13 +++++++++++++ bootloader/uboot.c | 12 ++++++++++++ 4 files changed, 48 insertions(+), 4 deletions(-)