From efb615fc7c1fda8eb6ae5e4d56fcd61eca47e367 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 8 Jul 2021 16:00:03 +0200 Subject: [PATCH 01/70] ccimx8x-sbc-pro: fix typo on DT overlay filename The LVDS converter model is lt8912. Signed-off-by: Hector Palacios (cherry picked from commit a72fd737d1da50b00a5d16ec951c37ae2791003b) --- meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf index 24c7fb465..b59a050d4 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf @@ -18,7 +18,7 @@ KERNEL_DEVICETREE ?= " \ digi/_ov_board_gpio-watchdog_ccimx8x-sbc-pro.dtbo \ digi/_ov_board_hsd101pfw2-lvds_ccimx8x-sbc-pro.dtbo \ digi/_ov_board_lpuart3_ccimx8x-sbc-pro.dtbo \ - digi/_ov_board_lt9812-hdmi-dsi0_ccimx8x-sbc-pro.dtbo \ + digi/_ov_board_lt8912-hdmi-dsi0_ccimx8x-sbc-pro.dtbo \ digi/_ov_board_lvds1_ccimx8x-sbc-pro.dtbo \ digi/_ov_board_parallel-camera_ccimx8x-sbc-pro.dtbo \ digi/_ov_board_pcie-card_ccimx8x-sbc-pro.dtbo \ From c47377df22b7eb83ea1b38ac93fdab5e37993b1b Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Mon, 12 Jul 2021 17:11:39 +0200 Subject: [PATCH 02/70] recovery-utils: add check into recover library if dualboot is enabled This commit add a verification into the recovery library to avoid that it is executed when in dualboot mode. Signed-off-by: Mike Engel https://onedigi.atlassian.net/browse/DEL-7580 (cherry picked from commit 30aa4a74448043b9fa14f47c6f398f4dedee1747) --- .../recovery-utils/include/recovery.h | 7 +++ .../recovery-utils/lib/recovery.c | 54 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h index e73a86951..a94551a4c 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h @@ -70,4 +70,11 @@ int set_encryption_key(char *key, unsigned char force); */ int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force); +/* + * Check if device has dualboot enabled. + * + * Return: 1 if enabled and 0 if disabled, -1 on error when reading the environment + */ +int is_dualboot_enabled(void); + #endif /* RECOVERY_H */ diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c index debdcdc2c..6781b8930 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c @@ -83,6 +83,12 @@ static int append_recovery_command(const char *value) int rcvr_cmd_len; int ret = 0; + /* Check if we are in dualboot mode */ + if (is_dualboot_enabled()) { + fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); + goto err; + } + ret = uboot_getenv("recovery_command", &old_recovery_cmd); if (ret) { fprintf(stderr, "Error: getenv 'recovery_command'\n"); @@ -584,6 +590,12 @@ int update_firmware(const char *swu_path) int file_prefix_len = 0; int ret = -1; + /* Check if we are in dualboot mode */ + if (is_dualboot_enabled()) { + fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); + goto err; + } + /* Verify input parameter */ if (!swu_path) { fprintf(stderr, "Error: NULL 'swu_path'\n"); @@ -624,6 +636,12 @@ int reboot_recovery(unsigned int reboot_timeout) { int ret = 0; + /* Check if we are in dualboot mode */ + if (is_dualboot_enabled()) { + fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); + goto err; + } + sync(); printf("\nThe recovery commands have been properly configured and " @@ -668,6 +686,12 @@ int set_encryption_key(char *key, unsigned char force) int ret = -1; unsigned char i = 0; + /* Check if we are in dualboot mode */ + if (is_dualboot_enabled()) { + fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); + return ret; + } + /* Initialize arrays */ parts[0] = NULL; encrypted[0] = NULL; @@ -768,6 +792,12 @@ int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force int ret; + /* Check if we are in dualboot mode */ + if (is_dualboot_enabled()) { + fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); + return 1; + } + /* If both lists are empty, we have nothing to do */ if (!to_encrypt && !to_unencrypt) return 1; @@ -932,3 +962,27 @@ err: return ret < 0 ? -1 : ret; } +/* + * Function: is_device_closed + * Description: check if the device is in dualboot mode + */ +int is_dualboot_enabled (void) +{ + const char *var; + int ret; + + /* Parse dualboot */ + ret = uboot_getenv("dualboot", &var); + if (ret) { + fprintf(stderr, "Error: getenv 'dualboot'\n"); + return 0; + } + + /* Is dualboot enabled */ + if (!strcmp(var, "no")) + ret = 0; + else + ret = 1; + + return ret; +} From 96b47a48d2900974c32fd8aaaf8c610db1c2d164 Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Mon, 26 Jul 2021 13:39:14 +0200 Subject: [PATCH 03/70] meta-digi-dey: bump distro version to 3.2-r2 Signed-off-by: Mike Engel --- meta-digi-dey/conf/distro/dey.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-digi-dey/conf/distro/dey.conf b/meta-digi-dey/conf/distro/dey.conf index 614150a65..4749af8c8 100644 --- a/meta-digi-dey/conf/distro/dey.conf +++ b/meta-digi-dey/conf/distro/dey.conf @@ -1,6 +1,6 @@ DISTRO = "dey" DISTRO_NAME = "Digi Embedded Yocto" -DISTRO_VERSION = "3.2-r1" +DISTRO_VERSION = "3.2-r2" DISTRO_CODENAME = "gatesgarth" SDK_VENDOR = "-deysdk" SDK_VERSION := "${@d.getVar('DISTRO_VERSION')}" From e7921dfd937bae9ba5c036aa4c7e30a73f5f02ea Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Wed, 4 Aug 2021 11:56:07 +0200 Subject: [PATCH 04/70] distro: set GLIBC preferred version to 2.32 This commit sets the GLIBC version to 2.32. The newest eIQ packages require a newer glibc, but since said packages are optional, make sure to use the gatesgarth glibc version by default. Signed-off-by: Mike Engel https://onedigi.atlassian.net/browse/DEL-7625 --- meta-digi-dey/conf/distro/dey.conf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/meta-digi-dey/conf/distro/dey.conf b/meta-digi-dey/conf/distro/dey.conf index 4749af8c8..797392fd7 100644 --- a/meta-digi-dey/conf/distro/dey.conf +++ b/meta-digi-dey/conf/distro/dey.conf @@ -79,6 +79,11 @@ PREFERRED_PROVIDER_virtual/wpebackend = "wpebackend-fdo" # Use recipe from our meta-digi layer PREFERRED_VERSION_tensorflow-lite ?= "2.5.0" +# Use gatesgarth default GLIBC version +# This will be removed once we update to the next +# Yocto version +PREFERRED_VERSION_glibc ?= "2.32" + SDK_NAME = "${DISTRO}-${TCLIBC}-${SDKMACHINE}-${IMAGE_BASENAME}-${TUNE_PKGARCH}-${MACHINE}" SDKPATH = "/opt/${DISTRO}/${SDK_VERSION}/${MACHINE}" From 11b1aee7e73024e59ca73ddf0810bc220551ab39 Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Mon, 2 Aug 2021 17:09:28 +0200 Subject: [PATCH 05/70] opencv: update to latest NXP eIQ version This commit updates the eIQ support to the hardknott-5.10.35-2.0.0 release by NXP. Signed-off-by: Mike Engel --- ...dparty-ippicv-Use-pre-downloaded-ipp.patch | 36 +++ .../opencv/opencv/0001-Dont-use-isystem.patch | 28 ++ .../opencv/0001-Make-ts-module-external.patch | 42 +++ ...-around-deprecated-ffmpeg-RAW-functi.patch | 31 ++ .../0001-Use-Os-to-compile-tinyxml2.cpp.patch | 31 ++ .../opencv/0001-sfm-link-with-Glog_LIBS.patch | 44 +++ .../0003-To-fix-errors-as-following.patch | 70 ++++ .../opencv/opencv/OpenCV_DNN_examples.patch | 139 ++++++++ .../opencv/opencv/download.patch | 41 +++ .../opencv/opencv_4.5.2.imx.bb | 301 ++++++++++++++++++ .../opencv/opencv_4.5.2.imx.bbappend | 2 + 11 files changed, 765 insertions(+) create mode 100644 meta-digi-dey/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch create mode 100644 meta-digi-dey/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch create mode 100644 meta-digi-dey/recipes-support/opencv/opencv/0001-Make-ts-module-external.patch create mode 100644 meta-digi-dey/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch create mode 100644 meta-digi-dey/recipes-support/opencv/opencv/0001-Use-Os-to-compile-tinyxml2.cpp.patch create mode 100644 meta-digi-dey/recipes-support/opencv/opencv/0001-sfm-link-with-Glog_LIBS.patch create mode 100644 meta-digi-dey/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch create mode 100644 meta-digi-dey/recipes-support/opencv/opencv/OpenCV_DNN_examples.patch create mode 100644 meta-digi-dey/recipes-support/opencv/opencv/download.patch create mode 100644 meta-digi-dey/recipes-support/opencv/opencv_4.5.2.imx.bb create mode 100644 meta-digi-dey/recipes-support/opencv/opencv_4.5.2.imx.bbappend diff --git a/meta-digi-dey/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch b/meta-digi-dey/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch new file mode 100644 index 000000000..9e6a61371 --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch @@ -0,0 +1,36 @@ +From 9b4959b97d2e95d4b49cf6ca2a3fce3cdb484f2d Mon Sep 17 00:00:00 2001 +From: Ricardo Ribalda Delgado +Date: Thu, 31 Mar 2016 00:20:15 +0200 +Subject: [PATCH] 3rdparty/ippicv: Use pre-downloaded ipp + +Signed-off-by: Ricardo Ribalda Delgado +Signed-off-by: Ismo Puustinen + +--- + 3rdparty/ippicv/ippicv.cmake | 15 +-------------- + 1 file changed, 1 insertion(+), 14 deletions(-) + +diff --git a/3rdparty/ippicv/ippicv.cmake b/3rdparty/ippicv/ippicv.cmake +index 257af6fcc6..f88460450f 100644 +--- a/3rdparty/ippicv/ippicv.cmake ++++ b/3rdparty/ippicv/ippicv.cmake +@@ -34,18 +34,5 @@ function(download_ippicv root_var) + endif() + + set(THE_ROOT "${OpenCV_BINARY_DIR}/3rdparty/ippicv") +- ocv_download(FILENAME ${OPENCV_ICV_NAME} +- HASH ${OPENCV_ICV_HASH} +- URL +- "${OPENCV_IPPICV_URL}" +- "$ENV{OPENCV_IPPICV_URL}" +- "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/" +- DESTINATION_DIR "${THE_ROOT}" +- ID IPPICV +- STATUS res +- UNPACK RELATIVE_URL) +- +- if(res) +- set(${root_var} "${THE_ROOT}/${OPENCV_ICV_PACKAGE_SUBDIR}" PARENT_SCOPE) +- endif() ++ set(${root_var} "${THE_ROOT}/${OPENCV_ICV_PACKAGE_SUBDIR}" PARENT_SCOPE) + endfunction() diff --git a/meta-digi-dey/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch b/meta-digi-dey/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch new file mode 100644 index 000000000..948a80faf --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch @@ -0,0 +1,28 @@ +From 66e50ee69fa9ee2469d349100e70d8b296c4b4dc Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 11 Sep 2018 00:21:18 -0700 +Subject: [PATCH] Dont use isystem + +clang really does not like it + +Upstream-Status: Pending + +Signed-off-by: Khem Raj + +--- + cmake/OpenCVPCHSupport.cmake | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake +index 08cd06def4..46c9c02da3 100644 +--- a/cmake/OpenCVPCHSupport.cmake ++++ b/cmake/OpenCVPCHSupport.cmake +@@ -18,6 +18,8 @@ IF(CV_GCC) + SET(PCHSupport_FOUND TRUE) + ENDIF() + ++ SET(CMAKE_INCLUDE_SYSTEM_FLAG_C "-I") ++ SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-I") + SET(_PCH_include_prefix "-I") + SET(_PCH_isystem_prefix "-isystem") + SET(_PCH_define_prefix "-D") diff --git a/meta-digi-dey/recipes-support/opencv/opencv/0001-Make-ts-module-external.patch b/meta-digi-dey/recipes-support/opencv/opencv/0001-Make-ts-module-external.patch new file mode 100644 index 000000000..d56b8ae67 --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv/0001-Make-ts-module-external.patch @@ -0,0 +1,42 @@ +From 11bbf909e08594628bd757d989ae34cf1bfe200b Mon Sep 17 00:00:00 2001 +From: Mingli Yu +Date: Thu, 18 Jun 2020 05:51:38 +0000 +Subject: [PATCH] Make ts module external + +Make ts module external + +Reference: https://github.com/qbonnard/opencv/commit/6b229c5834cb9a0930425e762a6c7b03244d7abb + +Upstream-Status: Submitted [https://github.com/opencv/opencv/issues/8408] + +Signed-off-by: Mingli Yu +--- + modules/ts/CMakeLists.txt | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt +index f95bed0793..66f315bcca 100644 +--- a/modules/ts/CMakeLists.txt ++++ b/modules/ts/CMakeLists.txt +@@ -4,9 +4,6 @@ if(NOT BUILD_opencv_ts AND NOT BUILD_TESTS AND NOT BUILD_PERF_TESTS) + ocv_module_disable(ts) + endif() + +-set(OPENCV_MODULE_TYPE STATIC) +-set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE) +- + if(WINRT) + # WINRT doesn't have access to environment variables + # so adding corresponding macros during CMake run +@@ -16,7 +13,7 @@ endif() + + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) + +-ocv_add_module(ts INTERNAL opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui) ++ocv_add_module(ts opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui) + + ocv_glob_module_sources() + ocv_module_include_directories() +-- +2.24.1 + diff --git a/meta-digi-dey/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch b/meta-digi-dey/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch new file mode 100644 index 000000000..1e47f8b16 --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch @@ -0,0 +1,31 @@ +From e4ec6cea72da9e9ae5ba57140fa2f5c63f1f8295 Mon Sep 17 00:00:00 2001 +From: Jason Wessel +Date: Wed, 9 May 2018 13:33:59 -0700 +Subject: [PATCH] Temporarliy work around deprecated ffmpeg RAW function + compile failure until next uprev + +Signed-off-by: Jason Wessel + +--- + modules/videoio/src/cap_ffmpeg_impl.hpp | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp +index 6dca724a89..ae55dd4555 100644 +--- a/modules/videoio/src/cap_ffmpeg_impl.hpp ++++ b/modules/videoio/src/cap_ffmpeg_impl.hpp +@@ -774,6 +774,14 @@ struct ImplMutex::Impl + + #endif + ++/* NOTE This is deprecated in ffmpeg and the code should be removed */ ++#ifndef AVFMT_RAWPICTURE ++#define AVFMT_RAWPICTURE 0x0020 ++#endif /* AVFMT_RAWPICTURE */ ++#ifndef CODEC_FLAG_GLOBAL_HEADER ++#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER ++#endif ++ + void ImplMutex::init() + { + impl = new Impl(); diff --git a/meta-digi-dey/recipes-support/opencv/opencv/0001-Use-Os-to-compile-tinyxml2.cpp.patch b/meta-digi-dey/recipes-support/opencv/opencv/0001-Use-Os-to-compile-tinyxml2.cpp.patch new file mode 100644 index 000000000..c5a64387f --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv/0001-Use-Os-to-compile-tinyxml2.cpp.patch @@ -0,0 +1,31 @@ +From 59fafe6e39759e193b5764b36b4c5a93da352123 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 18 Aug 2020 00:36:49 -0700 +Subject: [PATCH] Use -Os to compile tinyxml2.cpp + +This workarounds issue [1] seen on riscv with gcc + +[1] https://github.com/riscv/riscv-gnu-toolchain/issues/624 + +Upstream-Status: Inappropriate [ OE-Specific ] +Signed-off-by: Khem Raj +--- + modules/datasets/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules/datasets/CMakeLists.txt b/modules/datasets/CMakeLists.txt +index 56ca9e310..99b7a33f6 100644 +--- a/modules/datasets/CMakeLists.txt ++++ b/modules/datasets/CMakeLists.txt +@@ -2,7 +2,7 @@ set(the_description "datasets framework") + + set(filter_srcs "${CMAKE_CURRENT_LIST_DIR}/src/tinyxml2/tinyxml2.cpp") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +- ocv_append_source_files_cxx_compiler_options(filter_srcs "-Wno-suggest-override") # GCC ++ ocv_append_source_files_cxx_compiler_options(filter_srcs "-Wno-suggest-override -Os") # GCC + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + ocv_append_source_files_cxx_compiler_options(filter_srcs "-Wno-inconsistent-missing-override") # Clang + endif() +-- +2.28.0 + diff --git a/meta-digi-dey/recipes-support/opencv/opencv/0001-sfm-link-with-Glog_LIBS.patch b/meta-digi-dey/recipes-support/opencv/opencv/0001-sfm-link-with-Glog_LIBS.patch new file mode 100644 index 000000000..7b2c4100a --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv/0001-sfm-link-with-Glog_LIBS.patch @@ -0,0 +1,44 @@ +From ffe20fc4ec46c6b491eff29a38f90686d4d035f6 Mon Sep 17 00:00:00 2001 +From: Martin Jansa +Date: Mon, 12 Apr 2021 20:37:40 +0000 +Subject: [PATCH] sfm: link with Glog_LIBS + +* in 4.5.0 there was explicit linkage with GLOG_LIBRARY, but since 4.5.1 with: + https://github.com/opencv/opencv_contrib/commit/23ee62a19b7a3e50d6dbf295359d8b1aff2e03fd + + it's gone, probably because Glog_FOUND is already set from Ceres, + but then GLOG_LIBRARIES is empty in LIBMV_LIGHT_LIBS and build with gold fails: + +FAILED: bin/example_tutorial_perspective_correction +: && TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-g++ -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot= -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native= -fvisibility-inlines-hidden -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -DNDEBUG -DNDEBUG -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot= -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native= -fvisibility-inlines-hidden -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,--gc-sections -Wl,--as-needed samples/cpp/CMakeFiles/example_tutorial_perspective_correction.dir/tutorial_code/features2D/Homography/perspective_correction.cpp.o -o bin/example_tutorial_perspective_correction -ldl -lm -lpthread -lrt lib/libopencv_gapi.so.4.5.2 lib/libopencv_stitching.so.4.5.2 lib/libopencv_ts.so.4.5.2 lib/libopencv_alphamat.so.4.5.2 lib/libopencv_aruco.so.4.5.2 lib/libopencv_bgsegm.so.4.5.2 lib/libopencv_bioinspired.so.4.5.2 lib/libopencv_ccalib.so.4.5.2 lib/libopencv_dnn_objdetect.so.4.5.2 lib/libopencv_dnn_superres.so.4.5.2 lib/libopencv_dpm.so.4.5.2 lib/libopencv_face.so.4.5.2 lib/libopencv_fuzzy.so.4.5.2 lib/libopencv_hfs.so.4.5.2 lib/libopencv_img_hash.so.4.5.2 lib/libopencv_intensity_transform.so.4.5.2 lib/libopencv_line_descriptor.so.4.5.2 lib/libopencv_mcc.so.4.5.2 lib/libopencv_quality.so.4.5.2 lib/libopencv_rapid.so.4.5.2 lib/libopencv_reg.so.4.5.2 lib/libopencv_rgbd.so.4.5.2 lib/libopencv_saliency.so.4.5.2 lib/libopencv_sfm.so.4.5.2 lib/libopencv_stereo.so.4.5.2 lib/libopencv_structured_light.so.4.5.2 lib/libopencv_superres.so.4.5.2 lib/libopencv_surface_matching.so.4.5.2 lib/libopencv_tracking.so.4.5.2 lib/libopencv_videostab.so.4.5.2 lib/libopencv_wechat_qrcode.so.4.5.2 lib/libopencv_xfeatures2d.so.4.5.2 lib/libopencv_xobjdetect.so.4.5.2 lib/libopencv_xphoto.so.4.5.2 lib/libopencv_shape.so.4.5.2 lib/libopencv_highgui.so.4.5.2 lib/libopencv_datasets.so.4.5.2 lib/libopencv_ml.so.4.5.2 lib/libopencv_plot.so.4.5.2 lib/libopencv_phase_unwrapping.so.4.5.2 lib/libopencv_optflow.so.4.5.2 lib/libopencv_ximgproc.so.4.5.2 lib/libopencv_videoio.so.4.5.2 lib/libopencv_video.so.4.5.2 lib/libopencv_dnn.so.4.5.2 lib/libopencv_imgcodecs.so.4.5.2 lib/libopencv_objdetect.so.4.5.2 lib/libopencv_calib3d.so.4.5.2 lib/libopencv_features2d.so.4.5.2 lib/libopencv_flann.so.4.5.2 lib/libopencv_photo.so.4.5.2 lib/libopencv_imgproc.so.4.5.2 lib/libopencv_core.so.4.5.2 -Wl,-rpath-link,TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/build/lib && : +lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::LogMessage(char const*, int)' +lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::stream()' +lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::~LogMessage()' +lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::kLogSiteUninitialized' +lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'fLI::FLAGS_v' +lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::InitVLOG3__(int**, int*, char const*, int)' +lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessageFatal::LogMessageFatal(char const*, int)' +lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessageFatal::~LogMessageFatal()' +collect2: error: ld returned 1 exit status + + Add Glog_LIBS which is set to the same value as GLOG_LIBRARIES used to be. + +Upstream-Status: Submitted [https://github.com/opencv/opencv_contrib/pull/2923] + +Signed-off-by: Martin Jansa +--- + modules/sfm/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/modules/sfm/CMakeLists.txt b/modules/sfm/CMakeLists.txt +index 045a1fe6e..ee7cecdac 100644 +--- a/modules/sfm/CMakeLists.txt ++++ b/modules/sfm/CMakeLists.txt +@@ -84,6 +84,7 @@ set(LIBMV_LIGHT_LIBS + multiview + numeric + ${GLOG_LIBRARIES} ++ ${Glog_LIBS} + ${GFLAGS_LIBRARIES} + ) + diff --git a/meta-digi-dey/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch b/meta-digi-dey/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch new file mode 100644 index 000000000..bb47ef2ba --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch @@ -0,0 +1,70 @@ +From f42c9b8c7bafcadc7e95fb25a391707f970eb426 Mon Sep 17 00:00:00 2001 +From: Huang Qiyu +Date: Fri, 19 May 2017 04:27:50 +0900 +Subject: [PATCH] To fix errors as following: + +"test_main.cpp:45: undefined reference to `parseCustomOptions(int, char**)'" +"perf_abs.cpp:13: undefined reference to `cvtest::param_seed'" +"test_superres.cpp:270: undefined reference to `checkIppStatus()'" + +Signed-off-by: Huang Qiyu + +Also add the visibility changes for certain OpenCL-related functions in +ts module. + +Signed-off-by: Ismo Puustinen + +--- + modules/ts/include/opencv2/ts.hpp | 4 ++-- + modules/ts/include/opencv2/ts/ocl_test.hpp | 2 +- + modules/ts/include/opencv2/ts/ts_ext.hpp | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp +index ed7491a89a..80919d13ee 100644 +--- a/modules/ts/include/opencv2/ts.hpp ++++ b/modules/ts/include/opencv2/ts.hpp +@@ -728,7 +728,7 @@ protected: + } + }; + +-extern uint64 param_seed; ++CV_EXPORTS extern uint64 param_seed; + + struct DefaultRngAuto + { +@@ -791,7 +791,7 @@ private: + #endif + #endif + +-void parseCustomOptions(int argc, char **argv); ++CV_EXPORTS void parseCustomOptions(int argc, char **argv); + + #define CV_TEST_INIT0_NOOP (void)0 + +diff --git a/modules/ts/include/opencv2/ts/ocl_test.hpp b/modules/ts/include/opencv2/ts/ocl_test.hpp +index 11572e9f48..438112e2aa 100644 +--- a/modules/ts/include/opencv2/ts/ocl_test.hpp ++++ b/modules/ts/include/opencv2/ts/ocl_test.hpp +@@ -82,7 +82,7 @@ inline UMat ToUMat(InputArray src) + return dst; + } + +-extern int test_loop_times; ++CV_EXPORTS extern int test_loop_times; + + #define MAX_VALUE 357 + +diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp +index b2a4cac241..b94c681c0c 100644 +--- a/modules/ts/include/opencv2/ts/ts_ext.hpp ++++ b/modules/ts/include/opencv2/ts/ts_ext.hpp +@@ -9,7 +9,7 @@ + #define OPENCV_TS_EXT_HPP + + namespace cvtest { +-void checkIppStatus(); ++CV_EXPORTS void checkIppStatus(); + extern bool skipUnstableTests; + extern bool runBigDataTests; + extern int testThreads; diff --git a/meta-digi-dey/recipes-support/opencv/opencv/OpenCV_DNN_examples.patch b/meta-digi-dey/recipes-support/opencv/opencv/OpenCV_DNN_examples.patch new file mode 100644 index 000000000..0e83e9941 --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv/OpenCV_DNN_examples.patch @@ -0,0 +1,139 @@ +From 3c4daafb54f961e376104a461ca7ec114ff0331a Mon Sep 17 00:00:00 2001 +From: Ludek Slosarcik +Date: Fri, 14 Feb 2020 15:46:50 +0100 +Subject: [PATCH] opencv_dnn: added video device for 2 examples, and change text labels + +Signed-off-by: Ludek Slosarcik + +Upstream-Status: Pending +--- + samples/cpp/logistic_regression.cpp | 2 +- + samples/dnn/classification.cpp | 7 ++++--- + samples/dnn/object_detection.cpp | 10 +++++----- + samples/dnn/segmentation.cpp | 2 +- + samples/dnn/text_detection.cpp | 5 +++-- + 5 files changed, 14 insertions(+), 12 deletions(-) + +Index: git/samples/cpp/logistic_regression.cpp +=================================================================== +--- git.orig/samples/cpp/logistic_regression.cpp ++++ git/samples/cpp/logistic_regression.cpp +@@ -28,7 +28,7 @@ static float calculateAccuracyPercent(co + + int main() + { +- const String filename = samples::findFile("data01.xml"); ++ const String filename = samples::findFile("../data/data01.xml"); + cout << "**********************************************************************" << endl; + cout << filename + << " contains digits 0 and 1 of 20 samples each, collected on an Android device" << endl; +Index: git/samples/dnn/classification.cpp +=================================================================== +--- git.orig/samples/dnn/classification.cpp ++++ git/samples/dnn/classification.cpp +@@ -11,6 +11,7 @@ std::string keys = + "{ help h | | Print help message. }" + "{ @alias | | An alias name of model to extract preprocessing parameters from models.yml file. }" + "{ zoo | models.yml | An optional path to file with preprocessing parameters }" ++ "{ device | 0 | camera device number. }" + "{ input i | | Path to input image or video file. Skip this argument to capture frames from a camera.}" + "{ initial_width | 0 | Preprocess input image by initial resizing to a specific width.}" + "{ initial_height | 0 | Preprocess input image by initial resizing to a specific height.}" +@@ -102,7 +103,7 @@ int main(int argc, char** argv) + if (parser.has("input")) + cap.open(parser.get("input")); + else +- cap.open(0); ++ cap.open(parser.get("device")); + //! [Open a video file or an image file or a camera stream] + + // Process frames. +@@ -151,13 +152,13 @@ int main(int argc, char** argv) + double freq = getTickFrequency() / 1000; + double t = net.getPerfProfile(layersTimes) / freq; + std::string label = format("Inference time: %.2f ms", t); +- putText(frame, label, Point(0, 15), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0)); ++ putText(frame, label, Point(0, 20), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false); + + // Print predicted class. + label = format("%s: %.4f", (classes.empty() ? format("Class #%d", classId).c_str() : + classes[classId].c_str()), + confidence); +- putText(frame, label, Point(0, 40), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0)); ++ putText(frame, label, Point(0, 45), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false); + + imshow(kWinName, frame); + } +Index: git/samples/dnn/object_detection.cpp +=================================================================== +--- git.orig/samples/dnn/object_detection.cpp ++++ git/samples/dnn/object_detection.cpp +@@ -251,13 +251,13 @@ int main(int argc, char** argv) + if (predictionsQueue.counter > 1) + { + std::string label = format("Camera: %.2f FPS", framesQueue.getFPS()); +- putText(frame, label, Point(0, 15), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0)); ++ putText(frame, label, Point(0, 20), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false); + + label = format("Network: %.2f FPS", predictionsQueue.getFPS()); +- putText(frame, label, Point(0, 30), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0)); ++ putText(frame, label, Point(0, 45), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false); + + label = format("Skipped frames: %d", framesQueue.counter - predictionsQueue.counter); +- putText(frame, label, Point(0, 45), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0)); ++ putText(frame, label, Point(0, 70), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false); + } + imshow(kWinName, frame); + } +@@ -293,7 +293,7 @@ int main(int argc, char** argv) + double freq = getTickFrequency() / 1000; + double t = net.getPerfProfile(layersTimes) / freq; + std::string label = format("Inference time: %.2f ms", t); +- putText(frame, label, Point(0, 15), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0)); ++ putText(frame, label, Point(0, 20), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false); + + imshow(kWinName, frame); + } +@@ -462,7 +462,7 @@ void drawPred(int classId, float conf, i + top = max(top, labelSize.height); + rectangle(frame, Point(left, top - labelSize.height), + Point(left + labelSize.width, top + baseLine), Scalar::all(255), FILLED); +- putText(frame, label, Point(left, top), FONT_HERSHEY_SIMPLEX, 0.5, Scalar()); ++ putText(frame, label, Point(left, top), FONT_HERSHEY_SIMPLEX, 0.8, Scalar()); + } + + void callback(int pos, void*) +Index: git/samples/dnn/segmentation.cpp +=================================================================== +--- git.orig/samples/dnn/segmentation.cpp ++++ git/samples/dnn/segmentation.cpp +@@ -157,7 +157,7 @@ int main(int argc, char** argv) + double freq = getTickFrequency() / 1000; + double t = net.getPerfProfile(layersTimes) / freq; + std::string label = format("Inference time: %.2f ms", t); +- putText(frame, label, Point(0, 15), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0)); ++ putText(frame, label, Point(0, 20), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false); + + imshow(kWinName, frame); + if (!classes.empty()) +Index: git/samples/dnn/text_detection.cpp +=================================================================== +--- git.orig/samples/dnn/text_detection.cpp ++++ git/samples/dnn/text_detection.cpp +@@ -30,6 +30,7 @@ using namespace cv::dnn; + const char* keys = + "{ help h | | Print help message. }" + "{ input i | | Path to input image or video file. Skip this argument to capture frames from a camera.}" ++ "{ device | 0 | camera device number. }" + "{ detModel dmp | | Path to a binary .pb file contains trained detector network.}" + "{ width | 320 | Preprocess input image by resizing to a specific width. It should be multiple by 32. }" + "{ height | 320 | Preprocess input image by resizing to a specific height. It should be multiple by 32. }" +@@ -106,7 +107,7 @@ int main(int argc, char** argv) + + // Open a video file or an image file or a camera stream. + VideoCapture cap; +- bool openSuccess = parser.has("input") ? cap.open(parser.get("input")) : cap.open(0); ++ bool openSuccess = parser.has("input") ? cap.open(parser.get("input")) : cap.open(parser.get("device")); + CV_Assert(openSuccess); + + static const std::string kWinName = "EAST: An Efficient and Accurate Scene Text Detector"; diff --git a/meta-digi-dey/recipes-support/opencv/opencv/download.patch b/meta-digi-dey/recipes-support/opencv/opencv/download.patch new file mode 100644 index 000000000..33ac48312 --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv/download.patch @@ -0,0 +1,41 @@ +From b18a280fab06a680d9f831bf8b462647f3cb6214 Mon Sep 17 00:00:00 2001 +From: Ross Burton +Date: Thu, 9 Jan 2020 16:24:24 +0000 +Subject: [PATCH] opencv: abort configure if we need to download + +This CMake module will download files during do_configure. This is bad as it +means we can't do offline builds. + +Add an option to disallow downloads by emitting a fatal error. + +Upstream-Status: Pending +Signed-off-by: Ross Burton + +--- + cmake/OpenCVDownload.cmake | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake +index 63cf6d3238..4acf477f70 100644 +--- a/cmake/OpenCVDownload.cmake ++++ b/cmake/OpenCVDownload.cmake +@@ -14,6 +14,7 @@ + # RELATIVE_URL - if set, then URL is treated as a base, and FILENAME will be appended to it + # Note: uses OPENCV_DOWNLOAD_PATH folder as cache, default is /.cache + ++set(OPENCV_ALLOW_DOWNLOADS ON CACHE BOOL "Allow downloads") + set(HELP_OPENCV_DOWNLOAD_PATH "Cache directory for downloaded files") + if(DEFINED ENV{OPENCV_DOWNLOAD_PATH}) + set(OPENCV_DOWNLOAD_PATH "$ENV{OPENCV_DOWNLOAD_PATH}" CACHE PATH "${HELP_OPENCV_DOWNLOAD_PATH}") +@@ -156,6 +157,11 @@ function(ocv_download) + + # Download + if(NOT EXISTS "${CACHE_CANDIDATE}") ++ if(NOT OPENCV_ALLOW_DOWNLOADS) ++ message(FATAL_ERROR "Not going to download ${DL_FILENAME}") ++ return() ++ endif() ++ + ocv_download_log("#cmake_download \"${CACHE_CANDIDATE}\" \"${DL_URL}\"") + foreach(try ${OPENCV_DOWNLOAD_TRIES_LIST}) + ocv_download_log("#try ${try}") diff --git a/meta-digi-dey/recipes-support/opencv/opencv_4.5.2.imx.bb b/meta-digi-dey/recipes-support/opencv/opencv_4.5.2.imx.bb new file mode 100644 index 000000000..2d71acfc6 --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv_4.5.2.imx.bb @@ -0,0 +1,301 @@ +# This recipe is for the i.MX fork of opencv. For ease of +# maintenance, the top section is a verbatim copy of an OE-core +# recipe. The second section customizes the recipe for i.MX. + +########## meta-openembedded copy ########### + +SUMMARY = "Opencv : The Open Computer Vision Library" +HOMEPAGE = "http://opencv.org/" +SECTION = "libs" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +ARM_INSTRUCTION_SET_armv4 = "arm" +ARM_INSTRUCTION_SET_armv5 = "arm" + +DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp" + +SRCREV_opencv = "69357b1e88680658a07cffde7678a4d697469f03" +SRCREV_contrib = "f5d7f6712d4ff229ba4f45cf79dfd11c557d56fd" +SRCREV_ipp = "a56b6ac6f030c312b2dce17430eef13aed9af274" +SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" +SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" +SRCREV_face = "8afa57abc8229d611c4937165d20e2a2d9fc5a12" +SRCREV_wechat-qrcode = "a8b69ccc738421293254aec5ddb38bd523503252" + +def ipp_filename(d): + import re + arch = d.getVar('TARGET_ARCH') + if re.match("i.86$", arch): + return "ippicv_2020_lnx_ia32_20191018_general.tgz" + else: + return "ippicv_2020_lnx_intel64_20191018_general.tgz" + +def ipp_md5sum(d): + import re + arch = d.getVar('TARGET_ARCH') + if re.match("i.86$", arch): + return "ad189a940fb60eb71f291321322fe3e8" + else: + return "7421de0095c7a39162ae13a6098782f9" + +IPP_FILENAME = "${@ipp_filename(d)}" +IPP_MD5 = "${@ipp_md5sum(d)}" + +SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg" +SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \ + git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \ + git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20191018;destsuffix=ipp;name=ipp \ + git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=boostdesc;name=boostdesc \ + git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=vgg;name=vgg \ + git://github.com/opencv/opencv_3rdparty.git;branch=contrib_face_alignment_20170818;destsuffix=face;name=face \ + git://github.com/WeChatCV/opencv_3rdparty.git;branch=wechat_qrcode;destsuffix=wechat_qrcode;name=wechat-qrcode \ + file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \ + file://0003-To-fix-errors-as-following.patch \ + file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \ + file://0001-Dont-use-isystem.patch \ + file://download.patch \ + file://0001-Make-ts-module-external.patch \ + file://0001-sfm-link-with-Glog_LIBS.patch;patchdir=../contrib \ + " +SRC_URI_append_riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=../contrib" + +S = "${WORKDIR}/git" + +# OpenCV wants to download more files during configure. We download these in +# do_fetch and construct a source cache in the format it expects +OPENCV_DLDIR = "${WORKDIR}/downloads" + +do_unpack_extra() { + tar xzf ${WORKDIR}/ipp/ippicv/${IPP_FILENAME} -C ${WORKDIR} + + md5() { + # Return the MD5 of $1 + echo $(md5sum $1 | cut -d' ' -f1) + } + cache() { + TAG=$1 + shift + mkdir --parents ${OPENCV_DLDIR}/$TAG + for F in $*; do + DEST=${OPENCV_DLDIR}/$TAG/$(md5 $F)-$(basename $F) + test -e $DEST || ln -s $F $DEST + done + } + cache xfeatures2d/boostdesc ${WORKDIR}/boostdesc/*.i + cache xfeatures2d/vgg ${WORKDIR}/vgg/*.i + cache data ${WORKDIR}/face/*.dat + cache wechat_qrcode ${WORKDIR}/wechat_qrcode/*.caffemodel + cache wechat_qrcode ${WORKDIR}/wechat_qrcode/*.prototxt +} +addtask unpack_extra after do_unpack before do_patch + +CMAKE_VERBOSE = "VERBOSE=1" + +EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \ + -DWITH_1394=OFF \ + -DENABLE_PRECOMPILED_HEADERS=OFF \ + -DCMAKE_SKIP_RPATH=ON \ + -DOPENCV_ICV_HASH=${IPP_MD5} \ + -DIPPROOT=${WORKDIR}/ippicv_lnx \ + -DOPENCV_GENERATE_PKGCONFIG=ON \ + -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \ + -DOPENCV_ALLOW_DOWNLOADS=OFF \ + ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \ + ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \ + ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.2", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1 -DENABLE_SSE42=1", "", d)} \ +" +EXTRA_OECMAKE_append_x86 = " -DX86=ON" + +PACKAGECONFIG ??= "gapi python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \ + ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \ + ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}" + +PACKAGECONFIG[gapi] = "-DWITH_ADE=ON -Dade_DIR=${STAGING_LIBDIR},-DWITH_ADE=OFF,ade" +PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas," +PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft," +PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native," +PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog," +PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype," +PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2," +PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base," +PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3," +PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper," +PACKAGECONFIG[java] = "-DJAVA_INCLUDE_PATH=${JAVA_HOME}/include -DJAVA_INCLUDE_PATH2=${JAVA_HOME}/include/linux -DJAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include -DJAVA_AWT_LIBRARY=${JAVA_HOME}/lib/amd64/libjawt.so -DJAVA_JVM_LIBRARY=${JAVA_HOME}/lib/amd64/server/libjvm.so,,ant-native fastjar-native openjdk-8-native," +PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg," +PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav," +PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils," +PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd," +PACKAGECONFIG[oracle-java] = "-DJAVA_INCLUDE_PATH=${ORACLE_JAVA_HOME}/include -DJAVA_INCLUDE_PATH2=${ORACLE_JAVA_HOME}/include/linux -DJAVA_AWT_INCLUDE_PATH=${ORACLE_JAVA_HOME}/include -DJAVA_AWT_LIBRARY=${ORACLE_JAVA_HOME}/lib/amd64/libjawt.so -DJAVA_JVM_LIBRARY=${ORACLE_JAVA_HOME}/lib/amd64/server/libjvm.so,,ant-native oracle-jse-jdk oracle-jse-jdk-native," +PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng," +PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy," +PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy," +PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,," +PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb," +PACKAGECONFIG[tests] = "-DBUILD_TESTS=ON,-DBUILD_TESTS=OFF,," +PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract," +PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff," +PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils," + +inherit pkgconfig cmake + +inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)} +inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)} + +export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}" +export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}" +export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java" +export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native" +export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/" + +TARGET_CC_ARCH += "-I${S}/include " + +PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \ + ${PN}-apps" + +python populate_packages_prepend () { + cv_libdir = d.expand('${libdir}') + do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True) + do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') + do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') + do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True) + + pn = d.getVar('PN') + metapkg = pn + '-dev' + d.setVar('ALLOW_EMPTY_' + metapkg, "1") + blacklist = [ metapkg ] + metapkg_rdepends = [ ] + packages = d.getVar('PACKAGES').split() + for pkg in packages[1:]: + if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'): + metapkg_rdepends.append(pkg) + d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends)) + + metapkg = pn + d.setVar('ALLOW_EMPTY_' + metapkg, "1") + blacklist = [ metapkg, "libopencv-ts" ] + metapkg_rdepends = [ ] + for pkg in packages[1:]: + if not pkg in blacklist and not pkg in metapkg_rdepends and not pkg.endswith('-dev') and not pkg.endswith('-dbg') and not pkg.endswith('-doc') and not pkg.endswith('-locale') and not pkg.endswith('-staticdev'): + metapkg_rdepends.append(pkg) + d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends)) +} + +PACKAGES_DYNAMIC += "^libopencv-.*" + +FILES_${PN} = "" +FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*" +FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${libdir}/cmake/opencv4/*.cmake" +FILES_${PN}-staticdev += "${libdir}/opencv4/3rdparty/*.a" +FILES_${PN}-apps = "${bindir}/* ${datadir}/opencv4 ${datadir}/licenses" +FILES_${PN}-java = "${datadir}/OpenCV/java" +FILES_${PN}-samples = "${datadir}/opencv4/samples/" + +INSANE_SKIP_${PN}-java = "libdir" +INSANE_SKIP_${PN}-dbg = "libdir" + +ALLOW_EMPTY_${PN} = "1" + +SUMMARY_python-opencv = "Python bindings to opencv" +FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" +RDEPENDS_python-opencv = "python-core python-numpy" + +SUMMARY_python3-opencv = "Python bindings to opencv" +FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" +RDEPENDS_python3-opencv = "python3-core python3-numpy" + +RDEPENDS_${PN}-apps = "bash" + +do_compile_prepend() { + # remove the build host info to improve reproducibility + if [ -f ${WORKDIR}/build/modules/core/version_string.inc ]; then + sed -i "s#${WORKDIR}#/workdir#g" ${WORKDIR}/build/modules/core/version_string.inc + fi +} + +do_install_append() { + # Move Python files into correct library folder (for multilib build) + if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then + mv ${D}/usr/lib/* ${D}/${libdir}/ + rm -rf ${D}/usr/lib + fi + # remove build host path to improve reproducibility + if [ -f ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake ]; then + sed -e 's@${STAGING_DIR_HOST}@@g' \ + -i ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake + fi +} + +TOOLCHAIN = "gcc" + +########## End of meta-openembedded copy ########## + +########## i.MX overrides ########## + +SUMMARY = "Opencv : The Open Computer Vision Library, i.MX Fork" + +LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +# Replace the opencv URL with the fork +SRCREV_opencv = "5423d53ae0d116ee5bbe52f8b5503f0cd8586998" +OPENCV_SRC ?= "git://source.codeaurora.org/external/imx/opencv-imx.git;protocol=https" +SRCBRANCH = "4.5.2_imx" +SRC_URI_remove = "git://github.com/opencv/opencv.git;name=opencv" +SRC_URI =+ "${OPENCV_SRC};branch=${SRCBRANCH};name=opencv" + +# Add opencv_extra +SRCREV_extra = "855c4528402e563283f86f28c6393f57eb5dcf62" +SRC_URI += " \ + git://github.com/opencv/opencv_extra.git;destsuffix=extra;name=extra \ + file://0001-Add-smaller-version-of-download_models.py.patch;patchdir=../extra \ +" +SRCREV_FORMAT_append = "_extra" + +# Add tiny-dnn +SRC_URI[tinydnn.md5sum] = "adb1c512e09ca2c7a6faef36f9c53e59" +SRC_URI[tinydnn.sha256sum] = "e2c61ce8c5debaa644121179e9dbdcf83f497f39de853f8dd5175846505aa18b" +SRC_URI += " \ + https://github.com/tiny-dnn/tiny-dnn/archive/v1.0.0a3.tar.gz;destsuffix=git/3rdparty/tinydnn/tiny-dnn-1.0.0a3;name=tinydnn;unpack=false \ + file://OpenCV_DNN_examples.patch \ +" + +PACKAGECONFIG_remove = "eigen" +PACKAGECONFIG_append_mx8 = " dnn text" +PACKAGECONFIG_OPENCL = "" +PACKAGECONFIG_OPENCL_mx8 = "opencl" +PACKAGECONFIG_OPENCL_mx8dxl = "" +PACKAGECONFIG_OPENCL_mx8phantomdxl = "" +PACKAGECONFIG_OPENCL_mx8mm = "" +PACKAGECONFIG_OPENCL_mx8mnlite = "" +PACKAGECONFIG_append = " ${PACKAGECONFIG_OPENCL}" + +PACKAGECONFIG[openvx] = "-DWITH_OPENVX=ON -DOPENVX_ROOT=${STAGING_LIBDIR} -DOPENVX_LIB_CANDIDATES='OpenVX;OpenVXU',-DWITH_OPENVX=OFF,virtual/libopenvx," +PACKAGECONFIG[qt5] = "-DWITH_QT=ON -DOE_QMAKE_PATH_EXTERNAL_HOST_BINS=${STAGING_BINDIR_NATIVE} -DCMAKE_PREFIX_PATH=${STAGING_BINDIR_NATIVE}/cmake,-DWITH_QT=OFF,qtbase qtbase-native," +PACKAGECONFIG[tests-imx] = "-DINSTALL_TESTS=ON -DOPENCV_TEST_DATA_PATH=${S}/../extra/testdata, -DINSTALL_TESTS=OFF," + +do_unpack_extra_append() { + mkdir -p ${S}/3rdparty/tinydnn/ + tar xzf ${WORKDIR}/v1.0.0a3.tar.gz -C ${S}/3rdparty/tinydnn/ +} + +do_install_append() { + ln -sf opencv4/opencv2 ${D}${includedir}/opencv2 + install -d ${D}${datadir}/OpenCV/samples/data + cp -r ${S}/samples/data/* ${D}${datadir}/OpenCV/samples/data + install -d ${D}${datadir}/OpenCV/samples/bin/ + cp -f bin/example_* ${D}${datadir}/OpenCV/samples/bin/ + if ${@bb.utils.contains('PACKAGECONFIG', 'tests-imx', 'true', 'false', d)}; then + cp -r share/opencv4/testdata/cv/face/* ${D}${datadir}/opencv4/testdata/cv/face/ + fi +} + +FILES_${PN}-samples += "${datadir}/OpenCV/samples" + +COMPATIBLE_MACHINE = "(mx8)" + +########## End of i.MX overrides ########## diff --git a/meta-digi-dey/recipes-support/opencv/opencv_4.5.2.imx.bbappend b/meta-digi-dey/recipes-support/opencv/opencv_4.5.2.imx.bbappend new file mode 100644 index 000000000..019d9018a --- /dev/null +++ b/meta-digi-dey/recipes-support/opencv/opencv_4.5.2.imx.bbappend @@ -0,0 +1,2 @@ +SRCREV_opencv = "5423d53ae0d116ee5bbe52f8b5503f0cd8586998" +PACKAGECONFIG_OPENCL_mx8mnul = "" From 37832e8b3bc2ad2581b456e3f121d9ee74237c94 Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Tue, 3 Aug 2021 11:51:11 +0200 Subject: [PATCH 06/70] glibc: upgrade to version 2.33 for eIQ support Signed-off-by: Mike Engel --- .../glibc/cross-localedef-native_2.33.bb | 50 + .../recipes-core/glibc/glibc-collateral.inc | 12 + .../recipes-core/glibc/glibc-common.inc | 25 + meta-digi-dey/recipes-core/glibc/glibc-ld.inc | 20 + .../recipes-core/glibc/glibc-locale.inc | 103 ++ .../recipes-core/glibc/glibc-locale_2.33.bb | 1 + .../recipes-core/glibc/glibc-mtrace.inc | 16 + .../recipes-core/glibc/glibc-mtrace_2.33.bb | 1 + .../recipes-core/glibc/glibc-package.inc | 286 +++ .../recipes-core/glibc/glibc-scripts.inc | 23 + .../recipes-core/glibc/glibc-scripts_2.33.bb | 1 + .../glibc/glibc-testsuite_2.33.bb | 63 + .../recipes-core/glibc/glibc-version.inc | 8 + meta-digi-dey/recipes-core/glibc/glibc.inc | 52 + ...dd-hardlink-resolver-from-util-linux.patch | 1130 ++++++++++++ ...-private-futex-optimization-BZ-27304.patch | 49 + ...-fix-ups-hardlink-to-make-it-compile.patch | 238 +++ ...Look-for-host-system-ld.so.cache-as-.patch | 65 + ...Fix-buffer-overrun-with-a-relocated-.patch | 46 + ...Raise-the-size-of-arrays-containing-.patch | 153 ++ ...k-glibc-Allow-64-bit-atomics-for-x86.patch | 39 + ...Make-relocatable-install-for-locales.patch | 100 ++ ...5500-e6500-603e-fsqrt-implementation.patch | 1581 +++++++++++++++++ ...undefined-reference-to-__sqrt_finite.patch | 205 +++ ...-are-now-inline-functions-and-call-o.patch | 384 ++++ ...443-which-explains-what-the-patch-do.patch | 58 + ...m-err-tab.pl-with-specific-dirs-in-S.patch | 33 + ...-are-now-inline-functions-and-call-o.patch | 58 + ...igure.ac-handle-correctly-libc_cv_ro.patch | 39 + ...the-path-sets-wrong-config-variables.patch | 260 +++ ...zone-re-written-tzselect-as-posix-sh.patch | 42 + ...bash-dependency-for-nscd-init-script.patch | 72 + ...ss-building-and-testing-instructions.patch | 616 +++++++ ...glibc-Help-bootstrap-cross-toolchain.patch | 97 + ...eglibc-Resolve-__fpscr_values-on-SH4.patch | 53 + ...port-cross-locale-generation-support.patch | 560 ++++++ ...Define-DUMMY_LOCALE_T-if-not-defined.patch | 29 + ...-archive-uses-a-hard-coded-locale-pa.patch | 80 + ...ke-_dl_build_local_scope-breadth-fir.patch | 53 + ...it-no-lines-in-bison-generated-files.patch | 31 + ...aybe-uninitialized-errors-with-Os-BZ.patch | 53 + ...RE_KNOWN_INTERPRETER_NAMES-to-known-.patch | 29 + ...y-the-header-between-arm-and-aarch64.patch | 75 + ...Do-not-ask-compiler-for-finding-arch.patch | 48 + ...-ISA-support-for-x86-64-level-marker.patch | 116 ++ ...ork-around-GCC-PR-98512-in-rawmemchr.patch | 58 + ...-_SC_LEVEL1_ICACHE_LINESIZE-BZ-27444.patch | 185 ++ .../glibc/glibc/CVE-2021-27645.patch | 51 + .../glibc/glibc/check-test-wrapper | 80 + .../recipes-core/glibc/glibc/etc/ld.so.conf | 1 + .../glibc/glibc/faccessat2-perm.patch | 31 + .../glibc/glibc/generate-supported.mk | 11 + .../recipes-core/glibc/glibc/makedbs.sh | 177 ++ .../recipes-core/glibc/glibc_2.33.bb | 136 ++ .../ldconfig-native-2.12.1/32and64bit.patch | 331 ++++ .../glibc/ldconfig-native-2.12.1/README | 8 + .../add-64-bit-flag-for-ELF64-entries.patch | 116 ++ .../endian-ness_handling.patch | 454 +++++ .../endian-ness_handling_fix.patch | 47 + .../endianess-header.patch | 113 ++ .../ldconfig-native-2.12.1/flag_fix.patch | 24 + ...dconfig-default-to-all-multilib-dirs.patch | 37 + .../ldconfig-native-2.12.1.tar.bz2 | Bin 0 -> 21491 bytes .../ldconfig-native-2.12.1/ldconfig.patch | 471 +++++ .../ldconfig_aux-cache_path_fix.patch | 36 + .../ldconfig-native-2.12.1/no-aux-cache.patch | 19 + .../glibc/ldconfig-native_2.12.1.bb | 35 + 67 files changed, 9474 insertions(+) create mode 100644 meta-digi-dey/recipes-core/glibc/cross-localedef-native_2.33.bb create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-collateral.inc create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-common.inc create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-ld.inc create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-locale.inc create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-locale_2.33.bb create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-mtrace.inc create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-mtrace_2.33.bb create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-package.inc create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-scripts.inc create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-scripts_2.33.bb create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-testsuite_2.33.bb create mode 100644 meta-digi-dey/recipes-core/glibc/glibc-version.inc create mode 100644 meta-digi-dey/recipes-core/glibc/glibc.inc create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0001-nptl-Remove-private-futex-optimization-BZ-27304.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0009-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0010-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0011-Quote-from-bug-1443-which-explains-what-the-patch-do.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0012-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0013-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0014-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0017-Remove-bash-dependency-for-nscd-init-script.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0020-eglibc-Resolve-__fpscr_values-on-SH4.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0021-eglibc-Forward-port-cross-locale-generation-support.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0022-Define-DUMMY_LOCALE_T-if-not-defined.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0023-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0024-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0025-intl-Emit-no-lines-in-bison-generated-files.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0027-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0028-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0029-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0030-powerpc-Do-not-ask-compiler-for-finding-arch.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0031-x86-Require-full-ISA-support-for-x86-64-level-marker.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0032-string-Work-around-GCC-PR-98512-in-rawmemchr.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/0033-x86-Handle-_SC_LEVEL1_ICACHE_LINESIZE-BZ-27444.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/CVE-2021-27645.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/check-test-wrapper create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/etc/ld.so.conf create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/faccessat2-perm.patch create mode 100644 meta-digi-dey/recipes-core/glibc/glibc/generate-supported.mk create mode 100755 meta-digi-dey/recipes-core/glibc/glibc/makedbs.sh create mode 100644 meta-digi-dey/recipes-core/glibc/glibc_2.33.bb create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/32and64bit.patch create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/README create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/add-64-bit-flag-for-ELF64-entries.patch create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endian-ness_handling.patch create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endian-ness_handling_fix.patch create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endianess-header.patch create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/flag_fix.patch create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig-default-to-all-multilib-dirs.patch create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig-native-2.12.1.tar.bz2 create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig.patch create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/no-aux-cache.patch create mode 100644 meta-digi-dey/recipes-core/glibc/ldconfig-native_2.12.1.bb diff --git a/meta-digi-dey/recipes-core/glibc/cross-localedef-native_2.33.bb b/meta-digi-dey/recipes-core/glibc/cross-localedef-native_2.33.bb new file mode 100644 index 000000000..ec59c6ba1 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/cross-localedef-native_2.33.bb @@ -0,0 +1,50 @@ +SUMMARY = "Cross locale generation tool for glibc" +HOMEPAGE = "http://www.gnu.org/software/libc/libc.html" +SECTION = "libs" +LICENSE = "LGPL-2.1" + +LIC_FILES_CHKSUM = "file://LICENSES;md5=1541fd8f5e8f1579512bf05f533371ba \ + file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ + file://posix/rxspencer/COPYRIGHT;md5=dc5485bb394a13b2332ec1c785f5d83a \ + file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c" + +require glibc-version.inc + +# Tell autotools that we're working in the localedef directory +# +AUTOTOOLS_SCRIPT_PATH = "${S}/localedef" + +inherit autotools +inherit native + +FILESEXTRAPATHS =. "${FILE_DIRNAME}/${PN}:${FILE_DIRNAME}/glibc:" + +SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ + git://github.com/kraj/localedef;branch=master;name=localedef;destsuffix=git/localedef \ + \ + file://0001-localedef-Add-hardlink-resolver-from-util-linux.patch \ + file://0002-localedef-fix-ups-hardlink-to-make-it-compile.patch \ + \ + file://0016-timezone-re-written-tzselect-as-posix-sh.patch \ + file://0017-Remove-bash-dependency-for-nscd-init-script.patch \ + file://0018-eglibc-Cross-building-and-testing-instructions.patch \ + file://0019-eglibc-Help-bootstrap-cross-toolchain.patch \ + file://0020-eglibc-Resolve-__fpscr_values-on-SH4.patch \ + file://0021-eglibc-Forward-port-cross-locale-generation-support.patch \ + file://0022-Define-DUMMY_LOCALE_T-if-not-defined.patch \ + file://0023-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \ +" +# Makes for a rather long rev (22 characters), but... +# +SRCREV_FORMAT = "glibc_localedef" + +S = "${WORKDIR}/git" + +EXTRA_OECONF = "--with-glibc=${S}" +CFLAGS += "-fgnu89-inline -std=gnu99 -DIS_IN\(x\)='0'" + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${B}/localedef ${D}${bindir}/cross-localedef + install -m 0755 ${B}/cross-localedef-hardlink ${D}${bindir}/cross-localedef-hardlink +} diff --git a/meta-digi-dey/recipes-core/glibc/glibc-collateral.inc b/meta-digi-dey/recipes-core/glibc/glibc-collateral.inc new file mode 100644 index 000000000..4f81f07da --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-collateral.inc @@ -0,0 +1,12 @@ +require glibc-common.inc + +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 \ + file://${COMMON_LICENSE_DIR}/LGPL-2.1-only;md5=1a6d268fd218675ffea8be556788b780" + +deltask do_fetch +deltask do_unpack +deltask do_patch +do_configure[noexec] = "1" +do_compile[noexec] = "1" + +do_install[depends] += "virtual/${MLPREFIX}libc:do_stash_locale" diff --git a/meta-digi-dey/recipes-core/glibc/glibc-common.inc b/meta-digi-dey/recipes-core/glibc/glibc-common.inc new file mode 100644 index 000000000..41ff7e9a1 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-common.inc @@ -0,0 +1,25 @@ +SUMMARY = "GLIBC (GNU C Library)" +DESCRIPTION = "The GNU C Library is used as the system C library in most systems with the Linux kernel." +HOMEPAGE = "http://www.gnu.org/software/libc/libc.html" +SECTION = "libs" +LICENSE = "GPLv2 & LGPLv2.1" + +LIC_FILES_CHKSUM ?= "file://LICENSES;md5=1541fd8f5e8f1579512bf05f533371ba \ + file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ + file://posix/rxspencer/COPYRIGHT;md5=dc5485bb394a13b2332ec1c785f5d83a \ + file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c" + +CVE_PRODUCT = "glibc" + +INHIBIT_DEFAULT_DEPS = "1" + +ARM_INSTRUCTION_SET_armv4 = "arm" +ARM_INSTRUCTION_SET_armv5 = "arm" +ARM_INSTRUCTION_SET_armv6 = "arm" +# +# We will skip parsing glibc when target system C library selection is not glibc +# this helps in easing out parsing for non-glibc system libraries +# +COMPATIBLE_HOST_libc-musl_class-target = "null" + +PV = "2.33" diff --git a/meta-digi-dey/recipes-core/glibc/glibc-ld.inc b/meta-digi-dey/recipes-core/glibc/glibc-ld.inc new file mode 100644 index 000000000..041ffbb9c --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-ld.inc @@ -0,0 +1,20 @@ +inherit linuxloader + +GLIBC_GETLOADER = "${@get_linuxloader(d)}" + +def glibc_dl_info(d): + infos = {'ldconfig':set(), 'lddrewrite':set()} + + loaders = all_multilib_tune_values(d, "GLIBC_GETLOADER").split() + for loader in loaders: + infos['ldconfig'].add('{"' + loader + '",' + "FLAG_ELF_LIBC6" + ' }') + infos['lddrewrite'].add(loader) + + infos['ldconfig'] = ','.join(sorted(infos['ldconfig'])) + infos['lddrewrite'] = ' '.join(sorted(infos['lddrewrite'])) + return infos + +EGLIBC_KNOWN_INTERPRETER_NAMES = "${@glibc_dl_info(d)['ldconfig']}" +RTLDLIST = "${@glibc_dl_info(d)['lddrewrite']}" +RTLDLIST_class-nativesdk = "${base_libdir}/${@bb.utils.contains('SDK_ARCH', 'x86_64', 'ld-linux-x86-64.so.2', 'ld-linux.so.2', d)}" +glibc_dl_info[vardepsexclude] = "OVERRIDES" diff --git a/meta-digi-dey/recipes-core/glibc/glibc-locale.inc b/meta-digi-dey/recipes-core/glibc/glibc-locale.inc new file mode 100644 index 000000000..ef06389ff --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-locale.inc @@ -0,0 +1,103 @@ +require glibc-collateral.inc + +SUMMARY = "Locale data from glibc" + +BPN = "glibc" +LOCALEBASEPN = "${MLPREFIX}glibc" + +# glibc-collateral.inc inhibits all default deps, but do_package needs objcopy +# ERROR: objcopy failed with exit code 127 (cmd was 'i586-webos-linux-objcopy' --only-keep-debug 'glibc-locale/2.17-r0/package/usr/lib/gconv/IBM1166.so' 'glibc-locale/2.17-r0/package/usr/lib/gconv/.debug/IBM1166.so') +# ERROR: Function failed: split_and_strip_files +BINUTILSDEP = "virtual/${MLPREFIX}${TARGET_PREFIX}binutils:do_populate_sysroot" +BINUTILSDEP_class-nativesdk = "virtual/${TARGET_PREFIX}binutils-crosssdk:do_populate_sysroot" +do_package[depends] += "${BINUTILSDEP}" + +DEPENDS += "virtual/libc" + +# Binary locales are generated at build time if ENABLE_BINARY_LOCALE_GENERATION +# is set. The idea is to avoid running localedef on the target (at first boot) +# to decrease initial boot time and avoid localedef being killed by the OOM +# killer which used to effectively break i18n on machines with < 128MB RAM. + +# default to disabled +ENABLE_BINARY_LOCALE_GENERATION ?= "0" +ENABLE_BINARY_LOCALE_GENERATION_pn-nativesdk-glibc-locale = "1" + +#enable locale generation on these arches +# BINARY_LOCALE_ARCHES is a space separated list of regular expressions +BINARY_LOCALE_ARCHES ?= "arc arm.* aarch64 i[3-6]86 x86_64 powerpc mips mips64 riscv32 riscv64" + +# set "1" to use cross-localedef for locale generation +# set "0" for qemu emulation of native localedef for locale generation +LOCALE_GENERATION_WITH_CROSS-LOCALEDEF = "1" + +PROVIDES = "virtual/libc-locale" + +PACKAGES = "localedef ${PN}-dbg" + +PACKAGES_DYNAMIC = "^locale-base-.* \ + ^glibc-gconv-.* ^glibc-charmap-.* ^glibc-localedata-.* ^glibc-binary-localedata-.* \ + ^${MLPREFIX}glibc-gconv$" + +# Create a glibc-binaries package +ALLOW_EMPTY_${BPN}-binaries = "1" +PACKAGES += "${BPN}-binaries" +RRECOMMENDS_${BPN}-binaries = "${@" ".join([p for p in d.getVar('PACKAGES').split() if p.find("glibc-binary") != -1])}" + +# Create a glibc-charmaps package +ALLOW_EMPTY_${BPN}-charmaps = "1" +PACKAGES += "${BPN}-charmaps" +RRECOMMENDS_${BPN}-charmaps = "${@" ".join([p for p in d.getVar('PACKAGES').split() if p.find("glibc-charmap") != -1])}" + +# Create a glibc-gconvs package +ALLOW_EMPTY_${BPN}-gconvs = "1" +PACKAGES += "${BPN}-gconvs" +RRECOMMENDS_${BPN}-gconvs = "${@" ".join([p for p in d.getVar('PACKAGES').split() if p.find("glibc-gconv") != -1])}" + +# Create a glibc-localedatas package +ALLOW_EMPTY_${BPN}-localedatas = "1" +PACKAGES += "${BPN}-localedatas" +RRECOMMENDS_${BPN}-localedatas = "${@" ".join([p for p in d.getVar('PACKAGES').split() if p.find("glibc-localedata") != -1])}" + +DESCRIPTION_localedef = "glibc: compile locale definition files" + +# glibc-gconv is dynamically added into PACKAGES, thus +# FILES_glibc-gconv will not be automatically extended in multilib. +# Explicitly add ${MLPREFIX} for FILES_glibc-gconv. +FILES_${MLPREFIX}glibc-gconv = "${libdir}/gconv/*" +FILES_localedef = "${bindir}/localedef" + +LOCALETREESRC = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale" + +copy_locale_files() { + local dir=$1 mode=$2 + + [ -e "${LOCALETREESRC}$dir" ] || return 0 + + for d in . $(find "${LOCALETREESRC}$dir" -type d -printf '%P '); do + install -d ${D}$dir/$d + find "${LOCALETREESRC}$dir/$d" -maxdepth 1 -type f \ + -exec install -m $mode -t "${D}$dir/$d" {} \; + done +} + +do_install() { + copy_locale_files ${bindir} 0755 + copy_locale_files ${localedir} 0644 + if [ ${PACKAGE_NO_GCONV} -eq 0 ]; then + copy_locale_files ${libdir}/gconv 0755 + copy_locale_files ${datadir}/i18n 0644 + else + # Remove the libdir if it is empty when gconv is not copied + find ${D}${libdir} -type d -empty -delete + fi + copy_locale_files ${datadir}/locale 0644 + install -m 0644 ${LOCALETREESRC}/SUPPORTED ${WORKDIR}/SUPPORTED +} + +inherit libc-package + +BBCLASSEXTEND = "nativesdk" + +# Don't scan for CVEs as glibc will be scanned +CVE_PRODUCT = "" diff --git a/meta-digi-dey/recipes-core/glibc/glibc-locale_2.33.bb b/meta-digi-dey/recipes-core/glibc/glibc-locale_2.33.bb new file mode 100644 index 000000000..f7702e035 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-locale_2.33.bb @@ -0,0 +1 @@ +require glibc-locale.inc diff --git a/meta-digi-dey/recipes-core/glibc/glibc-mtrace.inc b/meta-digi-dey/recipes-core/glibc/glibc-mtrace.inc new file mode 100644 index 000000000..ef9d60ec2 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-mtrace.inc @@ -0,0 +1,16 @@ +require glibc-collateral.inc + +SUMMARY = "mtrace utility provided by glibc" +DESCRIPTION = "mtrace utility provided by glibc" +RDEPENDS_${PN} = "perl" +RPROVIDES_${PN} = "libc-mtrace" + +SRC = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale/scripts" + +do_install() { + install -d -m 0755 ${D}${bindir} + install -m 0755 ${SRC}/mtrace ${D}${bindir}/ +} + +# Don't scan for CVEs as glibc will be scanned +CVE_PRODUCT = "" diff --git a/meta-digi-dey/recipes-core/glibc/glibc-mtrace_2.33.bb b/meta-digi-dey/recipes-core/glibc/glibc-mtrace_2.33.bb new file mode 100644 index 000000000..0b69bad46 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-mtrace_2.33.bb @@ -0,0 +1 @@ +require glibc-mtrace.inc diff --git a/meta-digi-dey/recipes-core/glibc/glibc-package.inc b/meta-digi-dey/recipes-core/glibc/glibc-package.inc new file mode 100644 index 000000000..8d0cc8047 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-package.inc @@ -0,0 +1,286 @@ +INHIBIT_SYSROOT_STRIP = "1" + +PACKAGES = "${PN}-dbg catchsegv sln nscd ldconfig ldd tzcode glibc-thread-db ${PN}-pic libcidn libmemusage libnss-db libsegfault ${PN}-pcprofile libsotruss ${PN} ${PN}-utils glibc-extra-nss ${PN}-dev ${PN}-staticdev ${PN}-doc" + +# The ld.so in this glibc supports the GNU_HASH +RPROVIDES_${PN} = "eglibc rtld(GNU_HASH)" +RPROVIDES_${PN}-utils = "eglibc-utils" +RPROVIDES_${PN}-mtrace = "eglibc-mtrace libc-mtrace" +RPROVIDES_${PN}-pic = "eglibc-pic" +RPROVIDES_${PN}-dev = "eglibc-dev libc6-dev virtual-libc-dev" +RPROVIDES_${PN}-staticdev = "eglibc-staticdev" +RPROVIDES_${PN}-doc = "eglibc-doc" +RPROVIDES_glibc-extra-nss = "eglibc-extra-nss" +RPROVIDES_glibc-thread-db = "eglibc-thread-db" +RPROVIDES_${PN}-pcprofile = "eglibc-pcprofile" +RPROVIDES_${PN}-dbg = "eglibc-dbg" +libc_baselibs = "${base_libdir}/libc.so.* ${base_libdir}/libc-*.so ${base_libdir}/libm*.so.* ${base_libdir}/libm-*.so ${base_libdir}/libmvec-*.so ${base_libdir}/ld*.so.* ${base_libdir}/ld-*.so ${base_libdir}/libpthread*.so.* ${base_libdir}/libpthread-*.so ${base_libdir}/libresolv*.so.* ${base_libdir}/libresolv-*.so ${base_libdir}/librt*.so.* ${base_libdir}/librt-*.so ${base_libdir}/libutil*.so.* ${base_libdir}/libutil-*.so ${base_libdir}/libnsl*.so.* ${base_libdir}/libnsl-*.so ${base_libdir}/libnss_files*.so.* ${base_libdir}/libnss_files-*.so ${base_libdir}/libnss_compat*.so.* ${base_libdir}/libnss_compat-*.so ${base_libdir}/libnss_dns*.so.* ${base_libdir}/libnss_dns-*.so ${base_libdir}/libdl*.so.* ${base_libdir}/libdl-*.so ${base_libdir}/libanl*.so.* ${base_libdir}/libanl-*.so ${base_libdir}/libBrokenLocale*.so.* ${base_libdir}/libBrokenLocale-*.so" +ARCH_DYNAMIC_LOADER = "" +# The aarch64 ABI says the dynamic linker -must- be +# /lib/ld-linux-aarch64{,_be}.so.1. With usrmerge, that may mean that +# we need to install it in /usr/lib. +ARCH_DYNAMIC_LOADER_aarch64 = "ld-linux-${TARGET_ARCH}.so.1" +libc_baselibs_append = " ${@oe.utils.conditional('ARCH_DYNAMIC_LOADER', '', '', '${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}', d)}" +INSANE_SKIP_${PN}_append_aarch64 = " libdir" + +FILES_${PN} = "${libc_baselibs} ${libexecdir}/* ${sysconfdir}/ld.so.conf" +RRECOMMENDS_${PN} = "${@bb.utils.contains('DISTRO_FEATURES', 'ldconfig', '${MLPREFIX}ldconfig', '', d)}" +FILES_ldconfig = "${base_sbindir}/ldconfig" +FILES_ldd = "${bindir}/ldd" +FILES_libsegfault = "${base_libdir}/libSegFault*" +FILES_libcidn = "${base_libdir}/libcidn-*.so ${base_libdir}/libcidn.so.*" +FILES_libmemusage = "${base_libdir}/libmemusage.so" +FILES_libnss-db = "${base_libdir}/libnss_db.so.* ${base_libdir}/libnss_db-*.so ${localstatedir}/db/Makefile ${localstatedir}/db/makedbs.sh" +RDEPENDS_libnss-db = "${PN}-utils" +FILES_glibc-extra-nss = "${base_libdir}/libnss_*-*.so ${base_libdir}/libnss_*.so.*" +FILES_sln = "${base_sbindir}/sln" +FILES_${PN}-pic = "${libdir}/*_pic.a ${libdir}/*_pic.map ${libdir}/libc_pic/*.o" +FILES_libsotruss = "${libdir}/audit/sotruss-lib.so" +FILES_SOLIBSDEV = "${libdir}/lib*${SOLIBSDEV}" +FILES_${PN}-dev += "${libdir}/*_nonshared.a ${base_libdir}/*_nonshared.a ${base_libdir}/*.o ${datadir}/aclocal" +RDEPENDS_${PN}-dev = "linux-libc-headers-dev" +FILES_${PN}-staticdev += "${libdir}/*.a ${base_libdir}/*.a" +FILES_nscd = "${sbindir}/nscd* ${sysconfdir}/init.d/nscd ${systemd_unitdir}/system/nscd* ${sysconfdir}/tmpfiles.d/nscd.conf \ + ${sysconfdir}/nscd.conf ${sysconfdir}/default/volatiles/98_nscd ${localstatedir}/db/nscd" +FILES_${PN}-mtrace = "${bindir}/mtrace" +FILES_tzcode = "${bindir}/tzselect ${sbindir}/zic ${sbindir}/zdump" +FILES_${PN}-utils = "${bindir}/* ${sbindir}/*" +FILES_catchsegv = "${bindir}/catchsegv" +RDEPENDS_catchsegv = "libsegfault" +FILES_${PN}-pcprofile = "${base_libdir}/libpcprofile.so" +FILES_glibc-thread-db = "${base_libdir}/libthread_db.so.* ${base_libdir}/libthread_db-*.so" +RPROVIDES_${PN}-dev += "libc-dev" +RPROVIDES_${PN}-staticdev += "libc-staticdev" + +SUMMARY_sln = "The static ln" +DESCRIPTION_sln = "Similar to the 'ln' utility, but statically linked. sln is useful to make symbolic links to dynamic libraries if the dynamic linking system, for some reason, is not functional." +SUMMARY_nscd = "Name service cache daemon" +DESCRIPTION_nscd = "nscd, name service cache daemon, caches name service lookups for the passwd, group and hosts information. It can damatically improvide performance with remote, such as NIS or NIS+, name services." +SUMMARY_glibc-extra-nss = "hesiod, NIS and NIS+ nss libraries" +DESCRIPTION_glibc-extra-nss = "glibc: nis, nisplus and hesiod search services." +SUMMARY_ldd = "print shared library dependencies" +DESCRIPTION_ldd = "${bindir}/ldd prints shared library dependencies for each program or shared library specified on the command line." +SUMMARY_${PN}-utils = "Miscellaneous utilities provided by glibc" +DESCRIPTION_${PN}-utils = "Miscellaneous utilities including getconf, iconv, locale, gencat, ..." +DESCRIPTION_libsotruss = "Library to support sotruss which traces calls through PLTs" +DESCRIPTION_tzcode = "tzcode, timezone zoneinfo utils -- zic, zdump, tzselect" + +inherit multilib_header + +do_install() { + oe_runmake install_root=${D} install + install -Dm 0644 ${WORKDIR}/etc/ld.so.conf ${D}/${sysconfdir}/ld.so.conf + install -d ${D}${localedir} + make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED" + # get rid of some broken files... + for i in ${GLIBC_BROKEN_LOCALES}; do + sed -i "/$i/d" ${WORKDIR}/SUPPORTED + done + rm -f ${D}${sysconfdir}/rpc + rm -rf ${D}${datadir}/zoneinfo + rm -rf ${D}${libexecdir}/getconf + + rm -f ${D}${sysconfdir}/localtime + + # remove empty glibc dir + if [ -d ${D}${libexecdir} ]; then + rmdir --ignore-fail-on-non-empty ${D}${libexecdir} + fi + + oe_multilib_header bits/syscall.h bits/long-double.h bits/floatn.h bits/endianness.h bits/struct_rwlock.h + + if [ -f ${D}${bindir}/mtrace ]; then + sed -i -e '1s,#!.*perl,#! ${USRBINPATH}/env perl,' -e '2s,exec.*perl,exec ${USRBINPATH}/env perl,' ${D}${bindir}/mtrace + fi + # Info dir listing isn't interesting at this point so remove it if it exists. + if [ -e "${D}${infodir}/dir" ]; then + rm -f ${D}${infodir}/dir + fi + + install -d ${D}${sysconfdir}/init.d + install -d ${D}${localstatedir}/db/nscd + install -m 0755 ${S}/nscd/nscd.init ${D}${sysconfdir}/init.d/nscd + install -m 0755 ${S}/nscd/nscd.conf ${D}${sysconfdir}/nscd.conf + install -m 0755 ${WORKDIR}/makedbs.sh ${D}${localstatedir}/db + sed -i "s%daemon%start-stop-daemon --start --exec%g" ${D}${sysconfdir}/init.d/nscd + sed -i "s|\(enable-cache\t\+netgroup\t\+\)yes|\1no|" ${D}${sysconfdir}/nscd.conf + + install -d ${D}${systemd_unitdir}/system + install -m 0644 ${S}/nscd/nscd.service ${D}${systemd_unitdir}/system/ + + # The dynamic loader will have been installed into + # ${base_libdir}. However, if that isn't going to end up being + # available in the ABI-mandated location, then a symlink must + # be created. + + if [ -n "${ARCH_DYNAMIC_LOADER}" -a ! -e "${D}${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}" ]; then + install -d ${D}${root_prefix}/lib + ln -s ${@oe.path.relative('${root_prefix}/lib', '${base_libdir}')}/${ARCH_DYNAMIC_LOADER} \ + ${D}${root_prefix}/lib/${ARCH_DYNAMIC_LOADER} + fi +} + +def get_libc_fpu_setting(bb, d): + if d.getVar('TARGET_FPU') in [ 'soft', 'ppc-efd' ]: + return "--without-fp" + return "" + +do_install_append_class-target() { + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -d ${D}${sysconfdir}/tmpfiles.d + echo "d /run/nscd 755 root root -" \ + > ${D}${sysconfdir}/tmpfiles.d/nscd.conf + fi + + if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then + install -d ${D}${sysconfdir}/default/volatiles + echo "d root root 0755 /var/run/nscd none" \ + > ${D}${sysconfdir}/default/volatiles/98_nscd + fi + +} +do_install_append_aarch64 () { + do_install_armmultilib +} + +do_install_append_arm () { + do_install_armmultilib +} + +do_install_append_armeb () { + do_install_armmultilib +} + +do_install_armmultilib () { + oe_multilib_header bits/endian.h bits/fcntl.h bits/fenv.h bits/fp-fast.h bits/hwcap.h bits/ipc.h bits/link.h + oe_multilib_header bits/local_lim.h bits/mman.h bits/msq.h bits/pthreadtypes.h bits/pthreadtypes-arch.h bits/sem.h bits/semaphore.h bits/setjmp.h + oe_multilib_header bits/shm.h bits/sigstack.h bits/stat.h bits/statfs.h bits/typesizes.h + oe_multilib_header bits/procfs-id.h bits/procfs.h bits/shmlba.h + oe_multilib_header bits/struct_stat.h + + oe_multilib_header fpu_control.h gnu/lib-names.h gnu/stubs.h ieee754.h + + oe_multilib_header sys/elf.h sys/procfs.h sys/ptrace.h sys/ucontext.h sys/user.h +} + + +LOCALESTASH = "${WORKDIR}/stashed-locale" +bashscripts = "mtrace sotruss xtrace" + +do_stash_locale () { + dest=${LOCALESTASH} + install -d $dest${base_libdir} $dest${bindir} $dest${libdir} $dest${datadir} + # Hide away the locale data from the deployment + if [ -e ${D}${bindir}/localedef ]; then + cp -a ${D}${bindir}/localedef $dest${bindir} + fi + if [ -e ${D}${libdir}/gconv ]; then + cp -a ${D}${libdir}/gconv $dest${libdir} + fi + if [ -e ${D}${datadir}/i18n ]; then + cp -a ${D}${datadir}/i18n $dest${datadir} + fi + + # Make a copy of all the libraries into the locale stash + cp -fpPR ${D}${libdir}/* $dest${libdir} + if [ "${base_libdir}" != "${libdir}" ]; then + cp -fpPR ${D}${base_libdir}/* $dest${base_libdir} + fi + if [ -e ${D}${exec_prefix}/lib ]; then + if [ ${exec_prefix}/lib != ${base_libdir} ] && [ ${exec_prefix}/lib != ${libdir} ]; then + cp -fpPR ${D}${exec_prefix}/lib $dest${exec_prefix} + fi + fi + + cp -fpPR ${D}${datadir}/* $dest${datadir} + cp -fpPR ${WORKDIR}/SUPPORTED $dest + + target=$dest/scripts + mkdir -p $target + for i in ${bashscripts}; do + if [ -f ${D}${bindir}/$i ]; then + cp ${D}${bindir}/$i $target/ + fi + done +} + +addtask do_stash_locale after do_install before do_populate_sysroot do_package +do_stash_locale[dirs] = "${B}" +do_stash_locale[cleandirs] = "${LOCALESTASH}" +SSTATETASKS += "do_stash_locale" +do_stash_locale[sstate-inputdirs] = "${LOCALESTASH}" +do_stash_locale[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale" +do_stash_locale[sstate-fixmedir] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale" + +python do_stash_locale_setscene () { + sstate_setscene(d) +} +addtask do_stash_locale_setscene + +PACKAGE_PREPROCESS_FUNCS += "stash_locale_package_cleanup" +SYSROOT_PREPROCESS_FUNCS += "stash_locale_sysroot_cleanup" +stash_locale_cleanup () { + cleanupdir=$1 + # Remove all files which do_stash_locale() copies + for i in ${bashscripts}; do + rm -f $cleanupdir${bindir}/$i + done + rm -f $cleanupdir${bindir}/localedef + rm -rf $cleanupdir${datadir}/i18n + rm -rf $cleanupdir${libdir}/gconv + rm -rf $cleanupdir${localedir} + rm -rf $cleanupdir${datadir}/locale + rmdir --ignore-fail-on-non-empty $cleanupdir${datadir} + + if [ "${libdir}" != "${exec_prefix}/lib" ] && [ "${root_prefix}/lib" != "${exec_prefix}/lib" ]; then + if [ -d "$cleanupdir${exec_prefix}/lib" ]; then + if [ -z "${ARCH_DYNAMIC_LOADER}" -o \ + ! -e "$cleanupdir${exec_prefix}/lib/${ARCH_DYNAMIC_LOADER}" ]; then + # error out if directory isn't empty + # this dir should only contain locale dir + # which has been deleted in the previous step + rmdir $cleanupdir${exec_prefix}/lib + fi + fi + fi +} + +stash_locale_sysroot_cleanup() { + stash_locale_cleanup ${SYSROOT_DESTDIR} +} +stash_locale_package_cleanup() { + stash_locale_cleanup ${PKGD} +} + +python populate_packages_prepend () { + if d.getVar('DEBIAN_NAMES'): + pkgs = d.getVar('PACKAGES').split() + bpn = d.getVar('BPN') + prefix = d.getVar('MLPREFIX') or "" + # Set the base package... + d.setVar('PKG_' + prefix + bpn, prefix + 'libc6') + libcprefix = prefix + bpn + '-' + for p in pkgs: + # And all the subpackages. + if p.startswith(libcprefix): + renamed = p.replace(bpn, 'libc6', 1) + d.setVar('PKG_' + p, renamed) + # For backward compatibility with old -dbg package + d.appendVar('RPROVIDES_' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg') + d.appendVar('RCONFLICTS_' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg') + d.appendVar('RREPLACES_' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg') +} + +pkg_postinst_nscd () { + if [ -z "$D" ]; then + if command -v systemd-tmpfiles >/dev/null; then + systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/nscd.conf + elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then + ${sysconfdir}/init.d/populate-volatile.sh update + fi + fi +} +CONFFILES_nscd="${sysconfdir}/nscd.conf" + +SYSTEMD_PACKAGES = "nscd" +SYSTEMD_SERVICE_nscd = "nscd.service" diff --git a/meta-digi-dey/recipes-core/glibc/glibc-scripts.inc b/meta-digi-dey/recipes-core/glibc/glibc-scripts.inc new file mode 100644 index 000000000..14a14e451 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-scripts.inc @@ -0,0 +1,23 @@ +require glibc-collateral.inc + +SUMMARY = "utility scripts provided by glibc" +DESCRIPTION = "utility scripts provided by glibc" +RDEPENDS_${PN} = "bash glibc-mtrace" + +SRC = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale/scripts" + +bashscripts = "sotruss xtrace" + +do_install() { + install -d -m 0755 ${D}${bindir} + for i in ${bashscripts}; do + install -m 0755 ${SRC}/$i ${D}${bindir}/ + done +} + +# sotruss script requires sotruss-lib.so (given by libsotruss package), +# to produce trace of the library calls. +RDEPENDS_${PN} += "libsotruss" + +# Don't scan for CVEs as glibc will be scanned +CVE_PRODUCT = "" diff --git a/meta-digi-dey/recipes-core/glibc/glibc-scripts_2.33.bb b/meta-digi-dey/recipes-core/glibc/glibc-scripts_2.33.bb new file mode 100644 index 000000000..5a89bd802 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-scripts_2.33.bb @@ -0,0 +1 @@ +require glibc-scripts.inc diff --git a/meta-digi-dey/recipes-core/glibc/glibc-testsuite_2.33.bb b/meta-digi-dey/recipes-core/glibc/glibc-testsuite_2.33.bb new file mode 100644 index 000000000..d887aeff7 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-testsuite_2.33.bb @@ -0,0 +1,63 @@ +require glibc_${PV}.bb + +EXCLUDE_FROM_WORLD = "1" + +# handle PN differences +FILESEXTRAPATHS_prepend := "${THISDIR}/glibc:" + +# strip provides +PROVIDES = "" +# setup depends +INHIBIT_DEFAULT_DEPS = "" + +python () { + libc = d.getVar("PREFERRED_PROVIDER_virtual/libc") + libclocale = d.getVar("PREFERRED_PROVIDER_virtual/libc-locale") + if libc != "glibc" or libclocale != "glibc-locale": + raise bb.parse.SkipRecipe("glibc-testsuite requires that virtual/libc is glibc") +} + +DEPENDS += "glibc-locale libgcc gcc-runtime" + +# remove the initial depends +DEPENDS_remove = "libgcc-initial" + +inherit qemu + +SRC_URI += "file://check-test-wrapper" + +DEPENDS += "${@'qemu-native' if d.getVar('TOOLCHAIN_TEST_TARGET') == 'user' else ''}" + +TOOLCHAIN_TEST_TARGET ??= "user" +TOOLCHAIN_TEST_HOST ??= "localhost" +TOOLCHAIN_TEST_HOST_USER ??= "root" +TOOLCHAIN_TEST_HOST_PORT ??= "2222" + +do_check[dirs] += "${B}" +do_check[nostamp] = "1" +do_check () { + chmod 0755 ${WORKDIR}/check-test-wrapper + + # clean out previous test results + oe_runmake tests-clean + # makefiles don't clean entirely (and also sometimes fails due to too many args) + find ${B} -type f -name "*.out" -delete + find ${B} -type f -name "*.test-result" -delete + find ${B}/catgets -name "*.cat" -delete + find ${B}/conform -name "symlist-*" -delete + [ ! -e ${B}/timezone/testdata ] || rm -rf ${B}/timezone/testdata + + oe_runmake -i \ + QEMU_SYSROOT="${RECIPE_SYSROOT}" \ + QEMU_OPTIONS="${@qemu_target_binary(d)} ${QEMU_OPTIONS}" \ + SSH_HOST="${TOOLCHAIN_TEST_HOST}" \ + SSH_HOST_USER="${TOOLCHAIN_TEST_HOST_USER}" \ + SSH_HOST_PORT="${TOOLCHAIN_TEST_HOST_PORT}" \ + test-wrapper="${WORKDIR}/check-test-wrapper ${TOOLCHAIN_TEST_TARGET}" \ + check +} +addtask do_check after do_compile + +inherit nopackages +deltask do_stash_locale +deltask do_install diff --git a/meta-digi-dey/recipes-core/glibc/glibc-version.inc b/meta-digi-dey/recipes-core/glibc/glibc-version.inc new file mode 100644 index 000000000..3a9517317 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc-version.inc @@ -0,0 +1,8 @@ +SRCBRANCH ?= "release/2.33/master" +PV = "2.33" +SRCREV_glibc ?= "9826b03b747b841f5fc6de2054bf1ef3f5c4bdf3" +SRCREV_localedef ?= "bd644c9e6f3e20c5504da1488448173c69c56c28" + +GLIBC_GIT_URI ?= "git://sourceware.org/git/glibc.git" + +UPSTREAM_CHECK_GITTAGREGEX = "(?P\d+\.\d+(\.(?!90)\d+)*)" diff --git a/meta-digi-dey/recipes-core/glibc/glibc.inc b/meta-digi-dey/recipes-core/glibc/glibc.inc new file mode 100644 index 000000000..7d1430637 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc.inc @@ -0,0 +1,52 @@ +require glibc-common.inc +require glibc-ld.inc + +DEPENDS = "virtual/${TARGET_PREFIX}gcc libgcc-initial linux-libc-headers" + +PROVIDES = "virtual/libc" +PROVIDES += "virtual/libintl virtual/libiconv" +inherit autotools texinfo systemd + +LEAD_SONAME = "libc.so" + +# msgfmt could come from gettext-native but we don't depend on that and +# disable for reproducibility +CACHED_CONFIGUREVARS += " \ + ac_cv_path_BASH_SHELL=${base_bindir}/bash \ + ac_cv_prog_MSGFMT= \ + libc_cv_slibdir=${base_libdir} \ + libc_cv_rootsbindir=${base_sbindir} \ + libc_cv_localedir=${localedir} \ + libc_cv_ssp_strong=no \ + libc_cv_ssp_all=no \ + libc_cv_ssp=no \ + libc_cv_include_x86_isa_level=no \ +" + +# ifunc doesn't appear to work on mips, casuses libbfd assertion failures +CACHED_CONFIGUREVARS_append_mipsarch = " libc_cv_ld_gnu_indirect_function=no" + +GLIBC_EXTRA_OECONF ?= "" +GLIBC_EXTRA_OECONF_class-nativesdk = "" + +# glibc uses PARALLELMFLAGS variable to pass parallel build info so transfer +# PARALLEL_MAKE into PARALLELMFLAGS and empty out PARALLEL_MAKE +EGLIBCPARALLELISM := "PARALLELMFLAGS="${PARALLEL_MAKE}"" +EXTRA_OEMAKE[vardepsexclude] += "EGLIBCPARALLELISM" +EXTRA_OEMAKE += "${EGLIBCPARALLELISM}" +PARALLEL_MAKE = "" + +# glibc make-syscalls.sh has a number of issues with /bin/dash and +# it's output which make calls via the SHELL also has issues, so +# ensure make uses /bin/bash +EXTRA_OEMAKE += "SHELL=/bin/bash" + +do_configure_prepend() { + sed -e "s#@BASH@#/bin/sh#" -i ${S}/elf/ldd.bash.in +} + +# Enable backtrace from abort() +do_configure_append_arm () { + echo "CFLAGS-abort.c = -fasynchronous-unwind-tables" >> ${B}/configparms + echo "CFLAGS-raise.c = -fasynchronous-unwind-tables" >> ${B}/configparms +} diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch b/meta-digi-dey/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch new file mode 100644 index 000000000..f96da83a9 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch @@ -0,0 +1,1130 @@ +From d1f1671034a222417f9a829dcaa4f0c3d4f8954d Mon Sep 17 00:00:00 2001 +From: Jason Wessel +Date: Sat, 7 Dec 2019 09:59:22 -0800 +Subject: [PATCH] localedef: Add hardlink resolver from util-linux + +The hard link resolver that is built into localedef cannot be run in +parallel. It will search sibling directories (which are be processed +in parallel) and perform a creation of a .tmp file and remove the +original and move the .tmp file in. The problem is that if a probe +occurs a hard link can be requested to the file that is being removed. +This will lead to a stray copy or potentially, on a loaded system +cause race condition which pseudo cannot deal with, where it is left +with a hard link request to a file that no longer exists. In this +situation psuedo will inherit the permissions of what ever the target +inode had to offer. + +In short, there are two problems: + +1) You will be left with stray copies when using the hard link +resolution that is built in while running in parallel with +localedef. + +2) When running under pseudo the possibility exists for uid/gid +leakage when the source file is removed before the hard link can +be completed. + +The solution is to call localedef with --no-hard-links and separately +process the hardlinks at a later point. To do this requires the +inclusion of the hardlink utility found in modern versions of +util-linux. Most host systems do not have this, so it will be +included with the cross-localedef binary. + +[YOCTO #11299] +[YOCTO #12434] + +Upstream-Status: Pending + +Signed-off-by: Jason Wessel +Signed-off-by: Khem Raj +--- + locale/programs/c.h | 407 ++++++++++++++++ + locale/programs/cross-localedef-hardlink.c | 528 +++++++++++++++++++++ + locale/programs/xalloc.h | 129 +++++ + 3 files changed, 1064 insertions(+) + create mode 100644 locale/programs/c.h + create mode 100644 locale/programs/cross-localedef-hardlink.c + create mode 100644 locale/programs/xalloc.h + +diff --git a/locale/programs/c.h b/locale/programs/c.h +new file mode 100644 +index 0000000000..d0a402e90e +--- /dev/null ++++ b/locale/programs/c.h +@@ -0,0 +1,407 @@ ++/* ++ * Fundamental C definitions. ++ */ ++ ++#ifndef UTIL_LINUX_C_H ++#define UTIL_LINUX_C_H ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#ifdef HAVE_ERR_H ++# include ++#endif ++ ++#ifdef HAVE_SYS_SYSMACROS_H ++# include /* for major, minor */ ++#endif ++ ++#ifndef LOGIN_NAME_MAX ++# define LOGIN_NAME_MAX 256 ++#endif ++ ++#ifndef NAME_MAX ++# define NAME_MAX PATH_MAX ++#endif ++ ++/* ++ * __GNUC_PREREQ is deprecated in favour of __has_attribute() and ++ * __has_feature(). The __has macros are supported by clang and gcc>=5. ++ */ ++#ifndef __GNUC_PREREQ ++# if defined __GNUC__ && defined __GNUC_MINOR__ ++# define __GNUC_PREREQ(maj, min) \ ++ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) ++# else ++# define __GNUC_PREREQ(maj, min) 0 ++# endif ++#endif ++ ++#ifdef __GNUC__ ++ ++/* &a[0] degrades to a pointer: a different type from an array */ ++# define __must_be_array(a) \ ++ UL_BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(__typeof__(a), __typeof__(&a[0]))) ++ ++# define ignore_result(x) __extension__ ({ \ ++ __typeof__(x) __dummy __attribute__((__unused__)) = (x); (void) __dummy; \ ++}) ++ ++#else /* !__GNUC__ */ ++# define __must_be_array(a) 0 ++# define __attribute__(_arg_) ++# define ignore_result(x) ((void) (x)) ++#endif /* !__GNUC__ */ ++ ++/* ++ * It evaluates to 1 if the attribute/feature is supported by the current ++ * compilation targed. Fallback for old compilers. ++ */ ++#ifndef __has_attribute ++ #define __has_attribute(x) 0 ++#endif ++ ++#ifndef __has_feature ++ #define __has_feature(x) 0 ++#endif ++ ++/* ++ * Function attributes ++ */ ++#ifndef __ul_alloc_size ++# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3) ++# define __ul_alloc_size(s) __attribute__((alloc_size(s), warn_unused_result)) ++# else ++# define __ul_alloc_size(s) ++# endif ++#endif ++ ++#ifndef __ul_calloc_size ++# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3) ++# define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s), warn_unused_result)) ++# else ++# define __ul_calloc_size(n, s) ++# endif ++#endif ++ ++#if __has_attribute(returns_nonnull) || __GNUC_PREREQ (4, 9) ++# define __ul_returns_nonnull __attribute__((returns_nonnull)) ++#else ++# define __ul_returns_nonnull ++#endif ++ ++/* ++ * Force a compilation error if condition is true, but also produce a ++ * result (of value 0 and type size_t), so the expression can be used ++ * e.g. in a structure initializer (or wherever else comma expressions ++ * aren't permitted). ++ */ ++#define UL_BUILD_BUG_ON_ZERO(e) __extension__ (sizeof(struct { int:-!!(e); })) ++#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) ++ ++#ifndef ARRAY_SIZE ++# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) ++#endif ++ ++#ifndef PATH_MAX ++# define PATH_MAX 4096 ++#endif ++ ++#ifndef TRUE ++# define TRUE 1 ++#endif ++ ++#ifndef FALSE ++# define FALSE 0 ++#endif ++ ++#ifndef min ++# define min(x, y) __extension__ ({ \ ++ __typeof__(x) _min1 = (x); \ ++ __typeof__(y) _min2 = (y); \ ++ (void) (&_min1 == &_min2); \ ++ _min1 < _min2 ? _min1 : _min2; }) ++#endif ++ ++#ifndef max ++# define max(x, y) __extension__ ({ \ ++ __typeof__(x) _max1 = (x); \ ++ __typeof__(y) _max2 = (y); \ ++ (void) (&_max1 == &_max2); \ ++ _max1 > _max2 ? _max1 : _max2; }) ++#endif ++ ++#ifndef cmp_numbers ++# define cmp_numbers(x, y) __extension__ ({ \ ++ __typeof__(x) _a = (x); \ ++ __typeof__(y) _b = (y); \ ++ (void) (&_a == &_b); \ ++ _a == _b ? 0 : _a > _b ? 1 : -1; }) ++#endif ++ ++#ifndef offsetof ++#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) ++#endif ++ ++/* ++ * container_of - cast a member of a structure out to the containing structure ++ * @ptr: the pointer to the member. ++ * @type: the type of the container struct this is embedded in. ++ * @member: the name of the member within the struct. ++ */ ++#ifndef container_of ++#define container_of(ptr, type, member) __extension__ ({ \ ++ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ ++ (type *)( (char *)__mptr - offsetof(type,member) );}) ++#endif ++ ++#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME ++# ifdef HAVE___PROGNAME ++extern char *__progname; ++# define program_invocation_short_name __progname ++# else ++# ifdef HAVE_GETEXECNAME ++# define program_invocation_short_name \ ++ prog_inv_sh_nm_from_file(getexecname(), 0) ++# else ++# define program_invocation_short_name \ ++ prog_inv_sh_nm_from_file(__FILE__, 1) ++# endif ++static char prog_inv_sh_nm_buf[256]; ++static inline char * ++prog_inv_sh_nm_from_file(char *f, char stripext) ++{ ++ char *t; ++ ++ if ((t = strrchr(f, '/')) != NULL) ++ t++; ++ else ++ t = f; ++ ++ strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1); ++ prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0'; ++ ++ if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL) ++ *t = '\0'; ++ ++ return prog_inv_sh_nm_buf; ++} ++# endif ++#endif ++ ++ ++#ifndef HAVE_ERR_H ++static inline void ++errmsg(char doexit, int excode, char adderr, const char *fmt, ...) ++{ ++ fprintf(stderr, "%s: ", program_invocation_short_name); ++ if (fmt != NULL) { ++ va_list argp; ++ va_start(argp, fmt); ++ vfprintf(stderr, fmt, argp); ++ va_end(argp); ++ if (adderr) ++ fprintf(stderr, ": "); ++ } ++ if (adderr) ++ fprintf(stderr, "%m"); ++ fprintf(stderr, "\n"); ++ if (doexit) ++ exit(excode); ++} ++ ++#ifndef HAVE_ERR ++# define err(E, FMT...) errmsg(1, E, 1, FMT) ++#endif ++ ++#ifndef HAVE_ERRX ++# define errx(E, FMT...) errmsg(1, E, 0, FMT) ++#endif ++ ++#ifndef HAVE_WARN ++# define warn(FMT...) errmsg(0, 0, 1, FMT) ++#endif ++ ++#ifndef HAVE_WARNX ++# define warnx(FMT...) errmsg(0, 0, 0, FMT) ++#endif ++#endif /* !HAVE_ERR_H */ ++ ++ ++/* Don't use inline function to avoid '#include "nls.h"' in c.h ++ */ ++#define errtryhelp(eval) __extension__ ({ \ ++ fprintf(stderr, _("Try '%s --help' for more information.\n"), \ ++ program_invocation_short_name); \ ++ exit(eval); \ ++}) ++ ++/* After failed execvp() */ ++#define EX_EXEC_FAILED 126 /* Program located, but not usable. */ ++#define EX_EXEC_ENOENT 127 /* Could not find program to exec. */ ++#define errexec(name) err(errno == ENOENT ? EX_EXEC_ENOENT : EX_EXEC_FAILED, \ ++ _("failed to execute %s"), name) ++ ++ ++static inline __attribute__((const)) int is_power_of_2(unsigned long num) ++{ ++ return (num != 0 && ((num & (num - 1)) == 0)); ++} ++ ++#ifndef HAVE_LOFF_T ++typedef int64_t loff_t; ++#endif ++ ++#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD) ++#include ++#include ++static inline int dirfd(DIR *d) ++{ ++ return d->dd_fd; ++} ++#endif ++ ++/* ++ * Fallback defines for old versions of glibc ++ */ ++#include ++ ++#ifdef O_CLOEXEC ++#define UL_CLOEXECSTR "e" ++#else ++#define UL_CLOEXECSTR "" ++#endif ++ ++#ifndef O_CLOEXEC ++#define O_CLOEXEC 0 ++#endif ++ ++#ifdef __FreeBSD_kernel__ ++#ifndef F_DUPFD_CLOEXEC ++#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */ ++#endif ++#endif ++ ++ ++#ifndef AI_ADDRCONFIG ++#define AI_ADDRCONFIG 0x0020 ++#endif ++ ++#ifndef IUTF8 ++#define IUTF8 0040000 ++#endif ++ ++/* ++ * MAXHOSTNAMELEN replacement ++ */ ++static inline size_t get_hostname_max(void) ++{ ++ long len = sysconf(_SC_HOST_NAME_MAX); ++ ++ if (0 < len) ++ return len; ++ ++#ifdef MAXHOSTNAMELEN ++ return MAXHOSTNAMELEN; ++#elif HOST_NAME_MAX ++ return HOST_NAME_MAX; ++#endif ++ return 64; ++} ++ ++ ++/* ++ * Constant strings for usage() functions. For more info see ++ * Documentation/{howto-usage-function.txt,boilerplate.c} ++ */ ++#define USAGE_HEADER ("\nUsage:\n") ++#define USAGE_OPTIONS ("\nOptions:\n") ++#define USAGE_FUNCTIONS ("\nFunctions:\n") ++#define USAGE_COMMANDS ("\nCommands:\n") ++#define USAGE_COLUMNS ("\nAvailable output columns:\n") ++#define USAGE_SEPARATOR "\n" ++ ++#define USAGE_OPTSTR_HELP ("display this help") ++#define USAGE_OPTSTR_VERSION ("display version") ++ ++#define USAGE_HELP_OPTIONS(marg_dsc) \ ++ "%-" #marg_dsc "s%s\n" \ ++ "%-" #marg_dsc "s%s\n" \ ++ , " -h, --help", USAGE_OPTSTR_HELP \ ++ , " -V, --version", USAGE_OPTSTR_VERSION ++ ++#define USAGE_MAN_TAIL(_man) ("\nFor more details see %s.\n"), _man ++ ++#define UTIL_LINUX_VERSION ("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING ++ ++#define print_version(eval) __extension__ ({ \ ++ printf(UTIL_LINUX_VERSION); \ ++ exit(eval); \ ++}) ++ ++/* ++ * scanf modifiers for "strings allocation" ++ */ ++#ifdef HAVE_SCANF_MS_MODIFIER ++#define UL_SCNsA "%ms" ++#elif defined(HAVE_SCANF_AS_MODIFIER) ++#define UL_SCNsA "%as" ++#endif ++ ++/* ++ * seek stuff ++ */ ++#ifndef SEEK_DATA ++# define SEEK_DATA 3 ++#endif ++#ifndef SEEK_HOLE ++# define SEEK_HOLE 4 ++#endif ++ ++ ++/* ++ * Macros to convert #define'itions to strings, for example ++ * #define XYXXY 42 ++ * printf ("%s=%s\n", stringify(XYXXY), stringify_value(XYXXY)); ++ */ ++#define stringify_value(s) stringify(s) ++#define stringify(s) #s ++ ++/* ++ * UL_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time ++ * instrumentation shipped with Clang and GCC) to not instrument the ++ * annotated function. Furthermore, it will prevent the compiler from ++ * inlining the function because inlining currently breaks the blacklisting ++ * mechanism of AddressSanitizer. ++ */ ++#if __has_feature(address_sanitizer) && __has_attribute(no_sanitize_memory) && __has_attribute(no_sanitize_address) ++# define UL_ASAN_BLACKLIST __attribute__((noinline)) __attribute__((no_sanitize_memory)) __attribute__((no_sanitize_address)) ++#else ++# define UL_ASAN_BLACKLIST /* nothing */ ++#endif ++ ++/* ++ * Note that sysconf(_SC_GETPW_R_SIZE_MAX) returns *initial* suggested size for ++ * pwd buffer and in some cases it is not large enough. See POSIX and ++ * getpwnam_r man page for more details. ++ */ ++#define UL_GETPW_BUFSIZ (16 * 1024) ++ ++/* ++ * Darwin or other BSDs may only have MAP_ANON. To get it on Darwin we must ++ * define _DARWIN_C_SOURCE before including sys/mman.h. We do this in config.h. ++ */ ++#if !defined MAP_ANONYMOUS && defined MAP_ANON ++# define MAP_ANONYMOUS (MAP_ANON) ++#endif ++ ++#endif /* UTIL_LINUX_C_H */ +diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c +new file mode 100644 +index 0000000000..63615896b0 +--- /dev/null ++++ b/locale/programs/cross-localedef-hardlink.c +@@ -0,0 +1,528 @@ ++/* ++ * hardlink - consolidate duplicate files via hardlinks ++ * ++ * Copyright (C) 2018 Red Hat, Inc. All rights reserved. ++ * Written by Jakub Jelinek ++ * ++ * Copyright (C) 2019 Karel Zak ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it would be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ */ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#ifdef HAVE_PCRE ++# define PCRE2_CODE_UNIT_WIDTH 8 ++# include ++#endif ++ ++#include "c.h" ++#include "xalloc.h" ++#include "nls.h" ++#include "closestream.h" ++ ++#define NHASH (1<<17) /* Must be a power of 2! */ ++#define NBUF 64 ++ ++struct hardlink_file; ++ ++struct hardlink_hash { ++ struct hardlink_hash *next; ++ struct hardlink_file *chain; ++ off_t size; ++ time_t mtime; ++}; ++ ++struct hardlink_dir { ++ struct hardlink_dir *next; ++ char name[]; ++}; ++ ++struct hardlink_file { ++ struct hardlink_file *next; ++ ino_t ino; ++ dev_t dev; ++ unsigned int cksum; ++ char name[]; ++}; ++ ++struct hardlink_dynstr { ++ char *buf; ++ size_t alloc; ++}; ++ ++struct hardlink_ctl { ++ struct hardlink_dir *dirs; ++ struct hardlink_hash *hps[NHASH]; ++ char iobuf1[BUFSIZ]; ++ char iobuf2[BUFSIZ]; ++ /* summary counters */ ++ unsigned long long ndirs; ++ unsigned long long nobjects; ++ unsigned long long nregfiles; ++ unsigned long long ncomp; ++ unsigned long long nlinks; ++ unsigned long long nsaved; ++ /* current device */ ++ dev_t dev; ++ /* flags */ ++ unsigned int verbose; ++ unsigned int ++ no_link:1, ++ content_only:1, ++ force:1; ++}; ++/* ctl is in global scope due use in atexit() */ ++struct hardlink_ctl global_ctl; ++ ++__attribute__ ((always_inline)) ++static inline unsigned int hash(off_t size, time_t mtime) ++{ ++ return (size ^ mtime) & (NHASH - 1); ++} ++ ++__attribute__ ((always_inline)) ++static inline int stcmp(struct stat *st1, struct stat *st2, int content_scope) ++{ ++ if (content_scope) ++ return st1->st_size != st2->st_size; ++ ++ return st1->st_mode != st2->st_mode ++ || st1->st_uid != st2->st_uid ++ || st1->st_gid != st2->st_gid ++ || st1->st_size != st2->st_size ++ || st1->st_mtime != st2->st_mtime; ++} ++ ++static void print_summary(void) ++{ ++ struct hardlink_ctl const *const ctl = &global_ctl; ++ ++ if (!ctl->verbose) ++ return; ++ ++ if (ctl->verbose > 1 && ctl->nlinks) ++ fputc('\n', stdout); ++ ++ printf(_("Directories: %9lld\n"), ctl->ndirs); ++ printf(_("Objects: %9lld\n"), ctl->nobjects); ++ printf(_("Regular files: %9lld\n"), ctl->nregfiles); ++ printf(_("Comparisons: %9lld\n"), ctl->ncomp); ++ printf( "%s%9lld\n", (ctl->no_link ? ++ _("Would link: ") : ++ _("Linked: ")), ctl->nlinks); ++ printf( "%s %9lld\n", (ctl->no_link ? ++ _("Would save: ") : ++ _("Saved: ")), ctl->nsaved); ++} ++ ++static void __attribute__((__noreturn__)) usage(void) ++{ ++ fputs(USAGE_HEADER, stdout); ++ printf(_(" %s [options] directory...\n"), program_invocation_short_name); ++ ++ fputs(USAGE_SEPARATOR, stdout); ++ puts(_("Consolidate duplicate files using hardlinks.")); ++ ++ fputs(USAGE_OPTIONS, stdout); ++ puts(_(" -c, --content compare only contents, ignore permission, etc.")); ++ puts(_(" -n, --dry-run don't actually link anything")); ++ puts(_(" -v, --verbose print summary after hardlinking")); ++ puts(_(" -vv print every hardlinked file and summary")); ++ puts(_(" -f, --force force hardlinking across filesystems")); ++ puts(_(" -x, --exclude exclude files matching pattern")); ++ ++ fputs(USAGE_SEPARATOR, stdout); ++ printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */ ++ printf(USAGE_MAN_TAIL("hardlink(1)")); ++ exit(EXIT_SUCCESS); ++} ++ ++__attribute__ ((always_inline)) ++static inline size_t add2(size_t a, size_t b) ++{ ++ size_t sum = a + b; ++ ++ if (sum < a) ++ errx(EXIT_FAILURE, _("integer overflow")); ++ return sum; ++} ++ ++__attribute__ ((always_inline)) ++static inline size_t add3(size_t a, size_t b, size_t c) ++{ ++ return add2(add2(a, b), c); ++} ++ ++static void growstr(struct hardlink_dynstr *str, size_t newlen) ++{ ++ if (newlen < str->alloc) ++ return; ++ str->buf = xrealloc(str->buf, str->alloc = add2(newlen, 1)); ++} ++ ++static void process_path(struct hardlink_ctl *ctl, const char *name) ++{ ++ struct stat st, st2, st3; ++ const size_t namelen = strlen(name); ++ ++ ctl->nobjects++; ++ if (lstat(name, &st)) ++ return; ++ ++ if (st.st_dev != ctl->dev && !ctl->force) { ++ if (ctl->dev) ++ errx(EXIT_FAILURE, ++ _("%s is on different filesystem than the rest " ++ "(use -f option to override)."), name); ++ ctl->dev = st.st_dev; ++ } ++ if (S_ISDIR(st.st_mode)) { ++ struct hardlink_dir *dp = xmalloc(add3(sizeof(*dp), namelen, 1)); ++ memcpy(dp->name, name, namelen + 1); ++ dp->next = ctl->dirs; ++ ctl->dirs = dp; ++ ++ } else if (S_ISREG(st.st_mode)) { ++ int fd, i; ++ struct hardlink_file *fp, *fp2; ++ struct hardlink_hash *hp; ++ const char *n1, *n2; ++ unsigned int buf[NBUF]; ++ int cksumsize = sizeof(buf); ++ unsigned int cksum; ++ time_t mtime = ctl->content_only ? 0 : st.st_mtime; ++ unsigned int hsh = hash(st.st_size, mtime); ++ off_t fsize; ++ ++ ctl->nregfiles++; ++ if (ctl->verbose > 1) ++ printf("%s\n", name); ++ ++ fd = open(name, O_RDONLY); ++ if (fd < 0) ++ return; ++ ++ if ((size_t)st.st_size < sizeof(buf)) { ++ cksumsize = st.st_size; ++ memset(((char *)buf) + cksumsize, 0, ++ (sizeof(buf) - cksumsize) % sizeof(buf[0])); ++ } ++ if (read(fd, buf, cksumsize) != cksumsize) { ++ close(fd); ++ return; ++ } ++ cksumsize = (cksumsize + sizeof(buf[0]) - 1) / sizeof(buf[0]); ++ for (i = 0, cksum = 0; i < cksumsize; i++) { ++ if (cksum + buf[i] < cksum) ++ cksum += buf[i] + 1; ++ else ++ cksum += buf[i]; ++ } ++ for (hp = ctl->hps[hsh]; hp; hp = hp->next) { ++ if (hp->size == st.st_size && hp->mtime == mtime) ++ break; ++ } ++ if (!hp) { ++ hp = xmalloc(sizeof(*hp)); ++ hp->size = st.st_size; ++ hp->mtime = mtime; ++ hp->chain = NULL; ++ hp->next = ctl->hps[hsh]; ++ ctl->hps[hsh] = hp; ++ } ++ for (fp = hp->chain; fp; fp = fp->next) { ++ if (fp->cksum == cksum) ++ break; ++ } ++ for (fp2 = fp; fp2 && fp2->cksum == cksum; fp2 = fp2->next) { ++ if (fp2->ino == st.st_ino && fp2->dev == st.st_dev) { ++ close(fd); ++ return; ++ } ++ } ++ for (fp2 = fp; fp2 && fp2->cksum == cksum; fp2 = fp2->next) { ++ ++ if (!lstat(fp2->name, &st2) && S_ISREG(st2.st_mode) && ++ !stcmp(&st, &st2, ctl->content_only) && ++ st2.st_ino != st.st_ino && ++ st2.st_dev == st.st_dev) { ++ ++ int fd2 = open(fp2->name, O_RDONLY); ++ if (fd2 < 0) ++ continue; ++ ++ if (fstat(fd2, &st2) || !S_ISREG(st2.st_mode) ++ || st2.st_size == 0) { ++ close(fd2); ++ continue; ++ } ++ ctl->ncomp++; ++ lseek(fd, 0, SEEK_SET); ++ ++ for (fsize = st.st_size; fsize > 0; ++ fsize -= (off_t)sizeof(ctl->iobuf1)) { ++ ssize_t xsz; ++ ssize_t rsize = fsize > (ssize_t) sizeof(ctl->iobuf1) ? ++ (ssize_t) sizeof(ctl->iobuf1) : fsize; ++ ++ if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize) ++ warn(_("cannot read %s"), name); ++ else if ((xsz = read(fd2, ctl->iobuf2, rsize)) != rsize) ++ warn(_("cannot read %s"), fp2->name); ++ ++ if (xsz != rsize) { ++ close(fd); ++ close(fd2); ++ return; ++ } ++ if (memcmp(ctl->iobuf1, ctl->iobuf2, rsize)) ++ break; ++ } ++ close(fd2); ++ if (fsize > 0) ++ continue; ++ if (lstat(name, &st3)) { ++ warn(_("cannot stat %s"), name); ++ close(fd); ++ return; ++ } ++ st3.st_atime = st.st_atime; ++ if (stcmp(&st, &st3, 0)) { ++ warnx(_("file %s changed underneath us"), name); ++ close(fd); ++ return; ++ } ++ n1 = fp2->name; ++ n2 = name; ++ ++ if (!ctl->no_link) { ++ const char *suffix = ++ ".$$$___cleanit___$$$"; ++ const size_t suffixlen = strlen(suffix); ++ size_t n2len = strlen(n2); ++ struct hardlink_dynstr nam2 = { NULL, 0 }; ++ ++ growstr(&nam2, add2(n2len, suffixlen)); ++ memcpy(nam2.buf, n2, n2len); ++ memcpy(&nam2.buf[n2len], suffix, ++ suffixlen + 1); ++ /* First create a temporary link to n1 under a new name */ ++ if (link(n1, nam2.buf)) { ++ warn(_("failed to hardlink %s to %s (create temporary link as %s failed)"), ++ n1, n2, nam2.buf); ++ free(nam2.buf); ++ continue; ++ } ++ /* Then rename into place over the existing n2 */ ++ if (rename(nam2.buf, n2)) { ++ warn(_("failed to hardlink %s to %s (rename temporary link to %s failed)"), ++ n1, n2, n2); ++ /* Something went wrong, try to remove the now redundant temporary link */ ++ if (unlink(nam2.buf)) ++ warn(_("failed to remove temporary link %s"), nam2.buf); ++ free(nam2.buf); ++ continue; ++ } ++ free(nam2.buf); ++ } ++ ctl->nlinks++; ++ if (st3.st_nlink > 1) { ++ /* We actually did not save anything this time, since the link second argument ++ had some other links as well. */ ++ if (ctl->verbose > 1) ++ printf(_(" %s %s to %s\n"), ++ (ctl->no_link ? _("Would link") : _("Linked")), ++ n1, n2); ++ } else { ++ ctl->nsaved += ((st.st_size + 4095) / 4096) * 4096; ++ if (ctl->verbose > 1) ++ printf(_(" %s %s to %s, %s %jd\n"), ++ (ctl->no_link ? _("Would link") : _("Linked")), ++ n1, n2, ++ (ctl->no_link ? _("would save") : _("saved")), ++ (intmax_t)st.st_size); ++ } ++ close(fd); ++ return; ++ } ++ } ++ fp2 = xmalloc(add3(sizeof(*fp2), namelen, 1)); ++ close(fd); ++ fp2->ino = st.st_ino; ++ fp2->dev = st.st_dev; ++ fp2->cksum = cksum; ++ memcpy(fp2->name, name, namelen + 1); ++ ++ if (fp) { ++ fp2->next = fp->next; ++ fp->next = fp2; ++ } else { ++ fp2->next = hp->chain; ++ hp->chain = fp2; ++ } ++ return; ++ } ++} ++ ++int main(int argc, char **argv) ++{ ++ int ch; ++ int i; ++#ifdef HAVE_PCRE ++ int errornumber; ++ PCRE2_SIZE erroroffset; ++ pcre2_code *re = NULL; ++ PCRE2_SPTR exclude_pattern = NULL; ++ pcre2_match_data *match_data = NULL; ++#endif ++ struct hardlink_dynstr nam1 = { NULL, 0 }; ++ struct hardlink_ctl *ctl = &global_ctl; ++ ++ static const struct option longopts[] = { ++ { "content", no_argument, NULL, 'c' }, ++ { "dry-run", no_argument, NULL, 'n' }, ++ { "exclude", required_argument, NULL, 'x' }, ++ { "force", no_argument, NULL, 'f' }, ++ { "help", no_argument, NULL, 'h' }, ++ { "verbose", no_argument, NULL, 'v' }, ++ { "version", no_argument, NULL, 'V' }, ++ { NULL, 0, NULL, 0 }, ++ }; ++ ++ setlocale(LC_ALL, ""); ++ bindtextdomain(PACKAGE, LOCALEDIR); ++ textdomain(PACKAGE); ++ close_stdout_atexit(); ++ ++ while ((ch = getopt_long(argc, argv, "cnvfx:Vh", longopts, NULL)) != -1) { ++ switch (ch) { ++ case 'n': ++ ctl->no_link = 1; ++ break; ++ case 'v': ++ ctl->verbose++; ++ break; ++ case 'c': ++ ctl->content_only = 1; ++ break; ++ case 'f': ++ ctl->force = 1; ++ break; ++ case 'x': ++#ifdef HAVE_PCRE ++ exclude_pattern = (PCRE2_SPTR) optarg; ++#else ++ errx(EXIT_FAILURE, ++ _("option --exclude not supported (built without pcre2)")); ++#endif ++ break; ++ case 'V': ++ print_version(EXIT_SUCCESS); ++ case 'h': ++ usage(); ++ default: ++ errtryhelp(EXIT_FAILURE); ++ } ++ } ++ ++ if (optind == argc) { ++ warnx(_("no directory specified")); ++ errtryhelp(EXIT_FAILURE); ++ } ++ ++#ifdef HAVE_PCRE ++ if (exclude_pattern) { ++ re = pcre2_compile(exclude_pattern, /* the pattern */ ++ PCRE2_ZERO_TERMINATED, /* indicates pattern is zero-terminate */ ++ 0, /* default options */ ++ &errornumber, &erroroffset, NULL); /* use default compile context */ ++ if (!re) { ++ PCRE2_UCHAR buffer[256]; ++ pcre2_get_error_message(errornumber, buffer, ++ sizeof(buffer)); ++ errx(EXIT_FAILURE, _("pattern error at offset %d: %s"), ++ (int)erroroffset, buffer); ++ } ++ match_data = pcre2_match_data_create_from_pattern(re, NULL); ++ } ++#endif ++ atexit(print_summary); ++ ++ for (i = optind; i < argc; i++) ++ process_path(ctl, argv[i]); ++ ++ while (ctl->dirs) { ++ DIR *dh; ++ struct dirent *di; ++ struct hardlink_dir *dp = ctl->dirs; ++ size_t nam1baselen = strlen(dp->name); ++ ++ ctl->dirs = dp->next; ++ growstr(&nam1, add2(nam1baselen, 1)); ++ memcpy(nam1.buf, dp->name, nam1baselen); ++ free(dp); ++ nam1.buf[nam1baselen++] = '/'; ++ nam1.buf[nam1baselen] = 0; ++ dh = opendir(nam1.buf); ++ ++ if (dh == NULL) ++ continue; ++ ctl->ndirs++; ++ ++ while ((di = readdir(dh)) != NULL) { ++ if (!di->d_name[0]) ++ continue; ++ if (di->d_name[0] == '.') { ++ if (!di->d_name[1] || !strcmp(di->d_name, "..")) ++ continue; ++ } ++#ifdef HAVE_PCRE ++ if (re && pcre2_match(re, /* compiled regex */ ++ (PCRE2_SPTR) di->d_name, strlen(di->d_name), 0, /* start at offset 0 */ ++ 0, /* default options */ ++ match_data, /* block for storing the result */ ++ NULL) /* use default match context */ ++ >=0) { ++ if (ctl->verbose) { ++ nam1.buf[nam1baselen] = 0; ++ printf(_("Skipping %s%s\n"), nam1.buf, di->d_name); ++ } ++ continue; ++ } ++#endif ++ { ++ size_t subdirlen; ++ growstr(&nam1, ++ add2(nam1baselen, subdirlen = ++ strlen(di->d_name))); ++ memcpy(&nam1.buf[nam1baselen], di->d_name, ++ add2(subdirlen, 1)); ++ } ++ process_path(ctl, nam1.buf); ++ } ++ closedir(dh); ++ } ++ ++ return 0; ++} +diff --git a/locale/programs/xalloc.h b/locale/programs/xalloc.h +new file mode 100644 +index 0000000000..0129a85e2e +--- /dev/null ++++ b/locale/programs/xalloc.h +@@ -0,0 +1,129 @@ ++/* ++ * Copyright (C) 2010 Davidlohr Bueso ++ * ++ * This file may be redistributed under the terms of the ++ * GNU Lesser General Public License. ++ * ++ * General memory allocation wrappers for malloc, realloc, calloc and strdup ++ */ ++ ++#ifndef UTIL_LINUX_XALLOC_H ++#define UTIL_LINUX_XALLOC_H ++ ++#include ++#include ++ ++#include "c.h" ++ ++#ifndef XALLOC_EXIT_CODE ++# define XALLOC_EXIT_CODE EXIT_FAILURE ++#endif ++ ++static inline void __attribute__((__noreturn__)) ++__err_oom(const char *file, unsigned int line) ++{ ++ err(XALLOC_EXIT_CODE, "%s: %u: cannot allocate memory", file, line); ++} ++ ++#define err_oom() __err_oom(__FILE__, __LINE__) ++ ++static inline __ul_alloc_size(1) __ul_returns_nonnull ++void *xmalloc(const size_t size) ++{ ++ void *ret = malloc(size); ++ ++ if (!ret && size) ++ err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); ++ return ret; ++} ++ ++static inline __ul_alloc_size(2) __ul_returns_nonnull ++void *xrealloc(void *ptr, const size_t size) ++{ ++ void *ret = realloc(ptr, size); ++ ++ if (!ret && size) ++ err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); ++ return ret; ++} ++ ++static inline __ul_calloc_size(1, 2) __ul_returns_nonnull ++void *xcalloc(const size_t nelems, const size_t size) ++{ ++ void *ret = calloc(nelems, size); ++ ++ if (!ret && size && nelems) ++ err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); ++ return ret; ++} ++ ++static inline char __attribute__((warn_unused_result)) __ul_returns_nonnull ++*xstrdup(const char *str) ++{ ++ char *ret; ++ ++ if (!str) ++ return NULL; ++ ++ ret = strdup(str); ++ ++ if (!ret) ++ err(XALLOC_EXIT_CODE, "cannot duplicate string"); ++ return ret; ++} ++ ++static inline char * __attribute__((warn_unused_result)) __ul_returns_nonnull ++xstrndup(const char *str, size_t size) ++{ ++ char *ret; ++ ++ if (!str) ++ return NULL; ++ ++ ret = strndup(str, size); ++ ++ if (!ret) ++ err(XALLOC_EXIT_CODE, "cannot duplicate string"); ++ return ret; ++} ++ ++ ++static inline int __attribute__ ((__format__(printf, 2, 3))) ++ xasprintf(char **strp, const char *fmt, ...) ++{ ++ int ret; ++ va_list args; ++ va_start(args, fmt); ++ ret = vasprintf(&(*strp), fmt, args); ++ va_end(args); ++ if (ret < 0) ++ err(XALLOC_EXIT_CODE, "cannot allocate string"); ++ return ret; ++} ++ ++static inline int __attribute__ ((__format__(printf, 2, 0))) ++xvasprintf(char **strp, const char *fmt, va_list ap) ++{ ++ int ret = vasprintf(&(*strp), fmt, ap); ++ if (ret < 0) ++ err(XALLOC_EXIT_CODE, "cannot allocate string"); ++ return ret; ++} ++ ++ ++static inline char * __attribute__((warn_unused_result)) xgethostname(void) ++{ ++ char *name; ++ size_t sz = get_hostname_max() + 1; ++ ++ name = xmalloc(sizeof(char) * sz); ++ ++ if (gethostname(name, sz) != 0) { ++ free(name); ++ return NULL; ++ } ++ name[sz - 1] = '\0'; ++ return name; ++} ++ ++#endif diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0001-nptl-Remove-private-futex-optimization-BZ-27304.patch b/meta-digi-dey/recipes-core/glibc/glibc/0001-nptl-Remove-private-futex-optimization-BZ-27304.patch new file mode 100644 index 000000000..39fde5b78 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0001-nptl-Remove-private-futex-optimization-BZ-27304.patch @@ -0,0 +1,49 @@ +From c4ad832276f4dadfa40904109b26a521468f66bc Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Thu, 4 Feb 2021 15:00:20 +0100 +Subject: [PATCH] nptl: Remove private futex optimization [BZ #27304] + +It is effectively used, unexcept for pthread_cond_destroy, where we do +not want it; see bug 27304. The internal locks do not support a +process-shared mode. + +This fixes commit dc6cfdc934db9997c33728082d63552b9eee4563 ("nptl: +Move pthread_cond_destroy implementation into libc"). + +Reviewed-by: Adhemerval Zanella + +Upstream-Status: Backport [https://sourceware.org/bugzilla/show_bug.cgi?id=27304] +Signed-off-by: Yanfei Xu +--- + sysdeps/nptl/lowlevellock-futex.h | 14 +------------- + 1 file changed, 1 insertion(+), 13 deletions(-) + +diff --git a/sysdeps/nptl/lowlevellock-futex.h b/sysdeps/nptl/lowlevellock-futex.h +index ecb729da6b..ca96397a4a 100644 +--- a/sysdeps/nptl/lowlevellock-futex.h ++++ b/sysdeps/nptl/lowlevellock-futex.h +@@ -50,20 +50,8 @@ + #define LLL_SHARED FUTEX_PRIVATE_FLAG + + #ifndef __ASSEMBLER__ +- +-# if IS_IN (libc) || IS_IN (rtld) +-/* In libc.so or ld.so all futexes are private. */ +-# define __lll_private_flag(fl, private) \ +- ({ \ +- /* Prevent warnings in callers of this macro. */ \ +- int __lll_private_flag_priv __attribute__ ((unused)); \ +- __lll_private_flag_priv = (private); \ +- ((fl) | FUTEX_PRIVATE_FLAG); \ +- }) +-# else +-# define __lll_private_flag(fl, private) \ ++# define __lll_private_flag(fl, private) \ + (((fl) | FUTEX_PRIVATE_FLAG) ^ (private)) +-# endif + + # define lll_futex_syscall(nargs, futexp, op, ...) \ + ({ \ +-- +2.27.0 + diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch b/meta-digi-dey/recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch new file mode 100644 index 000000000..3dc4582f4 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch @@ -0,0 +1,238 @@ +From 14d256e2db009f8bac9a265e8393d7ed25050df9 Mon Sep 17 00:00:00 2001 +From: Jason Wessel +Date: Sat, 7 Dec 2019 10:01:37 -0800 +Subject: [PATCH] localedef: fix-ups hardlink to make it compile + +Upstream-Status: Pending +Signed-off-by: Jason Wessel +Signed-off-by: Khem Raj +--- + locale/programs/c.h | 2 +- + locale/programs/cross-localedef-hardlink.c | 79 +++++++++++----------- + 2 files changed, 39 insertions(+), 42 deletions(-) + +diff --git a/locale/programs/c.h b/locale/programs/c.h +index d0a402e90e..1804d31c73 100644 +--- a/locale/programs/c.h ++++ b/locale/programs/c.h +@@ -240,7 +240,7 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...) + /* Don't use inline function to avoid '#include "nls.h"' in c.h + */ + #define errtryhelp(eval) __extension__ ({ \ +- fprintf(stderr, _("Try '%s --help' for more information.\n"), \ ++ fprintf(stderr, ("Try '%s --help' for more information.\n"), \ + program_invocation_short_name); \ + exit(eval); \ + }) +diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c +index 63615896b0..726e6dd948 100644 +--- a/locale/programs/cross-localedef-hardlink.c ++++ b/locale/programs/cross-localedef-hardlink.c +@@ -20,6 +20,8 @@ + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ ++ ++#undef HAVE_PCRE + #include + #include + #include +@@ -38,8 +40,8 @@ + + #include "c.h" + #include "xalloc.h" +-#include "nls.h" +-#include "closestream.h" ++//#include "nls.h" ++//#include "closestream.h" + + #define NHASH (1<<17) /* Must be a power of 2! */ + #define NBUF 64 +@@ -124,33 +126,33 @@ static void print_summary(void) + if (ctl->verbose > 1 && ctl->nlinks) + fputc('\n', stdout); + +- printf(_("Directories: %9lld\n"), ctl->ndirs); +- printf(_("Objects: %9lld\n"), ctl->nobjects); +- printf(_("Regular files: %9lld\n"), ctl->nregfiles); +- printf(_("Comparisons: %9lld\n"), ctl->ncomp); ++ printf(("Directories: %9lld\n"), ctl->ndirs); ++ printf(("Objects: %9lld\n"), ctl->nobjects); ++ printf(("Regular files: %9lld\n"), ctl->nregfiles); ++ printf(("Comparisons: %9lld\n"), ctl->ncomp); + printf( "%s%9lld\n", (ctl->no_link ? +- _("Would link: ") : +- _("Linked: ")), ctl->nlinks); ++ ("Would link: ") : ++ ("Linked: ")), ctl->nlinks); + printf( "%s %9lld\n", (ctl->no_link ? +- _("Would save: ") : +- _("Saved: ")), ctl->nsaved); ++ ("Would save: ") : ++ ("Saved: ")), ctl->nsaved); + } + + static void __attribute__((__noreturn__)) usage(void) + { + fputs(USAGE_HEADER, stdout); +- printf(_(" %s [options] directory...\n"), program_invocation_short_name); ++ printf((" %s [options] directory...\n"), program_invocation_short_name); + + fputs(USAGE_SEPARATOR, stdout); +- puts(_("Consolidate duplicate files using hardlinks.")); ++ puts(("Consolidate duplicate files using hardlinks.")); + + fputs(USAGE_OPTIONS, stdout); +- puts(_(" -c, --content compare only contents, ignore permission, etc.")); +- puts(_(" -n, --dry-run don't actually link anything")); +- puts(_(" -v, --verbose print summary after hardlinking")); +- puts(_(" -vv print every hardlinked file and summary")); +- puts(_(" -f, --force force hardlinking across filesystems")); +- puts(_(" -x, --exclude exclude files matching pattern")); ++ puts((" -c, --content compare only contents, ignore permission, etc.")); ++ puts((" -n, --dry-run don't actually link anything")); ++ puts((" -v, --verbose print summary after hardlinking")); ++ puts((" -vv print every hardlinked file and summary")); ++ puts((" -f, --force force hardlinking across filesystems")); ++ puts((" -x, --exclude exclude files matching pattern")); + + fputs(USAGE_SEPARATOR, stdout); + printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */ +@@ -164,7 +166,7 @@ static inline size_t add2(size_t a, size_t b) + size_t sum = a + b; + + if (sum < a) +- errx(EXIT_FAILURE, _("integer overflow")); ++ errx(EXIT_FAILURE, ("integer overflow")); + return sum; + } + +@@ -193,7 +195,7 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) + if (st.st_dev != ctl->dev && !ctl->force) { + if (ctl->dev) + errx(EXIT_FAILURE, +- _("%s is on different filesystem than the rest " ++ ("%s is on different filesystem than the rest " + "(use -f option to override)."), name); + ctl->dev = st.st_dev; + } +@@ -287,9 +289,9 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) + (ssize_t) sizeof(ctl->iobuf1) : fsize; + + if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize) +- warn(_("cannot read %s"), name); ++ warn(("cannot read %s"), name); + else if ((xsz = read(fd2, ctl->iobuf2, rsize)) != rsize) +- warn(_("cannot read %s"), fp2->name); ++ warn(("cannot read %s"), fp2->name); + + if (xsz != rsize) { + close(fd); +@@ -303,13 +305,13 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) + if (fsize > 0) + continue; + if (lstat(name, &st3)) { +- warn(_("cannot stat %s"), name); ++ warn(("cannot stat %s"), name); + close(fd); + return; + } + st3.st_atime = st.st_atime; + if (stcmp(&st, &st3, 0)) { +- warnx(_("file %s changed underneath us"), name); ++ warnx(("file %s changed underneath us"), name); + close(fd); + return; + } +@@ -329,18 +331,18 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) + suffixlen + 1); + /* First create a temporary link to n1 under a new name */ + if (link(n1, nam2.buf)) { +- warn(_("failed to hardlink %s to %s (create temporary link as %s failed)"), ++ warn(("failed to hardlink %s to %s (create temporary link as %s failed)"), + n1, n2, nam2.buf); + free(nam2.buf); + continue; + } + /* Then rename into place over the existing n2 */ + if (rename(nam2.buf, n2)) { +- warn(_("failed to hardlink %s to %s (rename temporary link to %s failed)"), ++ warn(("failed to hardlink %s to %s (rename temporary link to %s failed)"), + n1, n2, n2); + /* Something went wrong, try to remove the now redundant temporary link */ + if (unlink(nam2.buf)) +- warn(_("failed to remove temporary link %s"), nam2.buf); ++ warn(("failed to remove temporary link %s"), nam2.buf); + free(nam2.buf); + continue; + } +@@ -351,16 +353,16 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) + /* We actually did not save anything this time, since the link second argument + had some other links as well. */ + if (ctl->verbose > 1) +- printf(_(" %s %s to %s\n"), +- (ctl->no_link ? _("Would link") : _("Linked")), ++ printf((" %s %s to %s\n"), ++ (ctl->no_link ? ("Would link") : ("Linked")), + n1, n2); + } else { + ctl->nsaved += ((st.st_size + 4095) / 4096) * 4096; + if (ctl->verbose > 1) +- printf(_(" %s %s to %s, %s %jd\n"), +- (ctl->no_link ? _("Would link") : _("Linked")), ++ printf((" %s %s to %s, %s %jd\n"), ++ (ctl->no_link ? ("Would link") : ("Linked")), + n1, n2, +- (ctl->no_link ? _("would save") : _("saved")), ++ (ctl->no_link ? ("would save") : ("saved")), + (intmax_t)st.st_size); + } + close(fd); +@@ -410,11 +412,6 @@ int main(int argc, char **argv) + { NULL, 0, NULL, 0 }, + }; + +- setlocale(LC_ALL, ""); +- bindtextdomain(PACKAGE, LOCALEDIR); +- textdomain(PACKAGE); +- close_stdout_atexit(); +- + while ((ch = getopt_long(argc, argv, "cnvfx:Vh", longopts, NULL)) != -1) { + switch (ch) { + case 'n': +@@ -434,7 +431,7 @@ int main(int argc, char **argv) + exclude_pattern = (PCRE2_SPTR) optarg; + #else + errx(EXIT_FAILURE, +- _("option --exclude not supported (built without pcre2)")); ++ ("option --exclude not supported (built without pcre2)")); + #endif + break; + case 'V': +@@ -447,7 +444,7 @@ int main(int argc, char **argv) + } + + if (optind == argc) { +- warnx(_("no directory specified")); ++ warnx(("no directory specified")); + errtryhelp(EXIT_FAILURE); + } + +@@ -461,7 +458,7 @@ int main(int argc, char **argv) + PCRE2_UCHAR buffer[256]; + pcre2_get_error_message(errornumber, buffer, + sizeof(buffer)); +- errx(EXIT_FAILURE, _("pattern error at offset %d: %s"), ++ errx(EXIT_FAILURE, ("pattern error at offset %d: %s"), + (int)erroroffset, buffer); + } + match_data = pcre2_match_data_create_from_pattern(re, NULL); +@@ -506,7 +503,7 @@ int main(int argc, char **argv) + >=0) { + if (ctl->verbose) { + nam1.buf[nam1baselen] = 0; +- printf(_("Skipping %s%s\n"), nam1.buf, di->d_name); ++ printf(("Skipping %s%s\n"), nam1.buf, di->d_name); + } + continue; + } diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch b/meta-digi-dey/recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch new file mode 100644 index 000000000..c4718a106 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch @@ -0,0 +1,65 @@ +From 32a4b8ae046fe4bb1b19f61378d079d44deaede7 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 01:48:24 +0000 +Subject: [PATCH] nativesdk-glibc: Look for host system ld.so.cache as well + +Upstream-Status: Inappropriate [embedded specific] + +The default lib search path order is: + + 1) LD_LIBRARY_PATH + 2) RPATH from the binary + 3) ld.so.cache + 4) default search paths embedded in the linker + +For nativesdk binaries which are being used alongside binaries on a host system, we +need the search paths to firstly search the shipped nativesdk libs but then also +cover the host system. For example we want the host system's libGL and this may be +in a non-standard location like /usr/lib/mesa. The only place the location is know +about is in the ld.so.cache of the host system. + +Since nativesdk has a simple structure and doesn't need to use a cache itself, we +repurpose the cache for use as a last resort in finding host system binaries. This +means we need to switch the order of 3 and 4 above to make this work effectively. + +RP 14/10/2010 + +Signed-off-by: Khem Raj +--- + elf/dl-load.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/elf/dl-load.c b/elf/dl-load.c +index 9e2089cfaa..ad01674027 100644 +--- a/elf/dl-load.c ++++ b/elf/dl-load.c +@@ -2175,6 +2175,14 @@ _dl_map_object (struct link_map *loader, const char *name, + } + } + ++ /* try the default path. */ ++ if (fd == -1 ++ && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL ++ || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1)) ++ && __rtld_search_dirs.dirs != (void *) -1) ++ fd = open_path (name, namelen, mode & __RTLD_SECURE, &__rtld_search_dirs, ++ &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); ++ /* Finally try ld.so.cache */ + #ifdef USE_LDCONFIG + if (fd == -1 + && (__glibc_likely ((mode & __RTLD_SECURE) == 0) +@@ -2233,14 +2241,6 @@ _dl_map_object (struct link_map *loader, const char *name, + } + #endif + +- /* Finally, try the default path. */ +- if (fd == -1 +- && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL +- || __glibc_likely (!(l->l_flags_1 & DF_1_NODEFLIB))) +- && __rtld_search_dirs.dirs != (void *) -1) +- fd = open_path (name, namelen, mode, &__rtld_search_dirs, +- &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); +- + /* Add another newline when we are tracing the library loading. */ + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) + _dl_debug_printf ("\n"); diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch b/meta-digi-dey/recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch new file mode 100644 index 000000000..a8e625d24 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch @@ -0,0 +1,46 @@ +From aa8393bff257e4badfd208b88473ead175c69362 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 01:50:00 +0000 +Subject: [PATCH] nativesdk-glibc: Fix buffer overrun with a relocated SDK + +When ld-linux-*.so.2 is relocated to a path that is longer than the +original fixed location, the dynamic loader will crash in open_path +because it implicitly assumes that max_dirnamelen is a fixed size that +never changes. + +The allocated buffer will not be large enough to contain the directory +path string which is larger than the fixed location provided at build +time. + +Upstream-Status: Inappropriate [OE SDK specific] + +Signed-off-by: Jason Wessel +Signed-off-by: Khem Raj +--- + elf/dl-load.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/elf/dl-load.c b/elf/dl-load.c +index ad01674027..f455207e79 100644 +--- a/elf/dl-load.c ++++ b/elf/dl-load.c +@@ -1871,7 +1871,19 @@ open_path (const char *name, size_t namelen, int mode, + given on the command line when rtld is run directly. */ + return -1; + ++ do ++ { ++ struct r_search_path_elem *this_dir = *dirs; ++ if (this_dir->dirnamelen > max_dirnamelen) ++ { ++ max_dirnamelen = this_dir->dirnamelen; ++ } ++ } ++ while (*++dirs != NULL); ++ + buf = alloca (max_dirnamelen + max_capstrlen + namelen); ++ ++ dirs = sps->dirs; + do + { + struct r_search_path_elem *this_dir = *dirs; diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch b/meta-digi-dey/recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch new file mode 100644 index 000000000..197caae92 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch @@ -0,0 +1,153 @@ +From 3ea08e491a8494ff03e598b5e0fc2d8131e75da9 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 01:51:38 +0000 +Subject: [PATCH] nativesdk-glibc: Raise the size of arrays containing dl paths + +This patch puts the dynamic loader path in the binaries, SYSTEM_DIRS strings +and lengths as well as ld.so.cache path in the dynamic loader to specific +sections in memory. The sections that contain paths have been allocated a 4096 +byte section, which is the maximum path length in linux. This will allow the +relocating script to parse the ELF binary, detect the section and easily replace +the strings in a certain path. + +Upstream-Status: Inappropriate [SDK specific] + +Signed-off-by: Laurentiu Palcu +Signed-off-by: Khem Raj +--- + elf/dl-cache.c | 4 ++++ + elf/dl-load.c | 4 ++-- + elf/dl-usage.c | 6 ++++-- + elf/interp.c | 2 +- + elf/ldconfig.c | 3 +++ + elf/rtld.c | 1 + + iconv/gconv_conf.c | 2 +- + sysdeps/generic/dl-cache.h | 4 ---- + 8 files changed, 16 insertions(+), 10 deletions(-) + +diff --git a/elf/dl-cache.c b/elf/dl-cache.c +index 32f3bef5ea..71f3a82dc0 100644 +--- a/elf/dl-cache.c ++++ b/elf/dl-cache.c +@@ -359,6 +359,10 @@ search_cache (const char *string_table, uint32_t string_table_size, + return best; + } + ++const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) = ++ SYSCONFDIR "/ld.so.cache"; ++ ++ + int + _dl_cache_libcmp (const char *p1, const char *p2) + { +diff --git a/elf/dl-load.c b/elf/dl-load.c +index f455207e79..a144e24fcf 100644 +--- a/elf/dl-load.c ++++ b/elf/dl-load.c +@@ -115,8 +115,8 @@ enum { ncapstr = 1, max_capstrlen = 0 }; + gen-trusted-dirs.awk. */ + #include "trusted-dirs.h" + +-static const char system_dirs[] = SYSTEM_DIRS; +-static const size_t system_dirs_len[] = ++static const char system_dirs[4096] __attribute__ ((section (".sysdirs"))) = SYSTEM_DIRS; ++volatile static const size_t system_dirs_len[] __attribute__ ((section (".sysdirslen"))) = + { + SYSTEM_DIRS_LEN + }; +diff --git a/elf/dl-usage.c b/elf/dl-usage.c +index 6e26818bd7..f09e8b93e5 100644 +--- a/elf/dl-usage.c ++++ b/elf/dl-usage.c +@@ -25,6 +25,8 @@ + #include + #include + ++extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); ++ + void + _dl_usage (const char *argv0, const char *wrong_option) + { +@@ -244,7 +246,7 @@ setting environment variables (which would be inherited by subprocesses).\n\ + --list list all dependencies and how they are resolved\n\ + --verify verify that given object really is a dynamically linked\n\ + object we can handle\n\ +- --inhibit-cache Do not use " LD_SO_CACHE "\n\ ++ --inhibit-cache Do not use %s\n\ + --library-path PATH use given PATH instead of content of the environment\n\ + variable LD_LIBRARY_PATH\n\ + --glibc-hwcaps-prepend LIST\n\ +@@ -266,7 +268,7 @@ setting environment variables (which would be inherited by subprocesses).\n\ + \n\ + This program interpreter self-identifies as: " RTLD "\n\ + ", +- argv0); ++ argv0, LD_SO_CACHE); + print_search_path_for_help (state); + print_hwcaps_subdirectories (state); + print_legacy_hwcap_directories (); +diff --git a/elf/interp.c b/elf/interp.c +index 91966702ca..dc86c20e83 100644 +--- a/elf/interp.c ++++ b/elf/interp.c +@@ -18,5 +18,5 @@ + + #include + +-const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp"))) ++const char __invoke_dynamic_linker__[4096] __attribute__ ((section (".interp"))) + = RUNTIME_LINKER; +diff --git a/elf/ldconfig.c b/elf/ldconfig.c +index 28ed637a29..5d38a60c5d 100644 +--- a/elf/ldconfig.c ++++ b/elf/ldconfig.c +@@ -176,6 +176,9 @@ static struct argp argp = + options, parse_opt, NULL, doc, NULL, more_help, NULL + }; + ++ ++extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); ++ + /* Check if string corresponds to an important hardware capability or + a platform. */ + static int +diff --git a/elf/rtld.c b/elf/rtld.c +index 596b6ac3d9..1ccd33f668 100644 +--- a/elf/rtld.c ++++ b/elf/rtld.c +@@ -185,6 +185,7 @@ dso_name_valid_for_suid (const char *p) + } + return *p != '\0'; + } ++extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); + + static void + audit_list_init (struct audit_list *list) +diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c +index 682f949834..7eed87bc9d 100644 +--- a/iconv/gconv_conf.c ++++ b/iconv/gconv_conf.c +@@ -36,7 +36,7 @@ + + + /* This is the default path where we look for module lists. */ +-static const char default_gconv_path[] = GCONV_PATH; ++static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH; + + /* Type to represent search path. */ + struct path_elem +diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h +index 964d50a486..94bf68ca9d 100644 +--- a/sysdeps/generic/dl-cache.h ++++ b/sysdeps/generic/dl-cache.h +@@ -34,10 +34,6 @@ + ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID) + #endif + +-#ifndef LD_SO_CACHE +-# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache" +-#endif +- + #ifndef add_system_dir + # define add_system_dir(dir) add_dir (dir) + #endif diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch b/meta-digi-dey/recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch new file mode 100644 index 000000000..172ade8d9 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch @@ -0,0 +1,39 @@ +From 19e3e45eb1838ee80af13c3d27fcff446773211e Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 31 Dec 2015 14:35:35 -0800 +Subject: [PATCH] nativesdk-glibc: Allow 64 bit atomics for x86 + +The fix consist of allowing 64bit atomic ops for x86. +This should be safe for i586 and newer CPUs. +It also makes the synchronization more efficient. + +Upstream-Status: Inappropriate [OE-Specific] + +Signed-off-by: Juro Bystricky +Signed-off-by: Richard Purdie +Signed-off-by: Khem Raj +--- + sysdeps/x86/atomic-machine.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h +index 695222e4fa..9d39bfdbd5 100644 +--- a/sysdeps/x86/atomic-machine.h ++++ b/sysdeps/x86/atomic-machine.h +@@ -52,15 +52,14 @@ typedef uintmax_t uatomic_max_t; + #define LOCK_PREFIX "lock;" + + #define USE_ATOMIC_COMPILER_BUILTINS 1 ++# define __HAVE_64B_ATOMICS 1 + + #ifdef __x86_64__ +-# define __HAVE_64B_ATOMICS 1 + # define SP_REG "rsp" + # define SEG_REG "fs" + # define BR_CONSTRAINT "q" + # define IBR_CONSTRAINT "iq" + #else +-# define __HAVE_64B_ATOMICS 0 + # define SP_REG "esp" + # define SEG_REG "gs" + # define BR_CONSTRAINT "r" diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch b/meta-digi-dey/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch new file mode 100644 index 000000000..14697567c --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch @@ -0,0 +1,100 @@ +From 732d4f4954fe60718870048d0583a20a7a8a8540 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 3 Aug 2018 09:55:12 -0700 +Subject: [PATCH] nativesdk-glibc: Make relocatable install for locales + +The glibc locale path is hard-coded to the install prefix, but in SDKs we need +to be able to relocate the binaries. Expand the strings to 4K and put them in a +magic segment that we can relocate at install time. + +Upstream-Status: Inappropriate (OE-specific) + +Signed-off-by: Ross Burton +Signed-off-by: Khem Raj +--- + locale/findlocale.c | 4 ++-- + locale/loadarchive.c | 2 +- + locale/localeinfo.h | 2 +- + locale/programs/locale.c | 7 ++++--- + 4 files changed, 8 insertions(+), 7 deletions(-) + +diff --git a/locale/findlocale.c b/locale/findlocale.c +index ab09122b0c..f42cc75780 100644 +--- a/locale/findlocale.c ++++ b/locale/findlocale.c +@@ -56,7 +56,7 @@ struct __locale_data *const _nl_C[] attribute_hidden = + which are somehow addressed. */ + struct loaded_l10nfile *_nl_locale_file_list[__LC_LAST]; + +-const char _nl_default_locale_path[] attribute_hidden = COMPLOCALEDIR; ++char _nl_default_locale_path[4096] attribute_hidden __attribute__ ((section (".gccrelocprefix"))) = COMPLOCALEDIR; + + /* Checks if the name is actually present, that is, not NULL and not + empty. */ +@@ -166,7 +166,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, + + /* Nothing in the archive. Set the default path to search below. */ + locale_path = _nl_default_locale_path; +- locale_path_len = sizeof _nl_default_locale_path; ++ locale_path_len = strlen(locale_path) + 1; + } + else + /* We really have to load some data. First see whether the name is +diff --git a/locale/loadarchive.c b/locale/loadarchive.c +index 4177fc8972..40247b1e68 100644 +--- a/locale/loadarchive.c ++++ b/locale/loadarchive.c +@@ -42,7 +42,7 @@ + + + /* Name of the locale archive file. */ +-static const char archfname[] = COMPLOCALEDIR "/locale-archive"; ++static const char archfname[4096] __attribute__ ((section (".gccrelocprefix"))) = COMPLOCALEDIR "/locale-archive"; + + /* Size of initial mapping window, optimal if large enough to + cover the header plus the initial locale. */ +diff --git a/locale/localeinfo.h b/locale/localeinfo.h +index b3d4da0185..22f9dc1140 100644 +--- a/locale/localeinfo.h ++++ b/locale/localeinfo.h +@@ -331,7 +331,7 @@ _nl_lookup_word (locale_t l, int category, int item) + } + + /* Default search path if no LOCPATH environment variable. */ +-extern const char _nl_default_locale_path[] attribute_hidden; ++extern char _nl_default_locale_path[4096] attribute_hidden; + + /* Load the locale data for CATEGORY from the file specified by *NAME. + If *NAME is "", use environment variables as specified by POSIX, and +diff --git a/locale/programs/locale.c b/locale/programs/locale.c +index 575b208e82..5ec630c3a4 100644 +--- a/locale/programs/locale.c ++++ b/locale/programs/locale.c +@@ -632,6 +632,7 @@ nameentcmp (const void *a, const void *b) + ((const struct nameent *) b)->name); + } + ++static char _write_archive_locales_path[4096] attribute_hidden __attribute__ ((section (".gccrelocprefix"))) = ARCHIVE_NAME; + + static int + write_archive_locales (void **all_datap, char *linebuf) +@@ -645,7 +646,7 @@ write_archive_locales (void **all_datap, char *linebuf) + int fd, ret = 0; + uint32_t cnt; + +- fd = open64 (ARCHIVE_NAME, O_RDONLY); ++ fd = open64 (_write_archive_locales_path, O_RDONLY); + if (fd < 0) + return 0; + +@@ -700,8 +701,8 @@ write_archive_locales (void **all_datap, char *linebuf) + if (cnt) + putchar_unlocked ('\n'); + +- printf ("locale: %-15.15s archive: " ARCHIVE_NAME "\n%s\n", +- names[cnt].name, linebuf); ++ printf ("locale: %-15.15s archive: %s\n%s\n", ++ names[cnt].name, _write_archive_locales_path, linebuf); + + locrec = (struct locrecent *) (addr + names[cnt].locrec_offset); + diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch b/meta-digi-dey/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch new file mode 100644 index 000000000..2162bf38c --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch @@ -0,0 +1,1581 @@ +From 3d58330390a7d4f4ed32f4a9c25628af3e0dd5c1 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:01:50 +0000 +Subject: [PATCH] fsl e500/e5500/e6500/603e fsqrt implementation + +Upstream-Status: Pending +Signed-off-by: Edmar Wienskoski +Signed-off-by: Khem Raj +--- + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c | 134 ++++++++++++++++++ + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c | 101 +++++++++++++ + sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c | 134 ++++++++++++++++++ + .../powerpc/powerpc32/e500mc/fpu/e_sqrtf.c | 101 +++++++++++++ + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c | 134 ++++++++++++++++++ + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c | 101 +++++++++++++ + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 134 ++++++++++++++++++ + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 101 +++++++++++++ + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c | 134 ++++++++++++++++++ + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c | 101 +++++++++++++ + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c | 134 ++++++++++++++++++ + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c | 101 +++++++++++++ + .../linux/powerpc/powerpc32/603e/fpu/Implies | 1 + + .../powerpc/powerpc32/e300c3/fpu/Implies | 2 + + .../powerpc/powerpc32/e500mc/fpu/Implies | 1 + + .../linux/powerpc/powerpc32/e5500/fpu/Implies | 1 + + .../linux/powerpc/powerpc32/e6500/fpu/Implies | 1 + + .../linux/powerpc/powerpc64/e5500/fpu/Implies | 1 + + .../linux/powerpc/powerpc64/e6500/fpu/Implies | 1 + + 19 files changed, 1418 insertions(+) + create mode 100644 sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c + create mode 100644 sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c + create mode 100644 sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c + create mode 100644 sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c + create mode 100644 sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c + create mode 100644 sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies + +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies +new file mode 100644 +index 0000000000..b103b4dea5 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/603e/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies +new file mode 100644 +index 0000000000..64db17fada +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies +@@ -0,0 +1,2 @@ ++# e300c3 is a variant of 603e so use the same optimizations for sqrt ++powerpc/powerpc32/603e/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies +new file mode 100644 +index 0000000000..7eac5fcf02 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/e500mc/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies +new file mode 100644 +index 0000000000..264b2a7700 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/e5500/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies +new file mode 100644 +index 0000000000..a25934467b +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/e6500/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies +new file mode 100644 +index 0000000000..a7bc854be8 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc64/e5500/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies +new file mode 100644 +index 0000000000..04ff8cc181 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc64/e6500/fpu diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0009-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch b/meta-digi-dey/recipes-core/glibc/glibc/0009-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch new file mode 100644 index 000000000..0c8bf94a7 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0009-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch @@ -0,0 +1,205 @@ +From 3b5fe5b1a7390cde0f07351415e3891f62d1f7e0 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:15:07 +0000 +Subject: [PATCH] ppc/sqrt: Fix undefined reference to `__sqrt_finite' + +on ppc fixes the errors like below +| ./.libs/libpulsecore-1.1.so: undefined reference to `__sqrt_finite' +| collect2: ld returned 1 exit status + +Upstream-Status: Pending + +ChangeLog + +2012-01-06 Khem Raj + + * sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c: Add __*_finite alias. + Remove cruft. + * sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c: Ditto. + * sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c: Ditto. + * sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c: Ditto. + +Signed-off-by: Khem Raj +--- + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c | 7 +------ + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c | 7 +------ + sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c | 1 + + sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c | 1 + + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c | 1 + + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c | 1 + + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 1 + + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 1 + + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c | 7 +------ + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c | 7 +------ + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c | 1 + + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c | 1 + + 12 files changed, 12 insertions(+), 24 deletions(-) + +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +index 71e516d1c8..1795fd6c3e 100644 +--- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +@@ -39,14 +39,8 @@ static const float half = 0.5; + We find the actual square root and half of its reciprocal + simultaneously. */ + +-#ifdef __STDC__ + double + __ieee754_sqrt (double b) +-#else +-double +-__ieee754_sqrt (b) +- double b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -132,3 +126,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +index 26fa067abf..a917f313ab 100644 +--- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +@@ -37,14 +37,8 @@ static const float threehalf = 1.5; + We find the reciprocal square root and use that to compute the actual + square root. */ + +-#ifdef __STDC__ + float + __ieee754_sqrtf (float b) +-#else +-float +-__ieee754_sqrtf (b) +- float b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -99,3 +93,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +index 71e516d1c8..fc4a74990e 100644 +--- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +index 26fa067abf..9d175122a8 100644 +--- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +index 71e516d1c8..fc4a74990e 100644 +--- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +index 26fa067abf..9d175122a8 100644 +--- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +index 71e516d1c8..fc4a74990e 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +index 26fa067abf..9d175122a8 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +index 71e516d1c8..1795fd6c3e 100644 +--- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +@@ -39,14 +39,8 @@ static const float half = 0.5; + We find the actual square root and half of its reciprocal + simultaneously. */ + +-#ifdef __STDC__ + double + __ieee754_sqrt (double b) +-#else +-double +-__ieee754_sqrt (b) +- double b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -132,3 +126,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +index 26fa067abf..a917f313ab 100644 +--- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +@@ -37,14 +37,8 @@ static const float threehalf = 1.5; + We find the reciprocal square root and use that to compute the actual + square root. */ + +-#ifdef __STDC__ + float + __ieee754_sqrtf (float b) +-#else +-float +-__ieee754_sqrtf (b) +- float b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -99,3 +93,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +index 71e516d1c8..fc4a74990e 100644 +--- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +index 26fa067abf..9d175122a8 100644 +--- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0010-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch b/meta-digi-dey/recipes-core/glibc/glibc/0010-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch new file mode 100644 index 000000000..cadaa0b2e --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0010-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch @@ -0,0 +1,384 @@ +From 6b6e1dcd707017598ea3bdc2d91a761943b62218 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:16:38 +0000 +Subject: [PATCH] __ieee754_sqrt{,f} are now inline functions and call out + __slow versions + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c | 12 ++++++++++-- + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c | 8 +++++++- + sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c | 14 +++++++++++--- + sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c | 12 ++++++++++-- + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c | 14 +++++++++++--- + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c | 12 ++++++++++-- + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 8 ++++++++ + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 8 ++++++++ + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c | 12 ++++++++++-- + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c | 9 ++++++++- + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c | 14 +++++++++++--- + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c | 12 ++++++++++-- + 12 files changed, 114 insertions(+), 21 deletions(-) + +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +index 1795fd6c3e..daa83f3fe8 100644 +--- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +@@ -40,7 +40,7 @@ static const float half = 0.5; + simultaneously. */ + + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -77,7 +77,7 @@ __ieee754_sqrt (double b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -126,4 +126,12 @@ __ieee754_sqrt (double b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +index a917f313ab..b812cf1705 100644 +--- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +@@ -38,7 +38,7 @@ static const float threehalf = 1.5; + square root. */ + + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -93,4 +93,10 @@ __ieee754_sqrtf (float b) + } + return f_washf (b); + } ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +index fc4a74990e..7038a70b47 100644 +--- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +index 9d175122a8..10de1f0cc3 100644 +--- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +index fc4a74990e..7038a70b47 100644 +--- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +index 9d175122a8..10de1f0cc3 100644 +--- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +index fc4a74990e..1c34244bd8 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +index 9d175122a8..812653558f 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +index 1795fd6c3e..13a81973e3 100644 +--- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +@@ -40,7 +40,7 @@ static const float half = 0.5; + simultaneously. */ + + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -77,7 +77,7 @@ __ieee754_sqrt (double b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -126,4 +126,12 @@ __ieee754_sqrt (double b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +index a917f313ab..fae2d81210 100644 +--- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +@@ -38,7 +38,7 @@ static const float threehalf = 1.5; + square root. */ + + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -93,4 +93,11 @@ __ieee754_sqrtf (float b) + } + return f_washf (b); + } ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +index fc4a74990e..7038a70b47 100644 +--- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +index 9d175122a8..10de1f0cc3 100644 +--- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0011-Quote-from-bug-1443-which-explains-what-the-patch-do.patch b/meta-digi-dey/recipes-core/glibc/glibc/0011-Quote-from-bug-1443-which-explains-what-the-patch-do.patch new file mode 100644 index 000000000..e4c78b5c7 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0011-Quote-from-bug-1443-which-explains-what-the-patch-do.patch @@ -0,0 +1,58 @@ +From 297bac9429260f8df495b81d3fae8ae4c6913f5f Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:20:09 +0000 +Subject: [PATCH] Quote from bug 1443 which explains what the patch does : + + We build some random program and link it with -lust. When we run it, + it dies with a SIGSEGV before reaching main(). + + Libust.so depends on liburcu-bp.so from the usermode-rcu package. + Although libust.so is not prelinked, liburcu-bp.so IS prelinked; this + is critical. + + Libust.so uses a TLS / __thread variable that is defined in liburcu- + bp.so. There are special ARM-specific relocation types that allow two + shared libraries to share thread-specific data. This is critical too. + + One more critical issue: although liburcu-bp.so is prelinked, we can't + load it at its prelinked address, because we also link against + librt.so, and librt.so uses that address. + + The dynamic linker is forced to relink liburcu-bp.so at a different + address. In the course of relinking, it processes the special ARM + relocation record mentioned above. The prelinker has already filled + in the information, which is a short offset into a table of thread- + specific data that is allocated per-thread for each library that uses + TLS. Because the normal behavior of a relocation is to add the symbol + value to an addend stored at the address being relocated, we end up + adding the short offset to itself, doubling it. + + Now we have an awkward situation. The libust.so library doesn't know + about the addend, so its TLS data for this element is correct. The + liburcu-bp.so library has a different offset for the element. When we + go to initialize the element for the first time in liburcu-bp.so, we + write the address of the result at the doubled (broken) offset. + Later, when we refer to the address from libust.so, we check the value + at the correct offset, but it's NULL, so we eat hot SIGSEGV. + +Upstream-Status: Pending + +Signed-off-by: Andrei Dinu +Signed-off-by: Khem Raj +--- + sysdeps/arm/dl-machine.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h +index ff5e09e207..d68bfe5cbe 100644 +--- a/sysdeps/arm/dl-machine.h ++++ b/sysdeps/arm/dl-machine.h +@@ -510,7 +510,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, + + case R_ARM_TLS_DTPOFF32: + if (sym != NULL) +- *reloc_addr += sym->st_value; ++ *reloc_addr = sym->st_value; + break; + + case R_ARM_TLS_TPOFF32: diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0012-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch b/meta-digi-dey/recipes-core/glibc/glibc/0012-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch new file mode 100644 index 000000000..c5e8e6473 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0012-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch @@ -0,0 +1,33 @@ +From f389babf3c920e68b7d7391556a78ebf62a21ebe Mon Sep 17 00:00:00 2001 +From: Ting Liu +Date: Wed, 19 Dec 2012 04:39:57 -0600 +Subject: [PATCH] eglibc: run libm-err-tab.pl with specific dirs in ${S} + +libm-err-tab.pl will parse all the files named "libm-test-ulps" +in the given dir recursively. To avoid parsing the one in +${S}/.pc/ (it does exist after eglibc adds aarch64 support, +${S}/.pc/aarch64-0001-glibc-fsf-v1-eaf6f205.patch/ports/sysdeps/ +aarch64/libm-test-ulps), run libm-err-tab.pl with specific dirs +in ${S}. + +Upstream-Status: inappropriate [OE specific] + +Signed-off-by: Ting Liu +--- + manual/Makefile | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/manual/Makefile b/manual/Makefile +index e83444341e..aa2645bc55 100644 +--- a/manual/Makefile ++++ b/manual/Makefile +@@ -103,7 +103,8 @@ $(objpfx)stamp-libm-err: $(..)math/gen-libm-test.py \ + $(wildcard $(foreach dir,$(sysdirs),\ + $(dir)/libm-test-ulps)) + pwd=`pwd`; \ +- $(PYTHON) $< -s $$pwd/.. -m $(objpfx)libm-err-tmp ++ $(PYTHON) $< -s $$pwd/../ports -m $(objpfx)libm-err-tmp ++ $(PYTHON) $< -s $$pwd/../sysdeps -m $(objpfx)libm-err-tmp + $(move-if-change) $(objpfx)libm-err-tmp $(objpfx)libm-err.texi + touch $@ + diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0013-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch b/meta-digi-dey/recipes-core/glibc/glibc/0013-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch new file mode 100644 index 000000000..7f362cace --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0013-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch @@ -0,0 +1,58 @@ +From 4b0d41a315e66f688fef7b0c2e2b6ce9fa16ec93 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:24:46 +0000 +Subject: [PATCH] __ieee754_sqrt{,f} are now inline functions and call out + __slow versions + +Upstream-Status: Pending + +Signed-off-by: chunrong guo +Signed-off-by: Khem Raj +--- + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 6 +++--- + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +index 1c34244bd8..7038a70b47 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +index 812653558f..10de1f0cc3 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0014-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch b/meta-digi-dey/recipes-core/glibc/glibc/0014-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch new file mode 100644 index 000000000..4da0e003c --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0014-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch @@ -0,0 +1,39 @@ +From c062a462fee53a30a85d693c8288b5bd8fe4ec6e Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:27:10 +0000 +Subject: [PATCH] sysdeps/gnu/configure.ac: handle correctly + $libc_cv_rootsbindir + +Upstream-Status:Pending + +Signed-off-by: Matthieu Crapet +Signed-off-by: Khem Raj +--- + sysdeps/gnu/configure | 2 +- + sysdeps/gnu/configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sysdeps/gnu/configure b/sysdeps/gnu/configure +index c15d1087e8..37cc983f2a 100644 +--- a/sysdeps/gnu/configure ++++ b/sysdeps/gnu/configure +@@ -32,6 +32,6 @@ case "$prefix" in + else + libc_cv_localstatedir=$localstatedir + fi +- libc_cv_rootsbindir=/sbin ++ test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin + ;; + esac +diff --git a/sysdeps/gnu/configure.ac b/sysdeps/gnu/configure.ac +index 634fe4de2a..3db1697f4f 100644 +--- a/sysdeps/gnu/configure.ac ++++ b/sysdeps/gnu/configure.ac +@@ -21,6 +21,6 @@ case "$prefix" in + else + libc_cv_localstatedir=$localstatedir + fi +- libc_cv_rootsbindir=/sbin ++ test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin + ;; + esac diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch b/meta-digi-dey/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch new file mode 100644 index 000000000..15e83f891 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch @@ -0,0 +1,260 @@ +From 0bd39d8907953f18e01742f42b24647ac7689d0a Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:31:06 +0000 +Subject: [PATCH] 'yes' within the path sets wrong config variables + +It seems that the 'AC_EGREP_CPP(yes...' example is quite popular +but being such a short word to grep it is likely to produce +false-positive matches with the path it is configured into. + +The change is to use a more elaborated string to grep for. + +Upstream-Status: Submitted [libc-alpha@sourceware.org] + +Signed-off-by: Benjamin Esquivel +Signed-off-by: Khem Raj +--- + sysdeps/aarch64/configure | 4 ++-- + sysdeps/aarch64/configure.ac | 4 ++-- + sysdeps/arm/configure | 4 ++-- + sysdeps/arm/configure.ac | 4 ++-- + sysdeps/mips/configure | 4 ++-- + sysdeps/mips/configure.ac | 4 ++-- + sysdeps/nios2/configure | 4 ++-- + sysdeps/nios2/configure.ac | 4 ++-- + sysdeps/unix/sysv/linux/mips/configure | 4 ++-- + sysdeps/unix/sysv/linux/mips/configure.ac | 4 ++-- + sysdeps/unix/sysv/linux/powerpc/powerpc64/configure | 8 ++++---- + sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac | 8 ++++---- + 12 files changed, 28 insertions(+), 28 deletions(-) + +diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure +index 83c3a23e44..a68c946277 100644 +--- a/sysdeps/aarch64/configure ++++ b/sysdeps/aarch64/configure +@@ -157,12 +157,12 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #ifdef __AARCH64EB__ +- yes ++ is_aarch64_be + #endif + + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "is_aarch64_be" >/dev/null 2>&1; then : + libc_cv_aarch64_be=yes + else + libc_cv_aarch64_be=no +diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac +index 66f755078a..a32b265bbe 100644 +--- a/sysdeps/aarch64/configure.ac ++++ b/sysdeps/aarch64/configure.ac +@@ -17,8 +17,8 @@ AC_DEFINE(SUPPORT_STATIC_PIE) + # the dynamic linker via %ifdef. + AC_CACHE_CHECK([for big endian], + [libc_cv_aarch64_be], +- [AC_EGREP_CPP(yes,[#ifdef __AARCH64EB__ +- yes ++ [AC_EGREP_CPP(is_aarch64_be,[#ifdef __AARCH64EB__ ++ is_aarch64_be + #endif + ], libc_cv_aarch64_be=yes, libc_cv_aarch64_be=no)]) + if test $libc_cv_aarch64_be = yes; then +diff --git a/sysdeps/arm/configure b/sysdeps/arm/configure +index 431e843b2b..e152461138 100644 +--- a/sysdeps/arm/configure ++++ b/sysdeps/arm/configure +@@ -151,12 +151,12 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #ifdef __ARM_PCS_VFP +- yes ++ use_arm_pcs_vfp + #endif + + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "use_arm_pcs_vfp" >/dev/null 2>&1; then : + libc_cv_arm_pcs_vfp=yes + else + libc_cv_arm_pcs_vfp=no +diff --git a/sysdeps/arm/configure.ac b/sysdeps/arm/configure.ac +index 90cdd69c75..05a262ba00 100644 +--- a/sysdeps/arm/configure.ac ++++ b/sysdeps/arm/configure.ac +@@ -15,8 +15,8 @@ AC_DEFINE(PI_STATIC_AND_HIDDEN) + # the dynamic linker via %ifdef. + AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI], + [libc_cv_arm_pcs_vfp], +- [AC_EGREP_CPP(yes,[#ifdef __ARM_PCS_VFP +- yes ++ [AC_EGREP_CPP(use_arm_pcs_vfp,[#ifdef __ARM_PCS_VFP ++ use_arm_pcs_vfp + #endif + ], libc_cv_arm_pcs_vfp=yes, libc_cv_arm_pcs_vfp=no)]) + if test $libc_cv_arm_pcs_vfp = yes; then +diff --git a/sysdeps/mips/configure b/sysdeps/mips/configure +index 4e13248c03..f14af952d0 100644 +--- a/sysdeps/mips/configure ++++ b/sysdeps/mips/configure +@@ -143,11 +143,11 @@ else + /* end confdefs.h. */ + dnl + #ifdef __mips_nan2008 +-yes ++use_mips_nan2008 + #endif + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "use_mips_nan2008" >/dev/null 2>&1; then : + libc_cv_mips_nan2008=yes + else + libc_cv_mips_nan2008=no +diff --git a/sysdeps/mips/configure.ac b/sysdeps/mips/configure.ac +index bcbdaffd9f..ad3057f4cc 100644 +--- a/sysdeps/mips/configure.ac ++++ b/sysdeps/mips/configure.ac +@@ -6,9 +6,9 @@ dnl position independent way. + dnl AC_DEFINE(PI_STATIC_AND_HIDDEN) + + AC_CACHE_CHECK([whether the compiler is using the 2008 NaN encoding], +- libc_cv_mips_nan2008, [AC_EGREP_CPP(yes, [dnl ++ libc_cv_mips_nan2008, [AC_EGREP_CPP(use_mips_nan2008, [dnl + #ifdef __mips_nan2008 +-yes ++use_mips_nan2008 + #endif], libc_cv_mips_nan2008=yes, libc_cv_mips_nan2008=no)]) + if test x$libc_cv_mips_nan2008 = xyes; then + AC_DEFINE(HAVE_MIPS_NAN2008) +diff --git a/sysdeps/nios2/configure b/sysdeps/nios2/configure +index 14c8a3a014..dde3814ef2 100644 +--- a/sysdeps/nios2/configure ++++ b/sysdeps/nios2/configure +@@ -142,12 +142,12 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #ifdef __nios2_big_endian__ +- yes ++ is_nios2_be + #endif + + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "is_nios2_be" >/dev/null 2>&1; then : + libc_cv_nios2_be=yes + else + libc_cv_nios2_be=no +diff --git a/sysdeps/nios2/configure.ac b/sysdeps/nios2/configure.ac +index f05f43802b..dc8639902d 100644 +--- a/sysdeps/nios2/configure.ac ++++ b/sysdeps/nios2/configure.ac +@@ -4,8 +4,8 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. + # Nios II big endian is not yet supported. + AC_CACHE_CHECK([for big endian], + [libc_cv_nios2_be], +- [AC_EGREP_CPP(yes,[#ifdef __nios2_big_endian__ +- yes ++ [AC_EGREP_CPP(is_nios2_be,[#ifdef __nios2_big_endian__ ++ is_nios2_be + #endif + ], libc_cv_nios2_be=yes, libc_cv_nios2_be=no)]) + if test $libc_cv_nios2_be = yes; then +diff --git a/sysdeps/unix/sysv/linux/mips/configure b/sysdeps/unix/sysv/linux/mips/configure +index f25f2a3a65..1b7483e6c6 100644 +--- a/sysdeps/unix/sysv/linux/mips/configure ++++ b/sysdeps/unix/sysv/linux/mips/configure +@@ -414,11 +414,11 @@ else + /* end confdefs.h. */ + dnl + #ifdef __mips_nan2008 +-yes ++use_mips_nan2008 + #endif + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "use_mips_nan2008" >/dev/null 2>&1; then : + libc_cv_mips_nan2008=yes + else + libc_cv_mips_nan2008=no +diff --git a/sysdeps/unix/sysv/linux/mips/configure.ac b/sysdeps/unix/sysv/linux/mips/configure.ac +index 049a0f4bdf..005526d4e8 100644 +--- a/sysdeps/unix/sysv/linux/mips/configure.ac ++++ b/sysdeps/unix/sysv/linux/mips/configure.ac +@@ -105,9 +105,9 @@ AC_COMPILE_IFELSE( + LIBC_CONFIG_VAR([mips-mode-switch],[${libc_mips_mode_switch}]) + + AC_CACHE_CHECK([whether the compiler is using the 2008 NaN encoding], +- libc_cv_mips_nan2008, [AC_EGREP_CPP(yes, [dnl ++ libc_cv_mips_nan2008, [AC_EGREP_CPP(use_mips_nan2008, [dnl + #ifdef __mips_nan2008 +-yes ++use_mips_nan2008 + #endif], libc_cv_mips_nan2008=yes, libc_cv_mips_nan2008=no)]) + + libc_mips_nan= +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure +index ae7f254da4..874519000b 100644 +--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure +@@ -155,12 +155,12 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #if _CALL_ELF == 2 +- yes ++ use_ppc_elfv2_abi + #endif + + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "use_ppc_elfv2_abi" >/dev/null 2>&1; then : + libc_cv_ppc64_elfv2_abi=yes + else + libc_cv_ppc64_elfv2_abi=no +@@ -188,12 +188,12 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #ifdef _CALL_ELF +- yes ++ is_def_call_elf + #endif + + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "is_def_call_elf" >/dev/null 2>&1; then : + libc_cv_ppc64_def_call_elf=yes + else + libc_cv_ppc64_def_call_elf=no +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac +index f9cba6e15d..b21f72f1e4 100644 +--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac +@@ -6,8 +6,8 @@ LIBC_SLIBDIR_RTLDDIR([lib64], [lib64]) + # Define default-abi according to compiler flags. + AC_CACHE_CHECK([whether the compiler is using the PowerPC64 ELFv2 ABI], + [libc_cv_ppc64_elfv2_abi], +- [AC_EGREP_CPP(yes,[#if _CALL_ELF == 2 +- yes ++ [AC_EGREP_CPP(use_ppc_elfv2_abi,[#if _CALL_ELF == 2 ++ use_ppc_elfv2_abi + #endif + ], libc_cv_ppc64_elfv2_abi=yes, libc_cv_ppc64_elfv2_abi=no)]) + if test $libc_cv_ppc64_elfv2_abi = yes; then +@@ -19,8 +19,8 @@ else + # Compiler that do not support ELFv2 ABI does not define _CALL_ELF + AC_CACHE_CHECK([whether the compiler defines _CALL_ELF], + [libc_cv_ppc64_def_call_elf], +- [AC_EGREP_CPP(yes,[#ifdef _CALL_ELF +- yes ++ [AC_EGREP_CPP(is_def_call_elf,[#ifdef _CALL_ELF ++ is_def_call_elf + #endif + ], libc_cv_ppc64_def_call_elf=yes, libc_cv_ppc64_def_call_elf=no)]) + if test $libc_cv_ppc64_def_call_elf = no; then diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch b/meta-digi-dey/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch new file mode 100644 index 000000000..79bd70415 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch @@ -0,0 +1,42 @@ +From 3feb4213628f1485000ffe1d3fd26e37a7b14336 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:33:03 +0000 +Subject: [PATCH] timezone: re-written tzselect as posix sh + +To avoid the bash dependency. + +Upstream-Status: Pending + +Signed-off-by: Hongxu Jia +Signed-off-by: Khem Raj +--- + timezone/Makefile | 2 +- + timezone/tzselect.ksh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/timezone/Makefile b/timezone/Makefile +index 395abfeebd..2d939edf75 100644 +--- a/timezone/Makefile ++++ b/timezone/Makefile +@@ -123,7 +123,7 @@ $(testdata)/XT%: testdata/XT% + cp $< $@ + + $(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make +- sed -e 's|/bin/bash|$(BASH)|' \ ++ sed -e 's|/bin/bash|/bin/sh|' \ + -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \ + -e '/TZVERSION=/s|see_Makefile|"$(version)"|' \ + -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \ +diff --git a/timezone/tzselect.ksh b/timezone/tzselect.ksh +index 18fce27e24..70745f9d36 100755 +--- a/timezone/tzselect.ksh ++++ b/timezone/tzselect.ksh +@@ -34,7 +34,7 @@ REPORT_BUGS_TO=tz@iana.org + + # Specify default values for environment variables if they are unset. + : ${AWK=awk} +-: ${TZDIR=`pwd`} ++: ${TZDIR=$(pwd)} + + # Output one argument as-is to standard output. + # Safer than 'echo', which can mishandle '\' or leading '-'. diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0017-Remove-bash-dependency-for-nscd-init-script.patch b/meta-digi-dey/recipes-core/glibc/glibc/0017-Remove-bash-dependency-for-nscd-init-script.patch new file mode 100644 index 000000000..c32d70b59 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0017-Remove-bash-dependency-for-nscd-init-script.patch @@ -0,0 +1,72 @@ +From f6119b98a9caa80642d69a97edc98f57ecef5c3c Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 31 Dec 2015 14:33:02 -0800 +Subject: [PATCH] Remove bash dependency for nscd init script + +The nscd init script uses #! /bin/bash but only really uses one bashism +(translated strings), so remove them and switch the shell to #!/bin/sh. + +Upstream-Status: Pending + +Signed-off-by: Ross Burton +Signed-off-by: Khem Raj +--- + nscd/nscd.init | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/nscd/nscd.init b/nscd/nscd.init +index a882da7d8b..b02986ec15 100644 +--- a/nscd/nscd.init ++++ b/nscd/nscd.init +@@ -1,4 +1,4 @@ +-#!/bin/bash ++#!/bin/sh + # + # nscd: Starts the Name Switch Cache Daemon + # +@@ -49,7 +49,7 @@ prog=nscd + start () { + [ -d /var/run/nscd ] || mkdir /var/run/nscd + [ -d /var/db/nscd ] || mkdir /var/db/nscd +- echo -n $"Starting $prog: " ++ echo -n "Starting $prog: " + daemon /usr/sbin/nscd + RETVAL=$? + echo +@@ -58,7 +58,7 @@ start () { + } + + stop () { +- echo -n $"Stopping $prog: " ++ echo -n "Stopping $prog: " + /usr/sbin/nscd -K + RETVAL=$? + if [ $RETVAL -eq 0 ]; then +@@ -67,9 +67,9 @@ stop () { + # a non-privileged user + rm -f /var/run/nscd/nscd.pid + rm -f /var/run/nscd/socket +- success $"$prog shutdown" ++ success "$prog shutdown" + else +- failure $"$prog shutdown" ++ failure "$prog shutdown" + fi + echo + return $RETVAL +@@ -103,13 +103,13 @@ case "$1" in + RETVAL=$? + ;; + force-reload | reload) +- echo -n $"Reloading $prog: " ++ echo -n "Reloading $prog: " + killproc /usr/sbin/nscd -HUP + RETVAL=$? + echo + ;; + *) +- echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" ++ echo "Usage: $0 {start|stop|status|restart|reload|condrestart}" + RETVAL=1 + ;; + esac diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch b/meta-digi-dey/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch new file mode 100644 index 000000000..826e5af46 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch @@ -0,0 +1,616 @@ +From 060ba13b5ac5e90517d540f009ebdcdcf62f9685 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:42:58 +0000 +Subject: [PATCH] eglibc: Cross building and testing instructions + +Ported from eglibc +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + GLIBC.cross-building | 383 +++++++++++++++++++++++++++++++++++++++++++ + GLIBC.cross-testing | 205 +++++++++++++++++++++++ + 2 files changed, 588 insertions(+) + create mode 100644 GLIBC.cross-building + create mode 100644 GLIBC.cross-testing + +diff --git a/GLIBC.cross-building b/GLIBC.cross-building +new file mode 100644 +index 0000000000..e6e0da1aaf +--- /dev/null ++++ b/GLIBC.cross-building +@@ -0,0 +1,383 @@ ++ -*- mode: text -*- ++ ++ Cross-Compiling GLIBC ++ Jim Blandy ++ ++ ++Introduction ++ ++Most GNU tools have a simple build procedure: you run their ++'configure' script, and then you run 'make'. Unfortunately, the ++process of cross-compiling the GNU C library is quite a bit more ++involved: ++ ++1) Build a cross-compiler, with certain facilities disabled. ++ ++2) Configure the C library using the compiler you built in step 1). ++ Build a few of the C run-time object files, but not the rest of the ++ library. Install the library's header files and the run-time ++ object files, and create a dummy libc.so. ++ ++3) Build a second cross-compiler, using the header files and object ++ files you installed in step 2. ++ ++4) Configure, build, and install a fresh C library, using the compiler ++ built in step 3. ++ ++5) Build a third cross-compiler, based on the C library built in step 4. ++ ++The reason for this complexity is that, although GCC and the GNU C ++library are distributed separately, they are not actually independent ++of each other: GCC requires the C library's headers and some object ++files to compile its own libraries, while the C library depends on ++GCC's libraries. GLIBC includes features and bug fixes to the stock ++GNU C library that simplify this process, but the fundamental ++interdependency stands. ++ ++In this document, we explain how to cross-compile an GLIBC/GCC pair ++from source. Our intended audience is developers who are already ++familiar with the GNU toolchain and comfortable working with ++cross-development tools. While we do present a worked example to ++accompany the explanation, for clarity's sake we do not cover many of ++the options available to cross-toolchain users. ++ ++ ++Preparation ++ ++GLIBC requires recent versions of the GNU binutils, GCC, and the ++Linux kernel. The web page ++documents the current requirements, and lists patches needed for ++certain target architectures. As of this writing, these build ++instructions have been tested with binutils 2.22.51, GCC 4.6.2, ++and Linux 3.1. ++ ++First, let's set some variables, to simplify later commands. We'll ++build GLIBC and GCC for an ARM target, known to the Linux kernel ++as 'arm', and we'll do the build on an Intel x86_64 Linux box: ++ ++ $ build=x86_64-pc-linux-gnu ++ $ host=$build ++ $ target=arm-none-linux-gnueabi ++ $ linux_arch=arm ++ ++We're using the aforementioned versions of Binutils, GCC, and Linux: ++ ++ $ binutilsv=binutils-2.22.51 ++ $ gccv=gcc-4.6.2 ++ $ linuxv=linux-3.1 ++ ++We're carrying out the entire process under '~/cross-build', which ++contains unpacked source trees for binutils, gcc, and linux kernel, ++along with GLIBC svn trunk (which can be checked-out with ++'svn co http://www.eglibc.org/svn/trunk eglibc'): ++ ++ $ top=$HOME/cross-build/$target ++ $ src=$HOME/cross-build/src ++ $ ls $src ++ binutils-2.22.51 glibc gcc-4.6.2 linux-3.1 ++ ++We're going to place our build directories in a subdirectory 'obj', ++we'll install the cross-development toolchain in 'tools', and we'll ++place our sysroot (containing files to be installed on the target ++system) in 'sysroot': ++ ++ $ obj=$top/obj ++ $ tools=$top/tools ++ $ sysroot=$top/sysroot ++ ++ ++Binutils ++ ++Configuring and building binutils for the target is straightforward: ++ ++ $ mkdir -p $obj/binutils ++ $ cd $obj/binutils ++ $ $src/$binutilsv/configure \ ++ > --target=$target \ ++ > --prefix=$tools \ ++ > --with-sysroot=$sysroot ++ $ make ++ $ make install ++ ++ ++The First GCC ++ ++For our work, we need a cross-compiler targeting an ARM Linux ++system. However, that configuration includes the shared library ++'libgcc_s.so', which is compiled against the GLIBC headers (which we ++haven't installed yet) and linked against 'libc.so' (which we haven't ++built yet). ++ ++Fortunately, there are configuration options for GCC which tell it not ++to build 'libgcc_s.so'. The '--without-headers' option is supposed to ++take care of this, but its implementation is incomplete, so you must ++also configure with the '--with-newlib' option. While '--with-newlib' ++appears to mean "Use the Newlib C library", its effect is to tell the ++GCC build machinery, "Don't assume there is a C library available." ++ ++We also need to disable some of the libraries that would normally be ++built along with GCC, and specify that only the compiler for the C ++language is needed. ++ ++So, we create a build directory, configure, make, and install. ++ ++ $ mkdir -p $obj/gcc1 ++ $ cd $obj/gcc1 ++ $ $src/$gccv/configure \ ++ > --target=$target \ ++ > --prefix=$tools \ ++ > --without-headers --with-newlib \ ++ > --disable-shared --disable-threads --disable-libssp \ ++ > --disable-libgomp --disable-libmudflap --disable-libquadmath \ ++ > --disable-decimal-float --disable-libffi \ ++ > --enable-languages=c ++ $ PATH=$tools/bin:$PATH make ++ $ PATH=$tools/bin:$PATH make install ++ ++ ++Linux Kernel Headers ++ ++To configure GLIBC, we also need Linux kernel headers in place. ++Fortunately, the Linux makefiles have a target that installs them for ++us. Since the process does modify the source tree a bit, we make a ++copy first: ++ ++ $ cp -r $src/$linuxv $obj/linux ++ $ cd $obj/linux ++ ++Now we're ready to install the headers into the sysroot: ++ ++ $ PATH=$tools/bin:$PATH \ ++ > make headers_install \ ++ > ARCH=$linux_arch CROSS_COMPILE=$target- \ ++ > INSTALL_HDR_PATH=$sysroot/usr ++ ++ ++GLIBC Headers and Preliminary Objects ++ ++Using the cross-compiler we've just built, we can now configure GLIBC ++well enough to install the headers and build the object files that the ++full cross-compiler will need: ++ ++ $ mkdir -p $obj/glibc-headers ++ $ cd $obj/glibc-headers ++ $ BUILD_CC=gcc \ ++ > CC=$tools/bin/$target-gcc \ ++ > CXX=$tools/bin/$target-g++ \ ++ > AR=$tools/bin/$target-ar \ ++ > RANLIB=$tools/bin/$target-ranlib \ ++ > $src/glibc/libc/configure \ ++ > --prefix=/usr \ ++ > --with-headers=$sysroot/usr/include \ ++ > --build=$build \ ++ > --host=$target \ ++ > --disable-profile --without-gd --without-cvs \ ++ > --enable-add-ons=nptl,libidn,../ports ++ ++The option '--prefix=/usr' may look strange, but you should never ++configure GLIBC with a prefix other than '/usr': in various places, ++GLIBC's build system checks whether the prefix is '/usr', and does ++special handling only if that is the case. Unless you use this ++prefix, you will get a sysroot that does not use the standard Linux ++directory layouts and cannot be used as a basis for the root ++filesystem on your target system compatibly with normal GLIBC ++installations. ++ ++The '--with-headers' option tells GLIBC where the Linux headers have ++been installed. ++ ++The '--enable-add-ons=nptl,libidn,../ports' option tells GLIBC to look ++for the listed glibc add-ons. Most notably the ports add-on (located ++just above the libc sources in the GLIBC svn tree) is required to ++support ARM targets. ++ ++We can now use the 'install-headers' makefile target to install the ++headers: ++ ++ $ make install-headers install_root=$sysroot \ ++ > install-bootstrap-headers=yes ++ ++The 'install_root' variable indicates where the files should actually ++be installed; its value is treated as the parent of the '--prefix' ++directory we passed to the configure script, so the headers will go in ++'$sysroot/usr/include'. The 'install-bootstrap-headers' variable ++requests special handling for certain tricky header files. ++ ++Next, there are a few object files needed to link shared libraries, ++which we build and install by hand: ++ ++ $ mkdir -p $sysroot/usr/lib ++ $ make csu/subdir_lib ++ $ cp csu/crt1.o csu/crti.o csu/crtn.o $sysroot/usr/lib ++ ++Finally, 'libgcc_s.so' requires a 'libc.so' to link against. However, ++since we will never actually execute its code, it doesn't matter what ++it contains. So, treating '/dev/null' as a C source file, we produce ++a dummy 'libc.so' in one step: ++ ++ $ $tools/bin/$target-gcc -nostdlib -nostartfiles -shared -x c /dev/null \ ++ > -o $sysroot/usr/lib/libc.so ++ ++ ++The Second GCC ++ ++With the GLIBC headers and selected object files installed, we can ++now build a GCC that is capable of compiling GLIBC. We configure, ++build, and install the second GCC, again building only the C compiler, ++and avoiding libraries we won't use: ++ ++ $ mkdir -p $obj/gcc2 ++ $ cd $obj/gcc2 ++ $ $src/$gccv/configure \ ++ > --target=$target \ ++ > --prefix=$tools \ ++ > --with-sysroot=$sysroot \ ++ > --disable-libssp --disable-libgomp --disable-libmudflap \ ++ > --disable-libffi --disable-libquadmath \ ++ > --enable-languages=c ++ $ PATH=$tools/bin:$PATH make ++ $ PATH=$tools/bin:$PATH make install ++ ++ ++GLIBC, Complete ++ ++With the second compiler built and installed, we're now ready for the ++full GLIBC build: ++ ++ $ mkdir -p $obj/glibc ++ $ cd $obj/glibc ++ $ BUILD_CC=gcc \ ++ > CC=$tools/bin/$target-gcc \ ++ > CXX=$tools/bin/$target-g++ \ ++ > AR=$tools/bin/$target-ar \ ++ > RANLIB=$tools/bin/$target-ranlib \ ++ > $src/glibc/libc/configure \ ++ > --prefix=/usr \ ++ > --with-headers=$sysroot/usr/include \ ++ > --with-kconfig=$obj/linux/scripts/kconfig \ ++ > --build=$build \ ++ > --host=$target \ ++ > --disable-profile --without-gd --without-cvs \ ++ > --enable-add-ons=nptl,libidn,../ports ++ ++Note the additional '--with-kconfig' option. This tells GLIBC where to ++find the host config tools used by the kernel 'make config' and 'make ++menuconfig'. These tools can be re-used by GLIBC for its own 'make ++*config' support, which will create 'option-groups.config' for you. ++But first make sure those tools have been built by running some ++dummy 'make *config' calls in the kernel directory: ++ ++ $ cd $obj/linux ++ $ PATH=$tools/bin:$PATH make config \ ++ > ARCH=$linux_arch CROSS_COMPILE=$target- \ ++ $ PATH=$tools/bin:$PATH make menuconfig \ ++ > ARCH=$linux_arch CROSS_COMPILE=$target- \ ++ ++Now we can configure and build the full GLIBC: ++ ++ $ cd $obj/glibc ++ $ PATH=$tools/bin:$PATH make defconfig ++ $ PATH=$tools/bin:$PATH make menuconfig ++ $ PATH=$tools/bin:$PATH make ++ $ PATH=$tools/bin:$PATH make install install_root=$sysroot ++ ++At this point, we have a complete GLIBC installation in '$sysroot', ++with header files, library files, and most of the C runtime startup ++files in place. ++ ++ ++The Third GCC ++ ++Finally, we recompile GCC against this full installation, enabling ++whatever languages and libraries we would like to use: ++ ++ $ mkdir -p $obj/gcc3 ++ $ cd $obj/gcc3 ++ $ $src/$gccv/configure \ ++ > --target=$target \ ++ > --prefix=$tools \ ++ > --with-sysroot=$sysroot \ ++ > --enable-__cxa_atexit \ ++ > --disable-libssp --disable-libgomp --disable-libmudflap \ ++ > --enable-languages=c,c++ ++ $ PATH=$tools/bin:$PATH make ++ $ PATH=$tools/bin:$PATH make install ++ ++The '--enable-__cxa_atexit' option tells GCC what sort of C++ ++destructor support to expect from the C library; it's required with ++GLIBC. ++ ++And since GCC's installation process isn't designed to help construct ++sysroot trees, we must manually copy certain libraries into place in ++the sysroot. ++ ++ $ cp -d $tools/$target/lib/libgcc_s.so* $sysroot/lib ++ $ cp -d $tools/$target/lib/libstdc++.so* $sysroot/usr/lib ++ ++ ++Trying Things Out ++ ++At this point, '$tools' contains a cross toolchain ready to use ++the GLIBC installation in '$sysroot': ++ ++ $ cat > hello.c < #include ++ > int ++ > main (int argc, char **argv) ++ > { ++ > puts ("Hello, world!"); ++ > return 0; ++ > } ++ > EOF ++ $ $tools/bin/$target-gcc -Wall hello.c -o hello ++ $ cat > c++-hello.cc < #include ++ > int ++ > main (int argc, char **argv) ++ > { ++ > std::cout << "Hello, C++ world!" << std::endl; ++ > return 0; ++ > } ++ > EOF ++ $ $tools/bin/$target-g++ -Wall c++-hello.cc -o c++-hello ++ ++ ++We can use 'readelf' to verify that these are indeed executables for ++our target, using our dynamic linker: ++ ++ $ $tools/bin/$target-readelf -hl hello ++ ELF Header: ++ ... ++ Type: EXEC (Executable file) ++ Machine: ARM ++ ++ ... ++ Program Headers: ++ Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align ++ PHDR 0x000034 0x10000034 0x10000034 0x00100 0x00100 R E 0x4 ++ INTERP 0x000134 0x00008134 0x00008134 0x00013 0x00013 R 0x1 ++ [Requesting program interpreter: /lib/ld-linux.so.3] ++ LOAD 0x000000 0x00008000 0x00008000 0x0042c 0x0042c R E 0x8000 ++ ... ++ ++Looking at the dynamic section of the installed 'libgcc_s.so', we see ++that the 'NEEDED' entry for the C library does include the '.6' ++suffix, indicating that was linked against our fully build GLIBC, and ++not our dummy 'libc.so': ++ ++ $ $tools/bin/$target-readelf -d $sysroot/lib/libgcc_s.so.1 ++ Dynamic section at offset 0x1083c contains 24 entries: ++ Tag Type Name/Value ++ 0x00000001 (NEEDED) Shared library: [libc.so.6] ++ 0x0000000e (SONAME) Library soname: [libgcc_s.so.1] ++ ... ++ ++ ++And on the target machine, we can run our programs: ++ ++ $ $sysroot/lib/ld.so.1 --library-path $sysroot/lib:$sysroot/usr/lib \ ++ > ./hello ++ Hello, world! ++ $ $sysroot/lib/ld.so.1 --library-path $sysroot/lib:$sysroot/usr/lib \ ++ > ./c++-hello ++ Hello, C++ world! +diff --git a/GLIBC.cross-testing b/GLIBC.cross-testing +new file mode 100644 +index 0000000000..b67b468466 +--- /dev/null ++++ b/GLIBC.cross-testing +@@ -0,0 +1,205 @@ ++ -*- mode: text -*- ++ ++ Cross-Testing With GLIBC ++ Jim Blandy ++ ++ ++Introduction ++ ++Developers writing software for embedded systems often use a desktop ++or other similarly capable computer for development, but need to run ++tests on the embedded system, or perhaps on a simulator. When ++configured for cross-compilation, the stock GNU C library simply ++disables running tests altogether: the command 'make tests' builds ++test programs, but does not run them. GLIBC, however, provides ++facilities for compiling tests and generating data files on the build ++system, but running the test programs themselves on a remote system or ++simulator. ++ ++ ++Test environment requirements ++ ++The test environment must meet certain conditions for GLIBC's ++cross-testing facilities to work: ++ ++- Shared filesystems. The 'build' system, on which you configure and ++ compile GLIBC, and the 'host' system, on which you intend to run ++ GLIBC, must share a filesystem containing the GLIBC build and ++ source trees. Files must appear at the same paths on both systems. ++ ++- Remote-shell like invocation. There must be a way to run a program ++ on the host system from the build system, passing it properly quoted ++ command-line arguments, setting environment variables, and ++ inheriting the caller's standard input and output. ++ ++ ++Usage ++ ++To use GLIBC's cross-testing support, provide values for the ++following Make variables when you invoke 'make': ++ ++- cross-test-wrapper ++ ++ This should be the name of the cross-testing wrapper command, along ++ with any arguments. ++ ++- cross-localedef ++ ++ This should be the name of a cross-capable localedef program, like ++ that included in the GLIBC 'localedef' module, along with any ++ arguments needed. ++ ++These are each explained in detail below. ++ ++ ++The Cross-Testing Wrapper ++ ++To run test programs reliably, the stock GNU C library takes care to ++ensure that test programs use the newly compiled dynamic linker and ++shared libraries, and never the host system's installed libraries. To ++accomplish this, it runs the tests by explicitly invoking the dynamic ++linker from the build tree, passing it a list of build tree ++directories to search for shared libraries, followed by the name of ++the executable to run and its arguments. ++ ++For example, where one might normally run a test program like this: ++ ++ $ ./tst-foo arg1 arg2 ++ ++the GNU C library might run that program like this: ++ ++ $ $objdir/elf/ld-linux.so.3 --library-path $objdir \ ++ ./tst-foo arg1 arg2 ++ ++(where $objdir is the path to the top of the build tree, and the ++trailing backslash indicates a continuation of the command). In other ++words, each test program invocation is 'wrapped up' inside an explicit ++invocation of the dynamic linker, which must itself execute the test ++program, having loaded shared libraries from the appropriate ++directories. ++ ++To support cross-testing, GLIBC allows the developer to optionally ++set the 'cross-test-wrapper' Make variable to another wrapper command, ++to which it passes the entire dynamic linker invocation shown above as ++arguments. For example, if the developer supplies a wrapper of ++'my-wrapper hostname', then GLIBC would run the test above as ++follows: ++ ++ $ my-wrapper hostname \ ++ $objdir/elf/ld-linux.so.3 --library-path $objdir \ ++ ./tst-foo arg1 arg2 ++ ++The 'my-wrapper' command is responsible for executing the command ++given on the host system. ++ ++Since tests are run in varying directories, the wrapper should either ++be in your command search path, or 'cross-test-wrapper' should give an ++absolute path for the wrapper. ++ ++The wrapper must meet several requirements: ++ ++- It must preserve the current directory. As explained above, the ++ build directory tree must be visible on both the build and host ++ systems, at the same path. The test wrapper must ensure that the ++ current directory it inherits is also inherited by the dynamic ++ linker (and thus the test program itself). ++ ++- It must preserve environment variables' values. Many GLIBC tests ++ set environment variables for test runs; in native testing, it ++ invokes programs like this: ++ ++ $ GCONV_PATH=$objdir/iconvdata \ ++ $objdir/elf/ld-linux.so.3 --library-path $objdir \ ++ ./tst-foo arg1 arg2 ++ ++ With the cross-testing wrapper, that invocation becomes: ++ ++ $ GCONV_PATH=$objdir/iconvdata \ ++ my-wrapper hostname \ ++ $objdir/elf/ld-linux.so.3 --library-path $objdir \ ++ ./tst-foo arg1 arg2 ++ ++ Here, 'my-wrapper' must ensure that the value it sees for ++ 'GCONV_PATH' will be seen by the dynamic linker, and thus 'tst-foo' ++ itself. (The wrapper supplied with GLIBC simply preserves the ++ values of *all* enviroment variables, with a fixed set of ++ exceptions.) ++ ++ If your wrapper is a shell script, take care to correctly propagate ++ environment variables whose values contain spaces and shell ++ metacharacters. ++ ++- It must pass the command's arguments, unmodified. The arguments ++ seen by the test program should be exactly those seen by the wrapper ++ (after whatever arguments are given to the wrapper itself). The ++ GLIBC test framework performs all needed shell word splitting and ++ expansion (wildcard expansion, parameter substitution, and so on) ++ before invoking the wrapper; further expansion may break the tests. ++ ++ ++The 'cross-test-ssh.sh' script ++ ++If you want to use 'ssh' (or something sufficiently similar) to run ++test programs on your host system, GLIBC includes a shell script, ++'scripts/cross-test-ssh.sh', which you can use as your wrapper ++command. This script takes care of setting the test command's current ++directory, propagating environment variable values, and carrying ++command-line arguments, all across an 'ssh' connection. You may even ++supply an alternative to 'ssh' on the command line, if needed. ++ ++For more details, pass 'cross-test-ssh.sh' the '--help' option. ++ ++ ++The Cross-Compiling Locale Definition Command ++ ++Some GLIBC tests rely on locales generated especially for the test ++process. In a native configuration, these tests simply run the ++'localedef' command built by the normal GLIBC build process, ++'locale/localedef', to process and install their locales. However, in ++a cross-compiling configuration, this 'localedef' is built for the ++host system, not the build system, and since it requires quite a bit ++of memory to run (we have seen it fail on systems with 64MiB of ++memory), it may not be practical to run it on the host system. ++ ++If set, GLIBC uses the 'cross-localedef' Make variable as the command ++to run on the build system to process and install locales. The ++localedef program built from the GLIBC 'localedef' module is ++suitable. ++ ++The value of 'cross-localedef' may also include command-line arguments ++to be passed to the program; if you are using GLIBC's 'localedef', ++you may include endianness and 'uint32_t' alignment arguments here. ++ ++ ++Example ++ ++In developing GLIBC's cross-testing facility, we invoked 'make' with ++the following script: ++ ++ #!/bin/sh ++ ++ srcdir=... ++ test_hostname=... ++ localedefdir=... ++ cross_gxx=...-g++ ++ ++ wrapper="$srcdir/scripts/cross-test-ssh.sh $test_hostname" ++ localedef="$localedefdir/localedef --little-endian --uint32-align=4" ++ ++ make cross-test-wrapper="$wrapper" \ ++ cross-localedef="$localedef" \ ++ CXX="$cross_gxx" \ ++ "$@" ++ ++ ++Other Cross-Testing Concerns ++ ++Here are notes on some other issues which you may encounter in running ++the GLIBC tests in a cross-compiling environment: ++ ++- Some tests require a C++ cross-compiler; you should set the 'CXX' ++ Make variable to the name of an appropriate cross-compiler. ++ ++- Some tests require access to libstdc++.so.6 and libgcc_s.so.1; we ++ simply place copies of these libraries in the top GLIBC build ++ directory. diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch b/meta-digi-dey/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch new file mode 100644 index 000000000..afac2e04f --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch @@ -0,0 +1,97 @@ +From f13c2f525e9bc82ce13e4cf486f7fe0831fc3fac Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:49:28 +0000 +Subject: [PATCH] eglibc: Help bootstrap cross toolchain + +Taken from EGLIBC, r1484 + r1525 + + 2007-02-20 Jim Blandy + + * Makefile (install-headers): Preserve old behavior: depend on + $(inst_includedir)/gnu/stubs.h only if install-bootstrap-headers + is set; otherwise, place gnu/stubs.h on the 'install-others' list. + + 2007-02-16 Jim Blandy + + * Makefile: Amend make install-headers to install everything + necessary for building a cross-compiler. Install gnu/stubs.h as + part of 'install-headers', not 'install-others'. + If install-bootstrap-headers is 'yes', install a dummy copy of + gnu/stubs.h, instead of computing the real thing. + * include/stubs-bootstrap.h: New file. + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- + Makefile | 22 +++++++++++++++++++++- + include/stubs-bootstrap.h | 12 ++++++++++++ + 2 files changed, 33 insertions(+), 1 deletion(-) + create mode 100644 include/stubs-bootstrap.h + +diff --git a/Makefile b/Makefile +index 50f99ca611..31eed15f02 100644 +--- a/Makefile ++++ b/Makefile +@@ -79,9 +79,18 @@ subdir-dirs = include + vpath %.h $(subdir-dirs) + + # What to install. +-install-others = $(inst_includedir)/gnu/stubs.h + install-bin-script = + ++# If we're bootstrapping, install a dummy gnu/stubs.h along with the ++# other headers, so 'make install-headers' produces a useable include ++# tree. Otherwise, install gnu/stubs.h later, after the rest of the ++# build is done. ++ifeq ($(install-bootstrap-headers),yes) ++install-headers: $(inst_includedir)/gnu/stubs.h ++else ++install-others = $(inst_includedir)/gnu/stubs.h ++endif ++ + ifeq (yes,$(build-shared)) + headers += gnu/lib-names.h + endif +@@ -416,6 +425,16 @@ others: $(common-objpfx)testrun.sh $(common-objpfx)debugglibc.sh + + subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs) + ++# gnu/stubs.h depends (via the subdir 'stubs' targets) on all the .o ++# files in EGLIBC. For bootstrapping a GCC/EGLIBC pair, an empty ++# gnu/stubs.h is good enough. ++ifeq ($(install-bootstrap-headers),yes) ++$(inst_includedir)/gnu/stubs.h: include/stubs-bootstrap.h $(+force) ++ $(make-target-directory) ++ $(INSTALL_DATA) $< $@ ++ ++installed-stubs = ++else + ifndef abi-variants + installed-stubs = $(inst_includedir)/gnu/stubs.h + else +@@ -442,6 +461,7 @@ $(inst_includedir)/gnu/stubs.h: $(+force) + + install-others-nosubdir: $(installed-stubs) + endif ++endif + + + # Since stubs.h is never needed when building the library, we simplify the +diff --git a/include/stubs-bootstrap.h b/include/stubs-bootstrap.h +new file mode 100644 +index 0000000000..1d2b669aff +--- /dev/null ++++ b/include/stubs-bootstrap.h +@@ -0,0 +1,12 @@ ++/* Placeholder stubs.h file for bootstrapping. ++ ++ When bootstrapping a GCC/EGLIBC pair, GCC requires that the EGLIBC ++ headers be installed, but we can't fully build EGLIBC without that ++ GCC. So we run the command: ++ ++ make install-headers install-bootstrap-headers=yes ++ ++ to install the headers GCC needs, but avoid building certain ++ difficult headers. The header depends, via the ++ EGLIBC subdir 'stubs' make targets, on every .o file in EGLIBC, but ++ an empty stubs.h like this will do fine for GCC. */ diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0020-eglibc-Resolve-__fpscr_values-on-SH4.patch b/meta-digi-dey/recipes-core/glibc/glibc/0020-eglibc-Resolve-__fpscr_values-on-SH4.patch new file mode 100644 index 000000000..9a610c670 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0020-eglibc-Resolve-__fpscr_values-on-SH4.patch @@ -0,0 +1,53 @@ +From 330c4e50e28e29c31fb8d6ab39cdbb2af4d3def7 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:55:53 +0000 +Subject: [PATCH] eglibc: Resolve __fpscr_values on SH4 + +2010-09-29 Nobuhiro Iwamatsu + Andrew Stubbs + + Resolve SH's __fpscr_values to symbol in libc.so. + + * sysdeps/sh/sh4/fpu/fpu_control.h: Add C++ __set_fpscr prototype. + * sysdeps/unix/sysv/linux/sh/Versions (GLIBC_2.2): Add __fpscr_values. + * sysdeps/unix/sysv/linux/sh/sysdep.S (___fpscr_values): New constant. + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + sysdeps/unix/sysv/linux/sh/Versions | 1 + + sysdeps/unix/sysv/linux/sh/sysdep.S | 11 +++++++++++ + 2 files changed, 12 insertions(+) + +diff --git a/sysdeps/unix/sysv/linux/sh/Versions b/sysdeps/unix/sysv/linux/sh/Versions +index e0938c4165..ca1d7da339 100644 +--- a/sysdeps/unix/sysv/linux/sh/Versions ++++ b/sysdeps/unix/sysv/linux/sh/Versions +@@ -2,6 +2,7 @@ libc { + GLIBC_2.2 { + # functions used in other libraries + __xstat64; __fxstat64; __lxstat64; ++ __fpscr_values; + + # a* + alphasort64; +diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.S b/sysdeps/unix/sysv/linux/sh/sysdep.S +index a18fbb2e8b..59421bfbb0 100644 +--- a/sysdeps/unix/sysv/linux/sh/sysdep.S ++++ b/sysdeps/unix/sysv/linux/sh/sysdep.S +@@ -30,3 +30,14 @@ ENTRY (__syscall_error) + + #define __syscall_error __syscall_error_1 + #include ++ ++ .data ++ .align 3 ++ .globl ___fpscr_values ++ .type ___fpscr_values, @object ++ .size ___fpscr_values, 8 ++___fpscr_values: ++ .long 0 ++ .long 0x80000 ++weak_alias (___fpscr_values, __fpscr_values) ++ diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0021-eglibc-Forward-port-cross-locale-generation-support.patch b/meta-digi-dey/recipes-core/glibc/glibc/0021-eglibc-Forward-port-cross-locale-generation-support.patch new file mode 100644 index 000000000..0b2f020fd --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0021-eglibc-Forward-port-cross-locale-generation-support.patch @@ -0,0 +1,560 @@ +From 557ed640b26bd208ce8d4a6fd725b124893668d7 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 01:33:49 +0000 +Subject: [PATCH] eglibc: Forward port cross locale generation support + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + locale/Makefile | 3 +- + locale/catnames.c | 46 +++++++++++++++++++++++++++ + locale/localeinfo.h | 2 +- + locale/programs/charmap-dir.c | 6 ++++ + locale/programs/ld-collate.c | 17 +++++----- + locale/programs/ld-ctype.c | 27 ++++++++-------- + locale/programs/ld-time.c | 31 ++++++++++++------ + locale/programs/linereader.c | 2 +- + locale/programs/localedef.c | 8 +++++ + locale/programs/locfile.c | 5 ++- + locale/programs/locfile.h | 59 +++++++++++++++++++++++++++++++++-- + locale/setlocale.c | 29 ----------------- + 12 files changed, 167 insertions(+), 68 deletions(-) + create mode 100644 locale/catnames.c + +diff --git a/locale/Makefile b/locale/Makefile +index b7c60681fa..07c606cde3 100644 +--- a/locale/Makefile ++++ b/locale/Makefile +@@ -26,7 +26,8 @@ headers = langinfo.h locale.h bits/locale.h \ + bits/types/locale_t.h bits/types/__locale_t.h + routines = setlocale findlocale loadlocale loadarchive \ + localeconv nl_langinfo nl_langinfo_l mb_cur_max \ +- newlocale duplocale freelocale uselocale ++ newlocale duplocale freelocale uselocale \ ++ catnames + tests = tst-C-locale tst-locname tst-duplocale + tests-container = tst-localedef-path-norm + categories = ctype messages monetary numeric time paper name \ +diff --git a/locale/catnames.c b/locale/catnames.c +new file mode 100644 +index 0000000000..538f3f5edb +--- /dev/null ++++ b/locale/catnames.c +@@ -0,0 +1,46 @@ ++/* Copyright (C) 2006 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include "localeinfo.h" ++ ++/* Define an array of category names (also the environment variable names). */ ++const struct catnamestr_t _nl_category_names attribute_hidden = ++ { ++#define DEFINE_CATEGORY(category, category_name, items, a) \ ++ category_name, ++#include "categories.def" ++#undef DEFINE_CATEGORY ++ }; ++ ++const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden = ++ { ++#define DEFINE_CATEGORY(category, category_name, items, a) \ ++ [category] = offsetof (struct catnamestr_t, CATNAMEMF (__LINE__)), ++#include "categories.def" ++#undef DEFINE_CATEGORY ++ }; ++ ++/* An array of their lengths, for convenience. */ ++const uint8_t _nl_category_name_sizes[] attribute_hidden = ++ { ++#define DEFINE_CATEGORY(category, category_name, items, a) \ ++ [category] = sizeof (category_name) - 1, ++#include "categories.def" ++#undef DEFINE_CATEGORY ++ [LC_ALL] = sizeof ("LC_ALL") - 1 ++ }; +diff --git a/locale/localeinfo.h b/locale/localeinfo.h +index 22f9dc1140..fa31b3c5ea 100644 +--- a/locale/localeinfo.h ++++ b/locale/localeinfo.h +@@ -230,7 +230,7 @@ __libc_tsd_define (extern, locale_t, LOCALE) + unused. We can manage this playing some tricks with weak references. + But with thread-local locale settings, it becomes quite ungainly unless + we can use __thread variables. So only in that case do we attempt this. */ +-#ifndef SHARED ++#if !defined SHARED && !defined IN_GLIBC_LOCALEDEF + # include + # define NL_CURRENT_INDIRECT 1 + #endif +diff --git a/locale/programs/charmap-dir.c b/locale/programs/charmap-dir.c +index 4841bfd05d..ffcba1fd79 100644 +--- a/locale/programs/charmap-dir.c ++++ b/locale/programs/charmap-dir.c +@@ -18,7 +18,9 @@ + #include + #include + #include ++#ifndef NO_UNCOMPRESS + #include ++#endif + #include + #include + #include +@@ -154,6 +156,7 @@ charmap_closedir (CHARMAP_DIR *cdir) + return closedir (dir); + } + ++#ifndef NO_UNCOMPRESS + /* Creates a subprocess decompressing the given pathname, and returns + a stream reading its output (the decompressed data). */ + static +@@ -202,6 +205,7 @@ fopen_uncompressed (const char *pathname, const char *compressor) + } + return NULL; + } ++#endif + + /* Opens a charmap for reading, given its name (not an alias name). */ + FILE * +@@ -224,6 +228,7 @@ charmap_open (const char *directory, const char *name) + if (stream != NULL) + return stream; + ++#ifndef NO_UNCOMPRESS + memcpy (p, ".gz", 4); + stream = fopen_uncompressed (pathname, "gzip"); + if (stream != NULL) +@@ -233,6 +238,7 @@ charmap_open (const char *directory, const char *name) + stream = fopen_uncompressed (pathname, "bzip2"); + if (stream != NULL) + return stream; ++#endif + + return NULL; + } +diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c +index 0af21e05e2..4980b0c52f 100644 +--- a/locale/programs/ld-collate.c ++++ b/locale/programs/ld-collate.c +@@ -349,7 +349,7 @@ new_element (struct locale_collate_t *collate, const char *mbs, size_t mbslen, + } + if (wcs != NULL) + { +- size_t nwcs = wcslen ((wchar_t *) wcs); ++ size_t nwcs = wcslen_uint32 (wcs); + uint32_t zero = 0; + /* Handle as a single character. */ + if (nwcs == 0) +@@ -1772,8 +1772,7 @@ symbol `%s' has the same encoding as"), (*eptr)->name); + + if ((*eptr)->nwcs == runp->nwcs) + { +- int c = wmemcmp ((wchar_t *) (*eptr)->wcs, +- (wchar_t *) runp->wcs, runp->nwcs); ++ int c = wmemcmp_uint32 ((*eptr)->wcs, runp->wcs, runp->nwcs); + + if (c == 0) + { +@@ -2000,9 +1999,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp) + one consecutive entry. */ + if (runp->wcnext != NULL + && runp->nwcs == runp->wcnext->nwcs +- && wmemcmp ((wchar_t *) runp->wcs, +- (wchar_t *)runp->wcnext->wcs, +- runp->nwcs - 1) == 0 ++ && wmemcmp_uint32 (runp->wcs, ++ runp->wcnext->wcs, ++ runp->nwcs - 1) == 0 + && (runp->wcs[runp->nwcs - 1] + == runp->wcnext->wcs[runp->nwcs - 1] + 1)) + { +@@ -2026,9 +2025,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp) + runp = runp->wcnext; + while (runp->wcnext != NULL + && runp->nwcs == runp->wcnext->nwcs +- && wmemcmp ((wchar_t *) runp->wcs, +- (wchar_t *)runp->wcnext->wcs, +- runp->nwcs - 1) == 0 ++ && wmemcmp_uint32 (runp->wcs, ++ runp->wcnext->wcs, ++ runp->nwcs - 1) == 0 + && (runp->wcs[runp->nwcs - 1] + == runp->wcnext->wcs[runp->nwcs - 1] + 1)); + +diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c +index 2fb579bbbf..d0be99581c 100644 +--- a/locale/programs/ld-ctype.c ++++ b/locale/programs/ld-ctype.c +@@ -915,7 +915,7 @@ ctype_output (struct localedef_t *locale, const struct charmap_t *charmap, + allocate_arrays (ctype, charmap, ctype->repertoire); + + default_missing_len = (ctype->default_missing +- ? wcslen ((wchar_t *) ctype->default_missing) ++ ? wcslen_uint32 (ctype->default_missing) + : 0); + + init_locale_data (&file, nelems); +@@ -1927,7 +1927,7 @@ read_translit_entry (struct linereader *ldfile, struct locale_ctype_t *ctype, + ignore = 1; + else + /* This value is usable. */ +- obstack_grow (ob, to_wstr, wcslen ((wchar_t *) to_wstr) * 4); ++ obstack_grow (ob, to_wstr, wcslen_uint32 (to_wstr) * 4); + + first = 0; + } +@@ -2461,8 +2461,8 @@ with character code range values one must use the absolute ellipsis `...'")); + } + + handle_tok_digit: +- class_bit = _ISwdigit; +- class256_bit = _ISdigit; ++ class_bit = BITw (tok_digit); ++ class256_bit = BIT (tok_digit); + handle_digits = 1; + goto read_charclass; + +@@ -3904,8 +3904,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, + + while (idx < number) + { +- int res = wcscmp ((const wchar_t *) sorted[idx]->from, +- (const wchar_t *) runp->from); ++ int res = wcscmp_uint32 (sorted[idx]->from, runp->from); + if (res == 0) + { + replace = 1; +@@ -3942,11 +3941,11 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, + for (size_t cnt = 0; cnt < number; ++cnt) + { + struct translit_to_t *srunp; +- from_len += wcslen ((const wchar_t *) sorted[cnt]->from) + 1; ++ from_len += wcslen_uint32 (sorted[cnt]->from) + 1; + srunp = sorted[cnt]->to; + while (srunp != NULL) + { +- to_len += wcslen ((const wchar_t *) srunp->str) + 1; ++ to_len += wcslen_uint32 (srunp->str) + 1; + srunp = srunp->next; + } + /* Plus one for the extra NUL character marking the end of +@@ -3970,18 +3969,18 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, + ctype->translit_from_idx[cnt] = from_len; + ctype->translit_to_idx[cnt] = to_len; + +- len = wcslen ((const wchar_t *) sorted[cnt]->from) + 1; +- wmemcpy ((wchar_t *) &ctype->translit_from_tbl[from_len], +- (const wchar_t *) sorted[cnt]->from, len); ++ len = wcslen_uint32 (sorted[cnt]->from) + 1; ++ wmemcpy_uint32 (&ctype->translit_from_tbl[from_len], ++ sorted[cnt]->from, len); + from_len += len; + + ctype->translit_to_idx[cnt] = to_len; + srunp = sorted[cnt]->to; + while (srunp != NULL) + { +- len = wcslen ((const wchar_t *) srunp->str) + 1; +- wmemcpy ((wchar_t *) &ctype->translit_to_tbl[to_len], +- (const wchar_t *) srunp->str, len); ++ len = wcslen_uint32 (srunp->str) + 1; ++ wmemcpy_uint32 (&ctype->translit_to_tbl[to_len], ++ srunp->str, len); + to_len += len; + srunp = srunp->next; + } +diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c +index dcd2a2386d..6814740325 100644 +--- a/locale/programs/ld-time.c ++++ b/locale/programs/ld-time.c +@@ -220,8 +220,10 @@ No definition for %s category found"), "LC_TIME"); + } + else + { ++ static const uint32_t wt_fmt_ampm[] ++ = { '%','I',':','%','M',':','%','S',' ','%','p',0 }; + time->t_fmt_ampm = "%I:%M:%S %p"; +- time->wt_fmt_ampm = (const uint32_t *) L"%I:%M:%S %p"; ++ time->wt_fmt_ampm = wt_fmt_ampm; + } + } + +@@ -231,7 +233,7 @@ No definition for %s category found"), "LC_TIME"); + const int days_per_month[12] = { 31, 29, 31, 30, 31, 30, + 31, 31, 30, 31 ,30, 31 }; + size_t idx; +- wchar_t *wstr; ++ uint32_t *wstr; + + time->era_entries = + (struct era_data *) xmalloc (time->num_era +@@ -457,18 +459,18 @@ No definition for %s category found"), "LC_TIME"); + } + + /* Now generate the wide character name and format. */ +- wstr = wcschr ((wchar_t *) time->wera[idx], L':');/* end direction */ +- wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end offset */ +- wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end start */ +- wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end end */ ++ wstr = wcschr_uint32 (time->wera[idx], L':'); /* end direction */ ++ wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end offset */ ++ wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end start */ ++ wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end end */ + if (wstr != NULL) + { +- time->era_entries[idx].wname = (uint32_t *) wstr + 1; +- wstr = wcschr (wstr + 1, L':'); /* end name */ ++ time->era_entries[idx].wname = wstr + 1; ++ wstr = wcschr_uint32 (wstr + 1, L':'); /* end name */ + if (wstr != NULL) + { + *wstr = L'\0'; +- time->era_entries[idx].wformat = (uint32_t *) wstr + 1; ++ time->era_entries[idx].wformat = wstr + 1; + } + else + time->era_entries[idx].wname = +@@ -527,7 +529,16 @@ No definition for %s category found"), "LC_TIME"); + if (time->date_fmt == NULL) + time->date_fmt = "%a %b %e %H:%M:%S %Z %Y"; + if (time->wdate_fmt == NULL) +- time->wdate_fmt = (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y"; ++ { ++ static const uint32_t wdate_fmt[] = ++ { '%','a',' ', ++ '%','b',' ', ++ '%','e',' ', ++ '%','H',':','%','M',':','%','S',' ', ++ '%','Z',' ', ++ '%','Y',0 }; ++ time->wdate_fmt = wdate_fmt; ++ } + } + + +diff --git a/locale/programs/linereader.c b/locale/programs/linereader.c +index 96d3ab66db..3af379d2c3 100644 +--- a/locale/programs/linereader.c ++++ b/locale/programs/linereader.c +@@ -595,7 +595,7 @@ get_string (struct linereader *lr, const struct charmap_t *charmap, + { + int return_widestr = lr->return_widestr; + char *buf; +- wchar_t *buf2 = NULL; ++ uint32_t *buf2 = NULL; + size_t bufact; + size_t bufmax = 56; + +diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c +index 832c8fd1fc..fe689b3ae1 100644 +--- a/locale/programs/localedef.c ++++ b/locale/programs/localedef.c +@@ -109,6 +109,7 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version; + #define OPT_NO_WARN 402 + #define OPT_WARN 403 + #define OPT_NO_HARD_LINKS 404 ++#define OPT_UINT32_ALIGN 405 + + /* Definitions of arguments for argp functions. */ + static const struct argp_option options[] = +@@ -153,6 +154,8 @@ static const struct argp_option options[] = + N_("Generate little-endian output") }, + { "big-endian", OPT_BIG_ENDIAN, NULL, 0, + N_("Generate big-endian output") }, ++ { "uint32-align", OPT_UINT32_ALIGN, "ALIGNMENT", 0, ++ N_("Set the target's uint32_t alignment in bytes (default 4)") }, + { NULL, 0, NULL, 0, NULL } + }; + +@@ -243,12 +246,14 @@ main (int argc, char *argv[]) + ctype locale. (P1003.2 4.35.5.2) */ + setlocale (LC_CTYPE, "POSIX"); + ++#ifndef NO_SYSCONF + /* Look whether the system really allows locale definitions. POSIX + defines error code 3 for this situation so I think it must be + a fatal error (see P1003.2 4.35.8). */ + if (sysconf (_SC_2_LOCALEDEF) < 0) + record_error (3, 0, _("\ + FATAL: system does not define `_POSIX2_LOCALEDEF'")); ++#endif + + /* Process charmap file. */ + charmap = charmap_read (charmap_file, verbose, 1, be_quiet, 1); +@@ -400,6 +405,9 @@ parse_opt (int key, char *arg, struct argp_state *state) + /* Do not hard link to other locales. */ + hard_links = false; + break; ++ case OPT_UINT32_ALIGN: ++ uint32_align_mask = strtol (arg, NULL, 0) - 1; ++ break; + case 'c': + force_output = 1; + break; +diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c +index 0f1affa1d4..7d86fae801 100644 +--- a/locale/programs/locfile.c ++++ b/locale/programs/locfile.c +@@ -544,6 +544,9 @@ compare_files (const char *filename1, const char *filename2, size_t size, + machine running localedef. */ + bool swap_endianness_p; + ++/* The target's value of __align__(uint32_t) - 1. */ ++unsigned int uint32_align_mask = 3; ++ + /* When called outside a start_locale_structure/end_locale_structure + or start_locale_prelude/end_locale_prelude block, record that the + next byte in FILE's obstack will be the first byte of a new element. +@@ -621,7 +624,7 @@ add_locale_string (struct locale_file *file, const char *string) + void + add_locale_wstring (struct locale_file *file, const uint32_t *string) + { +- add_locale_uint32_array (file, string, wcslen ((const wchar_t *) string) + 1); ++ add_locale_uint32_array (file, string, wcslen_uint32 (string) + 1); + } + + /* Record that FILE's next element is the 32-bit integer VALUE. */ +diff --git a/locale/programs/locfile.h b/locale/programs/locfile.h +index c986d599ec..222a779176 100644 +--- a/locale/programs/locfile.h ++++ b/locale/programs/locfile.h +@@ -71,6 +71,8 @@ extern void write_all_categories (struct localedef_t *definitions, + + extern bool swap_endianness_p; + ++extern unsigned int uint32_align_mask; ++ + /* Change the output to be big-endian if BIG_ENDIAN is true and + little-endian otherwise. */ + static inline void +@@ -89,7 +91,8 @@ maybe_swap_uint32 (uint32_t value) + } + + /* Likewise, but munge an array of N uint32_ts starting at ARRAY. */ +-static inline void ++static void ++__attribute__ ((unused)) + maybe_swap_uint32_array (uint32_t *array, size_t n) + { + if (swap_endianness_p) +@@ -99,7 +102,8 @@ maybe_swap_uint32_array (uint32_t *array, size_t n) + + /* Like maybe_swap_uint32_array, but the array of N elements is at + the end of OBSTACK's current object. */ +-static inline void ++static void ++__attribute__ ((unused)) + maybe_swap_uint32_obstack (struct obstack *obstack, size_t n) + { + maybe_swap_uint32_array ((uint32_t *) obstack_next_free (obstack) - n, n); +@@ -276,4 +280,55 @@ extern void identification_output (struct localedef_t *locale, + const struct charmap_t *charmap, + const char *output_path); + ++static size_t wcslen_uint32 (const uint32_t *str) __attribute__ ((unused)); ++static uint32_t * wmemcpy_uint32 (uint32_t *s1, const uint32_t *s2, size_t n) __attribute__ ((unused)); ++static uint32_t * wcschr_uint32 (const uint32_t *s, uint32_t ch) __attribute__ ((unused)); ++static int wcscmp_uint32 (const uint32_t *s1, const uint32_t *s2) __attribute__ ((unused)); ++static int wmemcmp_uint32 (const uint32_t *s1, const uint32_t *s2, size_t n) __attribute__ ((unused)); ++ ++static size_t ++wcslen_uint32 (const uint32_t *str) ++{ ++ size_t len = 0; ++ while (str[len] != 0) ++ len++; ++ return len; ++} ++ ++static int ++wmemcmp_uint32 (const uint32_t *s1, const uint32_t *s2, size_t n) ++{ ++ while (n-- != 0) ++ { ++ int diff = *s1++ - *s2++; ++ if (diff != 0) ++ return diff; ++ } ++ return 0; ++} ++ ++static int ++wcscmp_uint32 (const uint32_t *s1, const uint32_t *s2) ++{ ++ while (*s1 != 0 && *s1 == *s2) ++ s1++, s2++; ++ return *s1 - *s2; ++} ++ ++static uint32_t * ++wmemcpy_uint32 (uint32_t *s1, const uint32_t *s2, size_t n) ++{ ++ return memcpy (s1, s2, n * sizeof (uint32_t)); ++} ++ ++static uint32_t * ++wcschr_uint32 (const uint32_t *s, uint32_t ch) ++{ ++ do ++ if (*s == ch) ++ return (uint32_t *) s; ++ while (*s++ != 0); ++ return 0; ++} ++ + #endif /* locfile.h */ +diff --git a/locale/setlocale.c b/locale/setlocale.c +index 19ed85ae8e..f28ca11446 100644 +--- a/locale/setlocale.c ++++ b/locale/setlocale.c +@@ -63,35 +63,6 @@ static char *const _nl_current_used[] = + + #endif + +- +-/* Define an array of category names (also the environment variable names). */ +-const struct catnamestr_t _nl_category_names attribute_hidden = +- { +-#define DEFINE_CATEGORY(category, category_name, items, a) \ +- category_name, +-#include "categories.def" +-#undef DEFINE_CATEGORY +- }; +- +-const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden = +- { +-#define DEFINE_CATEGORY(category, category_name, items, a) \ +- [category] = offsetof (struct catnamestr_t, CATNAMEMF (__LINE__)), +-#include "categories.def" +-#undef DEFINE_CATEGORY +- }; +- +-/* An array of their lengths, for convenience. */ +-const uint8_t _nl_category_name_sizes[] attribute_hidden = +- { +-#define DEFINE_CATEGORY(category, category_name, items, a) \ +- [category] = sizeof (category_name) - 1, +-#include "categories.def" +-#undef DEFINE_CATEGORY +- [LC_ALL] = sizeof ("LC_ALL") - 1 +- }; +- +- + #ifdef NL_CURRENT_INDIRECT + # define WEAK_POSTLOAD(postload) weak_extern (postload) + #else diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0022-Define-DUMMY_LOCALE_T-if-not-defined.patch b/meta-digi-dey/recipes-core/glibc/glibc/0022-Define-DUMMY_LOCALE_T-if-not-defined.patch new file mode 100644 index 000000000..33d912d35 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0022-Define-DUMMY_LOCALE_T-if-not-defined.patch @@ -0,0 +1,29 @@ +From c8df3cf4556d8d78a98675865395ce42f3b67109 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 20 Apr 2016 21:11:00 -0700 +Subject: [PATCH] Define DUMMY_LOCALE_T if not defined + +This is a hack to fix building the locale bits on an older +CentOs 5.X machine + +Upstream-Status: Inappropriate [other] + +Signed-off-by: Khem Raj +--- + locale/programs/config.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/locale/programs/config.h b/locale/programs/config.h +index 2edcf3696c..5350101e38 100644 +--- a/locale/programs/config.h ++++ b/locale/programs/config.h +@@ -19,6 +19,9 @@ + #ifndef _LD_CONFIG_H + #define _LD_CONFIG_H 1 + ++#ifndef DUMMY_LOCALE_T ++#define DUMMY_LOCALE_T ++#endif + /* Use the internal textdomain used for libc messages. */ + #define PACKAGE _libc_intl_domainname + #ifndef VERSION diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0023-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch b/meta-digi-dey/recipes-core/glibc/glibc/0023-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch new file mode 100644 index 000000000..a5a7a0cad --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0023-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch @@ -0,0 +1,80 @@ +From 2ec233ce078b74030de9195096058cd502fdc395 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 3 Aug 2018 09:42:06 -0700 +Subject: [PATCH] localedef --add-to-archive uses a hard-coded locale path + +it doesn't exist in normal use, and there's no way to pass an +alternative filename. + +Add a fallback of $LOCALEARCHIVE from the environment, and allow +creation of new locale archives that are not the system archive. + +Upstream-Status: Inappropriate (OE-specific) + +Signed-off-by: Ross Burton +Signed-off-by: Khem Raj +--- + locale/programs/locarchive.c | 35 +++++++++++++++++++++++++---------- + 1 file changed, 25 insertions(+), 10 deletions(-) + +diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c +index 6bb189ae37..0711c5c44e 100644 +--- a/locale/programs/locarchive.c ++++ b/locale/programs/locarchive.c +@@ -340,12 +340,24 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) + struct namehashent *oldnamehashtab; + struct locarhandle new_ah; + size_t prefix_len = output_prefix ? strlen (output_prefix) : 0; +- char archivefname[prefix_len + sizeof (ARCHIVE_NAME)]; +- char fname[prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1]; ++ char *archivefname; ++ char *fname; ++ char *envarchive = getenv("LOCALEARCHIVE"); + +- if (output_prefix) +- memcpy (archivefname, output_prefix, prefix_len); +- strcpy (archivefname + prefix_len, ARCHIVE_NAME); ++ if (envarchive != NULL) ++ { ++ archivefname = xmalloc(strlen(envarchive) + 1); ++ fname = xmalloc(strlen(envarchive) + sizeof (".XXXXXX")); ++ strcpy (archivefname, envarchive); ++ } ++ else ++ { ++ archivefname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME)); ++ fname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1); ++ if (output_prefix) ++ memcpy (archivefname, output_prefix, prefix_len); ++ strcpy (archivefname + prefix_len, ARCHIVE_NAME); ++ } + strcpy (stpcpy (fname, archivefname), ".XXXXXX"); + + /* Not all of the old file has to be mapped. Change this now this +@@ -569,10 +581,13 @@ open_archive (struct locarhandle *ah, bool readonly) + /* If ah has a non-NULL fname open that otherwise open the default. */ + if (archivefname == NULL) + { +- archivefname = default_fname; +- if (output_prefix) +- memcpy (default_fname, output_prefix, prefix_len); +- strcpy (default_fname + prefix_len, ARCHIVE_NAME); ++ archivefname = getenv("LOCALEARCHIVE"); ++ if (archivefname == NULL) { ++ archivefname = default_fname; ++ if (output_prefix) ++ memcpy (default_fname, output_prefix, prefix_len); ++ strcpy (default_fname + prefix_len, ARCHIVE_NAME); ++ } + } + + while (1) +@@ -585,7 +600,7 @@ open_archive (struct locarhandle *ah, bool readonly) + the default locale archive we ignore the failure and + list an empty archive, otherwise we print an error + and exit. */ +- if (errno == ENOENT && archivefname == default_fname) ++ if (errno == ENOENT) + { + if (readonly) + { diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0024-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch b/meta-digi-dey/recipes-core/glibc/glibc/0024-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch new file mode 100644 index 000000000..d2691e1ee --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0024-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch @@ -0,0 +1,53 @@ +From f8289aa320b00f6db43213979cceab2325a7a611 Mon Sep 17 00:00:00 2001 +From: Mark Hatle +Date: Thu, 18 Aug 2016 14:07:58 -0500 +Subject: [PATCH] elf/dl-deps.c: Make _dl_build_local_scope breadth first + +According to the ELF specification: + +When resolving symbolic references, the dynamic linker examines the symbol +tables with a breadth-first search. + +This function was using a depth first search. By doing so the conflict +resolution reported to the prelinker (when LD_TRACE_PRELINKING=1 is set) +was incorrect. This caused problems when their were various circular +dependencies between libraries. The problem usually manifested itself by +the wrong IFUNC being executed. + +[BZ# 20488] + +Upstream-Status: Submitted [libc-alpha] + +Signed-off-by: Mark Hatle +--- + elf/dl-deps.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/elf/dl-deps.c b/elf/dl-deps.c +index 087a49b212..c09f9334f2 100644 +--- a/elf/dl-deps.c ++++ b/elf/dl-deps.c +@@ -73,13 +73,19 @@ _dl_build_local_scope (struct link_map **list, struct link_map *map) + { + struct link_map **p = list; + struct link_map **q; ++ struct link_map **r; + + *p++ = map; + map->l_reserved = 1; +- if (map->l_initfini) +- for (q = map->l_initfini + 1; *q; ++q) +- if (! (*q)->l_reserved) +- p += _dl_build_local_scope (p, *q); ++ ++ for (r = list; r < p; ++r) ++ if ((*r)->l_initfini) ++ for (q = (*r)->l_initfini + 1; *q; ++q) ++ if (! (*q)->l_reserved) ++ { ++ *p++ = *q; ++ (*q)->l_reserved = 1; ++ } + return p - list; + } + diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0025-intl-Emit-no-lines-in-bison-generated-files.patch b/meta-digi-dey/recipes-core/glibc/glibc/0025-intl-Emit-no-lines-in-bison-generated-files.patch new file mode 100644 index 000000000..32f8fd22b --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0025-intl-Emit-no-lines-in-bison-generated-files.patch @@ -0,0 +1,31 @@ +From 3156464f9a95bf1dafd2e22d19d7bf89c520acc1 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 3 Aug 2018 09:44:00 -0700 +Subject: [PATCH] intl: Emit no lines in bison generated files + +Improve reproducibility: +Do not put any #line preprocessor commands in bison generated files. +These lines contain absolute paths containing file locations on +the host build machine. + +Upstream-Status: Pending + +Signed-off-by: Juro Bystricky +Signed-off-by: Khem Raj +--- + intl/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/intl/Makefile b/intl/Makefile +index 93478d87e8..b27a7935eb 100644 +--- a/intl/Makefile ++++ b/intl/Makefile +@@ -155,7 +155,7 @@ $(objpfx)tst-gettext6.out: $(objpfx)tst-gettext.out + + CPPFLAGS += -D'LOCALEDIR="$(localedir)"' \ + -D'LOCALE_ALIAS_PATH="$(localedir)"' +-BISONFLAGS = --yacc --name-prefix=__gettext --output ++BISONFLAGS = --yacc --no-lines --name-prefix=__gettext --output + + $(inst_localedir)/locale.alias: locale.alias $(+force) + $(do-install) diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0027-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch b/meta-digi-dey/recipes-core/glibc/glibc/0027-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch new file mode 100644 index 000000000..782d931f2 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0027-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch @@ -0,0 +1,53 @@ +From 881f5b8134afd9a30049b93fc79dda7a44947a5f Mon Sep 17 00:00:00 2001 +From: Martin Jansa +Date: Mon, 17 Dec 2018 21:36:18 +0000 +Subject: [PATCH] locale: prevent maybe-uninitialized errors with -Os [BZ + #19444] + +Fixes following error when building for aarch64 with -Os: +| In file included from strcoll_l.c:43: +| strcoll_l.c: In function '__strcoll_l': +| ../locale/weight.h:31:26: error: 'seq2.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized] +| int_fast32_t i = table[*(*cpp)++]; +| ^~~~~~~~~ +| strcoll_l.c:304:18: note: 'seq2.back_us' was declared here +| coll_seq seq1, seq2; +| ^~~~ +| In file included from strcoll_l.c:43: +| ../locale/weight.h:31:26: error: 'seq1.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized] +| int_fast32_t i = table[*(*cpp)++]; +| ^~~~~~~~~ +| strcoll_l.c:304:12: note: 'seq1.back_us' was declared here +| coll_seq seq1, seq2; +| ^~~~ + + Partial fix for [BZ #19444] + * locale/weight.h: Fix build with -Os. + +Upstream-Status: Submitted [https://patchwork.ozlabs.org/patch/1014766] + +Signed-off-by: Martin Jansa +Signed-off-by: Khem Raj +--- + locale/weight.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/locale/weight.h b/locale/weight.h +index 723e1fefda..f5798d379a 100644 +--- a/locale/weight.h ++++ b/locale/weight.h +@@ -28,7 +28,14 @@ findidx (const int32_t *table, + const unsigned char *extra, + const unsigned char **cpp, size_t len) + { ++ /* With GCC 8 when compiling with -Os the compiler warns that ++ seq1.back_us and seq2.back_us might be used uninitialized. ++ This uninitialized use is impossible for the same reason ++ as described in comments in locale/weightwc.h. */ ++ DIAG_PUSH_NEEDS_COMMENT; ++ DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); + int_fast32_t i = table[*(*cpp)++]; ++ DIAG_POP_NEEDS_COMMENT; + const unsigned char *cp; + const unsigned char *usrc; + diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0028-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch b/meta-digi-dey/recipes-core/glibc/glibc/0028-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch new file mode 100644 index 000000000..d273cab4a --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0028-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch @@ -0,0 +1,29 @@ +From b4e0a034b12b313dcb82d22341bef6a66b3e9ef9 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:11:22 +0000 +Subject: [PATCH] readlib: Add OECORE_KNOWN_INTERPRETER_NAMES to known names + +This bolts in a hook for OE to pass its own version of interpreter +names into glibc especially for multilib case, where it differs from any +other distros + +Upstream-Status: Inappropriate [OE specific] + +Signed-off-by: Lianhao Lu +Signed-off-by: Khem Raj +--- + elf/readlib.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/elf/readlib.c b/elf/readlib.c +index 7383c23249..e97ea9449d 100644 +--- a/elf/readlib.c ++++ b/elf/readlib.c +@@ -51,6 +51,7 @@ static struct known_names interpreters[] = + #ifdef SYSDEP_KNOWN_INTERPRETER_NAMES + SYSDEP_KNOWN_INTERPRETER_NAMES + #endif ++ OECORE_KNOWN_INTERPRETER_NAMES + }; + + static struct known_names known_libs[] = diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0029-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch b/meta-digi-dey/recipes-core/glibc/glibc/0029-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch new file mode 100644 index 000000000..11a77cdf9 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0029-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch @@ -0,0 +1,75 @@ +From 2ae3ff3ae28abb1d0d100b4722da7ff188de9a30 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 15 May 2020 17:05:45 -0700 +Subject: [PATCH] wordsize.h: Unify the header between arm and aarch64 + +This helps OE multilibs to not sythesize this header which causes all +kind of recursions and other issues since wordsize is fundamental header +and ends up including itself in many case e.g. clang tidy, bpf etc. + +Upstream-Status: Inappropriate [ OE-Specific ] + +Signed-off-by: Khem Raj +--- + sysdeps/aarch64/bits/wordsize.h | 8 ++++++-- + sysdeps/{aarch64 => arm}/bits/wordsize.h | 10 +++++++--- + 2 files changed, 13 insertions(+), 5 deletions(-) + copy sysdeps/{aarch64 => arm}/bits/wordsize.h (80%) + +diff --git a/sysdeps/aarch64/bits/wordsize.h b/sysdeps/aarch64/bits/wordsize.h +index 91da566b74..9a754514b3 100644 +--- a/sysdeps/aarch64/bits/wordsize.h ++++ b/sysdeps/aarch64/bits/wordsize.h +@@ -17,12 +17,16 @@ + License along with the GNU C Library; if not, see + . */ + +-#ifdef __LP64__ ++#if defined (__aarch64__) && defined (__LP64__) + # define __WORDSIZE 64 +-#else ++#elif defined (__aarch64__) + # define __WORDSIZE 32 + # define __WORDSIZE32_SIZE_ULONG 1 + # define __WORDSIZE32_PTRDIFF_LONG 1 ++#else ++# define __WORDSIZE 32 ++# define __WORDSIZE32_SIZE_ULONG 0 ++# define __WORDSIZE32_PTRDIFF_LONG 0 + #endif + + #define __WORDSIZE_TIME64_COMPAT32 0 +diff --git a/sysdeps/aarch64/bits/wordsize.h b/sysdeps/arm/bits/wordsize.h +similarity index 80% +copy from sysdeps/aarch64/bits/wordsize.h +copy to sysdeps/arm/bits/wordsize.h +index 91da566b74..34fcdef1f1 100644 +--- a/sysdeps/aarch64/bits/wordsize.h ++++ b/sysdeps/arm/bits/wordsize.h +@@ -1,6 +1,6 @@ + /* Determine the wordsize from the preprocessor defines. + +- Copyright (C) 2016-2021 Free Software Foundation, Inc. ++ Copyright (C) 2016-2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or +@@ -17,12 +17,16 @@ + License along with the GNU C Library; if not, see + . */ + +-#ifdef __LP64__ ++#if defined (__aarch64__) && defined (__LP64__) + # define __WORDSIZE 64 +-#else ++#elif defined (__aarch64__) + # define __WORDSIZE 32 + # define __WORDSIZE32_SIZE_ULONG 1 + # define __WORDSIZE32_PTRDIFF_LONG 1 ++#else ++# define __WORDSIZE 32 ++# define __WORDSIZE32_SIZE_ULONG 0 ++# define __WORDSIZE32_PTRDIFF_LONG 0 + #endif + + #define __WORDSIZE_TIME64_COMPAT32 0 diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0030-powerpc-Do-not-ask-compiler-for-finding-arch.patch b/meta-digi-dey/recipes-core/glibc/glibc/0030-powerpc-Do-not-ask-compiler-for-finding-arch.patch new file mode 100644 index 000000000..5ef1ac2ed --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0030-powerpc-Do-not-ask-compiler-for-finding-arch.patch @@ -0,0 +1,48 @@ +From 5cc14938f05ae1354c8062f017a21f39d5fc9729 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 7 Aug 2020 14:31:16 -0700 +Subject: [PATCH] powerpc: Do not ask compiler for finding arch + +This does not work well in cross compiling environments like OE +and moreover it uses its own -mcpu/-march options via cflags + +Upstream-Status: Inappropriate [ OE-Specific] + +Signed-off-by: Khem Raj +--- + sysdeps/powerpc/preconfigure | 5 +---- + sysdeps/powerpc/preconfigure.ac | 5 +---- + 2 files changed, 2 insertions(+), 8 deletions(-) + +diff --git a/sysdeps/powerpc/preconfigure b/sysdeps/powerpc/preconfigure +index dfe8e20399..bbff040f0f 100644 +--- a/sysdeps/powerpc/preconfigure ++++ b/sysdeps/powerpc/preconfigure +@@ -29,10 +29,7 @@ esac + # directive which shows up, and try using it. + case "${machine}:${submachine}" in + *powerpc*:) +- archcpu=`echo "int foo () { return 0; }" \ +- | $CC $CFLAGS $CPPFLAGS -S -frecord-gcc-switches -xc -o - - \ +- | grep -E "mcpu=|.machine" -m 1 \ +- | sed -e "s/.*machine //" -e "s/.*mcpu=\(.*\)\"/\1/"` ++ archcpu='' + # Note if you add patterns here you must ensure that an appropriate + # directory exists in sysdeps/powerpc. Likewise, if we find a + # cpu, don't let the generic configure append extra compiler options. +diff --git a/sysdeps/powerpc/preconfigure.ac b/sysdeps/powerpc/preconfigure.ac +index 6c63bd8257..3e925f1d48 100644 +--- a/sysdeps/powerpc/preconfigure.ac ++++ b/sysdeps/powerpc/preconfigure.ac +@@ -29,10 +29,7 @@ esac + # directive which shows up, and try using it. + case "${machine}:${submachine}" in + *powerpc*:) +- archcpu=`echo "int foo () { return 0; }" \ +- | $CC $CFLAGS $CPPFLAGS -S -frecord-gcc-switches -xc -o - - \ +- | grep -E "mcpu=|[.]machine" -m 1 \ +- | sed -e "s/.*machine //" -e "s/.*mcpu=\(.*\)\"/\1/"` ++ archcpu='' + # Note if you add patterns here you must ensure that an appropriate + # directory exists in sysdeps/powerpc. Likewise, if we find a + # cpu, don't let the generic configure append extra compiler options. diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0031-x86-Require-full-ISA-support-for-x86-64-level-marker.patch b/meta-digi-dey/recipes-core/glibc/glibc/0031-x86-Require-full-ISA-support-for-x86-64-level-marker.patch new file mode 100644 index 000000000..3cb60b2e5 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0031-x86-Require-full-ISA-support-for-x86-64-level-marker.patch @@ -0,0 +1,116 @@ +From b1971f6f1331d738d1d6b376b4741668a7546125 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Tue, 2 Feb 2021 13:45:58 -0800 +Subject: [PATCH] x86: Require full ISA support for x86-64 level marker [BZ #27318] + +Since -march=sandybridge enables ISAs in x86-64 ISA level v3, the v3 +marker is set on libc.so. We couldn't set the needed ISA marker to v2 +since this libc won't run on all v2 machines. Technically, the v3 marker +is correct. But the resulting libc.so won't run on Sandy Brigde, which +is a v2 machine, even when libc is compiled with -march=sandybridge: + +$ ./elf/ld.so ./libc.so +./libc.so: (p) CPU ISA level is lower than required: needed: 7; got: 3 + +Instead, we require full ISA support for x86-64 level marker and disable +x86-64 level marker for -march=sandybridge which enables ISAs between v2 +and v3. + +Upstream-Status: Submitted [https://sourceware.org/pipermail/libc-alpha/2021-February/122297.html] +Signed-off-by: Khem Raj +--- + + sysdeps/x86/configure | 7 ++++++- + sysdeps/x86/configure.ac | 2 +- + sysdeps/x86/isa-level.c | 21 ++++++++++++++++++++- + 3 files changed, 27 insertions(+), 3 deletions(-) + +diff --git a/sysdeps/x86/configure b/sysdeps/x86/configure +index 5e32dc62b3..5b20646843 100644 +--- a/sysdeps/x86/configure ++++ b/sysdeps/x86/configure +@@ -133,7 +133,12 @@ if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -nostartfiles -nostdlib -r -o conftest c + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + count=`LC_ALL=C $READELF -n conftest | grep NT_GNU_PROPERTY_TYPE_0 | wc -l` +- if test "$count" = 1; then ++ if test "$count" = 1 && { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -DINCLUDE_X86_ISA_LEVEL -S -o conftest.s $srcdir/sysdeps/x86/isa-level.c' ++ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; }; then + libc_cv_include_x86_isa_level=yes + fi + fi +diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac +index f94088f377..54ecd33d2c 100644 +--- a/sysdeps/x86/configure.ac ++++ b/sysdeps/x86/configure.ac +@@ -100,7 +100,7 @@ EOF + libc_cv_include_x86_isa_level=no + if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -nostartfiles -nostdlib -r -o conftest conftest1.S conftest2.S); then + count=`LC_ALL=C $READELF -n conftest | grep NT_GNU_PROPERTY_TYPE_0 | wc -l` +- if test "$count" = 1; then ++ if test "$count" = 1 && AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -DINCLUDE_X86_ISA_LEVEL -S -o conftest.s $srcdir/sysdeps/x86/isa-level.c); then + libc_cv_include_x86_isa_level=yes + fi + fi +diff --git a/sysdeps/x86/isa-level.c b/sysdeps/x86/isa-level.c +index aaf524cb56..7f83449061 100644 +--- a/sysdeps/x86/isa-level.c ++++ b/sysdeps/x86/isa-level.c +@@ -25,12 +25,17 @@ + License along with the GNU C Library; if not, see + . */ + +-#include ++#ifdef _LIBC ++# include ++#endif + + /* ELF program property for x86 ISA level. */ + #ifdef INCLUDE_X86_ISA_LEVEL + # if defined __x86_64__ || defined __FXSR__ || !defined _SOFT_FLOAT \ + || defined __MMX__ || defined __SSE__ || defined __SSE2__ ++# if !defined __SSE__ || !defined __SSE2__ ++# error "Missing ISAs for x86-64 ISA level baseline" ++# endif + # define ISA_BASELINE GNU_PROPERTY_X86_ISA_1_BASELINE + # else + # define ISA_BASELINE 0 +@@ -40,6 +45,11 @@ + || (defined __x86_64__ && defined __LAHF_SAHF__) \ + || defined __POPCNT__ || defined __SSE3__ \ + || defined __SSSE3__ || defined __SSE4_1__ || defined __SSE4_2__ ++# if !defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 \ ++ || !defined __POPCNT__ || !defined __SSE3__ \ ++ || !defined __SSSE3__ || !defined __SSE4_1__ || !defined __SSE4_2__ ++# error "Missing ISAs for x86-64 ISA level v2" ++# endif + # define ISA_V2 GNU_PROPERTY_X86_ISA_1_V2 + # else + # define ISA_V2 0 +@@ -48,6 +58,10 @@ + # if defined __AVX__ || defined __AVX2__ || defined __F16C__ \ + || defined __FMA__ || defined __LZCNT__ || defined __MOVBE__ \ + || defined __XSAVE__ ++# if !defined __AVX__ || !defined __AVX2__ || !defined __F16C__ \ ++ || !defined __FMA__ || !defined __LZCNT__ ++# error "Missing ISAs for x86-64 ISA level v3" ++# endif + # define ISA_V3 GNU_PROPERTY_X86_ISA_1_V3 + # else + # define ISA_V3 0 +@@ -55,6 +69,11 @@ + + # if defined __AVX512F__ || defined __AVX512BW__ || defined __AVX512CD__ \ + || defined __AVX512DQ__ || defined __AVX512VL__ ++# if !defined __AVX512F__ || !defined __AVX512BW__ \ ++ || !defined __AVX512CD__ || !defined __AVX512DQ__ \ ++ || !defined __AVX512VL__ ++# error "Missing ISAs for x86-64 ISA level v4" ++# endif + # define ISA_V4 GNU_PROPERTY_X86_ISA_1_V4 + # else + # define ISA_V4 0 diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0032-string-Work-around-GCC-PR-98512-in-rawmemchr.patch b/meta-digi-dey/recipes-core/glibc/glibc/0032-string-Work-around-GCC-PR-98512-in-rawmemchr.patch new file mode 100644 index 000000000..e904b28a0 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0032-string-Work-around-GCC-PR-98512-in-rawmemchr.patch @@ -0,0 +1,58 @@ +From 044e603b698093cf48f6e6229e0b66acf05227e4 Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Fri, 19 Feb 2021 13:29:00 +0100 +Subject: [PATCH] string: Work around GCC PR 98512 in rawmemchr + +Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;h=044e603b698093cf48f6e6229e0b66acf05227e4] +Signed-off-by: Khem Raj +--- + string/rawmemchr.c | 26 +++++++++++++++----------- + 1 file changed, 15 insertions(+), 11 deletions(-) + +diff --git a/string/rawmemchr.c b/string/rawmemchr.c +index 59bbeeaa42..b8523118e5 100644 +--- a/string/rawmemchr.c ++++ b/string/rawmemchr.c +@@ -22,24 +22,28 @@ + # define RAWMEMCHR __rawmemchr + #endif + +-/* Find the first occurrence of C in S. */ +-void * +-RAWMEMCHR (const void *s, int c) +-{ +- DIAG_PUSH_NEEDS_COMMENT; ++/* The pragmata should be nested inside RAWMEMCHR below, but that ++ triggers GCC PR 98512. */ ++DIAG_PUSH_NEEDS_COMMENT; + #if __GNUC_PREREQ (7, 0) +- /* GCC 8 warns about the size passed to memchr being larger than +- PTRDIFF_MAX; the use of SIZE_MAX is deliberate here. */ +- DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-overflow="); ++/* GCC 8 warns about the size passed to memchr being larger than ++ PTRDIFF_MAX; the use of SIZE_MAX is deliberate here. */ ++DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-overflow="); + #endif + #if __GNUC_PREREQ (11, 0) +- /* Likewise GCC 11, with a different warning option. */ +- DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread"); ++/* Likewise GCC 11, with a different warning option. */ ++DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread"); + #endif ++ ++/* Find the first occurrence of C in S. */ ++void * ++RAWMEMCHR (const void *s, int c) ++{ + if (c != '\0') + return memchr (s, c, (size_t)-1); +- DIAG_POP_NEEDS_COMMENT; + return (char *)s + strlen (s); + } + libc_hidden_def (__rawmemchr) + weak_alias (__rawmemchr, rawmemchr) ++ ++DIAG_POP_NEEDS_COMMENT; +-- +2.30.1 + diff --git a/meta-digi-dey/recipes-core/glibc/glibc/0033-x86-Handle-_SC_LEVEL1_ICACHE_LINESIZE-BZ-27444.patch b/meta-digi-dey/recipes-core/glibc/glibc/0033-x86-Handle-_SC_LEVEL1_ICACHE_LINESIZE-BZ-27444.patch new file mode 100644 index 000000000..3a004e227 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/0033-x86-Handle-_SC_LEVEL1_ICACHE_LINESIZE-BZ-27444.patch @@ -0,0 +1,185 @@ +From 750b00a1ddae220403fd892a6fd4e0791ffd154a Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Fri, 18 Sep 2020 07:55:14 -0700 +Subject: [PATCH] x86: Handle _SC_LEVEL1_ICACHE_LINESIZE [BZ #27444] + + x86: Move x86 processor cache info to cpu_features + +missed _SC_LEVEL1_ICACHE_LINESIZE. + +1. Add level1_icache_linesize to struct cpu_features. +2. Initialize level1_icache_linesize by calling handle_intel, +handle_zhaoxin and handle_amd with _SC_LEVEL1_ICACHE_LINESIZE. +3. Return level1_icache_linesize for _SC_LEVEL1_ICACHE_LINESIZE. + +Upstream-Status: Backport [https://sourceware.org/bugzilla/show_bug.cgi?id=27444] +Signed-off-by: Andrei Gherzan +--- + sysdeps/x86/Makefile | 8 +++ + sysdeps/x86/cacheinfo.c | 3 + + sysdeps/x86/dl-cacheinfo.h | 6 ++ + sysdeps/x86/include/cpu-features.h | 2 + + .../x86/tst-sysconf-cache-linesize-static.c | 1 + + sysdeps/x86/tst-sysconf-cache-linesize.c | 57 +++++++++++++++++++ + 6 files changed, 77 insertions(+) + create mode 100644 sysdeps/x86/tst-sysconf-cache-linesize-static.c + create mode 100644 sysdeps/x86/tst-sysconf-cache-linesize.c + +diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile +index dd82674342..d231263051 100644 +--- a/sysdeps/x86/Makefile ++++ b/sysdeps/x86/Makefile +@@ -208,3 +208,11 @@ $(objpfx)check-cet.out: $(..)sysdeps/x86/check-cet.awk \ + generated += check-cet.out + endif + endif ++ ++ifeq ($(subdir),posix) ++tests += \ ++ tst-sysconf-cache-linesize \ ++ tst-sysconf-cache-linesize-static ++tests-static += \ ++ tst-sysconf-cache-linesize-static ++endif +diff --git a/sysdeps/x86/cacheinfo.c b/sysdeps/x86/cacheinfo.c +index 7b8df45e3b..5ea4723ca6 100644 +--- a/sysdeps/x86/cacheinfo.c ++++ b/sysdeps/x86/cacheinfo.c +@@ -32,6 +32,9 @@ __cache_sysconf (int name) + case _SC_LEVEL1_ICACHE_SIZE: + return cpu_features->level1_icache_size; + ++ case _SC_LEVEL1_ICACHE_LINESIZE: ++ return cpu_features->level1_icache_linesize; ++ + case _SC_LEVEL1_DCACHE_SIZE: + return cpu_features->level1_dcache_size; + +diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h +index a31fa0783a..7cd00b92f1 100644 +--- a/sysdeps/x86/dl-cacheinfo.h ++++ b/sysdeps/x86/dl-cacheinfo.h +@@ -707,6 +707,7 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) + long int core; + unsigned int threads = 0; + unsigned long int level1_icache_size = -1; ++ unsigned long int level1_icache_linesize = -1; + unsigned long int level1_dcache_size = -1; + unsigned long int level1_dcache_assoc = -1; + unsigned long int level1_dcache_linesize = -1; +@@ -726,6 +727,8 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) + + level1_icache_size + = handle_intel (_SC_LEVEL1_ICACHE_SIZE, cpu_features); ++ level1_icache_linesize ++ = handle_intel (_SC_LEVEL1_ICACHE_LINESIZE, cpu_features); + level1_dcache_size = data; + level1_dcache_assoc + = handle_intel (_SC_LEVEL1_DCACHE_ASSOC, cpu_features); +@@ -753,6 +756,7 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) + shared = handle_zhaoxin (_SC_LEVEL3_CACHE_SIZE); + + level1_icache_size = handle_zhaoxin (_SC_LEVEL1_ICACHE_SIZE); ++ level1_icache_linesize = handle_zhaoxin (_SC_LEVEL1_ICACHE_LINESIZE); + level1_dcache_size = data; + level1_dcache_assoc = handle_zhaoxin (_SC_LEVEL1_DCACHE_ASSOC); + level1_dcache_linesize = handle_zhaoxin (_SC_LEVEL1_DCACHE_LINESIZE); +@@ -772,6 +776,7 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) + shared = handle_amd (_SC_LEVEL3_CACHE_SIZE); + + level1_icache_size = handle_amd (_SC_LEVEL1_ICACHE_SIZE); ++ level1_icache_linesize = handle_amd (_SC_LEVEL1_ICACHE_LINESIZE); + level1_dcache_size = data; + level1_dcache_assoc = handle_amd (_SC_LEVEL1_DCACHE_ASSOC); + level1_dcache_linesize = handle_amd (_SC_LEVEL1_DCACHE_LINESIZE); +@@ -833,6 +838,7 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) + } + + cpu_features->level1_icache_size = level1_icache_size; ++ cpu_features->level1_icache_linesize = level1_icache_linesize; + cpu_features->level1_dcache_size = level1_dcache_size; + cpu_features->level1_dcache_assoc = level1_dcache_assoc; + cpu_features->level1_dcache_linesize = level1_dcache_linesize; +diff --git a/sysdeps/x86/include/cpu-features.h b/sysdeps/x86/include/cpu-features.h +index 624736b40e..39a3f4f311 100644 +--- a/sysdeps/x86/include/cpu-features.h ++++ b/sysdeps/x86/include/cpu-features.h +@@ -874,6 +874,8 @@ struct cpu_features + unsigned long int rep_stosb_threshold; + /* _SC_LEVEL1_ICACHE_SIZE. */ + unsigned long int level1_icache_size; ++ /* _SC_LEVEL1_ICACHE_LINESIZE. */ ++ unsigned long int level1_icache_linesize; + /* _SC_LEVEL1_DCACHE_SIZE. */ + unsigned long int level1_dcache_size; + /* _SC_LEVEL1_DCACHE_ASSOC. */ +diff --git a/sysdeps/x86/tst-sysconf-cache-linesize-static.c b/sysdeps/x86/tst-sysconf-cache-linesize-static.c +new file mode 100644 +index 0000000000..152ae68821 +--- /dev/null ++++ b/sysdeps/x86/tst-sysconf-cache-linesize-static.c +@@ -0,0 +1 @@ ++#include "tst-sysconf-cache-linesize.c" +diff --git a/sysdeps/x86/tst-sysconf-cache-linesize.c b/sysdeps/x86/tst-sysconf-cache-linesize.c +new file mode 100644 +index 0000000000..642dbde5d2 +--- /dev/null ++++ b/sysdeps/x86/tst-sysconf-cache-linesize.c +@@ -0,0 +1,57 @@ ++/* Test system cache line sizes. ++ Copyright (C) 2021 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++#include ++#include ++#include ++#include ++ ++static struct ++{ ++ const char *name; ++ int _SC_val; ++} sc_options[] = ++ { ++#define N(name) { "_SC_"#name, _SC_##name } ++ N (LEVEL1_ICACHE_LINESIZE), ++ N (LEVEL1_DCACHE_LINESIZE), ++ N (LEVEL2_CACHE_LINESIZE) ++ }; ++ ++static int ++do_test (void) ++{ ++ int result = EXIT_SUCCESS; ++ ++ for (int i = 0; i < array_length (sc_options); ++i) ++ { ++ long int scret = sysconf (sc_options[i]._SC_val); ++ if (scret < 0) ++ { ++ printf ("sysconf (%s) returned < 0 (%ld)\n", ++ sc_options[i].name, scret); ++ result = EXIT_FAILURE; ++ } ++ else ++ printf ("sysconf (%s): %ld\n", sc_options[i].name, scret); ++ } ++ ++ return result; ++} ++ ++#include diff --git a/meta-digi-dey/recipes-core/glibc/glibc/CVE-2021-27645.patch b/meta-digi-dey/recipes-core/glibc/glibc/CVE-2021-27645.patch new file mode 100644 index 000000000..26c5c0d2a --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/CVE-2021-27645.patch @@ -0,0 +1,51 @@ +From dca565886b5e8bd7966e15f0ca42ee5cff686673 Mon Sep 17 00:00:00 2001 +From: DJ Delorie +Date: Thu, 25 Feb 2021 16:08:21 -0500 +Subject: [PATCH] nscd: Fix double free in netgroupcache [BZ #27462] + +In commit 745664bd798ec8fd50438605948eea594179fba1 a use-after-free +was fixed, but this led to an occasional double-free. This patch +tracks the "live" allocation better. + +Tested manually by a third party. + +Related: RHBZ 1927877 + +Reviewed-by: Siddhesh Poyarekar +Reviewed-by: Carlos O'Donell + +Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;h=dca565886b5e8bd7966e15f0ca42ee5cff686673] + +CVE: CVE-2021-27645 + +Reviewed-by: Carlos O'Donell +Signed-off-by: Khairul Rohaizzat Jamaluddin +--- + nscd/netgroupcache.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c +index dba6ceec1b..ad2daddafd 100644 +--- a/nscd/netgroupcache.c ++++ b/nscd/netgroupcache.c +@@ -248,7 +248,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req, + : NULL); + ndomain = (ndomain ? newbuf + ndomaindiff + : NULL); +- buffer = newbuf; ++ *tofreep = buffer = newbuf; + } + + nhost = memcpy (buffer + bufused, +@@ -319,7 +319,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req, + else if (status == NSS_STATUS_TRYAGAIN && e == ERANGE) + { + buflen *= 2; +- buffer = xrealloc (buffer, buflen); ++ *tofreep = buffer = xrealloc (buffer, buflen); + } + else if (status == NSS_STATUS_RETURN + || status == NSS_STATUS_NOTFOUND +-- +2.27.0 + diff --git a/meta-digi-dey/recipes-core/glibc/glibc/check-test-wrapper b/meta-digi-dey/recipes-core/glibc/glibc/check-test-wrapper new file mode 100644 index 000000000..6ec9b9b29 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/check-test-wrapper @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +import sys +import os +import subprocess +import resource + +env = os.environ.copy() +args = sys.argv[1:] +targettype = args.pop(0) + +if targettype == "user": + qemuargs = os.environ.get("QEMU_OPTIONS", "").split() + if not os.path.exists(qemuargs[0]): + # ensure qemu args has a valid absolute path + for i in os.environ.get("PATH", "").split(":"): + if os.path.exists(os.path.join(i, qemuargs[0])): + qemuargs[0] = os.path.join(i, qemuargs[0]) + break + sysroot = os.environ.get("QEMU_SYSROOT", None) + if not sysroot: + sys.exit(-1) + libpaths = [sysroot + "/usr/lib", sysroot + "/lib"] + + if args[0] == "env": + args.pop(0) + if len(args) == 0: + args = ["env"] + else: + # process options + while args[0].startswith("-"): + opt = args.pop(0).lstrip("-") + if "i" in opt: + env.clear() + # process environment vars + while "=" in args[0]: + key, val = args.pop(0).split("=", 1) + if key == "LD_LIBRARY_PATH": + libpaths += val.split(":") + else: + env[key] = val + if args[0] == "cp": + # ignore copies, the filesystem is the same + sys.exit(0) + + qemuargs += ["-L", sysroot] + qemuargs += ["-E", "LD_LIBRARY_PATH={}".format(":".join(libpaths))] + command = qemuargs + args + + # We've seen qemu-arm using up all system memory for some glibc + # tests e.g. nptl/tst-pthread-timedlock-lockloop + # Cap at 8GB since no test should need more than that + # (5GB adds 7 failures for qemuarm glibc test run) + limit = 8*1024*1024*1024 + resource.setrlimit(resource.RLIMIT_AS, (limit, limit)) + +elif targettype == "ssh": + host = os.environ.get("SSH_HOST", None) + user = os.environ.get("SSH_HOST_USER", None) + port = os.environ.get("SSH_HOST_PORT", None) + + command = ["ssh", "-o", "UserKnownHostsFile=/dev/null", "-o", "StrictHostKeyChecking=no"] + if port: + command += ["-p", str(port)] + if not host: + sys.exit(-1) + command += ["{}@{}".format(user, host) if user else host] + + # wrap and replace quotes for correct transformation on ssh + wrapped = " ".join(["'{0}'".format(i.replace("'", r"'\''")) for i in ["cd", os.getcwd()]]) + "; " + wrapped += " ".join(["'{0}'".format(i.replace("'", r"'\''")) for i in args]) + command += ["sh", "-c", "\"{}\"".format(wrapped)] +else: + sys.exit(-1) + +try: + r = subprocess.run(command, timeout = 1800, env = env) + sys.exit(r.returncode) +except subprocess.TimeoutExpired: + sys.exit(-1) + diff --git a/meta-digi-dey/recipes-core/glibc/glibc/etc/ld.so.conf b/meta-digi-dey/recipes-core/glibc/glibc/etc/ld.so.conf new file mode 100644 index 000000000..83327c01b --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/etc/ld.so.conf @@ -0,0 +1 @@ +include /etc/ld.so.conf.d/*.conf diff --git a/meta-digi-dey/recipes-core/glibc/glibc/faccessat2-perm.patch b/meta-digi-dey/recipes-core/glibc/glibc/faccessat2-perm.patch new file mode 100644 index 000000000..2ee7110ca --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/faccessat2-perm.patch @@ -0,0 +1,31 @@ +Older seccomp-based filters used in container frameworks will block faccessat2 +calls as it's a relatively new syscall. This isn't a big problem with +glibc <2.33 but 2.33 will call faccessat2 itself, get EPERM, and thenn be confused +about what to do as EPERM isn't an expected error code. + +This manifests itself as mysterious errors, for example a kernel failing to link. + +The root cause of bad seccomp filters is mostly fixed (systemd 247, Docker 20.10.0) +but we can't expect everyone to upgrade, so add a workaound (originally from +Red Hat) to handle EPERM like ENOSYS and fallback to faccessat(). + +Upstream-Status: Inappropriate +Signed-off-by: Ross Burton + +diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c +index 56cb6dcc8b4d58d3..5de75032bbc93a2c 100644 +--- a/sysdeps/unix/sysv/linux/faccessat.c ++++ b/sysdeps/unix/sysv/linux/faccessat.c +@@ -34,7 +34,11 @@ faccessat (int fd, const char *file, int mode, int flag) + #if __ASSUME_FACCESSAT2 + return ret; + #else +- if (ret == 0 || errno != ENOSYS) ++ /* Fedora-specific workaround: ++ As a workround for a broken systemd-nspawn that returns ++ EPERM when a syscall is not allowed instead of ENOSYS ++ we must check for EPERM here and fall back to faccessat. */ ++ if (ret == 0 || !(errno == ENOSYS || errno == EPERM)) + return ret; + + if (flag & ~(AT_SYMLINK_NOFOLLOW | AT_EACCESS)) diff --git a/meta-digi-dey/recipes-core/glibc/glibc/generate-supported.mk b/meta-digi-dey/recipes-core/glibc/glibc/generate-supported.mk new file mode 100644 index 000000000..d2a28c2dc --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/generate-supported.mk @@ -0,0 +1,11 @@ +#!/usr/bin/make + +include $(IN) + +all: + rm -f $(OUT) + touch $(OUT) + for locale in $(SUPPORTED-LOCALES); do \ + [ $$locale = true ] && continue; \ + echo $$locale | sed 's,/, ,' >> $(OUT); \ + done diff --git a/meta-digi-dey/recipes-core/glibc/glibc/makedbs.sh b/meta-digi-dey/recipes-core/glibc/glibc/makedbs.sh new file mode 100755 index 000000000..7d51a6735 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc/makedbs.sh @@ -0,0 +1,177 @@ +#!/bin/sh + +# +# Make passwd.db, group.db, etc. +# + +VAR_DB=/var/db + +# Use make if available +if [ -x /usr/bin/make -o -x /bin/make ]; then + make -C $VAR_DB + exit 0 +fi + +# No make available, do it in hard way + +# passwd.db +if [ -e /etc/passwd ]; then +target=$VAR_DB/passwd.db +echo -n "passwd... " +awk 'BEGIN { FS=":"; OFS=":" } \ + /^[ \t]*$$/ { next } \ + /^[ \t]*#/ { next } \ + /^[^#]/ { printf ".%s ", $$1; print; \ + printf "=%s ", $$3; print }' /etc/passwd | \ +makedb --quiet -o $target - +echo "done." +fi + +# group.db +if [ -e /etc/group ]; then +target=$VAR_DB/group.db +echo -n "group... " +awk 'BEGIN { FS=":"; OFS=":" } \ + /^[ \t]*$$/ { next } \ + /^[ \t]*#/ { next } \ + /^[^#]/ { printf ".%s ", $$1; print; \ + printf "=%s ", $$3; print; \ + if ($$4 != "") { \ + split($$4, grmems, ","); \ + for (memidx in grmems) { \ + mem=grmems[memidx]; \ + if (members[mem] == "") \ + members[mem]=$$3; \ + else \ + members[mem]=members[mem] "," $$3; \ + } \ + delete grmems; } } \ + END { for (mem in members) \ + printf ":%s %s %s\n", mem, mem, members[mem]; }' /etc/group | \ +makedb --quiet -o $target - +echo "done." +fi + +# ethers.db +if [ -e /etc/ethers ]; then +target=$VAR_DB/ethers.db +echo -n "ethers... " +awk '/^[ \t]*$$/ { next } \ + /^[ \t]*#/ { next } \ + /^[^#]/ { printf ".%s ", $$1; print; \ + printf "=%s ", $$2; print }' /etc/ethers | \ +makedb --quiet -o $target - +echo "done." +fi + +# protocols.db +if [ -e /etc/protocols ]; then +target=$VAR_DB/protocols.db +echo -n "protocols... " +awk '/^[ \t]*$$/ { next } \ + /^[ \t]*#/ { next } \ + /^[^#]/ { printf ".%s ", $$1; print; \ + printf "=%s ", $$2; print; \ + for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \ + { printf ".%s ", $$i; print } }' /etc/protocols | \ +makedb --quiet -o $target - +echo "done." +fi + +# rpc.db +if [ -e /etc/rpc ]; then +target=$VAR_DB/rpc.db +echo -n "rpc... " +awk '/^[ \t]*$$/ { next } \ + /^[ \t]*#/ { next } \ + /^[^#]/ { printf ".%s ", $$1; print; \ + printf "=%s ", $$2; print; \ + for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \ + { printf ".%s ", $$i; print } }' /etc/rpc | \ +makedb --quiet -o $target - +echo "done." +fi + +# services.db +if [ -e /etc/services ]; then +target=$VAR_DB/services.db +echo -n "services... " +awk 'BEGIN { FS="[ \t/]+" } \ + /^[ \t]*$$/ { next } \ + /^[ \t]*#/ { next } \ + /^[^#]/ { sub(/[ \t]*#.*$$/, "");\ + printf ":%s/%s ", $$1, $$3; print; \ + printf ":%s/ ", $$1; print; \ + printf "=%s/%s ", $$2, $$3; print; \ + printf "=%s/ ", $$2; print; \ + for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \ + { printf ":%s/%s ", $$i, $$3; print; \ + printf ":%s/ ", $$i; print } }' /etc/services | \ +makedb --quiet -o $target - +echo "done." +fi + +# shadow.db +if [ -e /etc/shadow ]; then +target=$VAR_DB/shadow.db +echo -n "shadow... " +awk 'BEGIN { FS=":"; OFS=":" } \ + /^[ \t]*$$/ { next } \ + /^[ \t]*#/ { next } \ + /^[^#]/ { printf ".%s ", $$1; print }' /etc/shadow | \ +(umask 077 && makedb --quiet -o $target -) +echo "done." +if chgrp shadow $target 2>/dev/null; then + chmod g+r $target +else + chown 0 $target; chgrp 0 $target; chmod 600 $target; + echo + echo "Warning: The shadow password database $target" + echo "has been set to be readable only by root. You may want" + echo "to make it readable by the \`shadow' group depending" + echo "on your configuration." + echo +fi +fi + +# gshadow.db +if [ -e /etc/gshadow ]; then +target=$VAR_DB/gshadow.db +echo -n "gshadow... " +awk 'BEGIN { FS=":"; OFS=":" } \ + /^[ \t]*$$/ { next } \ + /^[ \t]*#/ { next } \ + /^[^#]/ { printf ".%s ", $$1; print }' /etc/gshadow | \ +(umask 077 && makedb --quiet -o $target -) +echo "done." +if chgrp shadow $target 2>/dev/null; then + chmod g+r $target +else + chown 0 $target; chgrp 0 $target; chmod 600 $target + echo + echo "Warning: The shadow group database $target" + echo "has been set to be readable only by root. You may want" + echo "to make it readable by the \`shadow' group depending" + echo "on your configuration." + echo +fi +fi + +# netgroup.db +if [ -e /etc/netgroup ]; then +target=$VAR_DB/netgroup.db +echo -n "netgroup... " +awk 'BEGIN { ini=1 } \ + /^[ \t]*$$/ { next } \ + /^[ \t]*#/ { next } \ + /^[^#]/ { if (sub(/[ \t]*\\$$/, " ") == 0) end="\n"; \ + else end=""; \ + gsub(/[ \t]+/, " "); \ + sub(/^[ \t]*/, ""); \ + if (ini == 0) printf "%s%s", $$0, end; \ + else printf ".%s %s%s", $$1, $$0, end; \ + ini=end == "" ? 0 : 1; } \ + END { if (ini==0) printf "\n" }' /etc/netgroup | \ +makedb --quiet -o $target +echo "done." +fi diff --git a/meta-digi-dey/recipes-core/glibc/glibc_2.33.bb b/meta-digi-dey/recipes-core/glibc/glibc_2.33.bb new file mode 100644 index 000000000..75a1f36d6 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/glibc_2.33.bb @@ -0,0 +1,136 @@ +require glibc.inc +require glibc-version.inc + +CVE_CHECK_WHITELIST += "CVE-2020-10029" + +# glibc https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-1010022 +# glibc https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-1010023 +# glibc https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-1010024 +# Upstream glibc maintainers dispute there is any issue and have no plans to address it further. +# "this is being treated as a non-security bug and no real threat." +CVE_CHECK_WHITELIST += "CVE-2019-1010022 CVE-2019-1010023 CVE-2019-1010024" + +# glibc https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-1010025 +# Allows for ASLR bypass so can bypass some hardening, not an exploit in itself, may allow +# easier access for another. "ASLR bypass itself is not a vulnerability." +# Potential patch at https://sourceware.org/bugzilla/show_bug.cgi?id=22853 +CVE_CHECK_WHITELIST += "CVE-2019-1010025" + +DEPENDS += "gperf-native bison-native make-native" + +NATIVESDKFIXES ?= "" +NATIVESDKFIXES_class-nativesdk = "\ + file://0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch \ + file://0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch \ + file://0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch \ + file://0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch \ + file://0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch \ + file://faccessat2-perm.patch \ +" + +SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ + file://etc/ld.so.conf \ + file://generate-supported.mk \ + file://makedbs.sh \ + \ + ${NATIVESDKFIXES} \ + file://0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch \ + file://0009-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch \ + file://0010-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch \ + file://0011-Quote-from-bug-1443-which-explains-what-the-patch-do.patch \ + file://0012-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch \ + file://0013-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch \ + file://0014-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch \ + file://0015-yes-within-the-path-sets-wrong-config-variables.patch \ + file://0016-timezone-re-written-tzselect-as-posix-sh.patch \ + file://0017-Remove-bash-dependency-for-nscd-init-script.patch \ + file://0018-eglibc-Cross-building-and-testing-instructions.patch \ + file://0019-eglibc-Help-bootstrap-cross-toolchain.patch \ + file://0020-eglibc-Resolve-__fpscr_values-on-SH4.patch \ + file://0021-eglibc-Forward-port-cross-locale-generation-support.patch \ + file://0022-Define-DUMMY_LOCALE_T-if-not-defined.patch \ + file://0023-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \ + file://0024-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch \ + file://0025-intl-Emit-no-lines-in-bison-generated-files.patch \ + file://0027-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch \ + file://0028-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch \ + file://0029-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch \ + file://0030-powerpc-Do-not-ask-compiler-for-finding-arch.patch \ + file://0031-x86-Require-full-ISA-support-for-x86-64-level-marker.patch \ + file://0032-string-Work-around-GCC-PR-98512-in-rawmemchr.patch \ + file://0033-x86-Handle-_SC_LEVEL1_ICACHE_LINESIZE-BZ-27444.patch \ + file://CVE-2021-27645.patch \ + file://0001-nptl-Remove-private-futex-optimization-BZ-27304.patch \ + " +S = "${WORKDIR}/git" +B = "${WORKDIR}/build-${TARGET_SYS}" + +PACKAGES_DYNAMIC = "" + +# the -isystem in bitbake.conf screws up glibc do_stage +BUILD_CPPFLAGS = "-I${STAGING_INCDIR_NATIVE}" +TARGET_CPPFLAGS = "-I${STAGING_DIR_TARGET}${includedir}" + +GLIBC_BROKEN_LOCALES = "" + +GLIBCPIE ??= "" + +EXTRA_OECONF = "--enable-kernel=${OLDEST_KERNEL} \ + --disable-profile \ + --disable-debug --without-gd \ + --enable-clocale=gnu \ + --with-headers=${STAGING_INCDIR} \ + --without-selinux \ + --enable-tunables \ + --enable-bind-now \ + --enable-stack-protector=strong \ + --enable-stackguard-randomization \ + --disable-crypt \ + --with-default-link \ + ${@bb.utils.contains_any('SELECTED_OPTIMIZATION', '-O0 -Og', '--disable-werror', '', d)} \ + ${GLIBCPIE} \ + ${GLIBC_EXTRA_OECONF}" + +EXTRA_OECONF += "${@get_libc_fpu_setting(bb, d)}" + +EXTRA_OECONF_append_x86 = " --enable-cet" +EXTRA_OECONF_append_x86-64 = " --enable-cet" + +PACKAGECONFIG ??= "nscd" +PACKAGECONFIG[nscd] = "--enable-nscd,--disable-nscd" + +do_patch_append() { + bb.build.exec_func('do_fix_readlib_c', d) +} + +do_fix_readlib_c () { + sed -i -e 's#OECORE_KNOWN_INTERPRETER_NAMES#${EGLIBC_KNOWN_INTERPRETER_NAMES}#' ${S}/elf/readlib.c +} + +do_configure () { +# override this function to avoid the autoconf/automake/aclocal/autoheader +# calls for now +# don't pass CPPFLAGS into configure, since it upsets the kernel-headers +# version check and doesn't really help with anything + (cd ${S} && gnu-configize) || die "failure in running gnu-configize" + find ${S} -name "configure" | xargs touch + CPPFLAGS="" oe_runconf +} + +LDFLAGS += "-fuse-ld=bfd" +do_compile () { + base_do_compile + echo "Adjust ldd script" + if [ -n "${RTLDLIST}" ] + then + prevrtld=`cat ${B}/elf/ldd | grep "^RTLDLIST=" | sed 's#^RTLDLIST="\?\([^"]*\)"\?$#\1#'` + # remove duplicate entries + newrtld=`echo $(printf '%s\n' ${prevrtld} ${RTLDLIST} | LC_ALL=C sort -u)` + echo "ldd \"${prevrtld} ${RTLDLIST}\" -> \"${newrtld}\"" + sed -i ${B}/elf/ldd -e "s#^RTLDLIST=.*\$#RTLDLIST=\"${newrtld}\"#" + fi +} + +require glibc-package.inc + +BBCLASSEXTEND = "nativesdk" diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/32and64bit.patch b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/32and64bit.patch new file mode 100644 index 000000000..cdfeaeadd --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/32and64bit.patch @@ -0,0 +1,331 @@ +Upstream-Status: Inappropriate [embedded specific] + +We run the ldconfig in the cross fashion. make the code bitsize aware so that +we can cross build ldconfig cache for various architectures. + +Richard Purdie 2009/05/19 +Nitin A Kamble 2009/03/29 + +Index: ldconfig-native-2.12.1/readelflib.c +=================================================================== +--- ldconfig-native-2.12.1.orig/readelflib.c ++++ ldconfig-native-2.12.1/readelflib.c +@@ -40,39 +40,212 @@ do \ + + /* Returns 0 if everything is ok, != 0 in case of error. */ + int +-process_elf_file (const char *file_name, const char *lib, int *flag, ++process_elf_file32 (const char *file_name, const char *lib, int *flag, + unsigned int *osversion, char **soname, void *file_contents, + size_t file_length) + { + int i; + unsigned int j; +- ElfW(Addr) loadaddr; ++ Elf32_Addr loadaddr; + unsigned int dynamic_addr; + size_t dynamic_size; + char *program_interpreter; + +- ElfW(Ehdr) *elf_header; +- ElfW(Phdr) *elf_pheader, *segment; +- ElfW(Dyn) *dynamic_segment, *dyn_entry; ++ Elf32_Ehdr *elf_header; ++ Elf32_Phdr *elf_pheader, *segment; ++ Elf32_Dyn *dynamic_segment, *dyn_entry; + char *dynamic_strings; + +- elf_header = (ElfW(Ehdr) *) file_contents; ++ elf_header = (Elf32_Ehdr *) file_contents; + *osversion = 0; + +- if (elf_header->e_ident [EI_CLASS] != ElfW (CLASS)) ++ if (elf_header->e_type != ET_DYN) + { +- if (opt_verbose) ++ error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name, ++ elf_header->e_type); ++ return 1; ++ } ++ ++ /* Get information from elf program header. */ ++ elf_pheader = (Elf32_Phdr *) (elf_header->e_phoff + file_contents); ++ check_ptr (elf_pheader); ++ ++ /* The library is an elf library, now search for soname and ++ libc5/libc6. */ ++ *flag = FLAG_ELF; ++ ++ loadaddr = -1; ++ dynamic_addr = 0; ++ dynamic_size = 0; ++ program_interpreter = NULL; ++ for (i = 0, segment = elf_pheader; ++ i < elf_header->e_phnum; i++, segment++) ++ { ++ check_ptr (segment); ++ ++ switch (segment->p_type) + { +- if (elf_header->e_ident [EI_CLASS] == ELFCLASS32) +- error (0, 0, _("%s is a 32 bit ELF file.\n"), file_name); +- else if (elf_header->e_ident [EI_CLASS] == ELFCLASS64) +- error (0, 0, _("%s is a 64 bit ELF file.\n"), file_name); +- else +- error (0, 0, _("Unknown ELFCLASS in file %s.\n"), file_name); ++ case PT_LOAD: ++ if (loadaddr == (Elf32_Addr) -1) ++ loadaddr = segment->p_vaddr - segment->p_offset; ++ break; ++ ++ case PT_DYNAMIC: ++ if (dynamic_addr) ++ error (0, 0, _("more than one dynamic segment\n")); ++ ++ dynamic_addr = segment->p_offset; ++ dynamic_size = segment->p_filesz; ++ break; ++ ++ case PT_INTERP: ++ program_interpreter = (char *) (file_contents + segment->p_offset); ++ check_ptr (program_interpreter); ++ ++ /* Check if this is enough to classify the binary. */ ++ for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]); ++ ++j) ++ if (strcmp (program_interpreter, interpreters[j].soname) == 0) ++ { ++ *flag = interpreters[j].flag; ++ break; ++ } ++ break; ++ ++ case PT_NOTE: ++ if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4) ++ { ++ Elf32_Word *abi_note = (Elf32_Word *) (file_contents ++ + segment->p_offset); ++ Elf32_Addr size = segment->p_filesz; ++ ++ while (abi_note [0] != 4 || abi_note [1] != 16 ++ || abi_note [2] != 1 ++ || memcmp (abi_note + 3, "GNU", 4) != 0) ++ { ++#define ROUND(len) (((len) + sizeof (Elf32_Word)) - 1) & -sizeof (Elf32_Word))) ++ Elf32_Addr) note_size = 3 * sizeof (Elf32_Word)) ++ + ROUND (abi_note[0]) ++ + ROUND (abi_note[1]); ++ ++ if (size - 32 < note_size || note_size == 0) ++ { ++ size = 0; ++ break; ++ } ++ size -= note_size; ++ abi_note = (void *) abi_note + note_size; ++ } ++ ++ if (size == 0) ++ break; ++ ++ *osversion = (abi_note [4] << 24) | ++ ((abi_note [5] & 0xff) << 16) | ++ ((abi_note [6] & 0xff) << 8) | ++ (abi_note [7] & 0xff); ++ } ++ break; ++ ++ default: ++ break; ++ } ++ ++ } ++ if (loadaddr == (Elf32_Addr) -1) ++ { ++ /* Very strange. */ ++ loadaddr = 0; ++ } ++ ++ /* Now we can read the dynamic sections. */ ++ if (dynamic_size == 0) ++ return 1; ++ ++ dynamic_segment = (Elf32_Dyn *) (file_contents + dynamic_addr); ++ check_ptr (dynamic_segment); ++ ++ /* Find the string table. */ ++ dynamic_strings = NULL; ++ for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ ++dyn_entry) ++ { ++ check_ptr (dyn_entry); ++ if (dyn_entry->d_tag == DT_STRTAB) ++ { ++ dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr); ++ check_ptr (dynamic_strings); ++ break; + } +- return 1; + } + ++ if (dynamic_strings == NULL) ++ return 1; ++ ++ /* Now read the DT_NEEDED and DT_SONAME entries. */ ++ for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ ++dyn_entry) ++ { ++ if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME) ++ { ++ char *name = dynamic_strings + dyn_entry->d_un.d_val; ++ check_ptr (name); ++ ++ if (dyn_entry->d_tag == DT_NEEDED) ++ { ++ ++ if (*flag == FLAG_ELF) ++ { ++ /* Check if this is enough to classify the binary. */ ++ for (j = 0; ++ j < sizeof (known_libs) / sizeof (known_libs [0]); ++ ++j) ++ if (strcmp (name, known_libs [j].soname) == 0) ++ { ++ *flag = known_libs [j].flag; ++ break; ++ } ++ } ++ } ++ ++ else if (dyn_entry->d_tag == DT_SONAME) ++ *soname = xstrdup (name); ++ ++ /* Do we have everything we need? */ ++ if (*soname && *flag != FLAG_ELF) ++ return 0; ++ } ++ } ++ ++ /* We reach this point only if the file doesn't contain a DT_SONAME ++ or if we can't classify the library. If it doesn't have a ++ soname, return the name of the library. */ ++ if (*soname == NULL) ++ *soname = xstrdup (lib); ++ ++ return 0; ++} ++ ++int ++process_elf_file64 (const char *file_name, const char *lib, int *flag, ++ unsigned int *osversion, char **soname, void *file_contents, ++ size_t file_length) ++{ ++ int i; ++ unsigned int j; ++ Elf64_Addr loadaddr; ++ unsigned int dynamic_addr; ++ size_t dynamic_size; ++ char *program_interpreter; ++ ++ Elf64_Ehdr *elf_header; ++ Elf64_Phdr *elf_pheader, *segment; ++ Elf64_Dyn *dynamic_segment, *dyn_entry; ++ char *dynamic_strings; ++ ++ elf_header = (Elf64_Ehdr *) file_contents; ++ *osversion = 0; ++ + if (elf_header->e_type != ET_DYN) + { + error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name, +@@ -81,7 +254,7 @@ process_elf_file (const char *file_name, + } + + /* Get information from elf program header. */ +- elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents); ++ elf_pheader = (Elf64_Phdr *) (elf_header->e_phoff + file_contents); + check_ptr (elf_pheader); + + /* The library is an elf library, now search for soname and +@@ -100,7 +273,7 @@ process_elf_file (const char *file_name, + switch (segment->p_type) + { + case PT_LOAD: +- if (loadaddr == (ElfW(Addr)) -1) ++ if (loadaddr == (Elf64_Addr) -1) + loadaddr = segment->p_vaddr - segment->p_offset; + break; + +@@ -129,16 +302,16 @@ process_elf_file (const char *file_name, + case PT_NOTE: + if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4) + { +- ElfW(Word) *abi_note = (ElfW(Word) *) (file_contents ++ Elf64_Word *abi_note = (Elf64_Word *) (file_contents + + segment->p_offset); +- ElfW(Addr) size = segment->p_filesz; ++ Elf64_Addr size = segment->p_filesz; + + while (abi_note [0] != 4 || abi_note [1] != 16 + || abi_note [2] != 1 + || memcmp (abi_note + 3, "GNU", 4) != 0) + { +-#define ROUND(len) (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word))) +- ElfW(Addr) note_size = 3 * sizeof (ElfW(Word)) ++#define ROUND(len) (((len) + sizeof (Elf64_Word) - 1) & -sizeof (Elf64_Word)) ++ Elf64_Addr note_size = 3 * sizeof (Elf64_Word) + + ROUND (abi_note[0]) + + ROUND (abi_note[1]); + +@@ -166,7 +339,7 @@ process_elf_file (const char *file_name, + } + + } +- if (loadaddr == (ElfW(Addr)) -1) ++ if (loadaddr == (Elf64_Addr) -1) + { + /* Very strange. */ + loadaddr = 0; +@@ -176,7 +349,7 @@ process_elf_file (const char *file_name, + if (dynamic_size == 0) + return 1; + +- dynamic_segment = (ElfW(Dyn) *) (file_contents + dynamic_addr); ++ dynamic_segment = (Elf64_Dyn *) (file_contents + dynamic_addr); + check_ptr (dynamic_segment); + + /* Find the string table. */ +@@ -233,3 +406,33 @@ process_elf_file (const char *file_name, + + return 0; + } ++/* Returns 0 if everything is ok, != 0 in case of error. */ ++int ++process_elf_file (const char *file_name, const char *lib, int *flag, ++ unsigned int *osversion, char **soname, void *file_contents, ++ size_t file_length) ++{ ++ int i; ++ unsigned int j; ++ ElfW(Addr) loadaddr; ++ unsigned int dynamic_addr; ++ size_t dynamic_size; ++ char *program_interpreter; ++ ++ ElfW(Ehdr) *elf_header; ++ ElfW(Phdr) *elf_pheader, *segment; ++ ElfW(Dyn) *dynamic_segment, *dyn_entry; ++ char *dynamic_strings; ++ ++ elf_header = (ElfW(Ehdr) *) file_contents; ++ *osversion = 0; ++ ++ if (elf_header->e_ident [EI_CLASS] == ELFCLASS32) ++ return process_elf_file32(file_name, lib,flag, osversion, soname, file_contents, file_length); ++ else if (elf_header->e_ident [EI_CLASS] == ELFCLASS64) ++ return process_elf_file64(file_name, lib,flag, osversion, soname, file_contents, file_length); ++ error (0, 0, _("Unknown ELFCLASS in file %s.\n"), file_name); ++ return 1; ++} ++ ++ diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/README b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/README new file mode 100644 index 000000000..43fb98372 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/README @@ -0,0 +1,8 @@ +The files are pulled verbatim from glibc 2.5 and then patched to allow +standalone compilation of ldconfig. + +Richard Purdie +OpenedHand Ltd. + +Upgraded the ldconfig recipe to eglibc 2.12.1 +Nitin A Kamble 2011/03/29 diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/add-64-bit-flag-for-ELF64-entries.patch b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/add-64-bit-flag-for-ELF64-entries.patch new file mode 100644 index 000000000..f4e38d425 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/add-64-bit-flag-for-ELF64-entries.patch @@ -0,0 +1,116 @@ +From 9d62544090b08849218cd1fc52a36cdd5d90363e Mon Sep 17 00:00:00 2001 +From: Yuanjie Huang +Date: Fri, 24 Apr 2015 03:29:31 +0000 +Subject: [PATCH] Add 64-bit flag for ELF64 entries. + +ldconfig-native was grepped from an old version of glibc, and its output +lacks neccessary 64bit flag in entries. +Due to this defect, ctypes.util.find_library() python function fails to +detect any library due to the old file format that ldconfig-native +creates. This fix sets architecture-dependent 64bit flags for 64-bit ELF. + +Upstream-Status: Inappropriate [embedded specific] + +Signed-off-by: Yuanjie Huang +--- + cache.c | 4 ++++ + ldconfig.h | 4 ++++ + readelflib.c | 34 ++++++++++++++++++++++++++++++++++ + 3 files changed, 42 insertions(+) + +diff --git a/cache.c b/cache.c +index a904d44..c4f5411 100644 +--- a/cache.c ++++ b/cache.c +@@ -121,6 +121,10 @@ print_entry (const char *lib, int flag, unsigned int osversion, + break; + case FLAG_MIPS64_LIBN64: + fputs (",64bit", stdout); ++ break; ++ case FLAG_AARCH64_LIB64: ++ fputs (",AArch64", stdout); ++ break; + case 0: + break; + default: +diff --git a/ldconfig.h b/ldconfig.h +index fadd5ec..6a8a750 100644 +--- a/ldconfig.h ++++ b/ldconfig.h +@@ -34,6 +34,10 @@ + #define FLAG_POWERPC_LIB64 0x0500 + #define FLAG_MIPS64_LIBN32 0x0600 + #define FLAG_MIPS64_LIBN64 0x0700 ++#define FLAG_X8664_LIBX32 0x0800 ++#define FLAG_ARM_LIBHF 0x0900 ++#define FLAG_AARCH64_LIB64 0x0a00 ++#define FLAG_ARM_LIBSF 0x0b00 + + /* Name of auxiliary cache. */ + #define _PATH_LDCONFIG_AUX_CACHE "/var/cache/ldconfig/aux-cache" +diff --git a/readelflib.c b/readelflib.c +index 0bf0de3..6e87afc 100644 +--- a/readelflib.c ++++ b/readelflib.c +@@ -28,6 +28,11 @@ + + #include "endian_extra.h" + ++/* Work-around for old host that does not have AArch64 defined in elf.h. */ ++#ifndef EM_AARCH64 ++#define EM_AARCH64 183 /* ARM AARCH64 */ ++#endif ++ + #undef check_ptr + #define check_ptr(ptr) \ + do \ +@@ -290,6 +295,48 @@ process_elf_file64 (const char *file_name, const char *lib, int *flag, + libc5/libc6. */ + *flag = FLAG_ELF; + ++ /* Set flags according to information in ELF header to align with target ++ ldconfig */ ++ switch (elf_header->e_machine) ++ { ++ case EM_IA_64: ++ /* Intel 64bit libraries are always libc.so.6+. */ ++ /* see sysdeps/unix/sysv/linux/ia64/readelflib.c */ ++ *flag |= FLAG_IA64_LIB64|FLAG_ELF_LIBC6; ++ break; ++ case EM_X86_64: ++ /* X86-64 64bit libraries are always libc.so.6+. */ ++ /* see sysdeps/unix/sysv/linux/i386/readelflib.c */ ++ *flag |= FLAG_X8664_LIB64|FLAG_ELF_LIBC6; ++ break; ++ case EM_S390: ++ /* S/390 64bit libraries are always libc.so.6+. */ ++ /* see sysdeps/unix/sysv/linux/s390/readelflib.c */ ++ *flag |= FLAG_S390_LIB64|FLAG_ELF_LIBC6; ++ break; ++ case EM_PPC64: ++ /* PowerPC 64bit libraries are always libc.so.6+. */ ++ /* see sysdeps/unix/sysv/linux/powerpc/readelflib.c */ ++ *flag |= FLAG_POWERPC_LIB64|FLAG_ELF_LIBC6; ++ break; ++ case EM_MIPS: ++ case EM_MIPS_RS3_LE: ++ /* n64 libraries are always libc.so.6+. */ ++ /* NOTE: This does not correctly distinguish NAN2008 binaries and is possibly broken */ ++ /* see sysdeps/unix/sysv/linux/mips/readelflib.c */ ++ *flag |= FLAG_MIPS64_LIBN64|FLAG_ELF_LIBC6; ++ break; ++ case EM_AARCH64: ++ /* AArch64 libraries are always libc.so.6+. */ ++ /* see sysdeps/unix/sysv/linux/arm/readelflib.c */ ++ *flag |= FLAG_AARCH64_LIB64|FLAG_ELF_LIBC6; ++ break; ++ default: ++ error(0, 0, "%s is a 64-bit ELF for unknown machine %lx\n", ++ file_name, (long)elf_header->e_machine); ++ break; ++ } ++ + loadaddr = -1; + dynamic_addr = 0; + dynamic_size = 0; +-- diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endian-ness_handling.patch b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endian-ness_handling.patch new file mode 100644 index 000000000..7f8e4db78 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endian-ness_handling.patch @@ -0,0 +1,454 @@ +Upstream-Status: Inappropriate [embedded specific] + +Do data input/output handling according to endien-ness of the library file. That +enables use of ldconfig in the cross fashion for any architecture. + +2011/04/04 +Richard Purdie +Nitin Kamble + +Index: ldconfig-native-2.12.1/readelflib.c +=================================================================== +--- ldconfig-native-2.12.1.orig/readelflib.c ++++ ldconfig-native-2.12.1/readelflib.c +@@ -38,6 +38,28 @@ do \ + } \ + while (0); + ++int be; ++static uint16_t read16(uint16_t x, int be) ++{ ++ if (be) ++ return be16toh(x); ++ return le16toh(x); ++} ++ ++static uint32_t read32(uint32_t x, int be) ++{ ++ if (be) ++ return be32toh(x); ++ return le32toh(x); ++} ++ ++static uint64_t read64(uint64_t x, int be) ++{ ++ if (be) ++ return be64toh(x); ++ return le64toh(x); ++} ++ + /* Returns 0 if everything is ok, != 0 in case of error. */ + int + process_elf_file32 (const char *file_name, const char *lib, int *flag, +@@ -59,15 +81,17 @@ process_elf_file32 (const char *file_nam + elf_header = (Elf32_Ehdr *) file_contents; + *osversion = 0; + +- if (elf_header->e_type != ET_DYN) ++ be = (elf_header->e_ident[EI_DATA] == ELFDATA2MSB); ++ ++ if (read16(elf_header->e_type, be) != ET_DYN) + { + error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name, +- elf_header->e_type); ++ read16(elf_header->e_type, be)); + return 1; + } + + /* Get information from elf program header. */ +- elf_pheader = (Elf32_Phdr *) (elf_header->e_phoff + file_contents); ++ elf_pheader = (Elf32_Phdr *) (read32(elf_header->e_phoff, be) + file_contents); + check_ptr (elf_pheader); + + /* The library is an elf library, now search for soname and +@@ -79,27 +103,27 @@ process_elf_file32 (const char *file_nam + dynamic_size = 0; + program_interpreter = NULL; + for (i = 0, segment = elf_pheader; +- i < elf_header->e_phnum; i++, segment++) ++ i < read16(elf_header->e_phnum, be); i++, segment++) + { + check_ptr (segment); + +- switch (segment->p_type) ++ switch (read32(segment->p_type, be)) + { + case PT_LOAD: + if (loadaddr == (Elf32_Addr) -1) +- loadaddr = segment->p_vaddr - segment->p_offset; ++ loadaddr = read32(segment->p_vaddr, be) - read32(segment->p_offset, be); + break; + + case PT_DYNAMIC: + if (dynamic_addr) + error (0, 0, _("more than one dynamic segment\n")); + +- dynamic_addr = segment->p_offset; +- dynamic_size = segment->p_filesz; ++ dynamic_addr = read32(segment->p_offset, be); ++ dynamic_size = read32(segment->p_filesz, be); + break; + + case PT_INTERP: +- program_interpreter = (char *) (file_contents + segment->p_offset); ++ program_interpreter = (char *) (file_contents + read32(segment->p_offset, be)); + check_ptr (program_interpreter); + + /* Check if this is enough to classify the binary. */ +@@ -113,20 +137,20 @@ process_elf_file32 (const char *file_nam + break; + + case PT_NOTE: +- if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4) ++ if (!*osversion && read32(segment->p_filesz, be) >= 32 && segment->p_align >= 4) + { + Elf32_Word *abi_note = (Elf32_Word *) (file_contents +- + segment->p_offset); +- Elf32_Addr size = segment->p_filesz; ++ + read32(segment->p_offset, be)); ++ Elf32_Addr size = read32(segment->p_filesz, be); + +- while (abi_note [0] != 4 || abi_note [1] != 16 +- || abi_note [2] != 1 ++ while (read32(abi_note [0], be) != 4 || read32(abi_note [1], be) != 16 ++ || read32(abi_note [2], be) != 1 + || memcmp (abi_note + 3, "GNU", 4) != 0) + { +-#define ROUND(len) (((len) + sizeof (Elf32_Word)) - 1) & -sizeof (Elf32_Word))) +- Elf32_Addr) note_size = 3 * sizeof (Elf32_Word)) +- + ROUND (abi_note[0]) +- + ROUND (abi_note[1]); ++#define ROUND(len) (((len) + sizeof (Elf32_Word) - 1) & -sizeof (Elf32_Word)) ++ Elf32_Addr note_size = 3 * sizeof (Elf32_Word) ++ + ROUND (read32(abi_note[0], be)) ++ + ROUND (read32(abi_note[1], be)); + + if (size - 32 < note_size || note_size == 0) + { +@@ -140,10 +164,10 @@ process_elf_file32 (const char *file_nam + if (size == 0) + break; + +- *osversion = (abi_note [4] << 24) | +- ((abi_note [5] & 0xff) << 16) | +- ((abi_note [6] & 0xff) << 8) | +- (abi_note [7] & 0xff); ++ *osversion = (read32(abi_note [4], be) << 24) | ++ ((read32(abi_note [5], be) & 0xff) << 16) | ++ ((read32(abi_note [6], be) & 0xff) << 8) | ++ (read32(abi_note [7], be) & 0xff); + } + break; + +@@ -167,13 +191,13 @@ process_elf_file32 (const char *file_nam + + /* Find the string table. */ + dynamic_strings = NULL; +- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ for (dyn_entry = dynamic_segment; read32(dyn_entry->d_tag, be) != DT_NULL; + ++dyn_entry) + { + check_ptr (dyn_entry); +- if (dyn_entry->d_tag == DT_STRTAB) ++ if (read32(dyn_entry->d_tag, be) == DT_STRTAB) + { +- dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr); ++ dynamic_strings = (char *) (file_contents + read32(dyn_entry->d_un.d_val, be) - loadaddr); + check_ptr (dynamic_strings); + break; + } +@@ -183,15 +207,15 @@ process_elf_file32 (const char *file_nam + return 1; + + /* Now read the DT_NEEDED and DT_SONAME entries. */ +- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ for (dyn_entry = dynamic_segment; read32(dyn_entry->d_tag, be) != DT_NULL; + ++dyn_entry) + { +- if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME) ++ if (read32(dyn_entry->d_tag, be) == DT_NEEDED || read32(dyn_entry->d_tag, be) == DT_SONAME) + { +- char *name = dynamic_strings + dyn_entry->d_un.d_val; ++ char *name = dynamic_strings + read32(dyn_entry->d_un.d_val, be); + check_ptr (name); + +- if (dyn_entry->d_tag == DT_NEEDED) ++ if (read32(dyn_entry->d_tag, be) == DT_NEEDED) + { + + if (*flag == FLAG_ELF) +@@ -208,7 +232,7 @@ process_elf_file32 (const char *file_nam + } + } + +- else if (dyn_entry->d_tag == DT_SONAME) ++ else if (read32(dyn_entry->d_tag, be) == DT_SONAME) + *soname = xstrdup (name); + + /* Do we have everything we need? */ +@@ -246,15 +270,17 @@ process_elf_file64 (const char *file_nam + elf_header = (Elf64_Ehdr *) file_contents; + *osversion = 0; + +- if (elf_header->e_type != ET_DYN) ++ be = (elf_header->e_ident[EI_DATA] == ELFDATA2MSB); ++ ++ if (read16(elf_header->e_type, be) != ET_DYN) + { + error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name, +- elf_header->e_type); ++ read16(elf_header->e_type, be)); + return 1; + } + + /* Get information from elf program header. */ +- elf_pheader = (Elf64_Phdr *) (elf_header->e_phoff + file_contents); ++ elf_pheader = (Elf64_Phdr *) (read64(elf_header->e_phoff, be) + file_contents); + check_ptr (elf_pheader); + + /* The library is an elf library, now search for soname and +@@ -266,27 +292,27 @@ process_elf_file64 (const char *file_nam + dynamic_size = 0; + program_interpreter = NULL; + for (i = 0, segment = elf_pheader; +- i < elf_header->e_phnum; i++, segment++) ++ i < read16(elf_header->e_phnum, be); i++, segment++) + { + check_ptr (segment); + +- switch (segment->p_type) ++ switch (read32(segment->p_type, be)) + { + case PT_LOAD: + if (loadaddr == (Elf64_Addr) -1) +- loadaddr = segment->p_vaddr - segment->p_offset; ++ loadaddr = read64(segment->p_vaddr, be) - read64(segment->p_offset, be); + break; + + case PT_DYNAMIC: + if (dynamic_addr) + error (0, 0, _("more than one dynamic segment\n")); + +- dynamic_addr = segment->p_offset; +- dynamic_size = segment->p_filesz; ++ dynamic_addr = read64(segment->p_offset, be); ++ dynamic_size = read32(segment->p_filesz, be); + break; + + case PT_INTERP: +- program_interpreter = (char *) (file_contents + segment->p_offset); ++ program_interpreter = (char *) (file_contents + read64(segment->p_offset, be)); + check_ptr (program_interpreter); + + /* Check if this is enough to classify the binary. */ +@@ -300,20 +326,21 @@ process_elf_file64 (const char *file_nam + break; + + case PT_NOTE: +- if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4) ++ if (!*osversion && read32(segment->p_filesz, be) >= 32 && read32(segment->p_align, be) >= 4) + { + Elf64_Word *abi_note = (Elf64_Word *) (file_contents +- + segment->p_offset); +- Elf64_Addr size = segment->p_filesz; ++ + read64(segment->p_offset, be)); ++ Elf64_Addr size = read32(segment->p_filesz, be); + +- while (abi_note [0] != 4 || abi_note [1] != 16 +- || abi_note [2] != 1 ++ while (read32(abi_note [0], be) != 4 || read32(abi_note [1], be) != 16 ++ || read32(abi_note [2], be) != 1 + || memcmp (abi_note + 3, "GNU", 4) != 0) + { ++#undef ROUND + #define ROUND(len) (((len) + sizeof (Elf64_Word) - 1) & -sizeof (Elf64_Word)) + Elf64_Addr note_size = 3 * sizeof (Elf64_Word) +- + ROUND (abi_note[0]) +- + ROUND (abi_note[1]); ++ + ROUND (read32(abi_note[0], be)) ++ + ROUND (read32(abi_note[1], be)); + + if (size - 32 < note_size || note_size == 0) + { +@@ -327,10 +354,10 @@ process_elf_file64 (const char *file_nam + if (size == 0) + break; + +- *osversion = (abi_note [4] << 24) | +- ((abi_note [5] & 0xff) << 16) | +- ((abi_note [6] & 0xff) << 8) | +- (abi_note [7] & 0xff); ++ *osversion = (read32(abi_note [4], be) << 24) | ++ ((read32(abi_note [5], be) & 0xff) << 16) | ++ ((read32(abi_note [6], be) & 0xff) << 8) | ++ (read32(abi_note [7], be) & 0xff); + } + break; + +@@ -354,13 +381,13 @@ process_elf_file64 (const char *file_nam + + /* Find the string table. */ + dynamic_strings = NULL; +- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ for (dyn_entry = dynamic_segment; read64(dyn_entry->d_tag, be) != DT_NULL; + ++dyn_entry) + { + check_ptr (dyn_entry); +- if (dyn_entry->d_tag == DT_STRTAB) ++ if (read64(dyn_entry->d_tag, be) == DT_STRTAB) + { +- dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr); ++ dynamic_strings = (char *) (file_contents + read64(dyn_entry->d_un.d_val, be) - loadaddr); + check_ptr (dynamic_strings); + break; + } +@@ -370,15 +397,15 @@ process_elf_file64 (const char *file_nam + return 1; + + /* Now read the DT_NEEDED and DT_SONAME entries. */ +- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ for (dyn_entry = dynamic_segment; read64(dyn_entry->d_tag, be) != DT_NULL; + ++dyn_entry) + { +- if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME) ++ if (read64(dyn_entry->d_tag, be) == DT_NEEDED || read64(dyn_entry->d_tag, be) == DT_SONAME) + { +- char *name = dynamic_strings + dyn_entry->d_un.d_val; ++ char *name = dynamic_strings + read64(dyn_entry->d_un.d_val, be); + check_ptr (name); + +- if (dyn_entry->d_tag == DT_NEEDED) ++ if (read64(dyn_entry->d_tag, be) == DT_NEEDED) + { + + if (*flag == FLAG_ELF) +@@ -395,7 +422,7 @@ process_elf_file64 (const char *file_nam + } + } + +- else if (dyn_entry->d_tag == DT_SONAME) ++ else if (read64(dyn_entry->d_tag, be) == DT_SONAME) + *soname = xstrdup (name); + + /* Do we have everything we need? */ +Index: ldconfig-native-2.12.1/readlib.c +=================================================================== +--- ldconfig-native-2.12.1.orig/readlib.c ++++ ldconfig-native-2.12.1/readlib.c +@@ -169,7 +169,8 @@ process_file (const char *real_file_name + ret = 1; + } + /* Libraries have to be shared object files. */ +- else if (elf_header->e_type != ET_DYN) ++ else if ((elf_header->e_ident[EI_DATA] == ELFDATA2MSB && be16toh(elf_header->e_type) != ET_DYN) || ++ (elf_header->e_ident[EI_DATA] == ELFDATA2LSB && le16toh(elf_header->e_type) != ET_DYN)) + ret = 1; + else if (process_elf_file (file_name, lib, flag, osversion, soname, + file_contents, statbuf.st_size)) +Index: ldconfig-native-2.12.1/cache.c +=================================================================== +--- ldconfig-native-2.12.1.orig/cache.c ++++ ldconfig-native-2.12.1/cache.c +@@ -39,6 +39,29 @@ + # define N_(msgid) msgid + #define _(msg) msg + ++extern int be; ++ ++static uint16_t write16(uint16_t x, int be) ++{ ++ if (be) ++ return htobe16(x); ++ return htole16(x); ++} ++ ++static uint32_t write32(uint32_t x, int be) ++{ ++ if (be) ++ return htobe32(x); ++ return htole32(x); ++} ++ ++static uint64_t write64(uint64_t x, int be) ++{ ++ if (be) ++ return htobe64(x); ++ return htole64(x); ++} ++ + struct cache_entry + { + char *lib; /* Library name. */ +@@ -279,7 +302,12 @@ save_cache (const char *cache_name) + /* Number of normal cache entries. */ + int cache_entry_old_count = 0; + +- for (entry = entries; entry != NULL; entry = entry->next) ++ if (be) ++ printf("saving cache in big endian encoding\n"); ++ else ++ printf("saving cache in little endian encoding\n"); ++ ++ for (entry = entries; entry != NULL; entry = entry->next) + { + /* Account the final NULs. */ + total_strlen += strlen (entry->lib) + strlen (entry->path) + 2; +@@ -310,7 +338,7 @@ save_cache (const char *cache_name) + memset (file_entries, '\0', sizeof (struct cache_file)); + memcpy (file_entries->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1); + +- file_entries->nlibs = cache_entry_old_count; ++ file_entries->nlibs = write32(cache_entry_old_count, be); + } + + struct cache_file_new *file_entries_new = NULL; +@@ -330,8 +358,8 @@ save_cache (const char *cache_name) + memcpy (file_entries_new->version, CACHE_VERSION, + sizeof CACHE_VERSION - 1); + +- file_entries_new->nlibs = cache_entry_count; +- file_entries_new->len_strings = total_strlen; ++ file_entries_new->nlibs = write32(cache_entry_count, be); ++ file_entries_new->len_strings = write32(total_strlen, be); + } + + /* Pad for alignment of cache_file_new. */ +@@ -358,9 +386,9 @@ save_cache (const char *cache_name) + /* First the library. */ + if (opt_format != 2 && entry->hwcap == 0) + { +- file_entries->libs[idx_old].flags = entry->flags; ++ file_entries->libs[idx_old].flags = write32(entry->flags, be); + /* XXX: Actually we can optimize here and remove duplicates. */ +- file_entries->libs[idx_old].key = str_offset + pad; ++ file_entries->libs[idx_old].key = write32(str_offset + pad, be); + } + if (opt_format != 0) + { +@@ -368,10 +396,10 @@ save_cache (const char *cache_name) + not doing so makes the code easier, the string table + always begins at the beginning of the the new cache + struct. */ +- file_entries_new->libs[idx_new].flags = entry->flags; +- file_entries_new->libs[idx_new].osversion = entry->osversion; +- file_entries_new->libs[idx_new].hwcap = entry->hwcap; +- file_entries_new->libs[idx_new].key = str_offset; ++ file_entries_new->libs[idx_new].flags = write32(entry->flags, be); ++ file_entries_new->libs[idx_new].osversion = write32(entry->osversion, be); ++ file_entries_new->libs[idx_new].hwcap = write64(entry->hwcap, be); ++ file_entries_new->libs[idx_new].key = write32(str_offset, be); + } + + size_t len = strlen (entry->lib) + 1; +@@ -379,9 +407,9 @@ save_cache (const char *cache_name) + str_offset += len; + /* Then the path. */ + if (opt_format != 2 && entry->hwcap == 0) +- file_entries->libs[idx_old].value = str_offset + pad; ++ file_entries->libs[idx_old].value = write32(str_offset + pad, be); + if (opt_format != 0) +- file_entries_new->libs[idx_new].value = str_offset; ++ file_entries_new->libs[idx_new].value = write32(str_offset, be); + len = strlen (entry->path) + 1; + str = mempcpy (str, entry->path, len); + str_offset += len; diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endian-ness_handling_fix.patch b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endian-ness_handling_fix.patch new file mode 100644 index 000000000..6aecfe526 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endian-ness_handling_fix.patch @@ -0,0 +1,47 @@ +Upstream-Status: Inappropriate [embedded specific] + +Fix problem during parsing of ELF headers for 64bit on big-endian. +Some header fields were read with wrong size. + +2014/10/24 +Par Olsson +Shan Hai + +diff --git a/readelflib.c b/readelflib.c +index 3f5b25b..0bf0de3 100644 +--- a/readelflib.c ++++ b/readelflib.c +@@ -261,8 +261,8 @@ process_elf_file64 (const char *file_name, const char *lib, int *flag, + int i; + unsigned int j; + Elf64_Addr loadaddr; +- unsigned int dynamic_addr; +- size_t dynamic_size; ++ Elf64_Addr dynamic_addr; ++ Elf64_Xword dynamic_size; + char *program_interpreter; + + Elf64_Ehdr *elf_header; +@@ -311,7 +311,7 @@ process_elf_file64 (const char *file_name, const char *lib, int *flag, + error (0, 0, _("more than one dynamic segment\n")); + + dynamic_addr = read64(segment->p_offset, be); +- dynamic_size = read32(segment->p_filesz, be); ++ dynamic_size = read64(segment->p_filesz, be); + break; + + case PT_INTERP: +@@ -329,11 +329,11 @@ process_elf_file64 (const char *file_name, const char *lib, int *flag, + break; + + case PT_NOTE: +- if (!*osversion && read32(segment->p_filesz, be) >= 32 && read32(segment->p_align, be) >= 4) ++ if (!*osversion && read64(segment->p_filesz, be) >= 32 && read64(segment->p_align, be) >= 4) + { + Elf64_Word *abi_note = (Elf64_Word *) (file_contents + + read64(segment->p_offset, be)); +- Elf64_Addr size = read32(segment->p_filesz, be); ++ Elf64_Xword size = read64(segment->p_filesz, be); + + while (read32(abi_note [0], be) != 4 || read32(abi_note [1], be) != 16 + || read32(abi_note [2], be) != 1 diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endianess-header.patch b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endianess-header.patch new file mode 100644 index 000000000..a18b2c20d --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/endianess-header.patch @@ -0,0 +1,113 @@ +Upstream-Status: Inappropriate [fix poky patch] + +This patch fixes build issues with a previous endian-ness_handling.patch on +distros that don't have macros referenced + +7/20/2011 +Matthew McClintock + +diff -purN ldconfig-native-2.12.1.orig/endian_extra.h ldconfig-native-2.12.1/endian_extra.h +--- ldconfig-native-2.12.1.orig/endian_extra.h 1969-12-31 18:00:00.000000000 -0600 ++++ ldconfig-native-2.12.1/endian_extra.h 2011-07-19 18:09:14.323048417 -0500 +@@ -0,0 +1,64 @@ ++/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++ ++#ifndef _ENDIAN_EXTRA_H ++#define _ENDIAN_EXTRA_H 1 ++ ++/* Don't redefine these macros if they already exist */ ++#ifndef htobe16 ++#ifdef __USE_BSD ++/* Conversion interfaces. */ ++# include ++ ++# if __BYTE_ORDER == __LITTLE_ENDIAN ++# define htobe16(x) __bswap_16 (x) ++# define htole16(x) (x) ++# define be16toh(x) __bswap_16 (x) ++# define le16toh(x) (x) ++ ++# define htobe32(x) __bswap_32 (x) ++# define htole32(x) (x) ++# define be32toh(x) __bswap_32 (x) ++# define le32toh(x) (x) ++ ++# define htobe64(x) __bswap_64 (x) ++# define htole64(x) (x) ++# define be64toh(x) __bswap_64 (x) ++# define le64toh(x) (x) ++# else ++# define htobe16(x) (x) ++# define htole16(x) __bswap_16 (x) ++# define be16toh(x) (x) ++# define le16toh(x) __bswap_16 (x) ++ ++# define htobe32(x) (x) ++# define htole32(x) __bswap_32 (x) ++# define be32toh(x) (x) ++# define le32toh(x) __bswap_32 (x) ++ ++# define htobe64(x) (x) ++# define htole64(x) __bswap_64 (x) ++# define be64toh(x) (x) ++# define le64toh(x) __bswap_64 (x) ++# endif ++#endif ++#endif ++ ++#endif /* endian_extra.h */ +diff -purN ldconfig-native-2.12.1.orig/cache.c ldconfig-native-2.12.1/cache.c +--- ldconfig-native-2.12.1.orig/cache.c 2011-07-19 18:21:28.347041301 -0500 ++++ ldconfig-native-2.12.1/cache.c 2011-07-19 18:22:54.118048064 -0500 +@@ -39,6 +39,8 @@ + # define N_(msgid) msgid + #define _(msg) msg + ++#include "endian_extra.h" ++ + extern int be; + + static uint16_t write16(uint16_t x, int be) +diff -purN ldconfig-native-2.12.1.orig/readelflib.c ldconfig-native-2.12.1/readelflib.c +--- ldconfig-native-2.12.1.orig/readelflib.c 2011-07-19 18:21:28.346041593 -0500 ++++ ldconfig-native-2.12.1/readelflib.c 2011-07-19 18:23:05.324059875 -0500 +@@ -25,6 +25,9 @@ + + /* check_ptr checks that a pointer is in the mmaped file and doesn't + point outside it. */ ++ ++#include "endian_extra.h" ++ + #undef check_ptr + #define check_ptr(ptr) \ + do \ +diff -purN ldconfig-native-2.12.1.orig/readlib.c ldconfig-native-2.12.1/readlib.c +--- ldconfig-native-2.12.1.orig/readlib.c 2011-07-19 18:21:28.346041593 -0500 ++++ ldconfig-native-2.12.1/readlib.c 2011-07-19 18:23:23.877046210 -0500 +@@ -40,6 +40,8 @@ + + #include "ldconfig.h" + ++#include "endian_extra.h" ++ + #define _(msg) msg + + #define Elf32_CLASS ELFCLASS32 diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/flag_fix.patch b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/flag_fix.patch new file mode 100644 index 000000000..4e9aab941 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/flag_fix.patch @@ -0,0 +1,24 @@ +Upstream-Status: Inappropriate [embedded specific] + +The native version of ldconfig was using native definition of LD_SO (i.e. +ld-linux-x86-64.so.2 ) which is not correct for doing the cross ldconfig. +This was causing libc.so on the target marked as ELF lib rather than +FLAG_ELF_LIBC6 in the ld.so.cache. + +Nitin A Kamble 2011/04/4 + +Index: ldconfig-native-2.12.1/readlib.c +=================================================================== +--- ldconfig-native-2.12.1.orig/readlib.c ++++ ldconfig-native-2.12.1/readlib.c +@@ -51,6 +51,10 @@ struct known_names + int flag; + }; + ++/* don't use host's definition of LD_SO */ ++#undef LD_SO ++#define LD_SO "ld.so.1" ++ + static struct known_names interpreters[] = + { + { "/lib/" LD_SO, FLAG_ELF_LIBC6 }, diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig-default-to-all-multilib-dirs.patch b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig-default-to-all-multilib-dirs.patch new file mode 100644 index 000000000..5ed4f6ff6 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig-default-to-all-multilib-dirs.patch @@ -0,0 +1,37 @@ +Upstream-Status: Inappropriate [embedded specific] + +make ldconfig default to both /lib+/usr/lib, /lib32+/usr/lib32 and +/lib64+/usr/lib64 on bi-ABI architectures. + +--- + ldconfig.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff -urpN a/ldconfig.c b/ldconfig.c +--- a/ldconfig.c ++++ b/ldconfig.c +@@ -52,7 +52,11 @@ + + #define SYSCONFDIR "/etc" + #define LIBDIR "/usr/lib" ++#define LIBDIR32 "/usr/lib32" ++#define LIBDIR64 "/usr/lib64" + #define SLIBDIR "/lib" ++#define SLIBDIR32 "/lib32" ++#define SLIBDIR64 "/lib64" + # define N_(msgid) msgid + #define _(msg) msg + +@@ -1373,6 +1377,12 @@ main (int argc, char **argv) + add_system_dir (SLIBDIR); + if (strcmp (SLIBDIR, LIBDIR)) + add_system_dir (LIBDIR); ++ add_system_dir (SLIBDIR32); ++ if (strcmp (SLIBDIR32, LIBDIR32)) ++ add_system_dir (LIBDIR32); ++ add_system_dir (SLIBDIR64); ++ if (strcmp (SLIBDIR64, LIBDIR64)) ++ add_system_dir (LIBDIR64); + } + + const char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE; diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig-native-2.12.1.tar.bz2 b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig-native-2.12.1.tar.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..dc1e79888e9bf28226cf18513ebd4478ec90175f GIT binary patch literal 21491 zcmV()K;OSYT4*^jL0KkKSzNplS^$e*|NsB+0D*h||NsC0|NsC0|Nj6$0t5gA00962 z004jx00>}o9{1DbKmvVzDYv|Oo@Idd)&QPl`WXNy6zLn^T+aJFJ@xJHcJ(j5^}OEz z8{PFaqTAjmX}$Aq(Durg+s;0^QlCt=)lQn~!262meCXQ+o>U5bXs3@iDt%-d-(Pv~ zKH2X0ci!{X_ulRAWG!S;gi;&5LVd*9)33dyT}f1d6e)Im&wI)?we`!~-S01U_15Z| z*{;rZvtFJOMq|u6cnUOOpeu*}d z%}Rc$>66lfAZYb81_3FcLI_O+CL(PDqx4hsru9eYBzlMHPt_h!+DE7W7>0lV2{ef! zOp_A|dNN6<{HgeYPe^)Al)(eh1JnVdKzdCEngO6fk`W1lWK+{dO-G=ZihB`H$xVpV z@uVivsp&L&BSwG#03t|&WHca5fJw4wCQ^RXdYWpU(KSC&->MK`=bcS=f9vIRwbb_ zMw%EY4A4NyLEaa=4n8~J4}kbh8cS=XOF=sO>h&LBG`l_~{6D8=YY zw`3F)Mhrn>kx?n3n4%gt%)f1$F__tidOwTN=>1z9blk{-B7%m5C?uCx-YKe{MRC?Q+ooOj3mcQj}E%4HVHuRWU^oOw?5rG$}x_#mT$apEim!g^`#(ML-A;-PggxP(mIO?bi7J9vknneZDyjdZ{RZtWBqH zZu+Gu0+yZ4!`z0cDk@r2vNC&PDnm0OQ&EjO#$Nt86uq)J2}=_*DGnt{0}fiphNl%en73woOd2%p;G!KNIQ4r$KUJ9z<KbzNcUuO3>f^xEfF0eUI#atfv`6kBcR_Gf>RmpR?u z+K?70q|MyJS}CoD>0{uih>9v|6^07Bg=Z|(sPL*@VU_{`o4J>s!MeJbWR|L9$9oQ( zX|=sH$5>l&>dx9@oa0*V=PqGRHe-SbhRV!Lr#VM--6{y0(K{iJ9Ar1Hi=8rwH*qf< zC^$l4{wfOJn@fmDP0<aFZ^WEBMC}7#{@Jc7Eedr_+ch6!C5&FHC}F94bH}3 zrXTGY!vk?D<)MOQGSdjFD{eG085mV$u2H8-LX4)Q#%Q*RShcHzDq!|;!LraOS|hnw zu2tNtjHFc_HMy80IMib8)n*e?i>5SZdyFv z*ynlk3)_9&syJS){g~#8zv!`Vi;)idOB|7^s7{)5Z|W?SJLZF`#Q&O zICl0Qw{4YA5f)z_LZYaQk4>nwNU23d1jSUD?75u7+z+NUWA9Z#)_zXE zk7VLFgML}GZ4@1ovTQ!GN>Q#gO#8Xqll9hRpFqE<6#+fSzz`5WQuxgkQ28?mU|N`B zppk-#Xd-AL2!f(YXenBn0hJN~loEsWVT4r-Oau{0M3hiaP+U$(($G+fMS_G89{XS3 zKRWfBFYj;f?ME$Cyt{h5H!*p+onCcbvR3AolTMzt?5|BU+0m;xfdnH>0YpPcLsL;q zEh5z|0YeZZO%%k`)RdGog$YAQP_ZpEQb{QlP|-0FKvfG6P^?8UK_LGWyP8$uXCLNvq#9!VI#eLxXgmoR=|n)28ED zR{87IXTzcnT+4mVuif}bJci_t(F4_fQ~gKR>-}c_d+$saXCLdfVpq3r7F!#Wnt^>1e;R=QW$~y0f&wqD&Z=E0M%7h zRrq}bgHT^YixU%{>(Rpl5_lEa@6cZf##q;x@{kfj>Z9EFN;A9gAh!CCf0XII*L0Eu zErfzBHxqN|*z{rA8 z&H7kKdTjKT6(6=aEyGLG9hRNu7ZC>glfdlsIaYqz9up!}pk!d8lNdiWF%Mrc zhWk*?#vFb2>^UKn+m_fA9~8S8!NC?Fmak=%;ecw#?);wnp?4UWL$U{25YWbVMZ+7+ zJ^xJ%$31NfK)@}B9k3clu=K_Uz!7$E=M)m7Nbs4Qx2%pW<{jLJ(5lBCwSFKuwEVp zoK$r<`K_TMRuGttaFz&dLPTXu`8SCaSIvKK5%K;Ta)&LS&TCRgcH#vS6qxIj7(E1) zAp1SydSLi3au4FES`i494!@amtsA%`rDZ~Gk_P1J!|XsJA}SQc2D!OsAFt}p}0m!dcs(P~C!L zf#FsbeiIZ*0h+#9`K8;ekl!r>SP$}J9fGl*-yr{C<(5xp&}k-(sn zN5}lh?vr`MsPtb&f97bw8z#LMn#9Q)5`?JLi}d{p^wk3S*RJI`cxQrf3b^O!ilOyk2ayfg+}SBJR@ zt-?yqBF&n2#S!FTp$Nc=O|-sF2k_a_F_8_V8%&P0DeK9{r>9o&u3LfRa7rBUjnlEh zZG=fh9>FA;x)|nSK_nd^)Ng8H5;5djZGXb~Q%Ckssq4%PwT3^evkdhx?6$;VDg3gCNoPRJjuA1lg zszSU*1vjAe1FBMxU62jg-zkwXSFamjR@3PFYm}HzVXL6oNRkBHff55n8|g7mq-g(o zo1>LiJU&ZI(?q2}K>4muz|>C+hYWiS8!`Ko_Nhu@NCZ>SpCS%gF#fNbz{9V481tnH zh%&cbHLBLSq$q=LCC@LccbE4kOZcRW&rz=j9T^I+^Ng)DP(YIc!95GDqh8 z`INAll6KgyTNH^D&*_HZMVCcmx=&)2ssJOn4ifhc4NDrRjJI2F*KYothT~qJ1yV=R zSq;~VJ3UQqbtv(5 zfYVGj3-wB69SnvLlUQ`a9>E*Wc~xACGu)dE@vk-rPL-GaPzq{s+=> zbcd~vQYVsl`6?{;o%$XdzOOsb_!nt}_{peZVl>s{d2-YS@2k7DPXg&vJX}~QYO7%j zBVgw$04x2(4O<*c$pwX@lkKS^l3x?gOTPNpC75zPU5-yq7Xg&%{9D)O8!@{JnwF9` z$e+Aog4H@Wu?J2OW^TqIwdwsDjN&axwdsEiVZNme0SYHykhsIP6^4cYZeo`*eQQXsZx#x7uO z*%jErcmu(Vpjedz&Wc$XNKq?nclfIpQ&TV;*Q4#x?{NA|14*-ksI>h#-a`7;U}0UT{dJC>KOJA;OCr?j#LY*S;}; zvcmA1wll#hZF3o;K-o7p}$3|V}eMS zlnP{sqFMrliAofuDWGCquyN1q6o%d#Ub#E1o~(%$*c6)dY!2a?8bcB_+rBWsj6!$x z{<@g?BH5G#&{>;j0z!djc*;Ccf0XQxi($#nS{m)L5Yy9!BI*jX=^kfjEDa<}ARM9* z5awH9W(^i&dBzSxCPAk$<({9p3!cP#Tl?I3-wwSGMJ*d2C4++kBVq{%ry>BrOx67o z_vq*Bmo(|C+u~5oBPvb^;yzToT=En)+~}xCj>>p(o_gg#DR?;$#EC%&o1LKHE~c_7 zcL`tG9$?SBCgq|vfm}p@Yd|p6zoUiY)BAUasGpx>^zP0OnM5R+ChXE8#}VlvHSsU= zMB?$!tnXzfN3?Bncs4fk)ALET3>-%-zgO?`XzaXk)pe*tEf*`}6`6TL(PlFe*K&W$ zRr=xF-I+%ZC!we^r1A(A;4b+a`?@80Q;dYu#^C3WXw`l z+1S*K(E@W7bQHW879?%o>c0-JuSKg1_&8VMHxe7EG@~*%2&Iz%k91o>sAo@0d!l}jcv~Jhc21j6ZemdhB-4356CPse^fd6sG-xM@ zJw$a;(T04Ro*s_)eexV29A<==L}EQs8l!Z#w{q-PQy0QR?d92=?x|<{vie6yL-j1*~<=go#Sf*le5q4RNMq$O`=7AikmB_+$ButTpoV?Ybd#}*p?#pHR z=Nai#b!!|$u*JabId`?kv2S=6GTHW<#4QB|prREbXtl?u;TKx&x*7#VzF#Hqyl)td z0|peIKOUidw~1rFQg_|<5;#J@tD{iD0;2A|LIya{OEi#`fVGu9e!REueZJ@PVv6*0 z3%QwiT+sRhgSN#@ntCGP_2rlcc7Y9+3p22DRvsHG<;(#c;fq4d2UCbu223%$iXQ;1 z9&jzj!N7GQ$WG86okh85->fhn7!o%jjX@)`&*>l=T+!c7%fo2n!uP{Ymbif9P8NuW zkn%dI%To?$gos2hdj`uU4606kiK#~zfQ6@P3(y7Uml`+s*Q%*YT6r+^W41#pY?Sh;f^$6{q}tJ@S* zntH)G9T7Z$?OvWe9-V9#d-gd*rF}5FQs%}TmN2eO%FhLvNF@<4x{WHN&mw%m$>5j<3=Vt)WcL`f9Wc_8Is_W!f`qff83|F5UzU0j9{V~6cXr|g0UNT3!=Mxh}XZRY$rO+*~{q;35HM$EA(ANC9|Obn zzDXg`=x5*Xvfkl`i$50V6?d!c`Tdfg!?xYMEB|R^SuEhm!Pc@iDhWsdsK>U+l7fWg zVvP(H4J<;%ep~sVHD+dIm@v^@e{3Jd{z5;LjS8k>ieI5nN%yrMxKtc&12h@NbB{4;-c9=FlN|P&;7rKm>@AY~7u=swD&9_=2ZS~pn z#>?zf9#)6iCFJ%`752h2t2W-gtDofKEd_*VyU0E?H$mGZd?*VTlO^rMKz0i(sIq>a{Z&zePIWfn!o8jAXrTsSNUdU`N_;z8~ zKI9lDB87%AbO?o8$o?+Q$iQs3J@w(2R4tcL)+_n-TKF!GaCrKww&`3D>!U~}Q&=oe zu?vsSNmX`cH@XzL+bd(P6JVC7xepiNz4NTSCrBPi4fz42knG;Fz@4`Oi!J?nXjaQ?b!sBX~<} z2Sv(Kku4h1WFY?ivrz2>K@!Y^sRJU6jqWO%gNT8M1NVeMAq36nS^@kZ242qjI=ud( zr{&jv^Yxc;8?vvIlw+LZYD7JdM}MEArA3*zx7_X3(EVZ(mwzbMJ$346)+=@QU3F#> z6B1D-Z5dyU4+K_m#u&HD!u&&MZ>^Y&e$UbVHUd85x%Oc3TOrVXkF9z2mMK(q$1Bfs zA9AusrS{vNu7hHTnAJhNVciU#XCxx*s(LqT9-R?LB&jM_I68&?Zg~gJdJ}#)LH&LD zcoty^FpLd^0uVB`z66V5KeMAP?6?0Q2Ep}2-eu+!Ut3C1c4c5^XJ!{a-blTn8GHq# ziZKaH@8?f>Mo}OJZ)=h}&mOB^O!`-U3M|Mn8tNP>p8u+synUH3zat>V0FneGfJCKa zUye6l8<$Hr9C34O+o(=1Q(34S8)pXyhJ(~N<+YPP3f2ijr#khI-?#le{vEbOy{RYW zEeSFK4TN*oqkTRmSm7{}2M@!V@T8!EUE@}ZwD~Q@!yODT7lD99EE%A6>S`fXG%lMq zVMX(toJ827*1()wUVJfS6K!zCtKo3go}D%;Tw8V;d)lg6S42x+OqU&&2Tt2JOS zKhQ^=#BpT7vYZY0Zn$AFGI=vCzK&Z$yJ(Qu*5i<%V5_h`LTxu_MhyZ(-;ca@c~_Di zXMVpgXiLnj4NxqVlbokB=tY071c;wR;}4+xXXW=7kZeTl_&F(LJCEL*quJu$!@=Y3 zT?TfNq3X=B3>qq8C0U5+^x!hsI8dBNgyH4*I30GrQfoy~TaF}{6<~5*n)-_%rZ#nu z&6Lz6bjhK*_ZY+GBvsx(xDk`;3=nW8EIUPO!|E1%q-*V<4e1SUaRx+cZyQs;PA)TX z^OqyX(Ga&l7I2bINI>UvsH+~qks~`{Do=rI(=YXYUHzJ>&LvMcd4m;K9`1-RgW8JV zuUFgl?PmUuyaFGFitO#Uy7hX>hwMwgzBg=dW9~sx>%DxC(<^*Dj_LPAVJ$>h`geOA zB)7xIGmo-+*=Dq@vs6!8KOv(-VgDVN&6v5P9+ zwBmkU^6pA8=TuYFvlEYw_*P@$-l#YJA9NX8A6z0zc59y9A@_BuWUquge>bPZNCY>f zDDN!MDA$Rr5aGiX^lZku{CcczGInUjA}U1I(AJSLA{dWR2lf>Dxb?(pV_)UPMZL|m zXB_H`<3z1_8$ld%HnTh$#-R8?w#@i6tbKcgVYm$S46vAPso3uKzJF5Y)-qrlk8#^{ zL1rgb7@0KF3x{{KRRiK2v?@Hr^P*eypP=*n_PywoN)n7}ZN?@wEl8jJg_SX~GR9WK zM(fOlim`KZ8fC>oqPUnDM#RcxF|?ym8*>J^o0TxO7PDq?IL;ijXAA_+VqMEyPBeFs z;2vsZPLT>49f2e%iaw)r)#~Z)L8FuIZii8m&-dPR4vIrUE-Bm(Eg&OHWT?fAa|hxz z;-B0M61yOuQ7GJEn8L*xeuXRm*ho*F^4XR|ejVC;-;Yl}$DVNor1}2;*ZaS+-*vyf zSf2Qg{o*;gXh;$YRU9RQHWMLz6V>aGwbE_t12nLRi~qgZ-zsA%IVqJ}9-Lj;J|8h)RuEcjrIaLh{v`>&A$ zrW(u$q3B*38vGdANMc64gc$VN38PYX5*n)LN|AeQ>cSv)^9e_Pi!OL}_j=u*!lI-` z0q%XN+h4y2Bw|`=p``m%Sf1gQ8IacNv}dK{G&XJ-J`aIli-&_a8S&j?^VP{g?4@TC!;?(ZA&{SE=MS&p1L447%R*h{?D`=!N=ySdOz z!w<{tdeqoyE`y^aH%JUbzWW3tFU-vh*Rz=PsKO4qW)a6gS=Kr!$~jEqj^Z#Egew=o zDlN*Q3Hph+N`IXt=p@YO}KGP4-e<*CV{=$A@oF< z^?|Iizs3RJAq=wH#yZ0eQgFRuc;Ze`nnv*3z}0?gNGvDhT;5rX%f9 z9`J<%HtUAEH@&bJe%J?uD#h)05ozoUqC>pa9&@fDl|LIqw^SGX$0ZYo4`sipaIH#- zlLmO!8U73({!MD+xTB0Tz3QlFs|HtVTIA58B5-0g)G=86+f*pDAp|z~Qyio&n4T6& z42B7*oLgmGeC85M3%%_Xp7Sy(Pnm<$jr}o9VcpU3Xg{vh7zhj{p~bV|2pHdnzv_IRdy}jY6Hg%yC!#wyAte?4kq2YtDQ$-6P2$n~n~m`=BtY=C1jrEt59h6m{&#M_ z-^b5bSK;kbZsXS8nxK@E7LV2O!NMiVh%}oB`4-BP-p>WCbtCA%pIFnop&b;bL&G(u zIr4L5D7HBHv_=nx@rLY;{$D?yT2_;xAo9N~^wF9a_-icsTx4dQ`1k9fOP1Il_) zs3077;Wq?8?%9x(A&~%2H&H7#cgHVU&{YpZgb>Kg@{NGrMJ;D27 zgP?yb5Iuka^(y}TLsMU=9mn$n#Y{0$E+L@^FbKmycf8HopOH%kV>^`97;z{}tAmrl z*msGz17Wc~WQZT82i4QK6r^HE9$ zBM6o$)Ly!SetFUaFz&Owz*|I+*7v3_gaQ{PGoq*-{*({t$N(9S~C<^tEHw4?* zH&0-VS@JLtP;~~$#B4~+j-gASUuQwq%jF9Y;W$s-jzmRd;B4;jg#jSRqOV&?VKKyp z3eYHBJca|@J}`0(bKnzj(7yB;3ZK(7sg~!eisdvQX*#NzMcncSiIM%@9FW1zfoUp` zxfC)GGKsJr2=>^r%Lriw0G-N2I(s%SfZ5qy2NoXRU;45-ksmULhCtA_J47VFJqYYO zfrvRb9D}>MZp-1=ft^FvCvz7-;;cu_N(XR1sRvU4)$2~kNDCOZAe;{Es*;LWYwWAS zU?pdGyy7X>6<$CAVD3j@JzDP`G#3dUQgee_>;chGvph<$H-}8Y-iO-|8^jp_3EE?t zPUppa{0Vd}X6S>^J46mBsmcx=W4g+9hwrri3iJ?18B)~K(LmUBt9YOK4sLd2h164dq9D|~BI}l)am$|)(!q!vTWWljv z#ZIN5@;7wqn~a7Y%nnA*z{2MBC=)ez?`{mD!D8n<2YeG?xMxDzG~iDqx)A0=ka1JA zz=6QwxF1=)_IPjNfsmcj8DiHJB{z!~9g{RPp$?8qHdvYW4&o=D__lJjqj zjD`lGN^$@XWKitb+=}=+pykT2_BI& z68geUbp198eVxB-0w_m;2scyk08vUrG&hBn(IRn9^MULjH2A`gY<+WY4n9FM5qCjlL9)KdIdS86F0S~4sD7V8HhG)mgpiLTw7a*8QM@_^r4(dbZkNxG*?>|Q z9vrVjkRIziaZDT;~M zHUZc_L0~@bmKhu2GHza2=hqLi1w`*VO1u(pG7g9Ilt7e0ARmhTy2r7NTE`Ot3av+f zFyTb5?Q-j7fRGyrIX%bRHGFgq!@KUCB^bUiQ%F!WRO<|n6c_=c`yEg^WCOwIA+eSr zA-Usz2LiaY4WT1CE~E$?gwQr%9TTYi*65T_5PAL0FG>eub|+h_!m!MF*0V!QJSSl* zZN&@1nCx{281BWCSl)Fn1Vx*fxT!f(meFw~WJHymVC9z6T)C43Mo?CB3NZ~{b0oQ8 zJfeAJJTE0$wGL=8B&eXE)Jco@k=Zo^e4?R2lr>yBx#AnnH(VhjBFQ7x7?|M3=1moD z&f*4v8dy~*7UmroJx%IkqiAmy@d`QUlJ=1~trHURT2h`8l&&6S)DfiVusHHjj6}7h z35L@En|3wXS6tqNgoLDbhhNLYeX*|3vaGi#s02i|0wjotyv$c9rHCLisXgJ$sR6Qa zmCf!;IPucWRn;Ttzfc}%EwS7>yfA9?eP z_SVv0mMR9Yv{(EFyH3>@kO6^S@?@>WPk20%_?(o&_;@h5fWf`gkm>|)lQ^Gw@Z&h3 z9_i+5j92ip8POf;CKx$b0}qfMCOgjWywsOB~cCilJwL}(eRkBKIC(>HwUUxh%3;`@vwMA z-uDKYM1+bYGt52$Ou^}2Lv`?>@Vy9ZF%Ty!A*!JOla9#25jYV$duaG41vo_^A?Lzm za#%pSR5Y~EHq9b!ubJXz1}^}h|CfCjK_oFJL=3s_M&}Pv5Yz}PK*{n&s)3X}$rsOt zK3QIU5#Tq0D;JeOvFb{f1=y?XozXd-uDplEfNq+=dI8l714`1jY2%U@?F#8r%^}sn z4N7h(WQz9!eKHuPnLBzmjHd516Ek4YdD7&gUcEs5>RNZBiLe$-q za^N)+m>QfHws&+~0?UATS`*E8@`XgRCSV<#gQAHHB0HP<^1@dnM?)MU{7&43X zcXgCQ)SkEDBjnBWsA^fXKrb%zj07~|4p2y>J}s-1&m-nRvqJ;r?mlV@KkG>{dt3VU zM`#9VIf9v_0vyI@d-Zz3Fg2hGQj4=StM*e5+5knyq_tgV|9YcWS;`4Uf)fjZXQ;G_1$nhV4Nvu z0f?d~u>9)T2d|o%>L{bg*OpNgMyT5ptds$es^(N!m^j;p{QH~St7k14y=Ge0MpQhX zRP{#Ay%MGcfiyKoJEt1JW)OtQnzpI<2n+&FAi9MBKB}pSL`h_fH}O-U{p~N+y=Fo%0DHdO4>d6vabfI8 z^F&V+Bu%+S0p~Yf_@fstp-lmNx^%6#kF+zg9VHYK z=r<2OR5qSozlV?zMJ3P`9I`;E!_FPwCRp?IfyNMKyrSSSVvK&MH=3>^Q6 zhVy1Ha+#f+4vrY}a*T=iNUFLKkjT+@+GtqRI+ z=8tXxoIe!`$fKQRCtQFmY&q;5_DxiP9wG(i)yUlOo??1ARvu<*s;pf*PL&#}qLQsS2XPjlk2(&peE~fU z8Sq_?#}{wEHal|XHN`lA-JDD8@Y3B$G|C{kVfCT-5UdC5F9BevgpnbP#>Qmeq*FtA zx58)>3Nlx50uYQ-CCFk-jzN$*+vM_f5JU}O=PdbxbX8o|?vM8B^8 z-%?0Zg= z?)UNV?j2s)L=gm5OcKUUn`psB^VNadmtp6_3DT`fXtYb)%-chi@W^7Ss;Z)>(gB2p zVk2aVO>&^PQk78PiyN#Ez|()fVs) zaF}jfc1W}~_Uj^64dFSYPB!gTb=c~K16(^X!*|$Wx*FQL=JL!?yFM65%tZEeMF;}Z zX_)P2chzdpj;BHlY0c72Y?-iwY|Zb*h7m)*S?1(sO@uzUM2M`CN+@lRPBiN##om>o zRlIF2Y{CI75w`Q$Dsb)$`@_c(r%%EuNP)NL+_Xa`d=AW7vb(byW-RMRLO9QEmBuqN zXTxMzD+a=>CmZflqLNXD614v7^M`sYcl7smcIjbYb(!Aes*XT{*xCi&=- z#gui!?o2~LE!rDtc_?>>jur|IP}KDr!?4QTg^KBPDDw4}Eh!KTEdgOMH%eou9grA{ zfh$I(+ey}4(h(`dwPVA?4EmVHLiySd;sZ-D+zJ#Qk{rG)9yCoN7DWheQ#NWq!zS%` zqZM~x))$3RIU$9@!X$m1jjO@bPE&~{d#uIT!omdB$CHFFI6VZzxZ-2eo7mQ>PFsc7 z4(KlKJ86`zV$;dpTsO1T;aEH5Z1Di~#vh%wy5XsQV2is{mJhd`IGq+!Fxx;h>=_X4n9A3^^_#dRp2eeE z8|J-sn;42z03QV|q}d#o{QGZEG$0^$){+wVEgGrt9HjzT(Kqu_Hd(q%{v+ZTJ;5XN z{0q9RL-iX0>N+RU{CdI#6s9Zlxmg7yO-UaK>EIye?SqZcJo36tnB83`*rqQD#=(0% zSQ%9#NKg?98M~qDJ97i7Qa7`OA6Y1Q{EkE~U&q(rc;pjdkIQOx;3L_F$I-v)Kshj+ z7swnwuv5Fd?|RyS2DB(iZ3mOe^i*IMUSK6M7iEPt2oy3f111}AyNN#^YtE=q60kW0 z8%>ZI7!2!@CH{{_!w_jnE~Xe&5Edgtwq_{AMJjN>L@&Xk4bBo(8PM4md8rdng2E@r zfE`b_yz&{bv;m^=h6{A1!1r!;op?l+hIB;?SKRUxbkQr^NW~(K8ISw54LXl*^7+D~>Wk zK!hwmmj;(DwBumjs6C^}Kf1}=-_nX92#}ANH+WD(zZSX@Psr)Mt>@3iv4?!>&`+Mv zA2mG877%#Sy&>X=!^-uW(|4^vq|!1qY>X#^^^>4t%uPTi~=b+X;8M+g}wi5>USV2We!wx!5wJ9fgs^A1BMJ=SaMiLP$zRdj-a53 zLMJ6U^w}nV4gZyO=K|DX9MMik2kF=wkO>k)!bqNe?X>Y&qF~dJ5l&de1lD3C7D1e| z0al~=E=(7g87J!HsoP7uaLR_}IayeZN;9&tL-muaC5r=4tp1a$nh7bHl~}5^SOp5b zs?3qC)CP=0tq>p+%AMbtkTtk|t2QTgQJc)eBaN{7H(Fsw_R$@QGn*4lE@G}O2N6?#O51CuByf?*3dU{IylE0k!%&~^?Zk6q{xbq&Bd zSDxFGMD;V#IGImGm512q}ZG!M~}(DRGeD6Xrf6bRBX(SMmj6sft+zk$#d40#c<4 zz*!q*N+2*w)+-RvQImi~GniH)#5n~eDAF{<20)Y{NhqLi%=(&?U|7_%$kY)ALU~9! zX!IY}?v@jBQNY5PV_0?4lwfiP1SHIw4ak9l38G0LVQ|xiT+KORr?&$%YJstk(G@}* zz-77;d~R)->~YUtR2;Mq=i!TmL#|m_n%I4tR=H*o<})MD9==%whs!(5Q9pp;3{FH4 zkH~@e`+M(d0G^@@l@F>>go;3vfs#Q@0>F5}Y-TEbdNmdKL@*d3iY#0~ZA%3Bgf#T) z?}lTaj`{+TJ=w&?H2eyku~tk`KvhtSm*~agZV$a8m6pw{UMi5-YDE zgR2&rz}`<0zLJJw>chD^6q|O7;6N=U6smP9ebbtHs%m4^nU)m)B2g64Xd5ny89tB1niWSV>7vOtGd|nI%+IiVEW>R-&kc1i>;uLPT1?$eM*Qa=2z&k3bAPhrf3QE1Yh&Sxa_3J_lzBH5@!kWh)Td;7w*Tt7;EfcmhX%tUBd zND(Mu5|ao417(piUzuGW03M)l3_Hvetk#byb7Cj54G!_6@p?8#pnE7eVk26FBtk(3 z6ucf!US@GSy4ahb10YC=-~L-Z6U&E$KIvF|;{Efz%8LLX0RmSrT$*8`RUDTn^Bf13 zk3OGNsM2&CE#lqo4H|4cKh}n7lb&8SdS=bbxa0{j2?>JOkTMPA_ebFNzRwM2dAkG; zno1NYLy_ViG4hdnBP==17qsExb=7rAP(bz3>&zvHPRV{a93Y4`2y%CZkR(-SQ0PhVP&t~U5wLG6c{4Z@g)L&@GC+nM1G?lr13NEwVlTi+XKw%MOlBaqpjW z@AgOC&f0A#fUDk5aecmGy-`BR#qxf9D<_a`df8C)3s##N)CN&eNN0!6d#$OD0VSTd zbaw;aBaEe{h?yw_rqsl8LM3)F!O{jU0~x>KAEc7?pq~U4Ar))L8_r45Yf z2u|f7=Z+Vw!QmkZAdRzpICYboWi+U33aJ)NrH0%vixH4H5n^UJD&Ok)qq^wh(3P+|%8)`{%yda0qA?7>)@bwz2uEh4AG)1)A?h5a*4K>MK$in) zS&M(Co8QBbhKz>gdea36zPK-wBGZ~|(qu$LeIJLp;o}qyZM(Q0gaODMpo6dAfDtt# zN6qqQ5Y3S0pad2Vz&Rsd4NBnC<)r+S;#?%!!?m_dkg0_qlLG-tlT&ypi1}WCJJJSE zzk!3{^kADHAAW6B$pG+xW+&qO+xofJo_mXZqwp1cue!vew|;Cj;-v=(-g;Hoq{^S_ z?KX;F5H1~Aj)NpTV-v?_ixgK_xq&|5;3}Jxx!Rgp zXXei=xk6^8Y$-JGw<>~lNy(u}W-HKlN8ki?@|%Vi+If5|vZ&titNh7P7)11r{{8eA zUFMLeOF2y;Eux7Sj1Io#J@Ld&{}KX*fQdk*2#Q|#B0_|NF;amMp<-GWQ@1xp1cT9) zRGy+KMDv`z;)FQ7BdBkTOp=sg@cO$r7yNSq9a&}uJxF^4tjIb;nR0n}34nYcI&|rK zft<9lJ)k64co8I170ePPukEnPT43r%lXiDe#EpXN+%HCqEknxDBd9S*14Q>p-c73E zOcztaicQd`F)rEp!@U3Y0_Z*;WuW8cdB}JUL338k-0%;CQWlS z(mRMg4F?TL$R&l?$Wl9|2E?VzpcX+Wg(6LGV>qC4!*Ba2?tpyFI0^vp`$0A+`ZF?uHMYY z!qC*GPGuG1Vh$~lP9`%3)Jja`u;RKih1ij1CkeM3Z+)g~Rl&@!Y_-HWO2WMy)NQbTI~X`W?BX~h|5|S+elx5nJ$B7AjL8Nih1G1Y4*DTx( z4+F8Vt2DDo6%thSdzdg#+7gd;5u)HZO;rlVH3+1W;ZwE*tN`@V|yKH z8lt9(_jAq#A;dF>kP+%12p1S&hLs6PK<@%TI}<_Ww0)+hzvbODhG&f*;El9mk`REh zAefla1#t56p*dS-!;W@_*KcEo-i?*lwa3doS;3Swtip{o#6LSqAJ3nmDP5IO<{pv_>J3qs&UYPE?m zs}L$8MwD?foCjc__3wx}MI;D5A`BhW`RI{AZX|#Z$URX?K--rz{8i@%O?hq|umSTw zf55{WUoIG=xfGO@kYCG*`u4!K#wGqc({Tp&Z;V2CU(p+cA<-O3x9R21r28_)9@Y@3 zvbWLWNO6%3n=mX1GqM_vU^V-Hq@m~DYicHukyex=^`15%tOl@lAY_kXs~ANEj{NX;Bq1aop#xBN@BltT>=k$WS9ggc7jLK%RvpG8#dM`%<|JBy=i|BcFym_`@QKB+_gE{yI0kp(2?k zK=glRs%8oXW5YMYs;YGa-lCXyVy5@4f?{xc{!;WZ72Q7D7l~1#0Dd$lF&+r9&SqP3 zwUDssB=nLVkZFC%uE>OfmP!?`>k9*5dk?ai--~&OV(OuB)M7QMNK{-#+@sNb|KTKZ zF*JONMioRNQ#*+V*jy6Fze>BvgWNnGlgaG#;jbdt>L=r}VfwCzO#U~&i5Og8j zmk-Auh5G(m#PK#ikx%j|dbm0s_@}goMi~?Bz;An{^2ziNbR`iFx}`$Imf1@5Qe2X?3r-2}{ZE%YFT?R? zH}+%R?smNTv=}bY-@W2^@(9DuKQ`L>Fl+OW(k$RnCXuAyH)(ycJy~?ae1=yC-4u|z zYb4grla@GQ658bYt}I}^YU-8^OS6>Qjj4X{NUxn^q)&A%dP+Q;6`OPs6t}MXUqNB62$+uxNd&l*pZ& z%=Xn>JkG(ynER{JJX^?u2q1k^zhW5&!3WmJpfj_TMQ!}4K(=zlo}Tl&rAUY}E1gJ; z4QsOt=bB;*n3E}CK?^M;7zn!| zY;Bcdq+}5~Y7=Yf_Z#&ccRUxlm>DC%$0b3)8s zg#Z{%43OwfNC&(LVgqjQeTq1wK!gP`4g)fF==119lYu7p5eQSev}*-*Fb1Df zo+SjFBZ#025&#u}>R#P#({N=}>CKVf(F3zCG{s@j2lTt~F)l*T>Pk=MxaP@FxXB<@ z)xyxaG!vJjwG{N8K)3CzLPhvei9|+~B}oKPBC3Rjr^F8Z5YP+-13)Q+1vGQ^r{qYc zrY0KX0PLzARHfn|WV1^ON?nr{zQK#LuM0+kgrMGiX_%*Ds9 zyOI_srWce%{z+VTiLkt$iFRE?XF`&rfH)M$6J#t6GeD$C6bo%+Wr0%w0PNj{;wvGR zGLQ-+1q)b!AThOwN>bEX<*>%kN`Ns`MPf)mVNzBUYYS@HR8c@kl_Z%5>HGJ$T669B zx1Ao|x_>*-cn7#m_ln*&nOIO?92>u#fz0a6Kud6eupxt%W5Lbh&9zJKn1i4=Z5d4j zaS+;w$*Q4Xg?7@g%EMis$MuK3b8R#so zXp$^D$a|^c@cKNA-S3~d21f|yCQfpAaZ(yiXB4o zY8mzV-jOq!kOG7rd;Y3S;nLn43w*328_nZ9Tfc&dFrbAv9@W#0kyQJ z;;)TVfK>ceS9b12pG@ypY1Jd_4+U^wNCu5^md8L_4_cH`Gd=UN*qf6{kwTQHR3kTMbdX64C2DD!R_3L8X(xiG_pm zsYdeHX1g9NX(!u+SO$i%cl$qV3@*b}x3wOc6xJSf(R z%+4`P&O=0dZHQ%j^$p<&HpzsCmL(xFly*CaVi=Nx2^=Hm-Sk~($2+PA=FC`o;=aj# z59@~Z*|@<>vQ&pveKAs^7zI%kQ$|pB*vLc+*+>OEM#P^fC9_2AR zP}f#E!>%$9O~JcrrQ2ougxbx_KBNmlxm(3N%2#71ZR$#+3nEl#CMhv(NN6PprVAA4 zHK+=S9{e&U$e~h&w$LqXVOc>XvY?H=Y?NHKTWvlJz|zGJj@jaetc*Wi9;gyf>i{^b z#-M2Y$4z$b4{W-s{B_87BlTwh=tZUP4-;eYgQ;^vlkzRyg12XSyY$@)l`wLKt>Q=& z*z*u*cXtv(NRu|5Zxa`x$oGo1g+|hmS~6^ske#e2+{{ByKzx>;E;`RzXQ>E-qIP3A zmS{}FWY#gu;gGgBqg}#N1k4uB7r6m7lw(WboX0rbPW_bD91Rda^^OrZW+=l;gf=Dc z=s+fM^iTwd+dOVe1>7VRr132&Vh*Tk5<(JTBYwJj)_I3nB>NJ}n9~@-W+QoHD{fmO z#IqSw)>|5T>5$gk#^w;oHv8=XJyuvqqO=y}%`x6Msf=7mvDa}{&N`N+LdIk~W~L4w zYcA9<7E2Sxc&$L~YGPpJP>ZJ)!^1JPOoX77RV>FaT{|(A{h@ZiL3c$P9euH=JEx+; zF3Txm?du#0fZ1nU_3E{iDob{Df}i}eFErT4%R(! zZ=157qM*Z?D{3*3!ZraQgi+)<*e)7rTWga-9obbw#1C~il9rR%k;}S+lA0-s8-c|)BuBT$ z-dGVFbyJzvIP4+a1EkV)n51O3dhENfn2JS(8ryKSBIJP*jyE-|jBb>nv1&ID6!hf>gbk0w2o&If!}T=aL>}GIdiuCu%={qzev_djs92 zzJq7;P*n0u`no`Y4hLN+w^zxHztALM?j01OO(i$9te}e*m=Zl zJ81qSh0nZ?Pf<2UpvU%mFWzL5)F_^hTY-_odU@j}$W#)UbR51cGD0Qvv5Hc#2o8)!kTm!#h7m7WC1`1(c3G{2a2ee>z2b_Ds+^g?J0JHVQO%f=4Fq3Apv1mw1 zVmm`o@E?d}Jy7cS$f+0r%VE%fBQC>JAFp<4 z@~5jP2e~a1e_=KY4jX$`*HwD3o@jN{hIEWH?QF(@so^YJ6Ay$ql^A9$myjJXuuVkF zl#R|Ts&FTZqekYG1gTt0w1UI+fbiaQ9G#J19gyT + #include + #include +@@ -31,8 +34,10 @@ + #include + #include + +-#include +-#include ++#include "ldconfig.h" ++#include "dl-cache.h" ++# define N_(msgid) msgid ++#define _(msg) msg + + struct cache_entry + { +Index: ldconfig-native-2.12.1/chroot_canon.c +=================================================================== +--- ldconfig-native-2.12.1.orig/chroot_canon.c ++++ ldconfig-native-2.12.1/chroot_canon.c +@@ -17,6 +17,9 @@ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + ++#define _LARGEFILE64_SOURCE ++#define _GNU_SOURCE ++ + #include + #include + #include +@@ -27,7 +30,9 @@ + #include + #include + +-#include ++#include "ldconfig.h" ++ ++#define __set_errno(Val) errno = (Val) + + #ifndef PATH_MAX + #define PATH_MAX 1024 +Index: ldconfig-native-2.12.1/dl-cache.c +=================================================================== +--- ldconfig-native-2.12.1.orig/dl-cache.c ++++ ldconfig-native-2.12.1/dl-cache.c +@@ -20,12 +20,12 @@ + + #include + #include +-#include ++//#include "ldsodefs.h" + #include + #include + #include + +-#include ++//#include "_itoa.h" + + #ifndef _DL_PLATFORMS_COUNT + # define _DL_PLATFORMS_COUNT 0 +@@ -39,103 +39,7 @@ static size_t cachesize; + /* 1 if cache_data + PTR points into the cache. */ + #define _dl_cache_verify_ptr(ptr) (ptr < cache_data_size) + +-#define SEARCH_CACHE(cache) \ +-/* We use binary search since the table is sorted in the cache file. \ +- The first matching entry in the table is returned. \ +- It is important to use the same algorithm as used while generating \ +- the cache file. */ \ +-do \ +- { \ +- left = 0; \ +- right = cache->nlibs - 1; \ +- \ +- while (left <= right) \ +- { \ +- __typeof__ (cache->libs[0].key) key; \ +- \ +- middle = (left + right) / 2; \ +- \ +- key = cache->libs[middle].key; \ +- \ +- /* Make sure string table indices are not bogus before using \ +- them. */ \ +- if (! _dl_cache_verify_ptr (key)) \ +- { \ +- cmpres = 1; \ +- break; \ +- } \ +- \ +- /* Actually compare the entry with the key. */ \ +- cmpres = _dl_cache_libcmp (name, cache_data + key); \ +- if (__builtin_expect (cmpres == 0, 0)) \ +- { \ +- /* Found it. LEFT now marks the last entry for which we \ +- know the name is correct. */ \ +- left = middle; \ +- \ +- /* There might be entries with this name before the one we \ +- found. So we have to find the beginning. */ \ +- while (middle > 0) \ +- { \ +- __typeof__ (cache->libs[0].key) key; \ +- \ +- key = cache->libs[middle - 1].key; \ +- /* Make sure string table indices are not bogus before \ +- using them. */ \ +- if (! _dl_cache_verify_ptr (key) \ +- /* Actually compare the entry. */ \ +- || _dl_cache_libcmp (name, cache_data + key) != 0) \ +- break; \ +- --middle; \ +- } \ +- \ +- do \ +- { \ +- int flags; \ +- __typeof__ (cache->libs[0]) *lib = &cache->libs[middle]; \ +- \ +- /* Only perform the name test if necessary. */ \ +- if (middle > left \ +- /* We haven't seen this string so far. Test whether the \ +- index is ok and whether the name matches. Otherwise \ +- we are done. */ \ +- && (! _dl_cache_verify_ptr (lib->key) \ +- || (_dl_cache_libcmp (name, cache_data + lib->key) \ +- != 0))) \ +- break; \ +- \ +- flags = lib->flags; \ +- if (_dl_cache_check_flags (flags) \ +- && _dl_cache_verify_ptr (lib->value)) \ +- { \ +- if (best == NULL || flags == GLRO(dl_correct_cache_id)) \ +- { \ +- HWCAP_CHECK; \ +- best = cache_data + lib->value; \ +- \ +- if (flags == GLRO(dl_correct_cache_id)) \ +- /* We've found an exact match for the shared \ +- object and no general `ELF' release. Stop \ +- searching. */ \ +- break; \ +- } \ +- } \ +- } \ +- while (++middle <= right); \ +- break; \ +- } \ +- \ +- if (cmpres < 0) \ +- left = middle + 1; \ +- else \ +- right = middle - 1; \ +- } \ +- } \ +-while (0) +- +- + int +-internal_function + _dl_cache_libcmp (const char *p1, const char *p2) + { + while (*p1 != '\0') +@@ -172,139 +76,3 @@ _dl_cache_libcmp (const char *p1, const + } + return *p1 - *p2; + } +- +- +-/* Look up NAME in ld.so.cache and return the file name stored there, +- or null if none is found. */ +- +-const char * +-internal_function +-_dl_load_cache_lookup (const char *name) +-{ +- int left, right, middle; +- int cmpres; +- const char *cache_data; +- uint32_t cache_data_size; +- const char *best; +- +- /* Print a message if the loading of libs is traced. */ +- if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)) +- _dl_debug_printf (" search cache=%s\n", LD_SO_CACHE); +- +- if (cache == NULL) +- { +- /* Read the contents of the file. */ +- void *file = _dl_sysdep_read_whole_file (LD_SO_CACHE, &cachesize, +- PROT_READ); +- +- /* We can handle three different cache file formats here: +- - the old libc5/glibc2.0/2.1 format +- - the old format with the new format in it +- - only the new format +- The following checks if the cache contains any of these formats. */ +- if (file != MAP_FAILED && cachesize > sizeof *cache +- && memcmp (file, CACHEMAGIC, sizeof CACHEMAGIC - 1) == 0) +- { +- size_t offset; +- /* Looks ok. */ +- cache = file; +- +- /* Check for new version. */ +- offset = ALIGN_CACHE (sizeof (struct cache_file) +- + cache->nlibs * sizeof (struct file_entry)); +- +- cache_new = (struct cache_file_new *) ((void *) cache + offset); +- if (cachesize < (offset + sizeof (struct cache_file_new)) +- || memcmp (cache_new->magic, CACHEMAGIC_VERSION_NEW, +- sizeof CACHEMAGIC_VERSION_NEW - 1) != 0) +- cache_new = (void *) -1; +- } +- else if (file != MAP_FAILED && cachesize > sizeof *cache_new +- && memcmp (file, CACHEMAGIC_VERSION_NEW, +- sizeof CACHEMAGIC_VERSION_NEW - 1) == 0) +- { +- cache_new = file; +- cache = file; +- } +- else +- { +- if (file != MAP_FAILED) +- __munmap (file, cachesize); +- cache = (void *) -1; +- } +- +- assert (cache != NULL); +- } +- +- if (cache == (void *) -1) +- /* Previously looked for the cache file and didn't find it. */ +- return NULL; +- +- best = NULL; +- +- if (cache_new != (void *) -1) +- { +- uint64_t platform; +- +- /* This is where the strings start. */ +- cache_data = (const char *) cache_new; +- +- /* Now we can compute how large the string table is. */ +- cache_data_size = (const char *) cache + cachesize - cache_data; +- +- platform = _dl_string_platform (GLRO(dl_platform)); +- if (platform != (uint64_t) -1) +- platform = 1ULL << platform; +- +-#define _DL_HWCAP_TLS_MASK (1LL << 63) +- uint64_t hwcap_exclude = ~((GLRO(dl_hwcap) & GLRO(dl_hwcap_mask)) +- | _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK); +- +- /* Only accept hwcap if it's for the right platform. */ +-#define HWCAP_CHECK \ +- if (lib->hwcap & hwcap_exclude) \ +- continue; \ +- if (GLRO(dl_osversion) && lib->osversion > GLRO(dl_osversion)) \ +- continue; \ +- if (_DL_PLATFORMS_COUNT \ +- && (lib->hwcap & _DL_HWCAP_PLATFORM) != 0 \ +- && (lib->hwcap & _DL_HWCAP_PLATFORM) != platform) \ +- continue +- SEARCH_CACHE (cache_new); +- } +- else +- { +- /* This is where the strings start. */ +- cache_data = (const char *) &cache->libs[cache->nlibs]; +- +- /* Now we can compute how large the string table is. */ +- cache_data_size = (const char *) cache + cachesize - cache_data; +- +-#undef HWCAP_CHECK +-#define HWCAP_CHECK do {} while (0) +- SEARCH_CACHE (cache); +- } +- +- /* Print our result if wanted. */ +- if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0) +- && best != NULL) +- _dl_debug_printf (" trying file=%s\n", best); +- +- return best; +-} +- +-#ifndef MAP_COPY +-/* If the system does not support MAP_COPY we cannot leave the file open +- all the time since this would create problems when the file is replaced. +- Therefore we provide this function to close the file and open it again +- once needed. */ +-void +-_dl_unload_cache (void) +-{ +- if (cache != NULL && cache != (struct cache_file *) -1) +- { +- __munmap (cache, cachesize); +- cache = NULL; +- } +-} +-#endif +Index: ldconfig-native-2.12.1/dl-cache.h +=================================================================== +--- ldconfig-native-2.12.1.orig/dl-cache.h ++++ ldconfig-native-2.12.1/dl-cache.h +@@ -101,5 +101,4 @@ struct cache_file_new + (((addr) + __alignof__ (struct cache_file_new) -1) \ + & (~(__alignof__ (struct cache_file_new) - 1))) + +-extern int _dl_cache_libcmp (const char *p1, const char *p2) +- internal_function; ++extern int _dl_cache_libcmp (const char *p1, const char *p2); +Index: ldconfig-native-2.12.1/ldconfig.c +=================================================================== +--- ldconfig-native-2.12.1.orig/ldconfig.c ++++ ldconfig-native-2.12.1/ldconfig.c +@@ -16,6 +16,9 @@ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + ++#define _LARGEFILE64_SOURCE ++#define _GNU_SOURCE ++ + #define PROCINFO_CLASS static + #include + #include +@@ -39,10 +42,20 @@ + #include + #include + +-#include +-#include ++#include "ldconfig.h" ++#include "dl-cache.h" ++ ++#include "dl-procinfo.h" ++ ++#include "argp.h" ++ ++ ++#define SYSCONFDIR "/etc" ++#define LIBDIR "/usr/lib" ++#define SLIBDIR "/lib" ++# define N_(msgid) msgid ++#define _(msg) msg + +-#include + + #ifdef _DL_FIRST_PLATFORM + # define _DL_FIRST_EXTRA (_DL_FIRST_PLATFORM + _DL_PLATFORMS_COUNT) +@@ -55,7 +68,7 @@ + #endif + + /* Get libc version number. */ +-#include ++#include "version.h" + + #define PACKAGE _libc_intl_domainname + +@@ -152,8 +165,8 @@ static const struct argp_option options[ + { NULL, 0, NULL, 0, NULL, 0 } + }; + +-#define PROCINFO_CLASS static +-#include ++//#define PROCINFO_CLASS static ++//#include + + /* Short description of program. */ + static const char doc[] = N_("Configure Dynamic Linker Run Time Bindings."); +@@ -291,6 +304,7 @@ parse_opt (int key, char *arg, struct ar + return 0; + } + ++#define REPORT_BUGS_TO "mailing list : poky@yoctoproject.org" + /* Print bug-reporting information in the help message. */ + static char * + more_help (int key, const char *text, void *input) +@@ -315,7 +329,7 @@ For bug reporting instructions, please s + static void + print_version (FILE *stream, struct argp_state *state) + { +- fprintf (stream, "ldconfig %s%s\n", PKGVERSION, VERSION); ++ fprintf (stream, "ldconfig (Hacked Poky Version)\n"); + fprintf (stream, gettext ("\ + Copyright (C) %s Free Software Foundation, Inc.\n\ + This is free software; see the source for copying conditions. There is NO\n\ +@@ -1233,6 +1247,7 @@ set_hwcap (void) + hwcap_mask = strtoul (mask, NULL, 0); + } + ++const char _libc_intl_domainname[] = "libc"; + + int + main (int argc, char **argv) +Index: ldconfig-native-2.12.1/readlib.c +=================================================================== +--- ldconfig-native-2.12.1.orig/readlib.c ++++ ldconfig-native-2.12.1/readlib.c +@@ -22,6 +22,9 @@ + development version. Besides the simplification, it has also been + modified to read some other file formats. */ + ++#define _LARGEFILE64_SOURCE ++#define _GNU_SOURCE ++ + #include + #include + #include +@@ -35,7 +38,9 @@ + #include + #include + +-#include ++#include "ldconfig.h" ++ ++#define _(msg) msg + + #define Elf32_CLASS ELFCLASS32 + #define Elf64_CLASS ELFCLASS64 +Index: ldconfig-native-2.12.1/xstrdup.c +=================================================================== +--- ldconfig-native-2.12.1.orig/xstrdup.c ++++ ldconfig-native-2.12.1/xstrdup.c +@@ -16,15 +16,10 @@ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +-#ifdef HAVE_CONFIG_H +-# include +-#endif ++#define _GNU_SOURCE ++ ++#include + +-#if defined STDC_HEADERS || defined HAVE_STRING_H || _LIBC +-# include +-#else +-# include +-#endif + void *xmalloc (size_t n) __THROW; + char *xstrdup (char *string) __THROW; + diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch new file mode 100644 index 000000000..27bc41107 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch @@ -0,0 +1,36 @@ +Upstream-Status: Pending + +Coming from this bug: http://sourceware.org/bugzilla/show_bug.cgi?id=11149 + +Nitin A Kamble 2011/03/29 + +--- ldconfig-native-2.12.1.orig/ldconfig.c ++++ ldconfig-native-2.12.1/ldconfig.c +@@ -1359,14 +1359,9 @@ main (int argc, char **argv) + + const char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE; + if (opt_chroot) +- { +- aux_cache_file = chroot_canon (opt_chroot, aux_cache_file); +- if (aux_cache_file == NULL) +- error (EXIT_FAILURE, errno, _("Can't open cache file %s\n"), +- _PATH_LDCONFIG_AUX_CACHE); +- } ++ aux_cache_file = chroot_canon (opt_chroot, aux_cache_file); + +- if (! opt_ignore_aux_cache) ++ if (! opt_ignore_aux_cache && aux_cache_file) + load_aux_cache (aux_cache_file); + else + init_aux_cache (); +@@ -1376,7 +1371,8 @@ main (int argc, char **argv) + if (opt_build_cache) + { + save_cache (cache_file); +- save_aux_cache (aux_cache_file); ++ if (aux_cache_file) ++ save_aux_cache (aux_cache_file); + } + + return 0; + diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/no-aux-cache.patch b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/no-aux-cache.patch new file mode 100644 index 000000000..c6765ba00 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native-2.12.1/no-aux-cache.patch @@ -0,0 +1,19 @@ +The ldconfig auxiliary cache is a dictionary where the keys include inode, so +there is no point in writing these files on the build host. + +Upstream-Status: Inappropriate +Signed-off-by: Ross Burton + +diff --git a/ldconfig.c b/ldconfig.c +index 2c4eb57..2d6dc92 100644 +--- a/ldconfig.c ++++ b/ldconfig.c +@@ -1399,8 +1399,6 @@ main (int argc, char **argv) + if (opt_build_cache) + { + save_cache (cache_file); +- if (aux_cache_file) +- save_aux_cache (aux_cache_file); + } + + return 0; diff --git a/meta-digi-dey/recipes-core/glibc/ldconfig-native_2.12.1.bb b/meta-digi-dey/recipes-core/glibc/ldconfig-native_2.12.1.bb new file mode 100644 index 000000000..919d11417 --- /dev/null +++ b/meta-digi-dey/recipes-core/glibc/ldconfig-native_2.12.1.bb @@ -0,0 +1,35 @@ +SUMMARY = "A standalone native ldconfig build" + +LICENSE = "GPLv2+" + +LIC_FILES_CHKSUM = "file://${S}/ldconfig.c;endline=17;md5=1d15f20937c055cb5de2329a4c054399" + +SRC_URI = "file://ldconfig-native-2.12.1.tar.bz2 \ + file://ldconfig.patch \ + file://ldconfig_aux-cache_path_fix.patch \ + file://32and64bit.patch \ + file://endian-ness_handling.patch \ + file://flag_fix.patch \ + file://endianess-header.patch \ + file://ldconfig-default-to-all-multilib-dirs.patch \ + file://endian-ness_handling_fix.patch \ + file://add-64-bit-flag-for-ELF64-entries.patch \ + file://no-aux-cache.patch \ +" + +PR = "r2" + +FILESEXTRAPATHS =. "${FILE_DIRNAME}/${P}:" + +inherit native + +S = "${WORKDIR}/${PN}-${PV}" + +do_compile () { + $CC ldconfig.c -std=gnu99 chroot_canon.c xmalloc.c xstrdup.c cache.c readlib.c -I. dl-cache.c -o ldconfig +} + +do_install () { + install -d ${D}/${bindir}/ + install ldconfig ${D}/${bindir}/ +} From c5b57d3e0c0c41130260b7d4ea78355c8cab3398 Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Tue, 3 Aug 2021 11:52:43 +0200 Subject: [PATCH 07/70] ml-security: update to new version This commit updates the ML security package to hardknott-5.10.35-2.0.0 release by NXP. Signed-off-by: Mike Engel --- .../{ml-security_1.0.3.bb => ml-security_1.0.4.bb} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename meta-digi-dey/recipes-security/ml-security/{ml-security_1.0.3.bb => ml-security_1.0.4.bb} (53%) diff --git a/meta-digi-dey/recipes-security/ml-security/ml-security_1.0.3.bb b/meta-digi-dey/recipes-security/ml-security/ml-security_1.0.4.bb similarity index 53% rename from meta-digi-dey/recipes-security/ml-security/ml-security_1.0.3.bb rename to meta-digi-dey/recipes-security/ml-security/ml-security_1.0.4.bb index 4119c4819..135d333c3 100644 --- a/meta-digi-dey/recipes-security/ml-security/ml-security_1.0.3.bb +++ b/meta-digi-dey/recipes-security/ml-security/ml-security_1.0.4.bb @@ -1,14 +1,14 @@ -# Copyright 2019-2020 NXP +# Copyright 2019-2021 NXP DESCRIPTION = "Hardening Library for Machine Learning Security" SECTION = "security" LICENSE = "Proprietary" -LIC_FILES_CHKSUM = "file://COPYING;md5=cf3f9b8d09bc3926b1004ea71f7a248a" +LIC_FILES_CHKSUM = "file://COPYING;md5=3c3fe2b904fd694f28d2f646ee16dddb" DEPENDS = "opencv" -SRC_URI[md5sum] = "933fc6fd993d0558128364787d459ed5" -SRC_URI[sha256sum] = "2c4aa7982f5dee49ff15cd63a236c17f513c01506c2faf6a5a4ca1b3140c7bba" +SRC_URI[md5sum] = "5f789532f11e5085278cbb637d7927d0" +SRC_URI[sha256sum] = "44b5a43e1cbd2c34245a45798db35ad080e586a81a940771a6b9a75af310d0d1" S = "${WORKDIR}/ml-security" From 54cb00e120b138d35f6acacee59a25cf9ee82794 Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Tue, 3 Aug 2021 11:54:12 +0200 Subject: [PATCH 08/70] layer: add new EULA license MD5SUM values This commit adds new EULA MD5SUM values that are required due to the update of the eIQ support by NXP. Signed-off-by: Mike Engel --- meta-digi-arm/conf/layer.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meta-digi-arm/conf/layer.conf b/meta-digi-arm/conf/layer.conf index ce7a33cda..0abac4a7c 100644 --- a/meta-digi-arm/conf/layer.conf +++ b/meta-digi-arm/conf/layer.conf @@ -17,9 +17,13 @@ LAYERSERIES_COMPAT_digi-arm = "gatesgarth" # See fsl-eula-unpack.bbclass. FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V13 = "1b4db4b25c3a1e422c0c0ed64feb65d2" FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V19 = "a632fefd1c359980434f9389833cab3a" +FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V22 = "3c3fe2b904fd694f28d2f646ee16dddb" +FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V25 = "f35df765ff17e69043ea21f350e3229c" FSL_EULA_FILE_MD5SUMS_append = " \ ${FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V13} \ ${FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V19} \ + ${FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V22} \ + ${FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V25} \ " # Digi's General and Open Source license agreements From 6462549f044772eab1ab0a86c362b3d5ddb62f45 Mon Sep 17 00:00:00 2001 From: Arturo Buzarra Date: Thu, 12 Aug 2021 11:07:25 +0200 Subject: [PATCH 09/70] build.sh: add support to provide cpus number to use https://onedigi.atlassian.net/browse/DEL-7629 Signed-off-by: Arturo Buzarra --- sdk/build-github.sh | 5 ++++- sdk/build.sh | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sdk/build-github.sh b/sdk/build-github.sh index 437ec5f8f..f3b25b159 100755 --- a/sdk/build-github.sh +++ b/sdk/build-github.sh @@ -151,7 +151,10 @@ YOCTO_IMGS_DIR="${WORKSPACE}/images" YOCTO_INST_DIR="${WORKSPACE}/dey.$(echo ${DY_REVISION} | tr '/' '_')" YOCTO_PROJ_DIR="${WORKSPACE}/projects" -CPUS="$(grep -c processor /proc/cpuinfo)" +# If CPUS is unset, set it with the machine cpus +if [ -z "${CPUS}" ]; then + CPUS="$(grep -c processor /proc/cpuinfo)" +fi [ ${CPUS} -gt 1 ] && MAKE_JOBS="-j${CPUS}" printf "\n[INFO] Build Yocto \"${DY_REVISION}\" for \"${DY_PLATFORMS}\" (cpus=${CPUS})\n\n" diff --git a/sdk/build.sh b/sdk/build.sh index cb8b75df9..a86aa5831 100755 --- a/sdk/build.sh +++ b/sdk/build.sh @@ -188,7 +188,10 @@ YOCTO_INST_DIR="${WORKSPACE}/digi-yocto-sdk.$(echo ${DY_REVISION} | tr '/' '_')" YOCTO_DOWNLOAD_DIR="${DY_DOWNLOADS:-${WORKSPACE}}/downloads" YOCTO_PROJ_DIR="${WORKSPACE}/projects" -CPUS="$(grep -c processor /proc/cpuinfo)" +# If CPUS is unset, set it with the machine cpus +if [ -z "${CPUS}" ]; then + CPUS="$(grep -c processor /proc/cpuinfo)" +fi [ ${CPUS} -gt 1 ] && MAKE_JOBS="-j${CPUS}" printf "\n[INFO] Build Yocto \"${DY_REVISION}\" for \"${DY_PLATFORMS}\" (cpus=${CPUS})\n\n" From feec2aa4f71a5ae010699b55d32bb0580bb37827 Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Tue, 10 Aug 2021 09:05:35 +0200 Subject: [PATCH 10/70] glib-2.0: backport 2.65 patch to prevent NetworkManager segmentation faults NetworkManager's main library went through a major overhaul in v1.22, changing the way it interacts with glib among other things. When using a NetworkManager version equal or newer than v1.22 along with a glib version between 2.63.3 and 2.65, a race condition can happen, randomly causing segmentation faults. Since Yocto 3.2 uses NetworkManager 1.22.14 and glib 2.64.5, the race condition is reproducible, but it can be fixed with the patch introduced in this commit. The patch in question is commit e4a690f5dd959e74b2d6054826f61509892c8aa7 in the glib git repo. https://onedigi.atlassian.net/browse/DEL-7523 Signed-off-by: Gabriel Valcazar --- ...-minor-race-between-GCancellable-and.patch | 216 ++++++++++++++++++ .../glib-2.0/glib-2.0_2.64.5.bbappend | 3 + 2 files changed, 219 insertions(+) create mode 100644 meta-digi-dey/recipes-core/glib-2.0/glib-2.0/0001-gcancellable-Fix-minor-race-between-GCancellable-and.patch create mode 100644 meta-digi-dey/recipes-core/glib-2.0/glib-2.0_2.64.5.bbappend diff --git a/meta-digi-dey/recipes-core/glib-2.0/glib-2.0/0001-gcancellable-Fix-minor-race-between-GCancellable-and.patch b/meta-digi-dey/recipes-core/glib-2.0/glib-2.0/0001-gcancellable-Fix-minor-race-between-GCancellable-and.patch new file mode 100644 index 000000000..aefadd408 --- /dev/null +++ b/meta-digi-dey/recipes-core/glib-2.0/glib-2.0/0001-gcancellable-Fix-minor-race-between-GCancellable-and.patch @@ -0,0 +1,216 @@ +From: Philip Withnall +Date: Fri, 21 Feb 2020 14:44:44 +0000 +Subject: [PATCH] gcancellable: Fix minor race between GCancellable and + GCancellableSource +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +There’s a minor race condition between cancellation of a `GCancellable`, +and disposal/finalisation of a `GCancellableSource` in another thread. + +Thread A Thread B + g_cancellable_cancel(C) + →cancellable_source_cancelled(C, S) + g_source_unref(S) + cancellable_source_dispose(S) + →→g_source_ref(S) + →→# S is invalid at this point; crash + +Thankfully, the `GCancellable` sets `cancelled_running` while it’s +emitting the `cancelled` signal, so if `cancellable_source_dispose()` is +called while that’s high, we know that the thread which is doing the +cancellation has already started (or is committed to starting) calling +`cancellable_source_cancelled()`. + +Fix the race by resurrecting the `GCancellableSource` in +`cancellable_source_dispose()`, and signalling this using +`GCancellableSource.resurrected_during_cancellation`. Check for that +flag in `cancellable_source_cancelled()` and ignore cancellation if it’s +set. + +The modifications to `resurrected_during_cancellation` and the +cancellable source’s refcount have to be done with `cancellable_mutex` +held so that they are seen atomically by each thread. This should not +affect performance too much, as it only happens during cancellation or +disposal of a `GCancellableSource`. + +Signed-off-by: Philip Withnall + +Fixes: #1841 +--- + gio/gcancellable.c | 43 +++++++++++++++++++++++ + gio/tests/cancellable.c | 77 +++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 120 insertions(+) + +diff --git a/gio/gcancellable.c b/gio/gcancellable.c +index d9e58b8e8..e687cca23 100644 +--- a/gio/gcancellable.c ++++ b/gio/gcancellable.c +@@ -643,6 +643,8 @@ typedef struct { + + GCancellable *cancellable; + gulong cancelled_handler; ++ /* Protected by cancellable_mutex: */ ++ gboolean resurrected_during_cancellation; + } GCancellableSource; + + /* +@@ -661,8 +663,24 @@ cancellable_source_cancelled (GCancellable *cancellable, + gpointer user_data) + { + GSource *source = user_data; ++ GCancellableSource *cancellable_source = (GCancellableSource *) source; ++ ++ g_mutex_lock (&cancellable_mutex); ++ ++ /* Drop the reference added in cancellable_source_dispose(); see the comment there. ++ * The reference must be dropped after unlocking @cancellable_mutex since ++ * it could be the final reference, and the dispose function takes ++ * @cancellable_mutex. */ ++ if (cancellable_source->resurrected_during_cancellation) ++ { ++ cancellable_source->resurrected_during_cancellation = FALSE; ++ g_mutex_unlock (&cancellable_mutex); ++ g_source_unref (source); ++ return; ++ } + + g_source_ref (source); ++ g_mutex_unlock (&cancellable_mutex); + g_source_set_ready_time (source, 0); + g_source_unref (source); + } +@@ -684,12 +702,37 @@ cancellable_source_dispose (GSource *source) + { + GCancellableSource *cancellable_source = (GCancellableSource *)source; + ++ g_mutex_lock (&cancellable_mutex); ++ + if (cancellable_source->cancellable) + { ++ if (cancellable_source->cancellable->priv->cancelled_running) ++ { ++ /* There can be a race here: if thread A has called ++ * g_cancellable_cancel() and has got as far as committing to call ++ * cancellable_source_cancelled(), then thread B drops the final ++ * ref on the GCancellableSource before g_source_ref() is called in ++ * cancellable_source_cancelled(), then cancellable_source_dispose() ++ * will run through and the GCancellableSource will be finalised ++ * before cancellable_source_cancelled() gets to g_source_ref(). It ++ * will then be left in a state where it’s committed to using a ++ * dangling GCancellableSource pointer. ++ * ++ * Eliminate that race by resurrecting the #GSource temporarily, and ++ * then dropping that reference in cancellable_source_cancelled(), ++ * which should be guaranteed to fire because we’re inside a ++ * @cancelled_running block. ++ */ ++ g_source_ref (source); ++ cancellable_source->resurrected_during_cancellation = TRUE; ++ } ++ + g_clear_signal_handler (&cancellable_source->cancelled_handler, + cancellable_source->cancellable); + g_clear_object (&cancellable_source->cancellable); + } ++ ++ g_mutex_unlock (&cancellable_mutex); + } + + static gboolean +diff --git a/gio/tests/cancellable.c b/gio/tests/cancellable.c +index cd349a8f3..492704d18 100644 +--- a/gio/tests/cancellable.c ++++ b/gio/tests/cancellable.c +@@ -228,6 +228,82 @@ test_cancel_null (void) + g_cancellable_cancel (NULL); + } + ++typedef struct ++{ ++ GCond cond; ++ GMutex mutex; ++ GSource *cancellable_source; /* (owned) */ ++} ThreadedDisposeData; ++ ++static gboolean ++cancelled_cb (GCancellable *cancellable, ++ gpointer user_data) ++{ ++ /* Nothing needs to be done here. */ ++ return G_SOURCE_CONTINUE; ++} ++ ++static gpointer ++threaded_dispose_thread_cb (gpointer user_data) ++{ ++ ThreadedDisposeData *data = user_data; ++ ++ /* Synchronise with the main thread before trying to reproduce the race. */ ++ g_mutex_lock (&data->mutex); ++ g_cond_broadcast (&data->cond); ++ g_mutex_unlock (&data->mutex); ++ ++ /* Race with cancellation of the cancellable. */ ++ g_source_unref (data->cancellable_source); ++ ++ return NULL; ++} ++ ++static void ++test_cancellable_source_threaded_dispose (void) ++{ ++ guint i; ++ ++ g_test_summary ("Test a thread race between disposing of a GCancellableSource " ++ "(in one thread) and cancelling the GCancellable it refers " ++ "to (in another thread)"); ++ g_test_bug ("https://gitlab.gnome.org/GNOME/glib/issues/1841"); ++ ++ for (i = 0; i < 100000; i++) ++ { ++ GCancellable *cancellable = NULL; ++ GSource *cancellable_source = NULL; ++ ThreadedDisposeData data; ++ GThread *thread = NULL; ++ ++ /* Create a cancellable and a cancellable source for it. For this test, ++ * there’s no need to attach the source to a #GMainContext. */ ++ cancellable = g_cancellable_new (); ++ cancellable_source = g_cancellable_source_new (cancellable); ++ g_source_set_callback (cancellable_source, G_SOURCE_FUNC (cancelled_cb), NULL, NULL); ++ ++ /* Create a new thread and wait until it’s ready to execute before ++ * cancelling our cancellable. */ ++ g_cond_init (&data.cond); ++ g_mutex_init (&data.mutex); ++ data.cancellable_source = g_steal_pointer (&cancellable_source); ++ ++ g_mutex_lock (&data.mutex); ++ thread = g_thread_new ("/cancellable-source/threaded-dispose", ++ threaded_dispose_thread_cb, &data); ++ g_cond_wait (&data.cond, &data.mutex); ++ g_mutex_unlock (&data.mutex); ++ ++ /* Race with disposal of the cancellable source. */ ++ g_cancellable_cancel (cancellable); ++ ++ g_thread_join (g_steal_pointer (&thread)); ++ g_mutex_clear (&data.mutex); ++ g_cond_clear (&data.cond); ++ g_object_unref (cancellable); ++ } ++} ++ + int + main (int argc, char *argv[]) + { +@@ -235,6 +311,7 @@ main (int argc, char *argv[]) + + g_test_add_func ("/cancellable/multiple-concurrent", test_cancel_multiple_concurrent); + g_test_add_func ("/cancellable/null", test_cancel_null); ++ g_test_add_func ("/cancellable-source/threaded-dispose", test_cancellable_source_threaded_dispose); + + return g_test_run (); + } diff --git a/meta-digi-dey/recipes-core/glib-2.0/glib-2.0_2.64.5.bbappend b/meta-digi-dey/recipes-core/glib-2.0/glib-2.0_2.64.5.bbappend new file mode 100644 index 000000000..05e4f1856 --- /dev/null +++ b/meta-digi-dey/recipes-core/glib-2.0/glib-2.0_2.64.5.bbappend @@ -0,0 +1,3 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" + +SRC_URI += " file://0001-gcancellable-Fix-minor-race-between-GCancellable-and.patch" From 225e6cafb5b78421d8a1058187e33c514089a8c2 Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Wed, 18 Aug 2021 14:11:42 +0200 Subject: [PATCH 11/70] mca-tool: update to v1.25 Includes minor improvements https://onedigi.atlassian.net/browse/CC6UL-1218 Signed-off-by: Gabriel Valcazar --- .../mca/{mca-tool_1.24.bb => mca-tool_1.25.bb} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename meta-digi-arm/recipes-digi/mca/{mca-tool_1.24.bb => mca-tool_1.25.bb} (62%) diff --git a/meta-digi-arm/recipes-digi/mca/mca-tool_1.24.bb b/meta-digi-arm/recipes-digi/mca/mca-tool_1.25.bb similarity index 62% rename from meta-digi-arm/recipes-digi/mca/mca-tool_1.24.bb rename to meta-digi-arm/recipes-digi/mca/mca-tool_1.25.bb index 5db9fd18f..be8e10a36 100644 --- a/meta-digi-arm/recipes-digi/mca/mca-tool_1.24.bb +++ b/meta-digi-arm/recipes-digi/mca/mca-tool_1.25.bb @@ -8,13 +8,13 @@ PKGNAME = "mca_tool" # ARM tarball SRC_URI_arm = "${DIGI_PKG_SRC}/${PKGNAME}-${PV}-${TUNE_ARCH}.tar.gz;name=arm" -SRC_URI[arm.md5sum] = "bbeded0a955a026d302cd4ee212d920e" -SRC_URI[arm.sha256sum] = "33de60f59bfa3e4b867bd872f05413a823852a1e33b21efcddd714454978bb9a" +SRC_URI[arm.md5sum] = "ffa8967cb9b684f3846b641a5d57b8f6" +SRC_URI[arm.sha256sum] = "057c289990d79f0b749e9d0d7af2570332e9215e697de75dc6851d89bdd61dff" # AARCH64 tarball SRC_URI_aarch64 = "${DIGI_PKG_SRC}/${PKGNAME}-${PV}-${TUNE_ARCH}.tar.gz;name=aarch64" -SRC_URI[aarch64.md5sum] = "cf64de7f5aad9cd6a102afd18aebd8bb" -SRC_URI[aarch64.sha256sum] = "c4652b8c0dd54315d7890c47798199948ea595a7dea8de5b6d68a1bfd3853557" +SRC_URI[aarch64.md5sum] = "12033830965f2861628461c612a7604e" +SRC_URI[aarch64.sha256sum] = "2467e426c6a4e6b89f4aaced846c1f52787e130f16ffb62e6f046bea7bc4f21f" S = "${WORKDIR}/${PKGNAME}-${PV}" From 53759cd29cfdfd66042ac00ab1be88f7faa0b79a Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Wed, 25 Aug 2021 11:45:40 +0200 Subject: [PATCH 12/70] recovery: check variable returned by uboot_getenv() is not NULL The use of this function, which is a wrapper over libuboot_get_env(), requires checking if the returned string is NULL. Manipulations of such string without checking whether it's NULL may lead to segfault errors. This was seen during firmware update on a device that didn't have the 'dualboot' variable set. Reported-by: Chandrababu Pigilam Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7645 (cherry picked from commit 8a4484bbd69d43fcea36fc73322f5a41e740565c) --- .../recovery/recovery-utils/recovery-utils/lib/recovery.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c index 6781b8930..d053a932c 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c @@ -439,7 +439,7 @@ static int parse_nand_partition_info(char **parts, char **encrypted, unsigned ch /* Parse mtdparts for all partition info */ ret = uboot_getenv("mtdparts", &var); - if (ret) { + if (ret || !var) { fprintf(stderr, "Error: getenv 'mtdparts'\n"); return ret; } @@ -978,6 +978,10 @@ int is_dualboot_enabled (void) return 0; } + /* Consider dualboot not enabled if variable doesn't exist */ + if (!var) + return 0; + /* Is dualboot enabled */ if (!strcmp(var, "no")) ret = 0; From 846bccc8bff0f8ebdea7a7114ba1aa3fd132a7cd Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Wed, 25 Aug 2021 12:11:59 +0200 Subject: [PATCH 13/70] recovery: rework is_dualboot_enabled() function - The function is only used internally in this file, so make it static. - Convert the function from 'int' to 'bool', since no other values are evaluated. - Only return true if the variable 'dualboot' is set to 'yes'. Before, the function returned true if 'dualboot' was different than 'no'. Signed-off-by: Hector Palacios (cherry picked from commit 9a519570ba79f4336322867b2f1484694d8b7a60) --- .../recovery-utils/include/recovery.h | 7 --- .../recovery-utils/lib/recovery.c | 56 +++++++++---------- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h index a94551a4c..e73a86951 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h @@ -70,11 +70,4 @@ int set_encryption_key(char *key, unsigned char force); */ int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force); -/* - * Check if device has dualboot enabled. - * - * Return: 1 if enabled and 0 if disabled, -1 on error when reading the environment - */ -int is_dualboot_enabled(void); - #endif /* RECOVERY_H */ diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c index d053a932c..8e91a96ce 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c @@ -19,6 +19,7 @@ #define _GNU_SOURCE /* For GNU version of basename */ +#include #include #include #include @@ -72,6 +73,32 @@ static char *emmc_parts_blacklist[] = { static char *rootfs[] = { "rootfs", NULL }; +/* + * Function: is_device_closed + * Description: check if the device is in dualboot mode + */ +static bool is_dualboot_enabled(void) +{ + const char *var; + bool ret = false; + + /* Parse dualboot */ + if (uboot_getenv("dualboot", &var)) { + fprintf(stderr, "Error: getenv 'dualboot'\n"); + return false; + } + + /* Consider dualboot not enabled if variable doesn't exist */ + if (!var) + return false; + + /* Is dualboot enabled */ + if (!strcmp(var, "yes")) + ret = true; + + return ret; +} + /* * Function: append_recovery_command * Description: append configuration to the 'recovery_command' variable @@ -961,32 +988,3 @@ err: return ret < 0 ? -1 : ret; } - -/* - * Function: is_device_closed - * Description: check if the device is in dualboot mode - */ -int is_dualboot_enabled (void) -{ - const char *var; - int ret; - - /* Parse dualboot */ - ret = uboot_getenv("dualboot", &var); - if (ret) { - fprintf(stderr, "Error: getenv 'dualboot'\n"); - return 0; - } - - /* Consider dualboot not enabled if variable doesn't exist */ - if (!var) - return 0; - - /* Is dualboot enabled */ - if (!strcmp(var, "no")) - ret = 0; - else - ret = 1; - - return ret; -} From c93945c9950d7e1382dad2f8ed6d823a648e5ed5 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Wed, 25 Aug 2021 12:16:01 +0200 Subject: [PATCH 14/70] recovery: [cosmetic] replace whitespaces with tabs where appropriate Signed-off-by: Hector Palacios (cherry picked from commit f806979c8454849322c9706a0c8721df969c47be) --- .../recovery-utils/lib/recovery.c | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c index 8e91a96ce..2af9c348f 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c @@ -332,7 +332,7 @@ static int is_subset(char **subset, char **set) * Description: convert a list into a NULL-terminated string array, while checking against a blacklist and a superset */ static int list_to_array(char *list, char **array, char **blacklist, - char **superset, const char *delim, unsigned char limit) + char **superset, const char *delim, unsigned char limit) { char *tmp = NULL; char *entry = NULL; @@ -618,10 +618,10 @@ int update_firmware(const char *swu_path) int ret = -1; /* Check if we are in dualboot mode */ - if (is_dualboot_enabled()) { - fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); - goto err; - } + if (is_dualboot_enabled()) { + fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); + goto err; + } /* Verify input parameter */ if (!swu_path) { @@ -664,10 +664,10 @@ int reboot_recovery(unsigned int reboot_timeout) int ret = 0; /* Check if we are in dualboot mode */ - if (is_dualboot_enabled()) { - fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); - goto err; - } + if (is_dualboot_enabled()) { + fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); + goto err; + } sync(); @@ -714,10 +714,10 @@ int set_encryption_key(char *key, unsigned char force) unsigned char i = 0; /* Check if we are in dualboot mode */ - if (is_dualboot_enabled()) { - fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); - return ret; - } + if (is_dualboot_enabled()) { + fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); + return ret; + } /* Initialize arrays */ parts[0] = NULL; @@ -773,10 +773,8 @@ int set_encryption_key(char *key, unsigned char force) } } - key_cmd = - calloc(1, - strlen("encryption_key=") + - (generate_random_key ? 0 : strlen(key)) + 1); + key_cmd = calloc(1, strlen("encryption_key=") + + (generate_random_key ? 0 : strlen(key)) + 1); if (!key_cmd) { fprintf(stderr, "Error: calloc 'key_cmd'\n"); goto err; @@ -820,10 +818,10 @@ int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force int ret; /* Check if we are in dualboot mode */ - if (is_dualboot_enabled()) { - fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); - return 1; - } + if (is_dualboot_enabled()) { + fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); + return 1; + } /* If both lists are empty, we have nothing to do */ if (!to_encrypt && !to_unencrypt) From 90706f5d39a9abda51c7eb1c5d3536919d14ce98 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Wed, 25 Aug 2021 12:30:44 +0200 Subject: [PATCH 15/70] recovery: free strings returned by uboot_getenv() The function uboot_getenv() is a wrapper over libuboot_get_env() and requires that the returned strings are freed when no longer in use. Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7645 (cherry picked from commit 27ce7a4f20a5ee17b2db49af0231f83a689f4f23) --- .../recovery/recovery-utils/recovery-utils/lib/recovery.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c index 2af9c348f..b807da11a 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c @@ -96,6 +96,7 @@ static bool is_dualboot_enabled(void) if (!strcmp(var, "yes")) ret = true; + free(var); return ret; } @@ -148,6 +149,7 @@ static int append_recovery_command(const char *value) free(new_recovery_cmd); err: + free(old_recovery_cmd); return ret ? -1 : 0; } @@ -522,6 +524,7 @@ static int parse_nand_partition_info(char **parts, char **encrypted, unsigned ch err: if (tmp) free(tmp); + free(var); /* NULL-terminate the arrays */ parts[i] = NULL; @@ -588,6 +591,7 @@ err: pclose(fp); if (tmp) free(tmp); + free(var); /* NULL-terminate the parts array */ parts[i] = NULL; From 9352fc1395ce80c64c7bbb8264439fb8f8ac2042 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 7 Sep 2021 11:01:29 +0200 Subject: [PATCH 16/70] digi: [cosmetic] remove final slash from Digi remotes and move it to recipes Signed-off-by: Hector Palacios --- meta-digi-arm/conf/layer.conf | 4 ++-- meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc | 2 +- .../recipes-digi/trustfence/trustfence-sign-tools_git.bb | 2 +- .../kernel-module-qualcomm/kernel-module-qualcomm.bb | 2 +- meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc | 2 +- meta-digi-dey/recipes-digi/dey-examples/dey-examples-src.inc | 2 +- meta-digi-dey/recipes-digi/libdigiapix/libdigiapix_git.bb | 2 +- meta-digi-dey/recipes-support/libsoc/libsoc_git.bbappend | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/meta-digi-arm/conf/layer.conf b/meta-digi-arm/conf/layer.conf index 0abac4a7c..b8fa17dd4 100644 --- a/meta-digi-arm/conf/layer.conf +++ b/meta-digi-arm/conf/layer.conf @@ -33,8 +33,8 @@ DIGI_OPEN_EULA_FILE = "${LAYERDIR}/DIGI_OPEN_EULA" # Additional license directories LICENSE_PATH += "${LAYERDIR}/custom-licenses" -DIGI_LOG_GIT ?= "git://log-sln-git.digi.com/" -DIGI_MTK_GIT ?= "git://stash.digi.com/" +DIGI_LOG_GIT ?= "git://log-sln-git.digi.com" +DIGI_MTK_GIT ?= "git://stash.digi.com" DIGI_GIT ?= "${DIGI_LOG_GIT}" DIGI_PKG_SRC ?= "https://ftp1.digi.com/support/digiembeddedyocto/source" diff --git a/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc b/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc index 3732e1caa..119565966 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc +++ b/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc @@ -15,7 +15,7 @@ PROVIDES += "u-boot" S = "${WORKDIR}/git" # Select internal or Github U-Boot repo -UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}u-boot-denx.git', '${DIGI_GITHUB_GIT}/u-boot.git;protocol=https', d)}" +UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}/u-boot-denx.git', '${DIGI_GITHUB_GIT}/u-boot.git;protocol=https', d)}" SRC_URI = " \ ${UBOOT_GIT_URI};branch=${SRCBRANCH} \ diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb index 135f203bc..51a5f54f6 100644 --- a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb +++ b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb @@ -12,7 +12,7 @@ SRCREV = "${AUTOREV}" S = "${WORKDIR}" # Select internal or Github U-Boot repo -UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}u-boot-denx.git', '${DIGI_GITHUB_GIT}/u-boot.git;protocol=https', d)}" +UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}/u-boot-denx.git', '${DIGI_GITHUB_GIT}/u-boot.git;protocol=https', d)}" SRC_URI = " \ ${UBOOT_GIT_URI};branch=${SRCBRANCH} \ diff --git a/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb b/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb index 73d8df971..d3543ea9c 100644 --- a/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb +++ b/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb @@ -11,7 +11,7 @@ PV = "v4.0.11.213X" SRCBRANCH = "qca65X4/master" SRCREV = "${AUTOREV}" -QCOM_GIT_URI = "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_MTK_GIT}linux/qcacld-2.0.git;protocol=ssh', '${DIGI_GITHUB_GIT}/qcacld-2.0.git;protocol=https', d)}" +QCOM_GIT_URI = "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_MTK_GIT}/linux/qcacld-2.0.git;protocol=ssh', '${DIGI_GITHUB_GIT}/qcacld-2.0.git;protocol=https', d)}" SRC_URI = " \ ${QCOM_GIT_URI};branch=${SRCBRANCH} \ diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc b/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc index 43449189a..7afefa3ae 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc @@ -8,7 +8,7 @@ SRCBRANCH = "v5.4.70/master" SRCREV = "${AUTOREV}" # Select internal or Github Linux repo -LINUX_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}linux-2.6.git', '${DIGI_GITHUB_GIT}/linux.git;protocol=https', d)}" +LINUX_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}/linux-2.6.git', '${DIGI_GITHUB_GIT}/linux.git;protocol=https', d)}" SRC_URI = "${LINUX_GIT_URI};branch=${SRCBRANCH}" S = "${WORKDIR}/git" diff --git a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-src.inc b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-src.inc index 8254dc160..1117c0537 100644 --- a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-src.inc +++ b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-src.inc @@ -3,7 +3,7 @@ SRCBRANCH = "master" SRCREV = "${AUTOREV}" -DEY_EXAMPLES_STASH = "${DIGI_MTK_GIT}dey/dey-examples.git;protocol=ssh" +DEY_EXAMPLES_STASH = "${DIGI_MTK_GIT}/dey/dey-examples.git;protocol=ssh" DEY_EXAMPLES_GITHUB = "${DIGI_GITHUB_GIT}/dey-examples.git;protocol=https" DEY_EXAMPLES_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DEY_EXAMPLES_STASH}', '${DEY_EXAMPLES_GITHUB}', d)}" diff --git a/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix_git.bb b/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix_git.bb index bf7d8bef8..ec957dd93 100644 --- a/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix_git.bb +++ b/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix_git.bb @@ -11,7 +11,7 @@ DEPENDS = "libsoc libsocketcan libgpiod" SRCBRANCH ?= "master" SRCREV = "${AUTOREV}" -LIBDIGIAPIX_URI_STASH = "${DIGI_MTK_GIT}dey/libdigiapix.git;protocol=ssh" +LIBDIGIAPIX_URI_STASH = "${DIGI_MTK_GIT}/dey/libdigiapix.git;protocol=ssh" LIBDIGIAPIX_URI_GITHUB = "${DIGI_GITHUB_GIT}/libdigiapix.git;protocol=https" LIBDIGIAPIX_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${LIBDIGIAPIX_URI_STASH}', '${LIBDIGIAPIX_URI_GITHUB}', d)}" diff --git a/meta-digi-dey/recipes-support/libsoc/libsoc_git.bbappend b/meta-digi-dey/recipes-support/libsoc/libsoc_git.bbappend index 6d571ff9d..8c158739a 100644 --- a/meta-digi-dey/recipes-support/libsoc/libsoc_git.bbappend +++ b/meta-digi-dey/recipes-support/libsoc/libsoc_git.bbappend @@ -2,7 +2,7 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" -LIBSOC_URI_STASH = "${DIGI_MTK_GIT}dey/libsoc.git;protocol=ssh" +LIBSOC_URI_STASH = "${DIGI_MTK_GIT}/dey/libsoc.git;protocol=ssh" LIBSOC_URI_GITHUB = "git://github.com/jackmitch/libsoc.git;protocol=https" LIBSOC_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${LIBSOC_URI_STASH}', '${LIBSOC_URI_GITHUB}', d)}" From c33fc8a7fe03e11dcee5b228bb389bdbae59a0e2 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 7 Sep 2021 12:01:32 +0200 Subject: [PATCH 17/70] uboot/linux: fix build from internal MTK Digi git server Enabling DIGI_INTERNAL_GIT defaults to LOG server. The build from local MTK Digi server was broken. Fix uboot and linux recipes declaring different repo paths depending on whether the local remote is LOG or MTK. Signed-off-by: Hector Palacios --- meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc | 7 ++++++- .../recipes-digi/trustfence/trustfence-sign-tools_git.bb | 7 ++++++- meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc | 8 +++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc b/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc index 119565966..03d34678a 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc +++ b/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc @@ -15,7 +15,12 @@ PROVIDES += "u-boot" S = "${WORKDIR}/git" # Select internal or Github U-Boot repo -UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}/u-boot-denx.git', '${DIGI_GITHUB_GIT}/u-boot.git;protocol=https', d)}" +DIGI_LOG_REPO = "u-boot-denx.git" +DIGI_MTK_REPO = "uboot/u-boot-denx.git" +GITHUB_REPO = "u-boot.git" +UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , \ + oe.utils.conditional('DIGI_GIT', '${DIGI_LOG_GIT}', '${DIGI_GIT}/${DIGI_LOG_REPO}', '${DIGI_GIT}/${DIGI_MTK_REPO};protocol=https', d), \ + '${DIGI_GITHUB_GIT}/${GITHUB_REPO};protocol=https', d)}" SRC_URI = " \ ${UBOOT_GIT_URI};branch=${SRCBRANCH} \ diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb index 51a5f54f6..6281d19b5 100644 --- a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb +++ b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb @@ -12,7 +12,12 @@ SRCREV = "${AUTOREV}" S = "${WORKDIR}" # Select internal or Github U-Boot repo -UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}/u-boot-denx.git', '${DIGI_GITHUB_GIT}/u-boot.git;protocol=https', d)}" +DIGI_LOG_REPO = "u-boot-denx.git" +DIGI_MTK_REPO = "uboot/u-boot-denx.git" +GITHUB_REPO = "u-boot.git" +UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , \ + oe.utils.conditional('DIGI_GIT', '${DIGI_LOG_GIT}', '${DIGI_GIT}/${DIGI_LOG_REPO}', '${DIGI_GIT}/${DIGI_MTK_REPO};protocol=ssh', d), \ + '${DIGI_GITHUB_GIT}/${GITHUB_REPO};protocol=https', d)}" SRC_URI = " \ ${UBOOT_GIT_URI};branch=${SRCBRANCH} \ diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc b/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc index 7afefa3ae..bc8311738 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc @@ -8,7 +8,13 @@ SRCBRANCH = "v5.4.70/master" SRCREV = "${AUTOREV}" # Select internal or Github Linux repo -LINUX_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}/linux-2.6.git', '${DIGI_GITHUB_GIT}/linux.git;protocol=https', d)}" +DIGI_LOG_REPO = "linux-2.6.git" +DIGI_MTK_REPO = "linux/linux.git" +GITHUB_REPO = "linux.git" +LINUX_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , \ + oe.utils.conditional('DIGI_GIT', '${DIGI_LOG_GIT}', '${DIGI_GIT}/${DIGI_LOG_REPO}', '${DIGI_GIT}/${DIGI_MTK_REPO};protocol=ssh', d), \ + '${DIGI_GITHUB_GIT}/${GITHUB_REPO};protocol=https', d)}" + SRC_URI = "${LINUX_GIT_URI};branch=${SRCBRANCH}" S = "${WORKDIR}/git" From 91bfa01a52dfed6ccc6ac38035e0c6812179ab39 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 20 Aug 2021 13:46:54 +0200 Subject: [PATCH 18/70] udev: automount UBI volumes named "linux" or "recovery" Traditionally, platforms based on NAND, used one UBI volume per MTD partition. Now it's possible to use only one MTD partition containing many UBI volumes. Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7614 --- .../recipes-core/udev/udev-extraconf/automount.rules | 1 + .../udev/udev-extraconf/mount_digiparts.sh | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules b/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules index 22534848d..2bd4c6843 100644 --- a/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules +++ b/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules @@ -16,6 +16,7 @@ # Digi-mounted partitions: linux, update SUBSYSTEM=="block", ENV{ID_PART_ENTRY_NAME}=="linux*|update*", ACTION=="add", RUN+="/etc/udev/scripts/mount_digiparts.sh", GOTO="automount_rules_end" SUBSYSTEM=="mtd", ATTRS{name}=="linux*|update*", ACTION=="add", RUN+="/etc/udev/scripts/mount_digiparts.sh", GOTO="automount_rules_end" +SUBSYSTEM=="ubi", ATTRS{name}=="linux*|update*", ACTION=="add", RUN+="/etc/udev/scripts/mount_digiparts.sh", GOTO="automount_rules_end" # Avoid mounting recovery partition SUBSYSTEM=="block", ENV{ID_PART_ENTRY_NAME}=="recovery*", ACTION=="add", GOTO="automount_rules_end" diff --git a/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_digiparts.sh b/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_digiparts.sh index 08772a222..a7a706f53 100644 --- a/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_digiparts.sh +++ b/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_digiparts.sh @@ -22,6 +22,8 @@ if [ "${SUBSYSTEM}" = "block" ]; then elif [ "${SUBSYSTEM}" = "mtd" ]; then MTDN="$(echo ${DEVNAME} | cut -f 3 -d /)" PARTNAME="$(grep ${MTDN} /proc/mtd | sed -ne 's,.*"\(.*\)",\1,g;T;p')" +elif [ "${SUBSYSTEM}" = "ubi" ]; then + PARTNAME="$(cat /sys/${DEVPATH}/name)" fi MOUNT_PARAMS="-o silent" @@ -89,4 +91,12 @@ elif [ "${SUBSYSTEM}" = "mtd" ]; then logger -t udev "ERROR: Could not mount '${PARTNAME}' partition, volume not found" rmdir --ignore-fail-on-non-empty ${MOUNTPOINT} fi +elif [ "${SUBSYSTEM}" = "ubi" ]; then + # In the case of a 'system' partition with many UBI volumes, the device + # is always /dev/ubi0 + # Mount the volume. + if ! mount -t ubifs ubi0:${PARTNAME} ${MOUNT_PARAMS} ${MOUNTPOINT}; then + logger -t udev "ERROR: Could not mount '${PARTNAME}' volume" + rmdir --ignore-fail-on-non-empty ${MOUNTPOINT} + fi fi From f00ce5ca9b118df6fb318f63112a078dd671ea41 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Mon, 23 Aug 2021 13:26:24 +0200 Subject: [PATCH 19/70] u-boot-dey: add support for dualboot to boot scripts The support for dualboot was integrated on meta-digi-dualboot layer, but it really depends only on environment variable 'dualboot' so we'd better integrate the support on the scripts in meta-digi, to avoid synchonization problems between both layers. This also allows to be able to easily enable dualboot in U-Boot with the variable, without needing to update the script on the linux partition. Signed-off-by: Hector Palacios --- .../u-boot/u-boot-dey/ccimx6qpsbc/boot.txt | 75 +++++++++++++--- .../u-boot/u-boot-dey/ccimx6sbc/boot.txt | 75 +++++++++++++--- .../u-boot/u-boot-dey/ccimx6ulsbc/boot.txt | 42 ++++++++- .../u-boot-dey/ccimx6ulstarter/boot.txt | 42 ++++++++- .../u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt | 88 ++++++++++++++++--- .../u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt | 88 ++++++++++++++++--- .../u-boot-dey/ccimx8x-sbc-express/boot.txt | 83 ++++++++++++++--- .../u-boot-dey/ccimx8x-sbc-pro/boot.txt | 83 ++++++++++++++--- 8 files changed, 496 insertions(+), 80 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt index 2ae28ea4a..5dedaa36d 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt @@ -25,19 +25,70 @@ else fi fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt index e15593d2c..12b927abd 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt @@ -53,19 +53,70 @@ else fi fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt index 03b3f7929..b3ddefaf9 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt @@ -37,11 +37,45 @@ else fi fi -if test "${mtdbootpart}" = "recovery"; then - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${mtdbootpart}" = "linux_a"; then + setenv mtdbootpart linux_b + setenv mtdlinuxindex ${mtdlinux_b_index} + setenv mtdrootfsindex ${mtdrootfs_b_index} + else + setenv mtdbootpart linux_a + setenv mtdlinuxindex ${mtdlinux_a_index} + setenv mtdrootfsindex ${mtdrootfs_a_index} + fi + setenv active_system ${mtdbootpart} + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + setenv mtdbootpart ${active_system} + setenv mtdlinuxindex ${mtdlinux_a_index} + setenv mtdrootfsindex ${mtdrootfs_a_index} + else + echo "Booting from system B" + setenv mtdbootpart ${active_system} + setenv mtdlinuxindex ${mtdlinux_b_index} + setenv mtdrootfsindex ${mtdrootfs_b_index} + fi + fi else - true + if test "${mtdbootpart}" = "recovery"; then + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + true + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux nand ${mtdbootpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt index 31825889d..84da4dfde 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt @@ -37,11 +37,45 @@ else fi fi -if test "${mtdbootpart}" = "recovery"; then - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${mtdbootpart}" = "linux_a"; then + setenv mtdbootpart linux_b + setenv mtdlinuxindex ${mtdlinux_b_index} + setenv mtdrootfsindex ${mtdrootfs_b_index} + else + setenv mtdbootpart linux_a + setenv mtdlinuxindex ${mtdlinux_a_index} + setenv mtdrootfsindex ${mtdrootfs_a_index} + fi + setenv active_system ${mtdbootpart} + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + setenv mtdbootpart ${active_system} + setenv mtdlinuxindex ${mtdlinux_a_index} + setenv mtdrootfsindex ${mtdrootfs_a_index} + else + echo "Booting from system B" + setenv mtdbootpart ${active_system} + setenv mtdlinuxindex ${mtdlinux_b_index} + setenv mtdrootfsindex ${mtdrootfs_b_index} + fi + fi else - true + if test "${mtdbootpart}" = "recovery"; then + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + true + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux nand ${mtdbootpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt index ff9e9e163..1513df9e9 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt @@ -6,6 +6,19 @@ setenv ORIG_overlays ${overlays} setenv ORIG_extra_bootargs ${extra_bootargs} +# Set SOC type to "imx8mm" if not already defined by U-Boot +if test ! -n "${soc_type}"; then + setenv soc_type "imx8mm" +fi + +# Reset overlays when using dualboot mode, because we need to +# save the environment in case of an installation fall back. +if test "${dual_boot}" = "yes"; then + if test -n "${overlays}"; then + setenv overlays + fi +fi + # # Determine overlays to apply depending on the hardware capabilities # described by the HWID, SOM version, and carrier board version. @@ -28,19 +41,70 @@ if test -n "${module_ram}"; then fi fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt index 38530dcaf..7b7df5917 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt @@ -6,6 +6,19 @@ setenv ORIG_overlays ${overlays} setenv ORIG_extra_bootargs ${extra_bootargs} +# Set SOC type to "imx8mn" if not already defined by U-Boot +if test ! -n "${soc_type}"; then + setenv soc_type "imx8mn" +fi + +# Reset overlays when using dualboot mode, because we need to +# save the environment in case of an installation fall back. +if test "${dual_boot}" = "yes"; then + if test -n "${overlays}"; then + setenv overlays + fi +fi + # # Determine overlays to apply depending on the hardware capabilities # described by the HWID, SOM version, and carrier board version. @@ -37,19 +50,70 @@ if test "${board_version}" -lt "3"; then setenv overlays _ov_board_v1-v2_ccimx8mn-dvk.dtbo,${overlays} fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt index 278914bcd..b99b3378b 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt @@ -11,6 +11,14 @@ if test ! -n "${soc_type}"; then setenv soc_type "imx8qxp" fi +# Reset overlays when using dualboot mode, because we need to +# save the environment in case of an installation fall back. +if test "${dual_boot}" = "yes"; then + if test -n "${overlays}"; then + setenv overlays + fi +fi + # # Determine overlays to apply depending on the hardware capabilities # described by the HWID, SOM version, and carrier board version. @@ -45,19 +53,70 @@ if test "${soc_type}" = "imx8qxp"; then setenv overlays _ov_som_quad_ccimx8x.dtbo,${overlays} fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt index 481c8cc2d..759308337 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt @@ -11,6 +11,14 @@ if test ! -n "${soc_type}"; then setenv soc_type "imx8qxp" fi +# Reset overlays when using dualboot mode, because we need to +# save the environment in case of an installation fall back. +if test "${dual_boot}" = "yes"; then + if test -n "${overlays}"; then + setenv overlays + fi +fi + # # Determine overlays to apply depending on the hardware capabilities # described by the HWID, SOM version, and carrier board version. @@ -50,19 +58,70 @@ if test "${board_version}" -le "3"; then setenv overlays _ov_board_v1-v3_ccimx8x-sbc-pro.dtbo,${overlays} fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} From fcd3791535c564943af8f0fbb21d3f697b71c489 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Mon, 23 Aug 2021 13:34:11 +0200 Subject: [PATCH 20/70] ccimx6ul: boot: set 'rootfsvol' variable for dualboot Set the new variable 'rootfsvol' to rootfs_a or rootfs_b when dualboot is enabled, to cover the case where the devices uses the 'system' partition with different UBI volumes. Signed-off-by: Hector Palacios --- .../recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt | 4 ++++ .../recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt index b3ddefaf9..9d931bd24 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt @@ -47,10 +47,12 @@ if test "${dualboot}" = "yes"; then setenv mtdbootpart linux_b setenv mtdlinuxindex ${mtdlinux_b_index} setenv mtdrootfsindex ${mtdrootfs_b_index} + setenv rootfsvol ${rootfsvol_b} else setenv mtdbootpart linux_a setenv mtdlinuxindex ${mtdlinux_a_index} setenv mtdrootfsindex ${mtdrootfs_a_index} + setenv rootfsvol ${rootfsvol_a} fi setenv active_system ${mtdbootpart} setenv upgrade_available @@ -62,11 +64,13 @@ if test "${dualboot}" = "yes"; then setenv mtdbootpart ${active_system} setenv mtdlinuxindex ${mtdlinux_a_index} setenv mtdrootfsindex ${mtdrootfs_a_index} + setenv rootfsvol ${rootfsvol_a} else echo "Booting from system B" setenv mtdbootpart ${active_system} setenv mtdlinuxindex ${mtdlinux_b_index} setenv mtdrootfsindex ${mtdrootfs_b_index} + setenv rootfsvol ${rootfsvol_b} fi fi else diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt index 84da4dfde..fab05eb51 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt @@ -47,10 +47,12 @@ if test "${dualboot}" = "yes"; then setenv mtdbootpart linux_b setenv mtdlinuxindex ${mtdlinux_b_index} setenv mtdrootfsindex ${mtdrootfs_b_index} + setenv rootfsvol ${rootfsvol_b} else setenv mtdbootpart linux_a setenv mtdlinuxindex ${mtdlinux_a_index} setenv mtdrootfsindex ${mtdrootfs_a_index} + setenv rootfsvol ${rootfsvol_a} fi setenv active_system ${mtdbootpart} setenv upgrade_available @@ -62,11 +64,13 @@ if test "${dualboot}" = "yes"; then setenv mtdbootpart ${active_system} setenv mtdlinuxindex ${mtdlinux_a_index} setenv mtdrootfsindex ${mtdrootfs_a_index} + setenv rootfsvol ${rootfsvol_a} else echo "Booting from system B" setenv mtdbootpart ${active_system} setenv mtdlinuxindex ${mtdlinux_b_index} setenv mtdrootfsindex ${mtdrootfs_b_index} + setenv rootfsvol ${rootfsvol_b} fi fi else From f46851e2450af4d7657d65bd993317c4bf7beb49 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 24 Aug 2021 10:04:02 +0200 Subject: [PATCH 21/70] uboot: ccimx6ul: add ubisysvols support to uuu install script With U-Boot supporting the creation of mtdparts and UBI volumes depending on the value of variable 'ubisysvols', adapt the install script to make use of those to generate a partition table and UBI volumes accordingly. This can be triggered with new option '-b'. Signed-off-by: Hector Palacios --- .../ccimx6ul/install_linux_fw_uuu.sh | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh index d093a4792..3c0ddcfa6 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh @@ -29,6 +29,9 @@ show_usage() echo "Usage: $0 [options]" echo "" echo " Options:" + echo " -b Use one MTD 'system' partition to hold system UBI volumes (linux," + echo " recovery, rootfs, update)." + echo " Default is the opposite: one UBI volume per MTD partition." echo " -h Show this help." echo " -i Image name that prefixes the image filenames, such as 'dey-image-qt', " echo " 'dey-image-webkit', 'core-image-base'..." @@ -67,9 +70,10 @@ echo "############################################################" # Command line admits the following parameters: # -u # -i -while getopts 'hi:nu:' c +while getopts 'bhi:nu:' c do case $c in + b) UBISYSVOLS=true ;; h) show_usage ;; i) IMAGE_NAME=${OPTARG} ;; n) NOWAIT=true ;; @@ -218,6 +222,18 @@ sleep 3 # Set fastboot buffer address to $loadaddr uuu fb: ucmd setenv fastboot_buffer \${loadaddr} +# Set up ubisysvols if so requested +if [ "${UBISYSVOLS}" = true ]; then + uuu fb: ucmd setenv ubisysvols yes +fi + +# Create partition table +uuu "fb[-t 10000]:" ucmd run partition_nand_linux + +if [ "${UBISYSVOLS}" = true ]; then + uuu "fb[-t 10000]:" ucmd run ubivolscript +fi + # Update Linux part_update "linux" "${INSTALL_LINUX_FILENAME}" 15000 @@ -227,8 +243,10 @@ part_update "recovery" "${INSTALL_RECOVERY_FILENAME}" 15000 # Update Rootfs part_update "rootfs" "${INSTALL_ROOTFS_FILENAME}" 90000 -# Erase the 'Update' partition -uuu fb: ucmd nand erase.part update +if [ ! "${UBISYSVOLS}" = true ]; then + # Erase the 'Update' partition + uuu fb: ucmd nand erase.part update +fi # Configure u-boot to boot into recovery mode uuu fb: ucmd setenv boot_recovery yes From e380377310d36aecd0002638be125fc5804a6da9 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 24 Aug 2021 11:22:51 +0200 Subject: [PATCH 22/70] uboot: exit on error on uuu install script Exit on error to prevent continuation of programming when there was an issue. Signed-off-by: Hector Palacios --- .../u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh | 3 +++ .../u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh | 3 +++ .../u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh | 3 +++ 3 files changed, 9 insertions(+) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh index 3c0ddcfa6..5179970c5 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh @@ -18,6 +18,9 @@ # U-Boot script for installing Linux images created by Yocto # +# Exit on any error +set -e + # Parse uuu cmd output getenv() { diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh index 3543c2d77..401ba22c0 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh @@ -18,6 +18,9 @@ # U-Boot script for installing Linux images created by Yocto # +# Exit on any error +set -e + # Parse uuu cmd output getenv() { diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh index d86079624..6f3316ba6 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh @@ -18,6 +18,9 @@ # U-Boot script for installing Linux images created by Yocto # +# Exit on any error +set -e + # Parse uuu cmd output getenv() { From 13df57c1fc5c30e3f3776269cf90a8db7a856bf5 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 26 Aug 2021 14:16:53 +0200 Subject: [PATCH 23/70] ccimx6ul: add support for ubisysvols on SD/USB install scripts The script preserves the current value of env variable 'ubisysvols' so that the new partition script generates the appropriate partition table before proceeding with the update operations. If using a UBI volumes layout, the script will not erase the partitions. Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7614 --- .../ccimx6ul/install_linux_fw_sd.txt | 23 +++++++++++++++---- .../ccimx6ul/install_linux_fw_usb.txt | 23 +++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt index 68c043aa7..ac0398c4c 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt @@ -121,6 +121,8 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults +# - Restore 'ubisysvols' if previously set +# - Run 'partition_nand_linux' script to re-partition the NAND if needed # - Save the environment # - Update the 'linux' partition # - Update the 'recovery' partition @@ -130,13 +132,20 @@ fi # - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; + setenv ubisysvols ${ubisysvols}; + run partition_nand_linux; saveenv; + if test -n \$\{ubisysvols\} && test \$\{ubisysvols\} = yes; then + run ubivolscript; + fi; echo \"\"; echo \"\"; echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; echo \"\"; echo \"\"; - nand erase.part linux; + if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then + nand erase.part linux; + fi; update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux partition!\"; @@ -149,7 +158,9 @@ setenv bootcmd " echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; echo \"\"; echo \"\"; - nand erase.part recovery; + if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then + nand erase.part recovery; + fi; update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; if test \$? -eq 1; then echo \"[ERROR] Failed to update recovery partition!\"; @@ -162,7 +173,9 @@ setenv bootcmd " echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; echo \"\"; echo \"\"; - nand erase.part rootfs; + if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then + nand erase.part rootfs; + fi; update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs partition!\"; @@ -171,7 +184,9 @@ setenv bootcmd " exit; fi; echo \"\"; - nand erase.part update; + if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then + nand erase.part update; + fi; setenv boot_recovery yes; setenv recovery_command wipe_update; saveenv; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt index b3b30ea60..da5cda0b8 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt @@ -121,6 +121,8 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults +# - Restore 'ubisysvols' if previously set +# - Run 'partition_nand_linux' script to re-partition the NAND if needed # - Save the environment # - Update the 'linux' partition # - Update the 'recovery' partition @@ -130,14 +132,21 @@ fi # - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; + setenv ubisysvols ${ubisysvols}; + run partition_nand_linux; saveenv; + if test -n \$\{ubisysvols\} && test \$\{ubisysvols\} = yes; then + run ubivolscript; + fi; usb start; echo \"\"; echo \"\"; echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; echo \"\"; echo \"\"; - nand erase.part linux; + if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then + nand erase.part linux; + fi; update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux partition!\"; @@ -150,7 +159,9 @@ setenv bootcmd " echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; echo \"\"; echo \"\"; - nand erase.part recovery; + if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then + nand erase.part recovery; + fi; update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; if test \$? -eq 1; then echo \"[ERROR] Failed to update recovery partition!\"; @@ -163,7 +174,9 @@ setenv bootcmd " echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; echo \"\"; echo \"\"; - nand erase.part rootfs; + if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then + nand erase.part rootfs; + fi; update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs partition!\"; @@ -172,7 +185,9 @@ setenv bootcmd " exit; fi; echo \"\"; - nand erase.part update; + if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then + nand erase.part update; + fi; setenv boot_recovery yes; setenv recovery_command wipe_update; saveenv; From ec08b1277adc99485cdf50ef18277af0f30983b6 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 27 Aug 2021 12:31:39 +0200 Subject: [PATCH 24/70] recovery-initramfs-init: add support for ubisysvols Adapt the format_ubi_volume() function to wipe out UBI volumes instead of formatting MTD partitions. Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7614 --- .../recovery-initramfs-init | 78 ++++++++++++------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init index e94758352..a74ce2914 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init @@ -231,38 +231,56 @@ format_ubi_volume() { psplash_message "Formatting '${1}' partition..." psplash_progress "0" - # Find the MTD partition. - local mtd_num="$(sed -ne "s/mtd\([0-9]\+\):.*\<${1}\>.*/\1/g;T;p" /proc/mtd 2>/dev/null)" - if [ -z "${mtd_num}" ]; then - quit_with_error "Could not find MTD partition for volume '${1}'" - else - # Umount in case partition is mounted, ignore errors. - if grep -qs "${1}" /proc/mounts; then - local path="$(sed -ne "s/.*:${1} \(.*\) ubifs.*/\1/g;T;p" /proc/mounts 2>/dev/null)" - umount "${path}" >/dev/null 2>&1 - fi - ubidetach -p "/dev/mtd${mtd_num}" >/dev/null 2>&1 - # Format MTD partition. - if ! ubiformat "/dev/mtd${mtd_num}" -q -y; then - quit_with_error "Error erasing '/dev/mtd${mtd_num}' block" - fi - psplash_progress "50" - # Attach and get UBI device number - local dev_number="$(ubiattach -p /dev/mtd${mtd_num} 2>/dev/null | sed -ne 's,.*device number \([0-9]\).*,\1,g;T;p' 2>/dev/null)" - # Create UBI Vol. - ubimkvol "/dev/ubi${dev_number}" -m -N "${1}" >/dev/null 2>&1 - if [ "$?" = "0" ]; then - # Configure the empty UBIFS partition to use ZLIB - [ "${1}" = "update" ] && UBIFS_COMPRESSION="-x zlib" + # Read the ubisysvols variable. + read_uboot_var ubisysvols ubisysvols - volid="$(ubinfo "/dev/ubi${dev_number}" -N "${1}" | sed -ne 's,Volume ID:[[:blank:]]\+\([0-9]\+\)[[:blank:]]\+.*,\1,g;T;p')" - mkfs.ubifs ${UBIFS_COMPRESSION} -F /dev/ubi${dev_number}_${volid} - psplash_progress "100" - log "Partition '${1}' successfully erased!" - # Detach MTD partition. - ubidetach -p "/dev/mtd${mtd_num}" >/dev/null 2>&1 + if [ "${ubisysvols}" = "yes" ]; then + # Find the volume number associated to the volume name + for d in /dev/ubi0_*; do + volname="$(ubinfo ${d} | grep ^Name | awk '{print $(2)}')" + if [ "${volname}" = "${1}" ]; then + # Find mountpoint + mountpoint="$(mount | grep ubi0:${1} | awk '{print $(3) }')" + umount ${mountpoint} 2> /dev/null + # Wipe out volume + ubiupdatevol ${d} -t + fi + done + psplash_progress "100" + else + # Find the MTD partition. + local mtd_num="$(sed -ne "s/mtd\([0-9]\+\):.*\<${1}\>.*/\1/g;T;p" /proc/mtd 2>/dev/null)" + if [ -z "${mtd_num}" ]; then + quit_with_error "Could not find MTD partition for volume '${1}'" else - quit_with_error "Error creating '${1}' UBI volume" + # Umount in case partition is mounted, ignore errors. + if grep -qs "${1}" /proc/mounts; then + local path="$(sed -ne "s/.*:${1} \(.*\) ubifs.*/\1/g;T;p" /proc/mounts 2>/dev/null)" + umount "${path}" >/dev/null 2>&1 + fi + ubidetach -p "/dev/mtd${mtd_num}" >/dev/null 2>&1 + # Format MTD partition. + if ! ubiformat "/dev/mtd${mtd_num}" -q -y; then + quit_with_error "Error erasing '/dev/mtd${mtd_num}' block" + fi + psplash_progress "50" + # Attach and get UBI device number + local dev_number="$(ubiattach -p /dev/mtd${mtd_num} 2>/dev/null | sed -ne 's,.*device number \([0-9]\).*,\1,g;T;p' 2>/dev/null)" + # Create UBI Vol. + ubimkvol "/dev/ubi${dev_number}" -m -N "${1}" >/dev/null 2>&1 + if [ "$?" = "0" ]; then + # Configure the empty UBIFS partition to use ZLIB + [ "${1}" = "update" ] && UBIFS_COMPRESSION="-x zlib" + + volid="$(ubinfo "/dev/ubi${dev_number}" -N "${1}" | sed -ne 's,Volume ID:[[:blank:]]\+\([0-9]\+\)[[:blank:]]\+.*,\1,g;T;p')" + mkfs.ubifs ${UBIFS_COMPRESSION} -F /dev/ubi${dev_number}_${volid} + psplash_progress "100" + log "Partition '${1}' successfully erased!" + # Detach MTD partition. + ubidetach -p "/dev/mtd${mtd_num}" >/dev/null 2>&1 + else + quit_with_error "Error creating '${1}' UBI volume" + fi fi fi } From 6910a11eab3b0fa3d9ae6b6df6e5b89b4be18735 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 27 Aug 2021 13:16:07 +0200 Subject: [PATCH 25/70] recovery: turn is_dualboot_enabled() into generic function The new function compares the value of the variable with one given as parameter. Signed-off-by: Hector Palacios --- .../recovery-utils/lib/recovery.c | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c index b807da11a..ebbf320f4 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c @@ -74,29 +74,29 @@ static char *emmc_parts_blacklist[] = { static char *rootfs[] = { "rootfs", NULL }; /* - * Function: is_device_closed - * Description: check if the device is in dualboot mode + * Function: check_uboot_var + * Description: Compares an env variable with a given value */ -static bool is_dualboot_enabled(void) +static bool check_uboot_var(char *name, char *value) { - const char *var; + const char *val; bool ret = false; - /* Parse dualboot */ - if (uboot_getenv("dualboot", &var)) { - fprintf(stderr, "Error: getenv 'dualboot'\n"); + /* Parse variable */ + if (uboot_getenv(name, &val)) { + fprintf(stderr, "Error: getenv '%s'\n", name); return false; } - /* Consider dualboot not enabled if variable doesn't exist */ - if (!var) + /* Return false if variable doesn't exist */ + if (!val) return false; - /* Is dualboot enabled */ - if (!strcmp(var, "yes")) + /* Is val == value */ + if (!strcmp(val, value)) ret = true; - free(var); + free(val); return ret; } @@ -112,7 +112,7 @@ static int append_recovery_command(const char *value) int ret = 0; /* Check if we are in dualboot mode */ - if (is_dualboot_enabled()) { + if (check_uboot_var("dualboot", "yes")) { fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); goto err; } @@ -622,7 +622,7 @@ int update_firmware(const char *swu_path) int ret = -1; /* Check if we are in dualboot mode */ - if (is_dualboot_enabled()) { + if (check_uboot_var("dualboot", "yes")) { fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); goto err; } @@ -668,7 +668,7 @@ int reboot_recovery(unsigned int reboot_timeout) int ret = 0; /* Check if we are in dualboot mode */ - if (is_dualboot_enabled()) { + if (check_uboot_var("dualboot", "yes")) { fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); goto err; } @@ -718,7 +718,7 @@ int set_encryption_key(char *key, unsigned char force) unsigned char i = 0; /* Check if we are in dualboot mode */ - if (is_dualboot_enabled()) { + if (check_uboot_var("dualboot", "yes")) { fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); return ret; } @@ -822,7 +822,7 @@ int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force int ret; /* Check if we are in dualboot mode */ - if (is_dualboot_enabled()) { + if (check_uboot_var("dualboot", "yes")) { fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n"); return 1; } From 27c13055ebf4f61cc86bcca0e284d260554d63a7 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 3 Sep 2021 16:10:09 +0200 Subject: [PATCH 26/70] uboot: ccimx6ul: decide on using UBI vols basing on ubisysvols The script required the passing of option '-b' for setting up the target to use a single MTD partition and multiple UBI volumes. If a target however already has the variable 'ubisysvols' set to 'yes' but this parameter is forgotten when calling the script, the partition layout would change to default (several MTD partitions). Remove the recently added '-b' option and make the script decide basing on the current value of 'ubisysvols' variable. Signed-off-by: Hector Palacios --- .../ccimx6ul/install_linux_fw_uuu.sh | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh index 5179970c5..8d22d569c 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh @@ -32,9 +32,6 @@ show_usage() echo "Usage: $0 [options]" echo "" echo " Options:" - echo " -b Use one MTD 'system' partition to hold system UBI volumes (linux," - echo " recovery, rootfs, update)." - echo " Default is the opposite: one UBI volume per MTD partition." echo " -h Show this help." echo " -i Image name that prefixes the image filenames, such as 'dey-image-qt', " echo " 'dey-image-webkit', 'core-image-base'..." @@ -73,10 +70,9 @@ echo "############################################################" # Command line admits the following parameters: # -u # -i -while getopts 'bhi:nu:' c +while getopts 'hi:nu:' c do case $c in - b) UBISYSVOLS=true ;; h) show_usage ;; i) IMAGE_NAME=${OPTARG} ;; n) NOWAIT=true ;; @@ -84,12 +80,18 @@ do esac done -echo "" -echo "Determining image files to use..." - # Enable the redirect support to get u-boot variables values uuu fb: ucmd setenv stdout serial,fastboot +# Check if ubisysvols variable is active +ubisysvols=$(getenv "ubisysvols") +if [ "${ubisysvols}" = "yes" ]; then + UBISYSVOLS=true; +fi + +echo "" +echo "Determining image files to use..." + # Determine U-Boot filename if not provided if [ -z "${INSTALL_UBOOT_FILENAME}" ]; then module_variant=$(getenv "module_variant") @@ -225,7 +227,7 @@ sleep 3 # Set fastboot buffer address to $loadaddr uuu fb: ucmd setenv fastboot_buffer \${loadaddr} -# Set up ubisysvols if so requested +# Restore ubisysvols if previously active if [ "${UBISYSVOLS}" = true ]; then uuu fb: ucmd setenv ubisysvols yes fi From 05d21a1310d1eed82f6235543bb7c576344ebbc5 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 9 Sep 2021 12:46:33 +0200 Subject: [PATCH 27/70] u-boot: boot.txt: move dualboot checks to the top When DualBoot mechanism is enabled and an update is pending, the boot script needs to change certain variables and save the environment. The regular boot script already changes a number of variables, such as 'extra_bootargs' and 'overlays' by appending strings to the already existing values. Saving the envionment may make these grow endlessly with each iteration of the boot script. For this reason, move the DualBoot check as the first thing in the script, save the environment if needed, and then continue with the normal flow, that changes variables before booting but doesn't save them. On certain scripts, this allows us to get rid of some instructions for resetting the overlays variable. Signed-off-by: Hector Palacios --- .../u-boot/u-boot-dey/ccimx6qpsbc/boot.txt | 51 ++++---- .../u-boot/u-boot-dey/ccimx6sbc/boot.txt | 107 +++++++++-------- .../u-boot/u-boot-dey/ccimx6ulsbc/boot.txt | 75 ++++++------ .../u-boot-dey/ccimx6ulstarter/boot.txt | 75 ++++++------ .../u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt | 75 ++++++------ .../u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt | 95 ++++++++------- .../u-boot-dey/ccimx8x-sbc-express/boot.txt | 99 ++++++++-------- .../u-boot-dey/ccimx8x-sbc-pro/boot.txt | 109 +++++++++--------- 8 files changed, 355 insertions(+), 331 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt index 5dedaa36d..fe794d0c6 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt @@ -2,28 +2,10 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# Back up environment variables -setenv ORIG_extra_bootargs ${extra_bootargs} - -# -# Set device tree filename depending on the board ID (if defined) -# -if test -n "${board_id}"; then - setenv fdt_file imx6qp-ccimx6qpsbc-id${board_id}.dtb -else - # - # Set device tree filename depending on the hardware variant - # - if test "${module_variant}" = "0x01"; then - setenv fdt_file imx6qp-ccimx6qpsbc-wb.dtb - elif test "${module_variant}" = "0x02"; then - setenv fdt_file imx6qp-ccimx6qpsbc-wb.dtb - elif test "${module_variant}" = "0x03"; then - setenv fdt_file imx6qp-ccimx6qpsbc.dtb - else - setenv fdt_file imx6qp-ccimx6qpsbc-wb.dtb - fi -fi +# As the first step in the boot script, check if we are using DualBoot and +# if an upgrade is available. This requires the script to change some variables +# and save them, while the rest of the script changes variables only temporarily +# without saving them. # Dual boot update verification if test "${dualboot}" = "yes"; then @@ -90,6 +72,31 @@ else setenv mmcroot /dev/mmcblk${mmcbootdev}p2 fi fi + + +# Back up environment variables +setenv ORIG_extra_bootargs ${extra_bootargs} + +# +# Set device tree filename depending on the board ID (if defined) +# +if test -n "${board_id}"; then + setenv fdt_file imx6qp-ccimx6qpsbc-id${board_id}.dtb +else + # + # Set device tree filename depending on the hardware variant + # + if test "${module_variant}" = "0x01"; then + setenv fdt_file imx6qp-ccimx6qpsbc-wb.dtb + elif test "${module_variant}" = "0x02"; then + setenv fdt_file imx6qp-ccimx6qpsbc-wb.dtb + elif test "${module_variant}" = "0x03"; then + setenv fdt_file imx6qp-ccimx6qpsbc.dtb + else + setenv fdt_file imx6qp-ccimx6qpsbc-wb.dtb + fi +fi + setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt index 12b927abd..a88f10150 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt @@ -2,56 +2,10 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# Back up environment variables -setenv ORIG_extra_bootargs ${extra_bootargs} - -# -# Set device tree filename depending on the board ID (if defined) -# -if test -n "${board_id}"; then - setenv fdt_file ${soc_family}-ccimx6sbc-id${board_id}.dtb -else - # - # Set device tree filename depending on the hardware variant - # - if test "${module_variant}" = "0x02"; then - setenv fdt_file imx6q-ccimx6sbc-wb.dtb - elif test "${module_variant}" = "0x03"; then - setenv fdt_file imx6q-ccimx6sbc-wb.dtb - elif test "${module_variant}" = "0x04"; then - setenv fdt_file imx6q-ccimx6sbc-wb.dtb - elif test "${module_variant}" = "0x05"; then - setenv fdt_file imx6q-ccimx6sbc-w.dtb - elif test "${module_variant}" = "0x06"; then - setenv fdt_file imx6q-ccimx6sbc-wb.dtb - elif test "${module_variant}" = "0x08"; then - setenv fdt_file imx6q-ccimx6sbc.dtb - elif test "${module_variant}" = "0x0a"; then - setenv fdt_file imx6dl-ccimx6sbc-w.dtb - elif test "${module_variant}" = "0x0b"; then - setenv fdt_file imx6dl-ccimx6sbc-wb.dtb - elif test "${module_variant}" = "0x0c"; then - setenv fdt_file imx6dl-ccimx6sbc.dtb - elif test "${module_variant}" = "0x0e"; then - setenv fdt_file imx6q-ccimx6sbc.dtb - elif test "${module_variant}" = "0x0f"; then - setenv fdt_file imx6q-ccimx6sbc.dtb - elif test "${module_variant}" = "0x11"; then - setenv fdt_file imx6q-ccimx6sbc-wb.dtb - elif test "${module_variant}" = "0x12"; then - setenv fdt_file imx6q-ccimx6sbc-wb.dtb - elif test "${module_variant}" = "0x13"; then - setenv fdt_file imx6dl-ccimx6sbc-wb.dtb - elif test "${module_variant}" = "0x14"; then - setenv fdt_file imx6q-ccimx6sbc.dtb - elif test "${module_variant}" = "0x15"; then - setenv fdt_file imx6dl-ccimx6sbc.dtb - elif test "${module_variant}" = "0x16"; then - setenv fdt_file imx6q-ccimx6sbc-wb.dtb - else - setenv fdt_file imx6q-ccimx6sbc-wb.dtb - fi -fi +# As the first step in the boot script, check if we are using DualBoot and +# if an upgrade is available. This requires the script to change some variables +# and save them, while the rest of the script changes variables only temporarily +# without saving them. # Dual boot update verification if test "${dualboot}" = "yes"; then @@ -118,6 +72,59 @@ else setenv mmcroot /dev/mmcblk${mmcbootdev}p2 fi fi + + +# Back up environment variables +setenv ORIG_extra_bootargs ${extra_bootargs} + +# +# Set device tree filename depending on the board ID (if defined) +# +if test -n "${board_id}"; then + setenv fdt_file ${soc_family}-ccimx6sbc-id${board_id}.dtb +else + # + # Set device tree filename depending on the hardware variant + # + if test "${module_variant}" = "0x02"; then + setenv fdt_file imx6q-ccimx6sbc-wb.dtb + elif test "${module_variant}" = "0x03"; then + setenv fdt_file imx6q-ccimx6sbc-wb.dtb + elif test "${module_variant}" = "0x04"; then + setenv fdt_file imx6q-ccimx6sbc-wb.dtb + elif test "${module_variant}" = "0x05"; then + setenv fdt_file imx6q-ccimx6sbc-w.dtb + elif test "${module_variant}" = "0x06"; then + setenv fdt_file imx6q-ccimx6sbc-wb.dtb + elif test "${module_variant}" = "0x08"; then + setenv fdt_file imx6q-ccimx6sbc.dtb + elif test "${module_variant}" = "0x0a"; then + setenv fdt_file imx6dl-ccimx6sbc-w.dtb + elif test "${module_variant}" = "0x0b"; then + setenv fdt_file imx6dl-ccimx6sbc-wb.dtb + elif test "${module_variant}" = "0x0c"; then + setenv fdt_file imx6dl-ccimx6sbc.dtb + elif test "${module_variant}" = "0x0e"; then + setenv fdt_file imx6q-ccimx6sbc.dtb + elif test "${module_variant}" = "0x0f"; then + setenv fdt_file imx6q-ccimx6sbc.dtb + elif test "${module_variant}" = "0x11"; then + setenv fdt_file imx6q-ccimx6sbc-wb.dtb + elif test "${module_variant}" = "0x12"; then + setenv fdt_file imx6q-ccimx6sbc-wb.dtb + elif test "${module_variant}" = "0x13"; then + setenv fdt_file imx6dl-ccimx6sbc-wb.dtb + elif test "${module_variant}" = "0x14"; then + setenv fdt_file imx6q-ccimx6sbc.dtb + elif test "${module_variant}" = "0x15"; then + setenv fdt_file imx6dl-ccimx6sbc.dtb + elif test "${module_variant}" = "0x16"; then + setenv fdt_file imx6q-ccimx6sbc-wb.dtb + else + setenv fdt_file imx6q-ccimx6sbc-wb.dtb + fi +fi + setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt index 9d931bd24..9b45affa5 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt @@ -2,40 +2,10 @@ # U-Boot bootscript for NAND images created by Yocto. # -# Back up environment variables -setenv ORIG_extra_bootargs ${extra_bootargs} - -# -# Set device tree filename depending on the board ID (if defined) -# -if test -n "${board_id}"; then - setenv fdt_file imx6ul-ccimx6ulsbc-id${board_id}.dtb -else - # - # Set device tree filename depending on the hardware variant - # - if test "${module_variant}" = "0x02"; then - setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb - elif test "${module_variant}" = "0x03"; then - setenv fdt_file imx6ul-ccimx6ulsbc.dtb - elif test "${module_variant}" = "0x04"; then - setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb - elif test "${module_variant}" = "0x05"; then - setenv fdt_file imx6ul-ccimx6ulsbc.dtb - elif test "${module_variant}" = "0x06"; then - setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb - elif test "${module_variant}" = "0x07"; then - setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb - elif test "${module_variant}" = "0x08"; then - setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb - elif test "${module_variant}" = "0x09"; then - setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb - elif test "${module_variant}" = "0x0a"; then - setenv fdt_file imx6ul-ccimx6ulsbc.dtb - else - setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb - fi -fi +# As the first step in the boot script, check if we are using DualBoot and +# if an upgrade is available. This requires the script to change some variables +# and save them, while the rest of the script changes variables only temporarily +# without saving them. # Dual boot update verification if test "${dualboot}" = "yes"; then @@ -81,6 +51,43 @@ else true fi fi + + +# Back up environment variables +setenv ORIG_extra_bootargs ${extra_bootargs} + +# +# Set device tree filename depending on the board ID (if defined) +# +if test -n "${board_id}"; then + setenv fdt_file imx6ul-ccimx6ulsbc-id${board_id}.dtb +else + # + # Set device tree filename depending on the hardware variant + # + if test "${module_variant}" = "0x02"; then + setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb + elif test "${module_variant}" = "0x03"; then + setenv fdt_file imx6ul-ccimx6ulsbc.dtb + elif test "${module_variant}" = "0x04"; then + setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb + elif test "${module_variant}" = "0x05"; then + setenv fdt_file imx6ul-ccimx6ulsbc.dtb + elif test "${module_variant}" = "0x06"; then + setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb + elif test "${module_variant}" = "0x07"; then + setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb + elif test "${module_variant}" = "0x08"; then + setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb + elif test "${module_variant}" = "0x09"; then + setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb + elif test "${module_variant}" = "0x0a"; then + setenv fdt_file imx6ul-ccimx6ulsbc.dtb + else + setenv fdt_file imx6ul-ccimx6ulsbc-wb.dtb + fi +fi + setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux nand ${mtdbootpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt index fab05eb51..3fe58e274 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt @@ -2,40 +2,10 @@ # U-Boot bootscript for NAND images created by Yocto. # -# Back up environment variables -setenv ORIG_extra_bootargs ${extra_bootargs} - -# -# Set device tree filename depending on the board ID (if defined) -# -if test -n "${board_id}"; then - setenv fdt_file imx6ul-ccimx6ulstarter-id${board_id}.dtb -else - # - # Set device tree filename depending on the hardware variant - # - if test "${module_variant}" = "0x02"; then - setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb - elif test "${module_variant}" = "0x03"; then - setenv fdt_file imx6ul-ccimx6ulstarter.dtb - elif test "${module_variant}" = "0x04"; then - setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb - elif test "${module_variant}" = "0x05"; then - setenv fdt_file imx6ul-ccimx6ulstarter.dtb - elif test "${module_variant}" = "0x06"; then - setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb - elif test "${module_variant}" = "0x07"; then - setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb - elif test "${module_variant}" = "0x08"; then - setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb - elif test "${module_variant}" = "0x09"; then - setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb - elif test "${module_variant}" = "0x0a"; then - setenv fdt_file imx6ul-ccimx6ulstarter.dtb - else - setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb - fi -fi +# As the first step in the boot script, check if we are using DualBoot and +# if an upgrade is available. This requires the script to change some variables +# and save them, while the rest of the script changes variables only temporarily +# without saving them. # Dual boot update verification if test "${dualboot}" = "yes"; then @@ -81,6 +51,43 @@ else true fi fi + + +# Back up environment variables +setenv ORIG_extra_bootargs ${extra_bootargs} + +# +# Set device tree filename depending on the board ID (if defined) +# +if test -n "${board_id}"; then + setenv fdt_file imx6ul-ccimx6ulstarter-id${board_id}.dtb +else + # + # Set device tree filename depending on the hardware variant + # + if test "${module_variant}" = "0x02"; then + setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb + elif test "${module_variant}" = "0x03"; then + setenv fdt_file imx6ul-ccimx6ulstarter.dtb + elif test "${module_variant}" = "0x04"; then + setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb + elif test "${module_variant}" = "0x05"; then + setenv fdt_file imx6ul-ccimx6ulstarter.dtb + elif test "${module_variant}" = "0x06"; then + setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb + elif test "${module_variant}" = "0x07"; then + setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb + elif test "${module_variant}" = "0x08"; then + setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb + elif test "${module_variant}" = "0x09"; then + setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb + elif test "${module_variant}" = "0x0a"; then + setenv fdt_file imx6ul-ccimx6ulstarter.dtb + else + setenv fdt_file imx6ul-ccimx6ulstarter-wb.dtb + fi +fi + setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux nand ${mtdbootpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt index 1513df9e9..121b71e07 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt @@ -2,44 +2,10 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# Back up environment variables -setenv ORIG_overlays ${overlays} -setenv ORIG_extra_bootargs ${extra_bootargs} - -# Set SOC type to "imx8mm" if not already defined by U-Boot -if test ! -n "${soc_type}"; then - setenv soc_type "imx8mm" -fi - -# Reset overlays when using dualboot mode, because we need to -# save the environment in case of an installation fall back. -if test "${dual_boot}" = "yes"; then - if test -n "${overlays}"; then - setenv overlays - fi -fi - -# -# Determine overlays to apply depending on the hardware capabilities -# described by the HWID, SOM version, and carrier board version. -# -if test -n "${module_ram}"; then - setexpr som_hv ${hwid_2} \& 38 - setexpr som_hv ${som_hv} / 8 - - setexpr module_has_wifi ${hwid_2} \& 10000 - setexpr module_has_wifi ${module_has_wifi} / 10000 - setexpr module_has_bt ${hwid_2} \& 20000 - setexpr module_has_bt ${module_has_bt} / 20000 - - if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then - setenv overlays _ov_som_bt_ccimx8m.dtbo,${overlays} - fi - - if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then - setenv overlays _ov_som_wifi_ccimx8m.dtbo,${overlays} - fi -fi +# As the first step in the boot script, check if we are using DualBoot and +# if an upgrade is available. This requires the script to change some variables +# and save them, while the rest of the script changes variables only temporarily +# without saving them. # Dual boot update verification if test "${dualboot}" = "yes"; then @@ -106,6 +72,39 @@ else setenv mmcroot /dev/mmcblk${mmcbootdev}p2 fi fi + + +# Back up environment variables +setenv ORIG_overlays ${overlays} +setenv ORIG_extra_bootargs ${extra_bootargs} + +# Set SOC type to "imx8mm" if not already defined by U-Boot +if test ! -n "${soc_type}"; then + setenv soc_type "imx8mm" +fi + +# +# Determine overlays to apply depending on the hardware capabilities +# described by the HWID, SOM version, and carrier board version. +# +if test -n "${module_ram}"; then + setexpr som_hv ${hwid_2} \& 38 + setexpr som_hv ${som_hv} / 8 + + setexpr module_has_wifi ${hwid_2} \& 10000 + setexpr module_has_wifi ${module_has_wifi} / 10000 + setexpr module_has_bt ${hwid_2} \& 20000 + setexpr module_has_bt ${module_has_bt} / 20000 + + if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then + setenv overlays _ov_som_bt_ccimx8m.dtbo,${overlays} + fi + + if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then + setenv overlays _ov_som_wifi_ccimx8m.dtbo,${overlays} + fi +fi + setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt index 7b7df5917..f39b8cfc5 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt @@ -2,53 +2,10 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# Back up environment variables -setenv ORIG_overlays ${overlays} -setenv ORIG_extra_bootargs ${extra_bootargs} - -# Set SOC type to "imx8mn" if not already defined by U-Boot -if test ! -n "${soc_type}"; then - setenv soc_type "imx8mn" -fi - -# Reset overlays when using dualboot mode, because we need to -# save the environment in case of an installation fall back. -if test "${dual_boot}" = "yes"; then - if test -n "${overlays}"; then - setenv overlays - fi -fi - -# -# Determine overlays to apply depending on the hardware capabilities -# described by the HWID, SOM version, and carrier board version. -# -if test -n "${module_ram}"; then - setexpr som_hv ${hwid_2} \& 38 - setexpr som_hv ${som_hv} / 8 - - setexpr module_has_wifi ${hwid_2} \& 10000 - setexpr module_has_wifi ${module_has_wifi} / 10000 - setexpr module_has_bt ${hwid_2} \& 20000 - setexpr module_has_bt ${module_has_bt} / 20000 - - if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then - setenv overlays _ov_som_bt_ccimx8m.dtbo,${overlays} - fi - - if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then - setenv overlays _ov_som_wifi_ccimx8m.dtbo,${overlays} - fi - - if test "${som_hv}" = "1"; then - setenv overlays _ov_som_v1_ccimx8mn.dtbo,${overlays} - fi -fi - -# Apply DVK v1-v2 overlay if the board version is < 3 -if test "${board_version}" -lt "3"; then - setenv overlays _ov_board_v1-v2_ccimx8mn-dvk.dtbo,${overlays} -fi +# As the first step in the boot script, check if we are using DualBoot and +# if an upgrade is available. This requires the script to change some variables +# and save them, while the rest of the script changes variables only temporarily +# without saving them. # Dual boot update verification if test "${dualboot}" = "yes"; then @@ -68,7 +25,7 @@ if test "${dualboot}" = "yes"; then else part number mmc ${mmcbootdev} linux_a pi setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index + # Save the partition index on variable rootfs_a_index part number mmc ${mmcbootdev} rootfs_a rootfs_a_index # Save the rootfs_a UUID into mmcroot_a part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a @@ -115,6 +72,48 @@ else setenv mmcroot /dev/mmcblk${mmcbootdev}p2 fi fi + + +# Back up environment variables +setenv ORIG_overlays ${overlays} +setenv ORIG_extra_bootargs ${extra_bootargs} + +# Set SOC type to "imx8mn" if not already defined by U-Boot +if test ! -n "${soc_type}"; then + setenv soc_type "imx8mn" +fi + +# +# Determine overlays to apply depending on the hardware capabilities +# described by the HWID, SOM version, and carrier board version. +# +if test -n "${module_ram}"; then + setexpr som_hv ${hwid_2} \& 38 + setexpr som_hv ${som_hv} / 8 + + setexpr module_has_wifi ${hwid_2} \& 10000 + setexpr module_has_wifi ${module_has_wifi} / 10000 + setexpr module_has_bt ${hwid_2} \& 20000 + setexpr module_has_bt ${module_has_bt} / 20000 + + if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then + setenv overlays _ov_som_bt_ccimx8m.dtbo,${overlays} + fi + + if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then + setenv overlays _ov_som_wifi_ccimx8m.dtbo,${overlays} + fi + + if test "${som_hv}" = "1"; then + setenv overlays _ov_som_v1_ccimx8mn.dtbo,${overlays} + fi +fi + +# Apply DVK v1-v2 overlay if the board version is < 3 +if test "${board_version}" -lt "3"; then + setenv overlays _ov_board_v1-v2_ccimx8mn-dvk.dtbo,${overlays} +fi + setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt index b99b3378b..836310230 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt @@ -2,56 +2,10 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# Back up environment variables -setenv ORIG_overlays ${overlays} -setenv ORIG_extra_bootargs ${extra_bootargs} - -# Set SOC type to "imx8qxp" if not already defined by U-Boot -if test ! -n "${soc_type}"; then - setenv soc_type "imx8qxp" -fi - -# Reset overlays when using dualboot mode, because we need to -# save the environment in case of an installation fall back. -if test "${dual_boot}" = "yes"; then - if test -n "${overlays}"; then - setenv overlays - fi -fi - -# -# Determine overlays to apply depending on the hardware capabilities -# described by the HWID, SOM version, and carrier board version. -# -if test -n "${module_ram}"; then - setexpr module_has_wifi ${hwid_3} \& 1 - setexpr module_has_bt ${hwid_3} \& 2 - setexpr module_has_bt ${module_has_bt} / 2 - - if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then - setenv overlays _ov_som_bt_ccimx8x.dtbo,${overlays} - fi - - if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then - setenv overlays _ov_som_wifi_ccimx8x.dtbo,${overlays} - fi -else - # - # Set overlays depending on the hardware variant - # - if test "${module_variant}" = "0x01"; then - setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} - elif test "${module_variant}" = "0x02"; then - setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} - elif test "${module_variant}" = "0x04"; then - setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} - fi -fi - -# Apply QXP overlay if the SOC type is "imx8qxp" -if test "${soc_type}" = "imx8qxp"; then - setenv overlays _ov_som_quad_ccimx8x.dtbo,${overlays} -fi +# As the first step in the boot script, check if we are using DualBoot and +# if an upgrade is available. This requires the script to change some variables +# and save them, while the rest of the script changes variables only temporarily +# without saving them. # Dual boot update verification if test "${dualboot}" = "yes"; then @@ -118,6 +72,51 @@ else setenv mmcroot /dev/mmcblk${mmcbootdev}p2 fi fi + + +# Back up environment variables +setenv ORIG_overlays ${overlays} +setenv ORIG_extra_bootargs ${extra_bootargs} + +# Set SOC type to "imx8qxp" if not already defined by U-Boot +if test ! -n "${soc_type}"; then + setenv soc_type "imx8qxp" +fi + +# +# Determine overlays to apply depending on the hardware capabilities +# described by the HWID, SOM version, and carrier board version. +# +if test -n "${module_ram}"; then + setexpr module_has_wifi ${hwid_3} \& 1 + setexpr module_has_bt ${hwid_3} \& 2 + setexpr module_has_bt ${module_has_bt} / 2 + + if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then + setenv overlays _ov_som_bt_ccimx8x.dtbo,${overlays} + fi + + if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then + setenv overlays _ov_som_wifi_ccimx8x.dtbo,${overlays} + fi +else + # + # Set overlays depending on the hardware variant + # + if test "${module_variant}" = "0x01"; then + setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} + elif test "${module_variant}" = "0x02"; then + setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} + elif test "${module_variant}" = "0x04"; then + setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} + fi +fi + +# Apply QXP overlay if the SOC type is "imx8qxp" +if test "${soc_type}" = "imx8qxp"; then + setenv overlays _ov_som_quad_ccimx8x.dtbo,${overlays} +fi + setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt index 759308337..0a6968ea1 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt @@ -2,61 +2,10 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# Back up environment variables -setenv ORIG_overlays ${overlays} -setenv ORIG_extra_bootargs ${extra_bootargs} - -# Set SOC type to "imx8qxp" if not already defined by U-Boot -if test ! -n "${soc_type}"; then - setenv soc_type "imx8qxp" -fi - -# Reset overlays when using dualboot mode, because we need to -# save the environment in case of an installation fall back. -if test "${dual_boot}" = "yes"; then - if test -n "${overlays}"; then - setenv overlays - fi -fi - -# -# Determine overlays to apply depending on the hardware capabilities -# described by the HWID, SOM version, and carrier board version. -# -if test -n "${module_ram}"; then - setexpr module_has_wifi ${hwid_3} \& 1 - setexpr module_has_bt ${hwid_3} \& 2 - setexpr module_has_bt ${module_has_bt} / 2 - - if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then - setenv overlays _ov_som_bt_ccimx8x.dtbo,${overlays} - fi - - if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then - setenv overlays _ov_som_wifi_ccimx8x.dtbo,${overlays} - fi -else - # - # Set overlays depending on the hardware variant - # - if test "${module_variant}" = "0x01"; then - setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} - elif test "${module_variant}" = "0x02"; then - setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} - elif test "${module_variant}" = "0x04"; then - setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} - fi -fi - -# Apply QXP overlay if the SOC type is "imx8qxp" -if test "${soc_type}" = "imx8qxp"; then - setenv overlays _ov_som_quad_ccimx8x.dtbo,${overlays} -fi - -# Apply SBCv3 overlay if the board_version is 3 or lesser -if test "${board_version}" -le "3"; then - setenv overlays _ov_board_v1-v3_ccimx8x-sbc-pro.dtbo,${overlays} -fi +# As the first step in the boot script, check if we are using DualBoot and +# if an upgrade is available. This requires the script to change some variables +# and save them, while the rest of the script changes variables only temporarily +# without saving them. # Dual boot update verification if test "${dualboot}" = "yes"; then @@ -123,6 +72,56 @@ else setenv mmcroot /dev/mmcblk${mmcbootdev}p2 fi fi + + +# Back up environment variables +setenv ORIG_overlays ${overlays} +setenv ORIG_extra_bootargs ${extra_bootargs} + +# Set SOC type to "imx8qxp" if not already defined by U-Boot +if test ! -n "${soc_type}"; then + setenv soc_type "imx8qxp" +fi + +# +# Determine overlays to apply depending on the hardware capabilities +# described by the HWID, SOM version, and carrier board version. +# +if test -n "${module_ram}"; then + setexpr module_has_wifi ${hwid_3} \& 1 + setexpr module_has_bt ${hwid_3} \& 2 + setexpr module_has_bt ${module_has_bt} / 2 + + if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then + setenv overlays _ov_som_bt_ccimx8x.dtbo,${overlays} + fi + + if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then + setenv overlays _ov_som_wifi_ccimx8x.dtbo,${overlays} + fi +else + # + # Set overlays depending on the hardware variant + # + if test "${module_variant}" = "0x01"; then + setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} + elif test "${module_variant}" = "0x02"; then + setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} + elif test "${module_variant}" = "0x04"; then + setenv overlays _ov_som_bt_ccimx8x.dtbo,_ov_som_wifi_ccimx8x.dtbo,${overlays} + fi +fi + +# Apply QXP overlay if the SOC type is "imx8qxp" +if test "${soc_type}" = "imx8qxp"; then + setenv overlays _ov_som_quad_ccimx8x.dtbo,${overlays} +fi + +# Apply SBCv3 overlay if the board_version is 3 or lesser +if test "${board_version}" -le "3"; then + setenv overlays _ov_board_v1-v3_ccimx8x-sbc-pro.dtbo,${overlays} +fi + setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} From c26d78d7a15cfbe779a2a612791ebf3f82e52601 Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Mon, 6 Sep 2021 12:56:09 +0200 Subject: [PATCH 28/70] firmware-imx: install firmware loading scripts regardless of the init manager When we added the SDMA fw systemd service, we accidentally made it so that all scripts were installed only when using systemd. These files are still needed when using sysvinit, so correct this change. While at it, include the SDMA fw service in firmware-imx-sdma's FILES. Signed-off-by: Gabriel Valcazar --- .../firmware-imx/firmware-imx_8.11.bb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/firmware-imx/firmware-imx_8.11.bb b/meta-digi-arm/recipes-bsp/firmware-imx/firmware-imx_8.11.bb index de49f7200..18c2f8236 100644 --- a/meta-digi-arm/recipes-bsp/firmware-imx/firmware-imx_8.11.bb +++ b/meta-digi-arm/recipes-bsp/firmware-imx/firmware-imx_8.11.bb @@ -24,14 +24,16 @@ SYSTEMD_SERVICE_${PN}-sdma = "sdma-firmware.service" do_install() { install -d ${D}${base_libdir}/firmware/imx + # Install loading scripts + install -d ${D}${sysconfdir} + install -m 0755 ${WORKDIR}/sdma ${D}${sysconfdir} + install -m 0755 ${WORKDIR}/epdc ${D}${sysconfdir} + install -m 0755 ${WORKDIR}/regulatory ${D}${sysconfdir} + install -m 0755 ${WORKDIR}/hdmi ${D}${sysconfdir} + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then - # Install loading scripts - install -d ${D}${sysconfdir} + # Install SDMA systemd service install -d ${D}${systemd_system_unitdir} - install -m 0755 ${WORKDIR}/sdma ${D}${sysconfdir} - install -m 0755 ${WORKDIR}/epdc ${D}${sysconfdir} - install -m 0755 ${WORKDIR}/regulatory ${D}${sysconfdir} - install -m 0755 ${WORKDIR}/hdmi ${D}${sysconfdir} install -m 0644 ${WORKDIR}/sdma-firmware.service ${D}${systemd_system_unitdir} fi @@ -100,7 +102,7 @@ PACKAGES_DYNAMIC = "${PN}-vpu-* ${PN}-sdma-*" PACKAGES =+ "${PN}-epdc ${PN}-sdma ${PN}-easrc ${PN}-regulatory ${PN}-hdmi ${PN}-xcvr ${PN}-xuvi" FILES_${PN}-epdc = "${base_libdir}/firmware/imx/epdc/ ${sysconfdir}/epdc" -FILES_${PN}-sdma = "${base_libdir}/firmware/imx/sdma ${sysconfdir}/sdma" +FILES_${PN}-sdma = "${base_libdir}/firmware/imx/sdma ${sysconfdir}/sdma ${systemd_system_unitdir}/sdma-firmware.service" FILES_${PN}-easrc = "${base_libdir}/firmware/imx/easrc/" FILES_${PN}-regulatory = "${sysconfdir}/regulatory" FILES_${PN}-hdmi = "${base_libdir}/firmware/imx/hdmi/ ${sysconfdir}/hdmi" From 96f54105d3c0e67b975131b6c29f5f39015fc86d Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Mon, 6 Sep 2021 13:02:43 +0200 Subject: [PATCH 29/70] ccimx6/6ul: add "firmware-imx-regulatory" package This package includes a script that is executed by a udev rule that we currently include in our sysvinit images. Without it, the regulatory firmware mechanism is broken and an error appears when booting the system. Signed-off-by: Gabriel Valcazar --- meta-digi-arm/conf/machine/include/ccimx6.inc | 2 +- meta-digi-arm/conf/machine/include/ccimx6ul.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/meta-digi-arm/conf/machine/include/ccimx6.inc b/meta-digi-arm/conf/machine/include/ccimx6.inc index 69becb213..ddcf63f45 100644 --- a/meta-digi-arm/conf/machine/include/ccimx6.inc +++ b/meta-digi-arm/conf/machine/include/ccimx6.inc @@ -21,7 +21,7 @@ STORAGE_MEDIA = "mmc" WIRELESS_MODULE ?= "" # Firmware -MACHINE_FIRMWARE ?= "firmware-imx-sdma" +MACHINE_FIRMWARE ?= "firmware-imx-sdma firmware-imx-regulatory" MACHINE_FIRMWARE_append_mx6q = " firmware-imx-vpu-imx6q" MACHINE_FIRMWARE_append_mx6dl = " firmware-imx-vpu-imx6d" diff --git a/meta-digi-arm/conf/machine/include/ccimx6ul.inc b/meta-digi-arm/conf/machine/include/ccimx6ul.inc index 265d22248..4b20b7d88 100644 --- a/meta-digi-arm/conf/machine/include/ccimx6ul.inc +++ b/meta-digi-arm/conf/machine/include/ccimx6ul.inc @@ -21,7 +21,7 @@ WIRELESS_MODULE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'kernel-mod HAS_WIFI_VIRTWLANS = "true" # Firmware -MACHINE_FIRMWARE ?= "firmware-imx-sdma" +MACHINE_FIRMWARE ?= "firmware-imx-sdma firmware-imx-regulatory" MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_BT', '1', 'firmware-qualcomm-qca6564-bt', '', d)}" MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'firmware-qualcomm-qca6564-wifi', '', d)}" From 4876bc07b6c2f0a40b23619044ffcca923fe603a Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Thu, 9 Sep 2021 13:05:14 +0200 Subject: [PATCH 30/70] openssl: update to v1.1.1l This fixes the following CVEs: * CVE-2021-3711 * CVE-2021-3712 Port the recipe and patches from the dunfell poky branch, since the hardknott version contains additional changes aside from the revision update. https://onedigi.atlassian.net/browse/DEL-7647 Signed-off-by: Gabriel Valcazar --- .../openssl/files/environment.d-openssl.sh | 1 + ...sysroot-and-debug-prefix-map-from-co.patch | 76 ++++++ .../0001-skip-test_symbol_presence.patch | 46 ++++ .../openssl/openssl/afalg.patch | 31 +++ .../openssl/openssl/reproducible.patch | 32 +++ .../openssl/openssl/run-ptest | 12 + .../openssl/openssl_1.1.1l.bb | 217 ++++++++++++++++++ 7 files changed, 415 insertions(+) create mode 100644 meta-digi-dey/recipes-connectivity/openssl/files/environment.d-openssl.sh create mode 100644 meta-digi-dey/recipes-connectivity/openssl/openssl/0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch create mode 100644 meta-digi-dey/recipes-connectivity/openssl/openssl/0001-skip-test_symbol_presence.patch create mode 100644 meta-digi-dey/recipes-connectivity/openssl/openssl/afalg.patch create mode 100644 meta-digi-dey/recipes-connectivity/openssl/openssl/reproducible.patch create mode 100644 meta-digi-dey/recipes-connectivity/openssl/openssl/run-ptest create mode 100644 meta-digi-dey/recipes-connectivity/openssl/openssl_1.1.1l.bb diff --git a/meta-digi-dey/recipes-connectivity/openssl/files/environment.d-openssl.sh b/meta-digi-dey/recipes-connectivity/openssl/files/environment.d-openssl.sh new file mode 100644 index 000000000..b9cc24a7a --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/openssl/files/environment.d-openssl.sh @@ -0,0 +1 @@ +export OPENSSL_CONF="$OECORE_NATIVE_SYSROOT/usr/lib/ssl/openssl.cnf" diff --git a/meta-digi-dey/recipes-connectivity/openssl/openssl/0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch b/meta-digi-dey/recipes-connectivity/openssl/openssl/0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch new file mode 100644 index 000000000..949c78834 --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/openssl/openssl/0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch @@ -0,0 +1,76 @@ +From 3e1d00481093e10775eaf69d619c45b32a4aa7dc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Hundeb=C3=B8ll?= +Date: Tue, 6 Nov 2018 14:50:47 +0100 +Subject: [PATCH] buildinfo: strip sysroot and debug-prefix-map from compiler + info +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The openssl build system generates buildinf.h containing the full +compiler command line used to compile objects. This breaks +reproducibility, as the compile command is baked into libcrypto, where +it is used when running `openssl version -f`. + +Add stripped build variables for the compiler and cflags lines, and use +those when generating buildinfo.h. + +This is based on a similar patch for older openssl versions: +https://patchwork.openembedded.org/patch/147229/ + +Upstream-Status: Inappropriate [OE specific] +Signed-off-by: Martin Hundebøll + + +Update to fix buildpaths qa issue for '-fmacro-prefix-map'. + +Signed-off-by: Kai Kang +--- + Configurations/unix-Makefile.tmpl | 10 +++++++++- + crypto/build.info | 2 +- + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl +index 16af4d2087..54c162784c 100644 +--- a/Configurations/unix-Makefile.tmpl ++++ b/Configurations/unix-Makefile.tmpl +@@ -317,13 +317,22 @@ BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (), + '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} + BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) + +-# CPPFLAGS_Q is used for one thing only: to build up buildinf.h ++# *_Q variables are used for one thing only: to build up buildinf.h + CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g; + $cppflags2 =~ s|([\\"])|\\$1|g; + $lib_cppflags =~ s|([\\"])|\\$1|g; + join(' ', $lib_cppflags || (), $cppflags2 || (), + $cppflags1 || ()) -} + ++CFLAGS_Q={- for (@{$config{CFLAGS}}) { ++ s|-fdebug-prefix-map=[^ ]+|-fdebug-prefix-map=|g; ++ s|-fmacro-prefix-map=[^ ]+|-fmacro-prefix-map=|g; ++ } ++ join(' ', @{$config{CFLAGS}}) -} ++ ++CC_Q={- $config{CC} =~ s|--sysroot=[^ ]+|--sysroot=recipe-sysroot|g; ++ join(' ', $config{CC}) -} ++ + PERLASM_SCHEME= {- $target{perlasm_scheme} -} + + # For x86 assembler: Set PROCESSOR to 386 if you want to support +diff --git a/crypto/build.info b/crypto/build.info +index b515b7318e..8c9cee2a09 100644 +--- a/crypto/build.info ++++ b/crypto/build.info +@@ -10,7 +10,7 @@ EXTRA= ../ms/uplink-x86.pl ../ms/uplink.c ../ms/applink.c \ + ppccpuid.pl pariscid.pl alphacpuid.pl arm64cpuid.pl armv4cpuid.pl + + DEPEND[cversion.o]=buildinf.h +-GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)" ++GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC_Q) $(CFLAGS_Q) $(CPPFLAGS_Q)" "$(PLATFORM)" + DEPEND[buildinf.h]=../configdata.pm + + GENERATE[uplink-x86.s]=../ms/uplink-x86.pl $(PERLASM_SCHEME) +-- +2.19.1 + diff --git a/meta-digi-dey/recipes-connectivity/openssl/openssl/0001-skip-test_symbol_presence.patch b/meta-digi-dey/recipes-connectivity/openssl/openssl/0001-skip-test_symbol_presence.patch new file mode 100644 index 000000000..d8d9651b6 --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/openssl/openssl/0001-skip-test_symbol_presence.patch @@ -0,0 +1,46 @@ +From a9401b2289656c5a36dd1b0ecebf0d23e291ce70 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia +Date: Tue, 2 Oct 2018 23:58:24 +0800 +Subject: [PATCH] skip test_symbol_presence + +We cannot skip `01-test_symbol_presence.t' by configuring option `no-shared' +as INSTALL told us the shared libraries will not be built. + +[INSTALL snip] + Notes on shared libraries + ------------------------- + + For most systems the OpenSSL Configure script knows what is needed to + build shared libraries for libcrypto and libssl. On these systems + the shared libraries will be created by default. This can be suppressed and + only static libraries created by using the "no-shared" option. On systems + where OpenSSL does not know how to build shared libraries the "no-shared" + option will be forced and only static libraries will be created. +[INSTALL snip] + +Hence directly modification the case to skip it. + +Upstream-Status: Inappropriate [OE Specific] + +Signed-off-by: Hongxu Jia +--- + test/recipes/01-test_symbol_presence.t | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/test/recipes/01-test_symbol_presence.t b/test/recipes/01-test_symbol_presence.t +index 7f2a2d7..0b93745 100644 +--- a/test/recipes/01-test_symbol_presence.t ++++ b/test/recipes/01-test_symbol_presence.t +@@ -14,8 +14,7 @@ use OpenSSL::Test::Utils; + + setup("test_symbol_presence"); + +-plan skip_all => "Only useful when building shared libraries" +- if disabled("shared"); ++plan skip_all => "The case needs debug symbols then we just disable it"; + + my @libnames = ("crypto", "ssl"); + my $testcount = scalar @libnames; +-- +2.7.4 + diff --git a/meta-digi-dey/recipes-connectivity/openssl/openssl/afalg.patch b/meta-digi-dey/recipes-connectivity/openssl/openssl/afalg.patch new file mode 100644 index 000000000..b7c0e9697 --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/openssl/openssl/afalg.patch @@ -0,0 +1,31 @@ +Don't refuse to build afalgeng if cross-compiling or the host kernel is too old. + +Upstream-Status: Submitted [hhttps://github.com/openssl/openssl/pull/7688] +Signed-off-by: Ross Burton + +diff --git a/Configure b/Configure +index 3baa8ce..9ef52ed 100755 +--- a/Configure ++++ b/Configure +@@ -1550,20 +1550,7 @@ unless ($disabled{"crypto-mdebug-backtrace"}) + unless ($disabled{afalgeng}) { + $config{afalgeng}=""; + if (grep { $_ eq 'afalgeng' } @{$target{enable}}) { +- my $minver = 4*10000 + 1*100 + 0; +- if ($config{CROSS_COMPILE} eq "") { +- my $verstr = `uname -r`; +- my ($ma, $mi1, $mi2) = split("\\.", $verstr); +- ($mi2) = $mi2 =~ /(\d+)/; +- my $ver = $ma*10000 + $mi1*100 + $mi2; +- if ($ver < $minver) { +- disable('too-old-kernel', 'afalgeng'); +- } else { +- push @{$config{engdirs}}, "afalg"; +- } +- } else { +- disable('cross-compiling', 'afalgeng'); +- } ++ push @{$config{engdirs}}, "afalg"; + } else { + disable('not-linux', 'afalgeng'); + } diff --git a/meta-digi-dey/recipes-connectivity/openssl/openssl/reproducible.patch b/meta-digi-dey/recipes-connectivity/openssl/openssl/reproducible.patch new file mode 100644 index 000000000..a24260c95 --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/openssl/openssl/reproducible.patch @@ -0,0 +1,32 @@ +The value for perl_archname can vary depending on the host, e.g. +x86_64-linux-gnu-thread-multi or x86_64-linux-thread-multi which +makes the ptest package non-reproducible. Its unused other than +these references so drop it. + +RP 2020/2/6 + +Upstream-Status: Pending +Signed-off-by: Richard Purdie + +Index: openssl-1.1.1d/Configure +=================================================================== +--- openssl-1.1.1d.orig/Configure ++++ openssl-1.1.1d/Configure +@@ -286,7 +286,7 @@ if (defined env($local_config_envname)) + # Save away perl command information + $config{perl_cmd} = $^X; + $config{perl_version} = $Config{version}; +-$config{perl_archname} = $Config{archname}; ++#$config{perl_archname} = $Config{archname}; + + $config{prefix}=""; + $config{openssldir}=""; +@@ -2517,7 +2517,7 @@ _____ + @{$config{perlargv}}), "\n"; + print "\nPerl information:\n\n"; + print ' ',$config{perl_cmd},"\n"; +- print ' ',$config{perl_version},' for ',$config{perl_archname},"\n"; ++ print ' ',$config{perl_version},"\n"; + } + if ($dump || $options) { + my $longest = 0; diff --git a/meta-digi-dey/recipes-connectivity/openssl/openssl/run-ptest b/meta-digi-dey/recipes-connectivity/openssl/openssl/run-ptest new file mode 100644 index 000000000..3fb22471f --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/openssl/openssl/run-ptest @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +# Optional arguments are 'list' to lists all tests, or the test name (base name +# ie test_evp, not 03_test_evp.t). + +export TOP=. +# OPENSSL_ENGINES is relative from the test binaries +export OPENSSL_ENGINES=../engines + +perl ./test/run_tests.pl $* | perl -0pe 's#(.*) \.*.ok#PASS: \1#g; s#(.*) \.*.skipped: (.*)#SKIP: \1 (\2)#g; s#(.*) \.*.\nDubious#FAIL: \1#;' diff --git a/meta-digi-dey/recipes-connectivity/openssl/openssl_1.1.1l.bb b/meta-digi-dey/recipes-connectivity/openssl/openssl_1.1.1l.bb new file mode 100644 index 000000000..9412b19fa --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/openssl/openssl_1.1.1l.bb @@ -0,0 +1,217 @@ +SUMMARY = "Secure Socket Layer" +DESCRIPTION = "Secure Socket Layer (SSL) binary and related cryptographic tools." +HOMEPAGE = "http://www.openssl.org/" +BUGTRACKER = "http://www.openssl.org/news/vulnerabilities.html" +SECTION = "libs/network" + +# "openssl" here actually means both OpenSSL and SSLeay licenses apply +# (see meta/files/common-licenses/OpenSSL to which "openssl" is SPDXLICENSEMAPped) +LICENSE = "openssl" +LIC_FILES_CHKSUM = "file://LICENSE;md5=d343e62fc9c833710bbbed25f27364c8" + +DEPENDS = "hostperl-runtime-native" + +SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \ + file://run-ptest \ + file://0001-skip-test_symbol_presence.patch \ + file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \ + file://afalg.patch \ + file://reproducible.patch \ + " + +SRC_URI_append_class-nativesdk = " \ + file://environment.d-openssl.sh \ + " + +SRC_URI[sha256sum] = "0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1" + +inherit lib_package multilib_header multilib_script ptest +MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash" + +PACKAGECONFIG ?= "" +PACKAGECONFIG_class-native = "" +PACKAGECONFIG_class-nativesdk = "" + +PACKAGECONFIG[cryptodev-linux] = "enable-devcryptoeng,disable-devcryptoeng,cryptodev-linux,,cryptodev-module" + +B = "${WORKDIR}/build" +do_configure[cleandirs] = "${B}" + +#| ./libcrypto.so: undefined reference to `getcontext' +#| ./libcrypto.so: undefined reference to `setcontext' +#| ./libcrypto.so: undefined reference to `makecontext' +EXTRA_OECONF_append_libc-musl = " no-async" +EXTRA_OECONF_append_libc-musl_powerpc64 = " no-asm" + +# adding devrandom prevents openssl from using getrandom() which is not available on older glibc versions +# (native versions can be built with newer glibc, but then relocated onto a system with older glibc) +EXTRA_OECONF_class-native = "--with-rand-seed=os,devrandom" +EXTRA_OECONF_class-nativesdk = "--with-rand-seed=os,devrandom" + +# Relying on hardcoded built-in paths causes openssl-native to not be relocateable from sstate. +CFLAGS_append_class-native = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin" +CFLAGS_append_class-nativesdk = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin" + +do_configure () { + os=${HOST_OS} + case $os in + linux-gnueabi |\ + linux-gnuspe |\ + linux-musleabi |\ + linux-muslspe |\ + linux-musl ) + os=linux + ;; + *) + ;; + esac + target="$os-${HOST_ARCH}" + case $target in + linux-arm*) + target=linux-armv4 + ;; + linux-aarch64*) + target=linux-aarch64 + ;; + linux-i?86 | linux-viac3) + target=linux-x86 + ;; + linux-gnux32-x86_64 | linux-muslx32-x86_64 ) + target=linux-x32 + ;; + linux-gnu64-x86_64) + target=linux-x86_64 + ;; + linux-mips | linux-mipsel) + # specifying TARGET_CC_ARCH prevents openssl from (incorrectly) adding target architecture flags + target="linux-mips32 ${TARGET_CC_ARCH}" + ;; + linux-gnun32-mips*) + target=linux-mips64 + ;; + linux-*-mips64 | linux-mips64 | linux-*-mips64el | linux-mips64el) + target=linux64-mips64 + ;; + linux-microblaze* | linux-nios2* | linux-sh3 | linux-sh4 | linux-arc*) + target=linux-generic32 + ;; + linux-powerpc) + target=linux-ppc + ;; + linux-powerpc64) + target=linux-ppc64 + ;; + linux-powerpc64le) + target=linux-ppc64le + ;; + linux-riscv32) + target=linux-generic32 + ;; + linux-riscv64) + target=linux-generic64 + ;; + linux-sparc | linux-supersparc) + target=linux-sparcv9 + ;; + esac + + useprefix=${prefix} + if [ "x$useprefix" = "x" ]; then + useprefix=/ + fi + # WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the + # environment variables set by bitbake. Adjust the environment variables instead. + HASHBANGPERL="/usr/bin/env perl" PERL=perl PERL5LIB="${S}/external/perl/Text-Template-1.46/lib/" \ + perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} --prefix=$useprefix --openssldir=${libdir}/ssl-1.1 --libdir=${libdir} $target + perl ${B}/configdata.pm --dump +} + +do_install () { + oe_runmake DESTDIR="${D}" MANDIR="${mandir}" MANSUFFIX=ssl install + + oe_multilib_header openssl/opensslconf.h + + # Create SSL structure for packages such as ca-certificates which + # contain hard-coded paths to /etc/ssl. Debian does the same. + install -d ${D}${sysconfdir}/ssl + mv ${D}${libdir}/ssl-1.1/certs \ + ${D}${libdir}/ssl-1.1/private \ + ${D}${libdir}/ssl-1.1/openssl.cnf \ + ${D}${sysconfdir}/ssl/ + + # Although absolute symlinks would be OK for the target, they become + # invalid if native or nativesdk are relocated from sstate. + ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl-1.1/certs + ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl-1.1/private + ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl-1.1/openssl.cnf +} + +do_install_append_class-native () { + create_wrapper ${D}${bindir}/openssl \ + OPENSSL_CONF=${libdir}/ssl-1.1/openssl.cnf \ + SSL_CERT_DIR=${libdir}/ssl-1.1/certs \ + SSL_CERT_FILE=${libdir}/ssl-1.1/cert.pem \ + OPENSSL_ENGINES=${libdir}/engines-1.1 +} + +do_install_append_class-nativesdk () { + mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d + install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh + sed 's|/usr/lib/ssl/|/usr/lib/ssl-1.1/|g' -i ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh +} + +PTEST_BUILD_HOST_FILES += "configdata.pm" +PTEST_BUILD_HOST_PATTERN = "perl_version =" +do_install_ptest () { + # Prune the build tree + rm -f ${B}/fuzz/*.* ${B}/test/*.* + + cp ${S}/Configure ${B}/configdata.pm ${D}${PTEST_PATH} + cp -r ${S}/external ${B}/test ${S}/test ${B}/fuzz ${S}/util ${B}/util ${D}${PTEST_PATH} + + # For test_shlibload + ln -s ${libdir}/libcrypto.so.1.1 ${D}${PTEST_PATH}/ + ln -s ${libdir}/libssl.so.1.1 ${D}${PTEST_PATH}/ + + install -d ${D}${PTEST_PATH}/apps + ln -s ${bindir}/openssl ${D}${PTEST_PATH}/apps + install -m644 ${S}/apps/*.pem ${S}/apps/*.srl ${S}/apps/openssl.cnf ${D}${PTEST_PATH}/apps + install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps + + install -d ${D}${PTEST_PATH}/engines + install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines +} + +# Add the openssl.cnf file to the openssl-conf package. Make the libcrypto +# package RRECOMMENDS on this package. This will enable the configuration +# file to be installed for both the openssl-bin package and the libcrypto +# package since the openssl-bin package depends on the libcrypto package. + +PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc" + +FILES_libcrypto = "${libdir}/libcrypto${SOLIBS}" +FILES_libssl = "${libdir}/libssl${SOLIBS}" +FILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf \ + ${libdir}/ssl-1.1/openssl.cnf* \ + " +FILES_${PN}-engines = "${libdir}/engines-1.1" +FILES_${PN}-misc = "${libdir}/ssl-1.1/misc" +FILES_${PN} =+ "${libdir}/ssl-1.1/*" +FILES_${PN}_append_class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh" + +CONFFILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf" + +RRECOMMENDS_libcrypto += "openssl-conf" +RDEPENDS_${PN}-ptest += "openssl-bin perl perl-modules bash" + +RDEPENDS_${PN}-bin += "openssl-conf" + +BBCLASSEXTEND = "native nativesdk" + +CVE_PRODUCT = "openssl:openssl" + +CVE_VERSION_SUFFIX = "alphabetical" + +# Only affects OpenSSL >= 1.1.1 in combination with Apache < 2.4.37 +# Apache in meta-webserver is already recent enough +CVE_CHECK_WHITELIST += "CVE-2019-0190" From 3bccb2a6dde9beabed60f89734aa9c362cc30bf5 Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Thu, 26 Aug 2021 17:49:54 +0200 Subject: [PATCH 31/70] bblayers.conf.sample: add meta-selinux layer to all supported platforms This layer has no effect unless "selinux" is in the DISTRO_FEATURES, so it's safe to add it to our default builds. https://onedigi.atlassian.net/browse/DEL-7641 Signed-off-by: Gabriel Valcazar --- sdk/config/ccimx6qpsbc/bblayers.conf.sample | 1 + sdk/config/ccimx6sbc/bblayers.conf.sample | 1 + sdk/config/ccimx8mm-dvk/bblayers.conf.sample | 1 + sdk/config/ccimx8mn-dvk/bblayers.conf.sample | 1 + sdk/config/ccimx8x-sbc-express/bblayers.conf.sample | 1 + sdk/config/ccimx8x-sbc-pro/bblayers.conf.sample | 1 + 6 files changed, 6 insertions(+) diff --git a/sdk/config/ccimx6qpsbc/bblayers.conf.sample b/sdk/config/ccimx6qpsbc/bblayers.conf.sample index 68d2495bf..cc67800f1 100644 --- a/sdk/config/ccimx6qpsbc/bblayers.conf.sample +++ b/sdk/config/ccimx6qpsbc/bblayers.conf.sample @@ -19,6 +19,7 @@ BBLAYERS ?= " \ ##DIGIBASE##/meta-fsl-demos \ ##DIGIBASE##/meta-python2 \ ##DIGIBASE##/meta-webkit \ + ##DIGIBASE##/meta-selinux \ ##DIGIBASE##/meta-digi/meta-digi-arm \ ##DIGIBASE##/meta-digi/meta-digi-dey \ " diff --git a/sdk/config/ccimx6sbc/bblayers.conf.sample b/sdk/config/ccimx6sbc/bblayers.conf.sample index 68d2495bf..cc67800f1 100644 --- a/sdk/config/ccimx6sbc/bblayers.conf.sample +++ b/sdk/config/ccimx6sbc/bblayers.conf.sample @@ -19,6 +19,7 @@ BBLAYERS ?= " \ ##DIGIBASE##/meta-fsl-demos \ ##DIGIBASE##/meta-python2 \ ##DIGIBASE##/meta-webkit \ + ##DIGIBASE##/meta-selinux \ ##DIGIBASE##/meta-digi/meta-digi-arm \ ##DIGIBASE##/meta-digi/meta-digi-dey \ " diff --git a/sdk/config/ccimx8mm-dvk/bblayers.conf.sample b/sdk/config/ccimx8mm-dvk/bblayers.conf.sample index 94458739a..491decb14 100644 --- a/sdk/config/ccimx8mm-dvk/bblayers.conf.sample +++ b/sdk/config/ccimx8mm-dvk/bblayers.conf.sample @@ -20,6 +20,7 @@ BBLAYERS ?= " \ ##DIGIBASE##/meta-python2 \ ##DIGIBASE##/meta-webkit \ ##DIGIBASE##/meta-imx/meta-ml \ + ##DIGIBASE##/meta-selinux \ ##DIGIBASE##/meta-digi/meta-digi-arm \ ##DIGIBASE##/meta-digi/meta-digi-dey \ " diff --git a/sdk/config/ccimx8mn-dvk/bblayers.conf.sample b/sdk/config/ccimx8mn-dvk/bblayers.conf.sample index 94458739a..491decb14 100644 --- a/sdk/config/ccimx8mn-dvk/bblayers.conf.sample +++ b/sdk/config/ccimx8mn-dvk/bblayers.conf.sample @@ -20,6 +20,7 @@ BBLAYERS ?= " \ ##DIGIBASE##/meta-python2 \ ##DIGIBASE##/meta-webkit \ ##DIGIBASE##/meta-imx/meta-ml \ + ##DIGIBASE##/meta-selinux \ ##DIGIBASE##/meta-digi/meta-digi-arm \ ##DIGIBASE##/meta-digi/meta-digi-dey \ " diff --git a/sdk/config/ccimx8x-sbc-express/bblayers.conf.sample b/sdk/config/ccimx8x-sbc-express/bblayers.conf.sample index 68d2495bf..cc67800f1 100644 --- a/sdk/config/ccimx8x-sbc-express/bblayers.conf.sample +++ b/sdk/config/ccimx8x-sbc-express/bblayers.conf.sample @@ -19,6 +19,7 @@ BBLAYERS ?= " \ ##DIGIBASE##/meta-fsl-demos \ ##DIGIBASE##/meta-python2 \ ##DIGIBASE##/meta-webkit \ + ##DIGIBASE##/meta-selinux \ ##DIGIBASE##/meta-digi/meta-digi-arm \ ##DIGIBASE##/meta-digi/meta-digi-dey \ " diff --git a/sdk/config/ccimx8x-sbc-pro/bblayers.conf.sample b/sdk/config/ccimx8x-sbc-pro/bblayers.conf.sample index 94458739a..491decb14 100644 --- a/sdk/config/ccimx8x-sbc-pro/bblayers.conf.sample +++ b/sdk/config/ccimx8x-sbc-pro/bblayers.conf.sample @@ -20,6 +20,7 @@ BBLAYERS ?= " \ ##DIGIBASE##/meta-python2 \ ##DIGIBASE##/meta-webkit \ ##DIGIBASE##/meta-imx/meta-ml \ + ##DIGIBASE##/meta-selinux \ ##DIGIBASE##/meta-digi/meta-digi-arm \ ##DIGIBASE##/meta-digi/meta-digi-dey \ " From a7b828851181b263466a2a8cbd7ba9caf9d6e28e Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Thu, 26 Aug 2021 14:43:33 +0200 Subject: [PATCH 32/70] images: include packagegroup-core-selinux if "selinux" is in DISTRO_FEATURES This packagegroup includes all of the userspace packages needed to use SELinux. For now, use the same variant of the packagegroup, which contains all available packages. Since the meta-selinux layer isn't available in all platforms, implement this change via a dynamic layer. https://onedigi.atlassian.net/browse/DEL-7641 Signed-off-by: Gabriel Valcazar --- meta-digi-dey/conf/layer.conf | 2 ++ .../selinux/recipes-core/images/dey-image-aws.bbappend | 1 + .../selinux/recipes-core/images/dey-image-qt.bbappend | 1 + .../selinux/recipes-core/images/dey-image-webkit.bbappend | 1 + .../dynamic-layers/selinux/recipes-core/images/selinux_dey.inc | 1 + 5 files changed, 6 insertions(+) create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-aws.bbappend create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-qt.bbappend create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-webkit.bbappend create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-core/images/selinux_dey.inc diff --git a/meta-digi-dey/conf/layer.conf b/meta-digi-dey/conf/layer.conf index 94fd8c7b0..f5f720bc0 100644 --- a/meta-digi-dey/conf/layer.conf +++ b/meta-digi-dey/conf/layer.conf @@ -8,6 +8,8 @@ BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ BBFILES_DYNAMIC += " \ webkit:${LAYERDIR}/dynamic-layers/webkit/*/*/*.bb \ webkit:${LAYERDIR}/dynamic-layers/webkit/*/*/*.bbappend \ + selinux:${LAYERDIR}/dynamic-layers/selinux/*/*/*.bb \ + selinux:${LAYERDIR}/dynamic-layers/selinux/*/*/*.bbappend \ " BBFILE_COLLECTIONS += "digi-dey" diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-aws.bbappend b/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-aws.bbappend new file mode 100644 index 000000000..072993cd7 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-aws.bbappend @@ -0,0 +1 @@ +include selinux_dey.inc diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-qt.bbappend b/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-qt.bbappend new file mode 100644 index 000000000..072993cd7 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-qt.bbappend @@ -0,0 +1 @@ +include selinux_dey.inc diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-webkit.bbappend b/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-webkit.bbappend new file mode 100644 index 000000000..072993cd7 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/dey-image-webkit.bbappend @@ -0,0 +1 @@ +include selinux_dey.inc diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/selinux_dey.inc b/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/selinux_dey.inc new file mode 100644 index 000000000..0bcf93ea6 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-core/images/selinux_dey.inc @@ -0,0 +1 @@ +IMAGE_INSTALL_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'packagegroup-core-selinux', '', d)}" From abba0948a9c0dfcca7c0ea7f684966420847c12c Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Thu, 26 Aug 2021 18:31:43 +0200 Subject: [PATCH 33/70] refpolicy: adapt reference policy to DEY prebuilt image features The default policy provided by meta-selinux breaks a lot of the features in DEY, so adapt it to make most features work. Note that this is simply an example, end users should create their own policies for their own needs. Make these changes toggleable so that users can use the reference policy instead. https://onedigi.atlassian.net/browse/DEL-7641 Signed-off-by: Gabriel Valcazar --- .../conf/machine/include/digi-defaults.inc | 3 + ...-Apply-rules-for-DEY-prebuilt-images.patch | 881 ++++++++++++++++++ ...-executables-run-in-the-udev_t-realm.patch | 86 ++ .../refpolicy/refpolicy-mcs_git.bbappend | 1 + .../refpolicy/refpolicy-minimum_git.bbappend | 1 + .../refpolicy/refpolicy-mls_git.bbappend | 1 + .../refpolicy/refpolicy-standard_git.bbappend | 1 + .../refpolicy/refpolicy-targeted_git.bbappend | 1 + .../refpolicy/refpolicy_dey.inc | 8 + 9 files changed, 983 insertions(+) create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/files/0001-Apply-rules-for-DEY-prebuilt-images.patch create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/files/0002-Make-udevadm_t-executables-run-in-the-udev_t-realm.patch create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-mcs_git.bbappend create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-minimum_git.bbappend create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-mls_git.bbappend create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-standard_git.bbappend create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-targeted_git.bbappend create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy_dey.inc diff --git a/meta-digi-arm/conf/machine/include/digi-defaults.inc b/meta-digi-arm/conf/machine/include/digi-defaults.inc index 0c21fa198..8daf9a1f6 100644 --- a/meta-digi-arm/conf/machine/include/digi-defaults.inc +++ b/meta-digi-arm/conf/machine/include/digi-defaults.inc @@ -79,3 +79,6 @@ DEFAULT_IMAGE_NAME ??= "dey-image-qt" # List of graphical images names (for install scripts) GRAPHICAL_IMAGES ?= "dey-image-qt dey-image-webkit" + +# Include DEY SELinux policy modifications by default +DEY_SELINUX_POLICY ?= "1" diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/files/0001-Apply-rules-for-DEY-prebuilt-images.patch b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/files/0001-Apply-rules-for-DEY-prebuilt-images.patch new file mode 100644 index 000000000..ae55f3c4f --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/files/0001-Apply-rules-for-DEY-prebuilt-images.patch @@ -0,0 +1,881 @@ +From: Gabriel Valcazar +Date: Fri, 20 Aug 2021 11:59:27 +0200 +Subject: [PATCH 1/2] Apply rules for DEY prebuilt images + +These rules were obtained by putting the system's SELinux in permissive mode, +extracting all of the AVC denials, and then running them through audit2allow. +This allows to use most of the features that are expected to work out of the +box in DEY. + +Signed-off-by: Gabriel Valcazar +--- + policy/modules/admin/alsa.te | 10 +++++ + policy/modules/admin/dmesg.te | 7 ++++ + policy/modules/admin/netutils.te | 7 ++++ + policy/modules/apps/pulseaudio.if | 9 +++++ + policy/modules/apps/pulseaudio.te | 15 +++++++ + policy/modules/kernel/corecommands.if | 8 ++++ + policy/modules/kernel/devices.if | 48 +++++++++++++++++++++++ + policy/modules/roles/sysadm.if | 24 ++++++++++++ + policy/modules/roles/sysadm.te | 47 ++++++++++++++++++++++ + policy/modules/services/acpi.if | 8 ++++ + policy/modules/services/acpi.te | 20 ++++++++++ + policy/modules/services/apache.if | 8 ++++ + policy/modules/services/bluetooth.if | 10 +++++ + policy/modules/services/bluetooth.te | 10 +++++ + policy/modules/services/consolekit.te | 7 ++++ + policy/modules/services/dbus.if | 8 ++++ + policy/modules/services/dbus.te | 7 ++++ + policy/modules/services/modemmanager.te | 10 +++++ + policy/modules/services/networkmanager.if | 8 ++++ + policy/modules/services/networkmanager.te | 23 +++++++++++ + policy/modules/system/init.te | 7 ++++ + policy/modules/system/libraries.if | 8 ++++ + policy/modules/system/locallogin.te | 9 +++++ + policy/modules/system/logging.if | 8 ++++ + policy/modules/system/logging.te | 11 ++++++ + policy/modules/system/modutils.te | 8 ++++ + policy/modules/system/mount.te | 7 ++++ + policy/modules/system/selinuxutil.te | 8 ++++ + policy/modules/system/sysnetwork.te | 8 ++++ + policy/modules/system/systemd.if | 24 ++++++++++++ + policy/modules/system/systemd.te | 22 +++++++++++ + policy/modules/system/udev.if | 8 ++++ + policy/modules/system/udev.te | 7 ++++ + policy/modules/system/userdomain.if | 8 ++++ + policy/modules/system/userdomain.te | 7 ++++ + policy/modules/system/xdg.if | 16 ++++++++ + 36 files changed, 460 insertions(+) + +diff --git a/policy/modules/admin/alsa.te b/policy/modules/admin/alsa.te +index 09d590add..2762fc664 100644 +--- a/policy/modules/admin/alsa.te ++++ b/policy/modules/admin/alsa.te +@@ -111,3 +111,13 @@ optional_policy(` + hal_use_fds(alsa_t) + hal_write_log(alsa_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow alsa_t var_lock_t:file { getattr lock open read write }; ++ ++allow alsa_t alsa_var_lib_t:lnk_file read; ++xdg_config_dirs_search(alsa_t) +diff --git a/policy/modules/admin/dmesg.te b/policy/modules/admin/dmesg.te +index 228baecd8..ccec67c80 100644 +--- a/policy/modules/admin/dmesg.te ++++ b/policy/modules/admin/dmesg.te +@@ -60,3 +60,10 @@ optional_policy(` + optional_policy(` + udev_read_db(dmesg_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++corecmd_map_exec_bin_files(dmesg_t) +diff --git a/policy/modules/admin/netutils.te b/policy/modules/admin/netutils.te +index 5cdfe2196..31e9d970c 100644 +--- a/policy/modules/admin/netutils.te ++++ b/policy/modules/admin/netutils.te +@@ -212,3 +212,10 @@ userdom_use_inherited_user_terminals(traceroute_t) + # nmap searches . + userdom_dontaudit_search_user_home_dirs(traceroute_t) + userdom_dontaudit_search_user_home_content(traceroute_t) ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow ping_t bin_t:file { execute map read }; +diff --git a/policy/modules/apps/pulseaudio.if b/policy/modules/apps/pulseaudio.if +index 1b9c6ccde..aeac19008 100644 +--- a/policy/modules/apps/pulseaudio.if ++++ b/policy/modules/apps/pulseaudio.if +@@ -147,6 +147,15 @@ interface(`pulseaudio_signull',` + allow $1 pulseaudio_t:process signull; + ') + ++interface(`pulseaudio_connectto',` ++ gen_require(` ++ type pulseaudio_t; ++ ') ++ ++ allow $1 pulseaudio_t:unix_stream_socket connectto; ++ allow $1 pulseaudio_t:fd use; ++') ++ + ######################################## + ## + ## Use file descriptors for +diff --git a/policy/modules/apps/pulseaudio.te b/policy/modules/apps/pulseaudio.te +index 3a50fc5b2..ce24736f3 100644 +--- a/policy/modules/apps/pulseaudio.te ++++ b/policy/modules/apps/pulseaudio.te +@@ -311,3 +311,18 @@ optional_policy(` + optional_policy(` + unconfined_signull(pulseaudio_client) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow pulseaudio_t self:capability net_admin; ++systemd_watch_logind_sessions_files(pulseaudio_t) ++allow pulseaudio_t user_runtime_root_t:dir { add_name create read remove_name write }; ++allow pulseaudio_t user_runtime_root_t:file { create getattr lock open read unlink write }; ++allow pulseaudio_t user_runtime_root_t:sock_file { create setattr }; ++allow pulseaudio_t user_home_dir_t:dir create; ++dbus_write_sock_file(pulseaudio_t) ++sysadm_use_fds(pulseaudio_t) ++sysadm_connectto_socket(pulseaudio_t) +diff --git a/policy/modules/kernel/corecommands.if b/policy/modules/kernel/corecommands.if +index c605ca5f7..e7b41c32c 100644 +--- a/policy/modules/kernel/corecommands.if ++++ b/policy/modules/kernel/corecommands.if +@@ -199,6 +199,14 @@ interface(`corecmd_check_exec_bin_files',` + allow $1 bin_t:file { execute getattr }; + ') + ++interface(`corecmd_map_exec_bin_files',` ++ gen_require(` ++ type bin_t; ++ ') ++ ++ allow $1 bin_t:file { execute map read }; ++') ++ + ######################################## + ## + ## Read files in bin directories. +diff --git a/policy/modules/kernel/devices.if b/policy/modules/kernel/devices.if +index 406b29796..e4ad0d3b8 100644 +--- a/policy/modules/kernel/devices.if ++++ b/policy/modules/kernel/devices.if +@@ -2114,6 +2114,14 @@ interface(`dev_getattr_input_dev',` + allow $1 event_device_t:chr_file getattr; + ') + ++interface(`dev_read_input_dev',` ++ gen_require(` ++ type event_device_t; ++ ') ++ ++ allow $1 event_device_t:chr_file read; ++') ++ + ######################################## + ## + ## Set the attributes of the event devices. +@@ -2260,6 +2268,38 @@ interface(`dev_dontaudit_setattr_framebuffer_dev',` + dontaudit $1 framebuf_device_t:chr_file setattr; + ') + ++interface(`dev_read_write_framebuffer_dev',` ++ gen_require(` ++ type framebuf_device_t; ++ ') ++ ++ allow $1 framebuf_device_t:chr_file { read write }; ++') ++ ++interface(`dev_use_gpiochip',` ++ gen_require(` ++ type gpiochip_device_t; ++ ') ++ ++ allow $1 gpiochip_device_t:chr_file { ioctl open read write }; ++') ++ ++interface(`dev_use_watchdog',` ++ gen_require(` ++ type watchdog_device_t; ++ ') ++ ++ allow $1 watchdog_device_t:chr_file { ioctl open read write }; ++') ++ ++interface(`dev_use_wireless',` ++ gen_require(` ++ type wireless_device_t; ++ ') ++ ++ allow $1 wireless_device_t:chr_file { ioctl open read write }; ++') ++ + ######################################## + ## + ## Read the framebuffer. +@@ -5064,6 +5104,14 @@ interface(`dev_dontaudit_getattr_video_dev',` + dontaudit $1 v4l_device_t:chr_file getattr; + ') + ++interface(`dev_handle_video_dev',` ++ gen_require(` ++ type v4l_device_t; ++ ') ++ ++ allow $1 v4l_device_t:chr_file { ioctl map open read write }; ++') ++ + ######################################## + ## + ## Set the attributes of video4linux device nodes. +diff --git a/policy/modules/roles/sysadm.if b/policy/modules/roles/sysadm.if +index 5c2871842..49416d26e 100644 +--- a/policy/modules/roles/sysadm.if ++++ b/policy/modules/roles/sysadm.if +@@ -211,6 +211,14 @@ interface(`sysadm_sigchld',` + allow $1 sysadm_t:process sigchld; + ') + ++interface(`sysadm_transition',` ++ gen_require(` ++ type sysadm_t; ++ ') ++ ++ allow $1 sysadm_t:process transition; ++') ++ + ######################################## + ## + ## Inherit and use sysadm file descriptors +@@ -229,6 +237,22 @@ interface(`sysadm_use_fds',` + allow $1 sysadm_t:fd use; + ') + ++interface(`sysadm_connectto_socket',` ++ gen_require(` ++ type sysadm_t; ++ ') ++ ++ allow $1 sysadm_t:unix_stream_socket connectto; ++') ++ ++interface(`sysadm_sendto_unix_dgram_socket',` ++ gen_require(` ++ type sysadm_t; ++ ') ++ ++ allow $1 sysadm_t:unix_dgram_socket sendto; ++') ++ + ######################################## + ## + ## Read and write sysadm user unnamed pipes. +diff --git a/policy/modules/roles/sysadm.te b/policy/modules/roles/sysadm.te +index 310a4fad2..4a3dc7a58 100644 +--- a/policy/modules/roles/sysadm.te ++++ b/policy/modules/roles/sysadm.te +@@ -1375,3 +1375,50 @@ ifndef(`distro_redhat',` + ') + ') + ++######################################## ++# ++# DEY custom rules ++# ++ ++allow sysadm_t init_exec_t:file entrypoint; ++allow sysadm_t init_t:unix_stream_socket { ioctl read write }; ++allow sysadm_t self:capability audit_write; ++allow sysadm_t self:system reload; ++allow sysadm_t user_runtime_root_t:blk_file create; ++allow sysadm_t user_runtime_root_t:chr_file create; ++allow sysadm_t usr_t:file execute; ++ ++allow sysadm_t device_t:chr_file { create ioctl open read write }; ++dev_read_write_framebuffer_dev(sysadm_t) ++allow sysadm_t initrc_t:unix_stream_socket connectto; ++pulseaudio_connectto(sysadm_t) ++ ++#!!!! This avc can be allowed using the boolean 'allow_execmem' ++allow sysadm_t self:process execmem; ++allow sysadm_t usr_t:file execute_no_trans; ++ ++allow sysadm_t user_tmpfs_t:file { execmod execute }; ++ ++dev_use_gpiochip(sysadm_t) ++allow sysadm_t kernel_t:system module_request; ++allow sysadm_t self:can_socket { bind create getopt read setopt write }; ++dev_use_watchdog(sysadm_t) ++ ++networkmanager_sendto_unix_dgram_socket(sysadm_t) ++allow sysadm_t initrc_t:fd use; ++xdg_dir_watch(sysadm_t) ++ ++allow sysadm_t device_t:chr_file map; ++allow sysadm_t device_t:dir watch; ++allow sysadm_t framebuf_device_t:chr_file { ioctl open }; ++apache_execute_runtime_files(sysadm_t) ++dev_handle_video_dev(sysadm_t) ++ ++allow sysadm_t self:bluetooth_socket create; ++allow sysadm_t self:process execstack; ++ ++allow sysadm_t self:bluetooth_socket ioctl; ++ ++dev_manage_dri_dev(sysadm_t) ++allow sysadm_t self:netlink_route_socket nlmsg_write; ++allow sysadm_t semanage_t:process { noatsecure rlimitinh siginh }; +diff --git a/policy/modules/services/acpi.if b/policy/modules/services/acpi.if +index e6805e1d3..849e3ea15 100644 +--- a/policy/modules/services/acpi.if ++++ b/policy/modules/services/acpi.if +@@ -119,6 +119,14 @@ interface(`acpi_append_log',` + allow $1 acpid_log_t:file append_file_perms; + ') + ++interface(`acpi_write_lock',` ++ gen_require(` ++ type acpid_lock_t; ++ ') ++ ++ allow $1 acpid_lock_t:file write; ++') ++ + ######################################## + ## + ## Connect to apmd over an unix +diff --git a/policy/modules/services/acpi.te b/policy/modules/services/acpi.te +index 26d16a369..c54302289 100644 +--- a/policy/modules/services/acpi.te ++++ b/policy/modules/services/acpi.te +@@ -235,3 +235,23 @@ optional_policy(` + optional_policy(` + xserver_domtrans(acpid_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++bluetooth_manage_config(acpid_t) ++kernel_search_debugfs(acpid_t) ++init_read_utmp(acpid_t) ++allow acpid_t self:bluetooth_socket { bind create ioctl write }; ++allow acpid_t self:capability { net_admin net_raw }; ++allow acpid_t self:process { getsched setpgid }; ++allow acpid_t var_log_t:file { open write }; ++ ++dev_use_gpiochip(acpid_t) ++allow acpid_t self:bluetooth_socket listen; ++ ++#!!!! This avc can be allowed using the boolean 'allow_ypbind' ++allow acpid_t self:capability net_bind_service; ++dev_use_wireless(acpid_t) +diff --git a/policy/modules/services/apache.if b/policy/modules/services/apache.if +index 71696f051..366f5fdeb 100644 +--- a/policy/modules/services/apache.if ++++ b/policy/modules/services/apache.if +@@ -1319,6 +1319,14 @@ interface(`apache_cgi_domain',` + allow httpd_t $1:process signal; + ') + ++interface(`apache_execute_runtime_files',` ++ gen_require(` ++ type httpd_runtime_t; ++ ') ++ ++ allow $1 httpd_runtime_t:file execute; ++') ++ + ######################################## + ## + ## All of the rules required to +diff --git a/policy/modules/services/bluetooth.if b/policy/modules/services/bluetooth.if +index e35e86312..1580a772c 100644 +--- a/policy/modules/services/bluetooth.if ++++ b/policy/modules/services/bluetooth.if +@@ -107,6 +107,16 @@ interface(`bluetooth_read_config',` + allow $1 bluetooth_conf_t:file read_file_perms; + ') + ++interface(`bluetooth_manage_config',` ++ gen_require(` ++ type bluetooth_conf_t, bluetooth_t; ++ ') ++ ++ allow $1 bluetooth_conf_t:dir search; ++ allow $1 bluetooth_conf_t:file { open read }; ++ allow $1 bluetooth_t:process signal; ++') ++ + ######################################## + ## + ## Send and receive messages from +diff --git a/policy/modules/services/bluetooth.te b/policy/modules/services/bluetooth.te +index 63e50aeda..ec822154f 100644 +--- a/policy/modules/services/bluetooth.te ++++ b/policy/modules/services/bluetooth.te +@@ -223,3 +223,13 @@ optional_policy(` + optional_policy(` + xserver_user_x_domain_template(bluetooth_helper, bluetooth_helper_t, bluetooth_helper_tmpfs_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++logging_allow_write_generic_logs(bluetooth_t) ++ ++allow bluetooth_t self:alg_socket { bind create }; ++allow bluetooth_t syslogd_runtime_t:sock_file write; +diff --git a/policy/modules/services/consolekit.te b/policy/modules/services/consolekit.te +index 105bd45c7..292fd5074 100644 +--- a/policy/modules/services/consolekit.te ++++ b/policy/modules/services/consolekit.te +@@ -172,3 +172,10 @@ optional_policy(` + optional_policy(` + unconfined_stream_connect(consolekit_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow consolekit_t var_log_t:dir create; +diff --git a/policy/modules/services/dbus.if b/policy/modules/services/dbus.if +index 146262d88..f59642950 100644 +--- a/policy/modules/services/dbus.if ++++ b/policy/modules/services/dbus.if +@@ -165,6 +165,14 @@ interface(`dbus_connect_all_session_bus',` + allow $1 session_bus_type:dbus acquire_svc; + ') + ++interface(`dbus_write_sock_file',` ++ gen_require(` ++ type session_dbusd_runtime_t; ++ ') ++ ++ allow $1 session_dbusd_runtime_t:sock_file write; ++') ++ + ####################################### + ## + ## Acquire service on specified +diff --git a/policy/modules/services/dbus.te b/policy/modules/services/dbus.te +index 8ae5c8d93..bcf8b9677 100644 +--- a/policy/modules/services/dbus.te ++++ b/policy/modules/services/dbus.te +@@ -315,3 +315,10 @@ optional_policy(` + + allow dbusd_unconfined { dbusd_session_bus_client dbusd_system_bus_client }:dbus send_msg; + allow dbusd_unconfined { system_dbusd_t session_bus_type }:dbus all_dbus_perms; ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow system_dbusd_t syslogd_runtime_t:sock_file write; +diff --git a/policy/modules/services/modemmanager.te b/policy/modules/services/modemmanager.te +index 784221a03..1f6f698c2 100644 +--- a/policy/modules/services/modemmanager.te ++++ b/policy/modules/services/modemmanager.te +@@ -58,3 +58,13 @@ optional_policy(` + udev_read_db(modemmanager_t) + udev_manage_runtime_files(modemmanager_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow modemmanager_t self:process setsched; ++allow modemmanager_t syslogd_runtime_t:sock_file write; ++ ++allow modemmanager_t self:capability sys_nice; +diff --git a/policy/modules/services/networkmanager.if b/policy/modules/services/networkmanager.if +index ef738db1e..7e203a0d2 100644 +--- a/policy/modules/services/networkmanager.if ++++ b/policy/modules/services/networkmanager.if +@@ -171,6 +171,14 @@ interface(`networkmanager_signal',` + allow $1 NetworkManager_t:process signal; + ') + ++interface(`networkmanager_sendto_unix_dgram_socket',` ++ gen_require(` ++ type NetworkManager_t; ++ ') ++ ++ allow $1 NetworkManager_t:unix_dgram_socket sendto; ++') ++ + ######################################## + ## + ## Watch networkmanager etc dirs. +diff --git a/policy/modules/services/networkmanager.te b/policy/modules/services/networkmanager.te +index ce48909dd..e5f9e5da0 100644 +--- a/policy/modules/services/networkmanager.te ++++ b/policy/modules/services/networkmanager.te +@@ -397,3 +397,26 @@ init_use_script_ptys(wpa_cli_t) + miscfiles_read_localization(wpa_cli_t) + + term_dontaudit_use_console(wpa_cli_t) ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow NetworkManager_t device_t:chr_file { ioctl open read write }; ++libs_watch(NetworkManager_t) ++fs_read_nsfs_files(NetworkManager_t) ++systemd_watch_logind_runtime_files(NetworkManager_t) ++systemd_watch_machines(NetworkManager_t) ++systemd_watch_logind_sessions_files(NetworkManager_t) ++ ++sysadm_sendto_unix_dgram_socket(NetworkManager_t) ++ ++allow NetworkManager_t etc_t:dir watch; ++ ++acpi_use_fds(NetworkManager_t) ++consolekit_watch_runtime_dir(NetworkManager_t) ++ ++acpi_write_lock(NetworkManager_t) ++acpi_append_log(NetworkManager_t) ++dev_read_input_dev(NetworkManager_t) +diff --git a/policy/modules/system/init.te b/policy/modules/system/init.te +index 6b6b723b8..f43acf976 100644 +--- a/policy/modules/system/init.te ++++ b/policy/modules/system/init.te +@@ -1486,3 +1486,10 @@ optional_policy(` + userdom_dontaudit_rw_all_users_stream_sockets(systemprocess) + userdom_dontaudit_write_user_tmp_files(systemprocess) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++sysadm_transition(init_t) +diff --git a/policy/modules/system/libraries.if b/policy/modules/system/libraries.if +index d1379fbe6..dc25cb26f 100644 +--- a/policy/modules/system/libraries.if ++++ b/policy/modules/system/libraries.if +@@ -251,6 +251,14 @@ interface(`libs_manage_lib_dirs',` + allow $1 lib_t:dir manage_dir_perms; + ') + ++interface(`libs_watch',` ++ gen_require(` ++ type lib_t; ++ ') ++ ++ allow $1 lib_t:dir watch; ++') ++ + ######################################## + ## + ## dontaudit attempts to setattr on library files +diff --git a/policy/modules/system/locallogin.te b/policy/modules/system/locallogin.te +index 971ca40e5..da4689d33 100644 +--- a/policy/modules/system/locallogin.te ++++ b/policy/modules/system/locallogin.te +@@ -289,3 +289,12 @@ optional_policy(` + optional_policy(` + nscd_use(sulogin_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow local_login_t init_runtime_t:sock_file write; ++allow local_login_t initrc_t:unix_stream_socket connectto; ++allow local_login_t syslogd_runtime_t:sock_file write; +diff --git a/policy/modules/system/logging.if b/policy/modules/system/logging.if +index e3cbe4f1a..81a512e7b 100644 +--- a/policy/modules/system/logging.if ++++ b/policy/modules/system/logging.if +@@ -1261,6 +1261,14 @@ interface(`logging_dontaudit_write_generic_logs',` + dontaudit $1 var_log_t:file write; + ') + ++interface(`logging_allow_write_generic_logs',` ++ gen_require(` ++ type var_log_t; ++ ') ++ ++ allow $1 var_log_t:file { getattr write }; ++') ++ + ######################################## + ## + ## Read and write generic log files. +diff --git a/policy/modules/system/logging.te b/policy/modules/system/logging.te +index c22613c0b..b332aeb21 100644 +--- a/policy/modules/system/logging.te ++++ b/policy/modules/system/logging.te +@@ -627,3 +627,14 @@ optional_policy(` + # log to the xconsole + xserver_rw_console(syslogd_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow klogd_t bin_t:file { execute map read }; ++ ++allow syslogd_t bin_t:file { execute map read }; ++udevadm_signull(syslogd_t) ++userdom_manage_user_runtime_root_dirs(syslogd_t) +diff --git a/policy/modules/system/modutils.te b/policy/modules/system/modutils.te +index 8fd009742..8c9056ead 100644 +--- a/policy/modules/system/modutils.te ++++ b/policy/modules/system/modutils.te +@@ -195,3 +195,11 @@ optional_policy(` + xserver_getattr_log(kmod_t) + ') + ++######################################## ++# ++# DEY custom rules ++# ++ ++acpi_write_lock(kmod_t) ++acpi_append_log(kmod_t) ++dev_read_input_dev(kmod_t) +diff --git a/policy/modules/system/mount.te b/policy/modules/system/mount.te +index 5bb4fe631..ddd6ce396 100644 +--- a/policy/modules/system/mount.te ++++ b/policy/modules/system/mount.te +@@ -230,3 +230,10 @@ optional_policy(` + files_etc_filetrans_etc_runtime(unconfined_mount_t, file) + unconfined_domain(unconfined_mount_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++userdom_append_getattr(mount_t) +diff --git a/policy/modules/system/selinuxutil.te b/policy/modules/system/selinuxutil.te +index 09fef149b..3fd8b81c5 100644 +--- a/policy/modules/system/selinuxutil.te ++++ b/policy/modules/system/selinuxutil.te +@@ -691,3 +691,11 @@ optional_policy(` + optional_policy(` + hotplug_use_fds(setfiles_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow semanage_t load_policy_t:process { noatsecure rlimitinh siginh }; ++allow semanage_t setfiles_t:process { noatsecure rlimitinh siginh }; +diff --git a/policy/modules/system/sysnetwork.te b/policy/modules/system/sysnetwork.te +index a77738924..28d7f42bb 100644 +--- a/policy/modules/system/sysnetwork.te ++++ b/policy/modules/system/sysnetwork.te +@@ -424,3 +424,11 @@ optional_policy(` + xen_append_log(ifconfig_t) + xen_dontaudit_rw_unix_stream_sockets(ifconfig_t) + ') ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow ifconfig_t bin_t:file { execute map read }; ++userdom_append_getattr(ifconfig_t); +diff --git a/policy/modules/system/systemd.if b/policy/modules/system/systemd.if +index b81300835..622682107 100644 +--- a/policy/modules/system/systemd.if ++++ b/policy/modules/system/systemd.if +@@ -234,6 +234,14 @@ interface(`systemd_read_logind_runtime_files',` + allow $1 systemd_logind_runtime_t:file read_file_perms; + ') + ++interface(`systemd_watch_logind_runtime_files',` ++ gen_require(` ++ type systemd_logind_runtime_t; ++ ') ++ ++ allow $1 systemd_logind_runtime_t:dir watch; ++') ++ + ###################################### + ## + ## Manage systemd-logind runtime pipes. +@@ -313,6 +321,14 @@ interface(`systemd_read_logind_sessions_files',` + read_files_pattern($1, systemd_sessions_runtime_t, systemd_sessions_runtime_t) + ') + ++interface(`systemd_watch_logind_sessions_files',` ++ gen_require(` ++ type systemd_sessions_runtime_t; ++ ') ++ ++ allow $1 systemd_sessions_runtime_t:dir watch; ++') ++ + ###################################### + ## + ## Write inherited logind sessions pipes. +@@ -445,6 +461,14 @@ interface(`systemd_read_machines',` + allow $1 systemd_machined_runtime_t:file read_file_perms; + ') + ++interface(`systemd_watch_machines',` ++ gen_require(` ++ type systemd_machined_runtime_t; ++ ') ++ ++ allow $1 systemd_machined_runtime_t:dir watch; ++') ++ + ######################################## + ## + ## Send and receive messages from +diff --git a/policy/modules/system/systemd.te b/policy/modules/system/systemd.te +index 7e573645b..4efc91a9b 100644 +--- a/policy/modules/system/systemd.te ++++ b/policy/modules/system/systemd.te +@@ -1420,3 +1420,25 @@ userdom_mounton_user_runtime_dirs(systemd_user_runtime_dir_t) + userdom_relabelto_user_runtime_dirs(systemd_user_runtime_dir_t) + + dbus_system_bus_client(systemd_user_runtime_dir_t) ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow systemd_backlight_t sysctl_kernel_t:dir search; ++allow systemd_backlight_t sysctl_kernel_t:file { getattr ioctl open read }; ++allow systemd_backlight_t sysctl_t:dir search; ++ ++allow systemd_generator_t cgroup_t:filesystem getattr; ++allow systemd_generator_t removable_device_t:blk_file { getattr ioctl open read }; ++allow systemd_generator_t self:capability dac_override; ++allow systemd_generator_t self:process setfscreate; ++allow systemd_generator_t tmpfs_t:filesystem getattr; ++ ++allow systemd_logind_t initrc_runtime_t:file watch; ++allow systemd_logind_t initrc_t:unix_stream_socket connectto; ++ ++allow systemd_resolved_t system_dbusd_runtime_t:dir read; ++allow systemd_resolved_t systemd_resolved_runtime_t:lnk_file { create rename }; ++allow systemd_resolved_t system_dbusd_runtime_t:sock_file read; +diff --git a/policy/modules/system/udev.if b/policy/modules/system/udev.if +index bdfd373da..468f83d2e 100644 +--- a/policy/modules/system/udev.if ++++ b/policy/modules/system/udev.if +@@ -597,3 +597,11 @@ interface(`udevadm_exec',` + + can_exec($1, udevadm_exec_t) + ') ++ ++interface(`udevadm_signull',` ++ gen_require(` ++ type udevadm_t; ++ ') ++ ++ allow $1 udevadm_t:process signull; ++') +diff --git a/policy/modules/system/udev.te b/policy/modules/system/udev.te +index e483d63d3..2bd2fcdc7 100644 +--- a/policy/modules/system/udev.te ++++ b/policy/modules/system/udev.te +@@ -427,3 +427,10 @@ seutil_read_file_contexts(udevadm_t) + + init_dontaudit_use_fds(udevadm_t) + term_dontaudit_use_console(udevadm_t) ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++allow udev_t init_t:system start; +diff --git a/policy/modules/system/userdomain.if b/policy/modules/system/userdomain.if +index 5aab9ada7..eb1d5ffbf 100644 +--- a/policy/modules/system/userdomain.if ++++ b/policy/modules/system/userdomain.if +@@ -4361,6 +4361,14 @@ interface(`userdom_write_user_tmp_files',` + allow $1 user_tmp_t:file write_file_perms; + ') + ++interface(`userdom_append_getattr',` ++ gen_require(` ++ type user_tmp_t; ++ ') ++ ++ allow $1 user_tmp_t:file { append getattr }; ++') ++ + ######################################## + ## + ## Do not audit attempts to write users +diff --git a/policy/modules/system/userdomain.te b/policy/modules/system/userdomain.te +index ce69ca10b..5cb2f75bc 100644 +--- a/policy/modules/system/userdomain.te ++++ b/policy/modules/system/userdomain.te +@@ -130,3 +130,10 @@ files_poly_member(user_runtime_t) + files_poly_parent(user_runtime_t) + ubac_constrained(user_runtime_t) + userdom_user_runtime_content(user_runtime_t) ++ ++######################################## ++# ++# DEY custom rules ++# ++ ++dev_associate(user_tmpfs_t) +diff --git a/policy/modules/system/xdg.if b/policy/modules/system/xdg.if +index 11fc43069..801c79d40 100644 +--- a/policy/modules/system/xdg.if ++++ b/policy/modules/system/xdg.if +@@ -215,6 +215,14 @@ interface(`xdg_create_cache_dirs',` + allow $1 xdg_cache_t:dir create_dir_perms; + ') + ++interface(`xdg_dir_watch',` ++ gen_require(` ++ type xdg_cache_t; ++ ') ++ ++ allow $1 xdg_cache_t:dir watch; ++') ++ + ######################################## + ## + ## Manage the xdg cache home files +@@ -465,6 +473,14 @@ interface(`xdg_create_config_dirs',` + allow $1 xdg_config_t:dir create_dir_perms; + ') + ++interface(`xdg_config_dirs_search',` ++ gen_require(` ++ type xdg_config_t; ++ ') ++ ++ allow $1 xdg_config_t:dir search; ++') ++ + ######################################## + ## + ## Manage the xdg config home files diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/files/0002-Make-udevadm_t-executables-run-in-the-udev_t-realm.patch b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/files/0002-Make-udevadm_t-executables-run-in-the-udev_t-realm.patch new file mode 100644 index 000000000..04d5e0eb5 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/files/0002-Make-udevadm_t-executables-run-in-the-udev_t-realm.patch @@ -0,0 +1,86 @@ +From: Gabriel Valcazar +Date: Fri, 20 Aug 2021 15:06:12 +0200 +Subject: [PATCH 2/2] Make udevadm_t executables run in the udev_t realm + +This prevents SELinux from denying udev activity in DEY. This is a partial port +of the following commit: + +https://www.spinics.net/lists/selinux-refpolicy/msg00805.html + +Signed-off-by: Gabriel Valcazar +--- + policy/modules/system/udev.fc | 4 ++-- + policy/modules/system/udev.if | 4 ++-- + policy/modules/system/udev.te | 6 +++--- + 3 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/policy/modules/system/udev.fc b/policy/modules/system/udev.fc +index ceb5b70b3..36d91f3a2 100644 +--- a/policy/modules/system/udev.fc ++++ b/policy/modules/system/udev.fc +@@ -10,7 +10,7 @@ + /etc/udev/scripts/.+ -- gen_context(system_u:object_r:udev_helper_exec_t,s0) + + /usr/bin/udev -- gen_context(system_u:object_r:udev_exec_t,s0) +-/usr/bin/udevadm -- gen_context(system_u:object_r:udevadm_exec_t,s0) ++/usr/bin/udevadm -- gen_context(system_u:object_r:udev_exec_t,s0) + /usr/bin/udevd -- gen_context(system_u:object_r:udev_exec_t,s0) + /usr/bin/udevinfo -- gen_context(system_u:object_r:udev_exec_t,s0) + /usr/bin/udevsend -- gen_context(system_u:object_r:udev_exec_t,s0) +@@ -22,7 +22,7 @@ ifdef(`distro_debian',` + ') + + /usr/sbin/udev -- gen_context(system_u:object_r:udev_exec_t,s0) +-/usr/sbin/udevadm -- gen_context(system_u:object_r:udevadm_exec_t,s0) ++/usr/sbin/udevadm -- gen_context(system_u:object_r:udev_exec_t,s0) + /usr/sbin/udevd -- gen_context(system_u:object_r:udev_exec_t,s0) + /usr/sbin/udevsend -- gen_context(system_u:object_r:udev_exec_t,s0) + /usr/sbin/udevstart -- gen_context(system_u:object_r:udev_exec_t,s0) +diff --git a/policy/modules/system/udev.if b/policy/modules/system/udev.if +index 468f83d2e..1b37166d2 100644 +--- a/policy/modules/system/udev.if ++++ b/policy/modules/system/udev.if +@@ -548,10 +548,10 @@ interface(`udev_manage_runtime_files',` + # + interface(`udevadm_domtrans',` + gen_require(` +- type udevadm_t, udevadm_exec_t; ++ type udevadm_t, udev_exec_t; + ') + +- domtrans_pattern($1, udevadm_exec_t, udevadm_t) ++ domtrans_pattern($1, udev_exec_t, udevadm_t) + ') + + ######################################## +diff --git a/policy/modules/system/udev.te b/policy/modules/system/udev.te +index 2bd2fcdc7..3bfde5bef 100644 +--- a/policy/modules/system/udev.te ++++ b/policy/modules/system/udev.te +@@ -8,6 +8,7 @@ attribute_role udevadm_roles; + + type udev_t; + type udev_exec_t; ++typealias udev_exec_t alias udevadm_exec_t; + type udev_helper_exec_t; + kernel_domtrans_to(udev_t, udev_exec_t) + domain_obj_id_change_exemption(udev_t) +@@ -17,9 +18,7 @@ init_daemon_domain(udev_t, udev_exec_t) + init_named_socket_activation(udev_t, udev_runtime_t) + + type udevadm_t; +-type udevadm_exec_t; +-init_system_domain(udevadm_t, udevadm_exec_t) +-application_domain(udevadm_t, udevadm_exec_t) ++application_domain(udevadm_t, udev_exec_t) + role udevadm_roles types udevadm_t; + + type udev_etc_t alias etc_udev_t; +@@ -86,6 +85,7 @@ manage_files_pattern(udev_t, udev_runtime_t, udev_runtime_t) + manage_lnk_files_pattern(udev_t, udev_runtime_t, udev_runtime_t) + manage_sock_files_pattern(udev_t, udev_runtime_t, udev_runtime_t) + files_runtime_filetrans(udev_t, udev_runtime_t, dir, "udev") ++allow udev_t udev_runtime_t:dir watch; + + kernel_load_module(udev_t) + kernel_read_system_state(udev_t) diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-mcs_git.bbappend b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-mcs_git.bbappend new file mode 100644 index 000000000..8538fe7b8 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-mcs_git.bbappend @@ -0,0 +1 @@ +include refpolicy_dey.inc diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-minimum_git.bbappend b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-minimum_git.bbappend new file mode 100644 index 000000000..8538fe7b8 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-minimum_git.bbappend @@ -0,0 +1 @@ +include refpolicy_dey.inc diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-mls_git.bbappend b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-mls_git.bbappend new file mode 100644 index 000000000..8538fe7b8 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-mls_git.bbappend @@ -0,0 +1 @@ +include refpolicy_dey.inc diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-standard_git.bbappend b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-standard_git.bbappend new file mode 100644 index 000000000..8538fe7b8 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-standard_git.bbappend @@ -0,0 +1 @@ +include refpolicy_dey.inc diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-targeted_git.bbappend b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-targeted_git.bbappend new file mode 100644 index 000000000..8538fe7b8 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-targeted_git.bbappend @@ -0,0 +1 @@ +include refpolicy_dey.inc diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy_dey.inc b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy_dey.inc new file mode 100644 index 000000000..89fdfe092 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-security/refpolicy/refpolicy_dey.inc @@ -0,0 +1,8 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +DEY_POLICY_PATCHES = " \ + file://0001-Apply-rules-for-DEY-prebuilt-images.patch \ + file://0002-Make-udevadm_t-executables-run-in-the-udev_t-realm.patch \ +" + +SRC_URI += " ${@oe.utils.conditional('DEY_SELINUX_POLICY', '1', '${DEY_POLICY_PATCHES}', '', d)}" From 32a39c7910f5aecc900b32acb7d21a45bb73dfce Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Tue, 7 Sep 2021 13:27:46 +0200 Subject: [PATCH 34/70] linux-dey: add support for configuration fragments This allows users to apply small changes to our kernel configuration without having to create a completely new defconfig. Use a simplified version of the kernel-yocto.bbclass implementation. https://onedigi.atlassian.net/browse/DEL-6706 Signed-off-by: Gabriel Valcazar --- meta-digi-arm/recipes-kernel/linux/linux-dey_5.4.bb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey_5.4.bb b/meta-digi-arm/recipes-kernel/linux/linux-dey_5.4.bb index 29145ed4f..d3d620517 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey_5.4.bb +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey_5.4.bb @@ -88,4 +88,14 @@ do_copy_defconfig () { } addtask copy_defconfig after do_patch before do_kernel_localversion +# Apply configuration fragments +do_configure_append() { + # Only accept fragments ending in .cfg. If the fragments contain + # something other than kernel configs, it will be filtered out + # automatically. + if [ -f ${WORKDIR}/*.cfg ]; then + ${S}/scripts/kconfig/merge_config.sh -O ${B} ${B}/.config ${WORKDIR}/*.cfg + fi +} + COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8x|ccimx8m|ccimx6)" From 1e196181578a9f0af3ae71c9ebd243558c51d0a0 Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Thu, 26 Aug 2021 18:13:04 +0200 Subject: [PATCH 35/70] linux-dey: add config fragment to enable SELinux configuration options These options should only be enabled when using SELinux, so apply them only when "selinux" is in the DISTRO_FEATURES. The fragment is a copy of the one in meta-selinux with the addition of DEFAULT_SECURITY_DAC and LSM. https://onedigi.atlassian.net/browse/DEL-7641 Signed-off-by: Gabriel Valcazar --- .../linux/linux-dey/selinux.cfg | 32 +++++++++++++++++++ .../linux/linux-dey_5.4.bbappend | 3 ++ 2 files changed, 35 insertions(+) create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-kernel/linux/linux-dey/selinux.cfg create mode 100644 meta-digi-dey/dynamic-layers/selinux/recipes-kernel/linux/linux-dey_5.4.bbappend diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-kernel/linux/linux-dey/selinux.cfg b/meta-digi-dey/dynamic-layers/selinux/recipes-kernel/linux/linux-dey/selinux.cfg new file mode 100644 index 000000000..5799acbec --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-kernel/linux/linux-dey/selinux.cfg @@ -0,0 +1,32 @@ +.......................................................................... +. WARNING +. +. This file is a kernel configuration fragment, and not a full kernel +. configuration file. The final kernel configuration is made up of +. an assembly of processed fragments, each of which is designed to +. capture a specific part of the final configuration (e.g. platform +. configuration, feature configuration, and board specific hardware +. configuration). For more information on kernel configuration, please +. consult the product documentation. +. +.......................................................................... +CONFIG_AUDIT=y +CONFIG_NETWORK_SECMARK=y +CONFIG_EXT2_FS_SECURITY=y +CONFIG_EXT3_FS_SECURITY=y +CONFIG_EXT4_FS_SECURITY=y +CONFIG_JFS_SECURITY=y +CONFIG_REISERFS_FS_SECURITY=y +CONFIG_JFFS2_FS_SECURITY=y +CONFIG_SECURITY=y +CONFIG_SECURITYFS=y +CONFIG_SECURITY_NETWORK=y +CONFIG_SECURITY_SELINUX=y +CONFIG_SECURITY_SELINUX_BOOTPARAM=y +CONFIG_SECURITY_SELINUX_DISABLE=y +CONFIG_SECURITY_SELINUX_DEVELOP=y +CONFIG_SECURITY_SELINUX_AVC_STATS=y +CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1 +CONFIG_AUDIT_GENERIC=y +CONFIG_DEFAULT_SECURITY_DAC=n +CONFIG_LSM="lockdown,yama,loadpin,safesetid,integrity,selinux,smack,tomoyo,apparmor" diff --git a/meta-digi-dey/dynamic-layers/selinux/recipes-kernel/linux/linux-dey_5.4.bbappend b/meta-digi-dey/dynamic-layers/selinux/recipes-kernel/linux/linux-dey_5.4.bbappend new file mode 100644 index 000000000..04f72532e --- /dev/null +++ b/meta-digi-dey/dynamic-layers/selinux/recipes-kernel/linux/linux-dey_5.4.bbappend @@ -0,0 +1,3 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" + +SRC_URI += " ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'file://selinux.cfg', '', d)}" From 42cab22b95c58c84840e1560d8301c6797d2a094 Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Wed, 15 Sep 2021 10:19:14 +0200 Subject: [PATCH 36/70] ccimx6: add "pam" to DISTRO_FEATURES This is necessary for images that have SELinux enabled. Aside from changing some package configurations and including an additional library in the rootfs, this change has no apparent effects on the core functionality of the system. https://onedigi.atlassian.net/browse/DEL-7641 Signed-off-by: Gabriel Valcazar --- meta-digi-arm/conf/machine/include/ccimx6.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta-digi-arm/conf/machine/include/ccimx6.inc b/meta-digi-arm/conf/machine/include/ccimx6.inc index ddcf63f45..65376765e 100644 --- a/meta-digi-arm/conf/machine/include/ccimx6.inc +++ b/meta-digi-arm/conf/machine/include/ccimx6.inc @@ -43,4 +43,5 @@ MACHINE_FEATURES += "accel-graphics accel-video wifi bluetooth pci" TRUSTFENCE_SIGN_MODE = "HAB" # Adding 'wayland' along with 'x11' enables the xwayland backend -DISTRO_FEATURES_append = " wayland" +# Adding pam is required for SELinux functionality +DISTRO_FEATURES_append = " wayland pam" From 4502004cd72c7c697c40b46250797ff41f907466 Mon Sep 17 00:00:00 2001 From: Gonzalo Ruiz Date: Wed, 15 Sep 2021 15:58:12 +0200 Subject: [PATCH 37/70] conf: machine: add flexSPI overlay to CC8X/CC8M https://onedigi.atlassian.net/browse/DEL-7584 Signed-off-by: Gonzalo Ruiz --- meta-digi-arm/conf/machine/ccimx8mm-dvk.conf | 1 + meta-digi-arm/conf/machine/ccimx8mn-dvk.conf | 1 + meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf | 1 + 3 files changed, 3 insertions(+) diff --git a/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf b/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf index 80eb3904b..2628634d3 100644 --- a/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf +++ b/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf @@ -21,6 +21,7 @@ UBOOT_DTB_NAME = "ccimx8mm-dvk.dtb" KERNEL_DEVICETREE ?= " \ digi/ccimx8mm-dvk.dtb \ + digi/_ov_board_flexspi_ccimx8m-dvk.dtbo \ digi/_ov_board_gpio-watchdog_ccimx8m-dvk.dtbo \ digi/_ov_board_hsd101pfw2-lvds_ccimx8m-dvk.dtbo \ digi/_ov_board_lvds_ccimx8m-dvk.dtbo \ diff --git a/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf b/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf index 7e8a98695..1eb371574 100644 --- a/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf +++ b/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf @@ -21,6 +21,7 @@ UBOOT_DTB_NAME = "ccimx8mn-dvk.dtb" KERNEL_DEVICETREE ?= " \ digi/ccimx8mn-dvk.dtb \ + digi/_ov_board_flexspi_ccimx8m-dvk.dtbo \ digi/_ov_board_gpio-watchdog_ccimx8m-dvk.dtbo \ digi/_ov_board_hsd101pfw2-lvds_ccimx8m-dvk.dtbo \ digi/_ov_board_lvds_ccimx8m-dvk.dtbo \ diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf index b59a050d4..7206a9a95 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf @@ -15,6 +15,7 @@ UBOOT_CONFIG[ccimx8x_sbc_pro512MB] = "ccimx8x_sbc_pro512MB_defconfig,,u-boot-dtb KERNEL_DEVICETREE ?= " \ digi/ccimx8x-sbc-pro.dtb \ digi/_ov_board_flexcan1_ccimx8x-sbc-pro.dtbo \ + digi/_ov_board_flexspi_ccimx8x-sbc-pro.dtbo \ digi/_ov_board_gpio-watchdog_ccimx8x-sbc-pro.dtbo \ digi/_ov_board_hsd101pfw2-lvds_ccimx8x-sbc-pro.dtbo \ digi/_ov_board_lpuart3_ccimx8x-sbc-pro.dtbo \ From 85d55a70a2b64e48449e9614ead32e67dfb50e51 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 16 Sep 2021 11:54:30 +0200 Subject: [PATCH 38/70] uboot: use ssh protocol when using Digi internal MTK remote Commit c33fc8a7fe03e11dcee5b228bb389bdbae59a0e2 wrongly used https protocol when using MTK remote when it should have been ssh. Signed-off-by: Hector Palacios --- meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc b/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc index 03d34678a..51cbeb728 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc +++ b/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc @@ -19,7 +19,7 @@ DIGI_LOG_REPO = "u-boot-denx.git" DIGI_MTK_REPO = "uboot/u-boot-denx.git" GITHUB_REPO = "u-boot.git" UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , \ - oe.utils.conditional('DIGI_GIT', '${DIGI_LOG_GIT}', '${DIGI_GIT}/${DIGI_LOG_REPO}', '${DIGI_GIT}/${DIGI_MTK_REPO};protocol=https', d), \ + oe.utils.conditional('DIGI_GIT', '${DIGI_LOG_GIT}', '${DIGI_GIT}/${DIGI_LOG_REPO}', '${DIGI_GIT}/${DIGI_MTK_REPO};protocol=ssh', d), \ '${DIGI_GITHUB_GIT}/${GITHUB_REPO};protocol=https', d)}" SRC_URI = " \ From dae2b5000a98dabf0f9a3a97edf7de202de77223 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 16 Sep 2021 12:49:25 +0200 Subject: [PATCH 39/70] uboot: add dualboot support to uuu firmware install script Check the status of 'dualboot' env variable. If set to "yes", use the dualboot partition table in the script and restore the variable (default is "no") after resetting the environment. Also, for dualboot, there's no need to wipe the recovery partition or boot into recovery mode. For dualboot, this script programs both systems A and B with the same images. Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7649 --- .../ccimx6ul/install_linux_fw_uuu.sh | 94 ++++++++++++------ .../ccimx8m/install_linux_fw_uuu.sh | 96 +++++++++++++------ .../ccimx8x/install_linux_fw_uuu.sh | 96 ++++++++++++------- 3 files changed, 194 insertions(+), 92 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh index 8d22d569c..01b626663 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh @@ -83,6 +83,12 @@ done # Enable the redirect support to get u-boot variables values uuu fb: ucmd setenv stdout serial,fastboot +# Check if dualboot variable is active +dualboot=$(getenv "dualboot") +if [ "${dualboot}" = "yes" ]; then + DUALBOOT=true; +fi + # Check if ubisysvols variable is active ubisysvols=$(getenv "ubisysvols") if [ "${ubisysvols}" = "yes" ]; then @@ -163,32 +169,43 @@ done; [ "${ABORT}" = true ] && exit 1 +# parts names +LINUX_NAME="linux" +RECOVERY_NAME="recovery" +ROOTFS_NAME="rootfs" # Print warning about storage media being deleted -if [ ! "${NOWAIT}" = true ]; then +if [ "${NOWAIT}" != true ]; then WAIT=10 - echo "" - echo " ====================" - echo " = IMPORTANT! =" - echo " ====================" - echo " This process will erase your NAND and will install the following files" - echo " on the partitions of the NAND." - echo "" - echo " PARTITION FILENAME" - echo " --------- --------" - echo " bootloader ${INSTALL_UBOOT_FILENAME}" - echo " linux ${INSTALL_LINUX_FILENAME}" - echo " recovery ${INSTALL_RECOVERY_FILENAME}" - echo " rootfs ${INSTALL_ROOTFS_FILENAME}" - echo "" - echo " Press CTRL+C now if you wish to abort." - echo "" + printf "\n" + printf " ====================\n" + printf " = IMPORTANT! =\n" + printf " ====================\n" + printf " This process will erase your NAND and will install the following files\n" + printf " on the partitions of the NAND.\n" + printf "\n" + printf " PARTITION\tFILENAME\n" + printf " ---------\t--------\n" + printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n" + if [ "${DUALBOOT}" = true ]; then + printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n" + printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n" + printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n" + printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n" + else + printf " ${LINUX_NAME}\t${INSTALL_LINUX_FILENAME}\n" + printf " ${RECOVERY_NAME}\t${INSTALL_RECOVERY_FILENAME}\n" + printf " ${ROOTFS_NAME}\t${INSTALL_ROOTFS_FILENAME}\n" + fi + printf "\n" + printf " Press CTRL+C now if you wish to abort.\n" + printf "\n" while [ ${WAIT} -gt 0 ]; do printf "\r Update process starts in %d " ${WAIT} sleep 1 WAIT=$(( ${WAIT} - 1 )) done printf "\r \n" - echo " Starting update process" + printf " Starting update process\n" fi # Set fastboot buffer address to $loadaddr, just in case @@ -227,6 +244,11 @@ sleep 3 # Set fastboot buffer address to $loadaddr uuu fb: ucmd setenv fastboot_buffer \${loadaddr} +# Restore dualboot if previously active +if [ "${DUALBOOT}" = true ]; then + uuu fb: ucmd setenv dualboot yes +fi + # Restore ubisysvols if previously active if [ "${UBISYSVOLS}" = true ]; then uuu fb: ucmd setenv ubisysvols yes @@ -239,24 +261,34 @@ if [ "${UBISYSVOLS}" = true ]; then uuu "fb[-t 10000]:" ucmd run ubivolscript fi -# Update Linux -part_update "linux" "${INSTALL_LINUX_FILENAME}" 15000 +if [ "${DUALBOOT}" = true ]; then + # Update Linux A + part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" 15000 + # Update Linux B + part_update "${LINUX_NAME}_b" "${INSTALL_LINUX_FILENAME}" 15000 + # Update Rootfs A + part_update "${ROOTFS_NAME}_a" "${INSTALL_ROOTFS_FILENAME}" 90000 + # Update Rootfs B + part_update "${ROOTFS_NAME}_b" "${INSTALL_ROOTFS_FILENAME}" 90000 +else + # Update Linux + part_update "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}" 15000 + # Update Recovery + part_update "${RECOVERY_NAME}" "${INSTALL_RECOVERY_FILENAME}" 15000 + # Update Rootfs + part_update "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}" 90000 +fi -# Update Recovery -part_update "recovery" "${INSTALL_RECOVERY_FILENAME}" 15000 - -# Update Rootfs -part_update "rootfs" "${INSTALL_ROOTFS_FILENAME}" 90000 - -if [ ! "${UBISYSVOLS}" = true ]; then +if [ "${UBISYSVOLS}" != true ] && [ "${DUALBOOT}" != true ]; then # Erase the 'Update' partition uuu fb: ucmd nand erase.part update fi -# Configure u-boot to boot into recovery mode -uuu fb: ucmd setenv boot_recovery yes -uuu fb: ucmd setenv recovery_command wipe_update - +if [ "${DUALBOOT}" != true ]; then + # Configure u-boot to boot into recovery mode + uuu fb: ucmd setenv boot_recovery yes + uuu fb: ucmd setenv recovery_command wipe_update +fi uuu fb: ucmd saveenv # Reset the target diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh index 401ba22c0..a723997f7 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh @@ -79,6 +79,18 @@ do esac done +# Enable the redirect support to get u-boot variables values +uuu fb: ucmd setenv stdout serial,fastboot + +# Check if dualboot variable is active +dualboot=$(getenv "dualboot") +if [ "${dualboot}" = "yes" ]; then + DUALBOOT=true; +fi + +# remove redirect +uuu fb: ucmd setenv stdout serial + echo "" echo "Determining image files to use..." @@ -127,32 +139,43 @@ done; [ "${ABORT}" = true ] && exit 1 +# parts names +LINUX_NAME="linux" +RECOVERY_NAME="recovery" +ROOTFS_NAME="rootfs" # Print warning about storage media being deleted -if [ ! "${NOWAIT}" = true ]; then +if [ "${NOWAIT}" != true ]; then WAIT=10 - echo "" - echo " ====================" - echo " = IMPORTANT! =" - echo " ====================" - echo " This process will erase your eMMC and will install the following files" - echo " on the partitions of the eMMC." - echo "" - echo " PARTITION FILENAME" - echo " --------- --------" - echo " bootloader ${INSTALL_UBOOT_FILENAME}" - echo " linux ${INSTALL_LINUX_FILENAME}" - echo " recovery ${INSTALL_RECOVERY_FILENAME}" - echo " rootfs ${INSTALL_ROOTFS_FILENAME}" - echo "" - echo " Press CTRL+C now if you wish to abort." - echo "" + printf "\n" + printf " ====================\n" + printf " = IMPORTANT! =\n" + printf " ====================\n" + printf " This process will erase your eMMC and will install the following files\n" + printf " on the partitions of the eMMC.\n" + printf "\n" + printf " PARTITION\tFILENAME\n" + printf " ---------\t--------\n" + printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n" + if [ "${DUALBOOT}" = true ]; then + printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n" + printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n" + printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n" + printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n" + else + printf " ${LINUX_NAME}\t${INSTALL_LINUX_FILENAME}\n" + printf " ${RECOVERY_NAME}\t${INSTALL_RECOVERY_FILENAME}\n" + printf " ${ROOTFS_NAME}\t${INSTALL_ROOTFS_FILENAME}\n" + fi + printf "\n" + printf " Press CTRL+C now if you wish to abort.\n" + printf "\n" while [ ${WAIT} -gt 0 ]; do printf "\r Update process starts in %d " ${WAIT} sleep 1 WAIT=$(( ${WAIT} - 1 )) done printf "\r \n" - echo " Starting update process" + printf " Starting update process\n" fi # Set fastboot buffer address to $loadaddr, just in case @@ -211,24 +234,39 @@ uuu fb: ucmd setenv fastboot_dev mmc # Set fastboot buffer address to $loadaddr, just in case uuu fb: ucmd setenv fastboot_buffer \${loadaddr} -# Update Linux -part_update "linux" "${INSTALL_LINUX_FILENAME}" +# Restore dualboot if previously active +if [ "${DUALBOOT}" = true ]; then + uuu fb: ucmd setenv dualboot yes +fi -# Update Recovery -part_update "recovery" "${INSTALL_RECOVERY_FILENAME}" - -# Update Rootfs -part_update "rootfs" "${INSTALL_ROOTFS_FILENAME}" +if [ "${DUALBOOT}" = true ]; then + # Update Linux A + part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" + # Update Linux B + part_update "${LINUX_NAME}_b" "${INSTALL_LINUX_FILENAME}" + # Update Rootfs A + part_update "${ROOTFS_NAME}_a" "${INSTALL_ROOTFS_FILENAME}" + # Update Rootfs B + part_update "${ROOTFS_NAME}_b" "${INSTALL_ROOTFS_FILENAME}" +else + # Update Linux + part_update "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}" + # Update Recovery + part_update "${RECOVERY_NAME}" "${INSTALL_RECOVERY_FILENAME}" + # Update Rootfs + part_update "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}" +fi # If the rootfs image was originally compressed, remove the uncompressed image if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then rm -f "${INSTALL_ROOTFS_FILENAME}" fi -# Configure u-boot to boot into recovery mode -uuu fb: ucmd setenv boot_recovery yes -uuu fb: ucmd setenv recovery_command wipe_update - +if [ "${DUALBOOT}" != true ]; then + # Configure u-boot to boot into recovery mode + uuu fb: ucmd setenv boot_recovery yes + uuu fb: ucmd setenv recovery_command wipe_update +fi uuu fb: ucmd saveenv # Reset the target diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh index 6f3316ba6..8da80e9c5 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh @@ -79,14 +79,20 @@ do esac done +# Enable the redirect support to get u-boot variables values +uuu fb: ucmd setenv stdout serial,fastboot + +# Check if dualboot variable is active +dualboot=$(getenv "dualboot") +if [ "${dualboot}" = "yes" ]; then + DUALBOOT=true; +fi + echo "" echo "Determining image files to use..." # Determine U-Boot file to program basing on SOM's SOC type (linked to bus width) if [ -z ${INSTALL_UBOOT_FILENAME} ]; then - # Enable the redirect support to get u-boot variables values - uuu fb: ucmd setenv stdout serial,fastboot - # Since SOMs with the B0 SOC might have an older U-Boot that doesn't export the # SOC revision to the environment, use B0 by default soc_rev=$(getenv "soc_rev") @@ -189,32 +195,43 @@ done; [ "${ABORT}" = true ] && exit 1 +# parts names +LINUX_NAME="linux" +RECOVERY_NAME="recovery" +ROOTFS_NAME="rootfs" # Print warning about storage media being deleted -if [ ! "${NOWAIT}" = true ]; then +if [ "${NOWAIT}" != true ]; then WAIT=10 - echo "" - echo " ====================" - echo " = IMPORTANT! =" - echo " ====================" - echo " This process will erase your eMMC and will install the following files" - echo " on the partitions of the eMMC." - echo "" - echo " PARTITION FILENAME" - echo " --------- --------" - echo " bootloader ${INSTALL_UBOOT_FILENAME}" - echo " linux ${INSTALL_LINUX_FILENAME}" - echo " recovery ${INSTALL_RECOVERY_FILENAME}" - echo " rootfs ${INSTALL_ROOTFS_FILENAME}" - echo "" - echo " Press CTRL+C now if you wish to abort." - echo "" + printf "\n" + printf " ====================\n" + printf " = IMPORTANT! =\n" + printf " ====================\n" + printf " This process will erase your eMMC and will install the following files\n" + printf " on the partitions of the eMMC.\n" + printf "\n" + printf " PARTITION\tFILENAME\n" + printf " ---------\t--------\n" + printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n" + if [ "${DUALBOOT}" = true ]; then + printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n" + printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n" + printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n" + printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n" + else + printf " ${LINUX_NAME}\t${INSTALL_LINUX_FILENAME}\n" + printf " ${RECOVERY_NAME}\t${INSTALL_RECOVERY_FILENAME}\n" + printf " ${ROOTFS_NAME}\t${INSTALL_ROOTFS_FILENAME}\n" + fi + printf "\n" + printf " Press CTRL+C now if you wish to abort.\n" + printf "\n" while [ ${WAIT} -gt 0 ]; do printf "\r Update process starts in %d " ${WAIT} sleep 1 WAIT=$(( ${WAIT} - 1 )) done printf "\r \n" - echo " Starting update process" + printf " Starting update process\n" fi # Skip user confirmation for U-Boot update @@ -270,24 +287,39 @@ uuu fb: ucmd setenv fastboot_dev mmc # Set fastboot buffer address to $loadaddr, just in case uuu fb: ucmd setenv fastboot_buffer \${loadaddr} -# Update Linux -part_update "linux" "${INSTALL_LINUX_FILENAME}" +# Restore dualboot if previously active +if [ "${DUALBOOT}" = true ]; then + uuu fb: ucmd setenv dualboot yes +fi -# Update Recovery -part_update "recovery" "${INSTALL_RECOVERY_FILENAME}" - -# Update Rootfs -part_update "rootfs" "${INSTALL_ROOTFS_FILENAME}" +if [ "${DUALBOOT}" = true ]; then + # Update Linux A + part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" + # Update Linux B + part_update "${LINUX_NAME}_b" "${INSTALL_LINUX_FILENAME}" + # Update Rootfs A + part_update "${ROOTFS_NAME}_a" "${INSTALL_ROOTFS_FILENAME}" + # Update Rootfs B + part_update "${ROOTFS_NAME}_b" "${INSTALL_ROOTFS_FILENAME}" +else + # Update Linux + part_update "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}" + # Update Recovery + part_update "${RECOVERY_NAME}" "${INSTALL_RECOVERY_FILENAME}" + # Update Rootfs + part_update "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}" +fi # If the rootfs image was originally compressed, remove the uncompressed image if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then rm -f "${INSTALL_ROOTFS_FILENAME}" fi -# Configure u-boot to boot into recovery mode -uuu fb: ucmd setenv boot_recovery yes -uuu fb: ucmd setenv recovery_command wipe_update - +if [ "${DUALBOOT}" != true ]; then + # Configure u-boot to boot into recovery mode + uuu fb: ucmd setenv boot_recovery yes + uuu fb: ucmd setenv recovery_command wipe_update +fi uuu fb: ucmd saveenv # Reset the target From f647e6d44254162a135d692fee09a623e911fbd7 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 17 Sep 2021 11:45:32 +0200 Subject: [PATCH 40/70] uboot: add dualboot support to fw install script from SD/USB Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7649 --- .../ccimx6qpsbc/install_linux_fw_sd.txt | 153 ++++++++++---- .../ccimx6qpsbc/install_linux_fw_usb.txt | 155 ++++++++++---- .../ccimx6sbc/install_linux_fw_sd.txt | 153 ++++++++++---- .../ccimx6sbc/install_linux_fw_usb.txt | 155 ++++++++++---- .../ccimx6ul/install_linux_fw_sd.txt | 193 +++++++++++------ .../ccimx6ul/install_linux_fw_usb.txt | 195 ++++++++++++------ .../ccimx8m/install_linux_fw_sd.txt | 154 ++++++++++---- .../ccimx8m/install_linux_fw_usb.txt | 156 +++++++++----- .../ccimx8x/install_linux_fw_sd.txt | 154 ++++++++++---- .../ccimx8x/install_linux_fw_usb.txt | 158 +++++++++----- 10 files changed, 1149 insertions(+), 477 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt index 1b50d223e..95cdb1a8c 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt @@ -77,9 +77,16 @@ echo "" echo " PARTITION FILENAME" echo " --------- --------" echo " bootloader ${INSTALL_UBOOT_FILENAME}" -echo " linux ${INSTALL_LINUX_FILENAME}" -echo " recovery ${INSTALL_RECOVERY_FILENAME}" -echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +if test \"\$\{dualboot\}\" = yes; then + echo " linux_a ${INSTALL_LINUX_FILENAME}" + echo " linux_b ${INSTALL_LINUX_FILENAME}" + echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}" + echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}" +else + echo " linux ${INSTALL_LINUX_FILENAME}" + echo " recovery ${INSTALL_RECOVERY_FILENAME}" + echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +fi echo "" echo " Press CTRL+C now if you wish to abort or wait 10 seconds" echo " to continue." @@ -116,15 +123,19 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults +# - Restore 'dualboot' if previously set # - Save the environment # - Partition the eMMC user data area for Linux -# - Update the 'linux' partition -# - Update the 'recovery' partition -# - Update the 'rootfs' partition -# - Configure recovery to wipe 'update' partition -# - Run 'recovery' and let the system boot after +# - If Dual Boot +# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b +# - If Normal Boot: +# - Update the system partitions: linux, recovery, rootfs +# - Erase the 'update' partition +# - Configure recovery to wipe 'update' partition +# - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; + setenv dualboot ${dualboot}; saveenv; echo \"\"; echo \"\"; @@ -138,49 +149,103 @@ setenv bootcmd " echo \"Aborted.\"; exit; fi; - echo \"\"; - echo \"\"; - echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; - echo \"\"; - echo \"\"; - update linux mmc ${INSTALL_MMCDEV} fat ${INSTALL_LINUX_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update linux partition!\"; + if test \"\$\{dualboot\}\" = yes; then echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; - echo \"\"; - echo \"\"; - update recovery mmc ${INSTALL_MMCDEV} fat ${INSTALL_RECOVERY_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; - echo \"\"; - echo \"\"; - update rootfs mmc ${INSTALL_MMCDEV} fat ${INSTALL_ROOTFS_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update rootfs partition!\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; - echo \"Aborted.\"; - exit; + echo \"\"; + update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_a!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; + echo \"\"; + echo \"\"; + update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_b!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; + echo \"\"; + echo \"\"; + update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_a partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; + echo \"\"; + echo \"\"; + update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_b partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + else + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; + echo \"\"; + echo \"\"; + update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; + echo \"\"; + echo \"\"; + update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; + echo \"\"; + echo \"\"; + update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; fi; - echo \"\"; - setenv boot_recovery yes; - setenv recovery_command wipe_update; saveenv; echo \"\"; echo \"\"; - echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \">> Firmware installation complete.\"; + if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + echo \"Rebooting into recovery mode for final deployment.\"; + fi; echo \"\"; echo \"\"; sleep 1; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt index e7da89ee7..cb49d84fd 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt @@ -77,9 +77,16 @@ echo "" echo " PARTITION FILENAME" echo " --------- --------" echo " bootloader ${INSTALL_UBOOT_FILENAME}" -echo " linux ${INSTALL_LINUX_FILENAME}" -echo " recovery ${INSTALL_RECOVERY_FILENAME}" -echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +if test \"\$\{dualboot\}\" = yes; then + echo " linux_a ${INSTALL_LINUX_FILENAME}" + echo " linux_b ${INSTALL_LINUX_FILENAME}" + echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}" + echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}" +else + echo " linux ${INSTALL_LINUX_FILENAME}" + echo " recovery ${INSTALL_RECOVERY_FILENAME}" + echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +fi echo "" echo " Press CTRL+C now if you wish to abort or wait 10 seconds" echo " to continue." @@ -116,15 +123,20 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults +# - Restore 'dualboot' if previously set # - Save the environment # - Partition the eMMC user data area for Linux -# - Update the 'linux' partition -# - Update the 'recovery' partition -# - Update the 'rootfs' partition -# - Configure recovery to wipe 'update' partition -# - Run 'recovery' and let the system boot after +# - If Dual Boot +# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b +# - If Normal Boot: +# - Update the system partitions: linux, recovery, rootfs +# - Erase the 'update' partition +# - Configure recovery to wipe 'update' partition +# - Run 'recovery' and let the system boot after +# NOTE: insert some 'usb reset' commands to avoid EHCI timeouts setenv bootcmd " env default -a; + setenv dualboot ${dualboot}; saveenv; echo \"\"; echo \"\"; @@ -139,49 +151,104 @@ setenv bootcmd " exit; fi; usb start; - echo \"\"; - echo \"\"; - echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; - echo \"\"; - echo \"\"; - update linux usb ${INSTALL_USBDEV} fat ${INSTALL_LINUX_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update linux partition!\"; + if test \"\$\{dualboot\}\" = yes; then echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; - echo \"\"; - echo \"\"; - update recovery usb ${INSTALL_USBDEV} fat ${INSTALL_RECOVERY_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; - echo \"\"; - echo \"\"; - update rootfs usb ${INSTALL_USBDEV} fat ${INSTALL_ROOTFS_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update rootfs partition!\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; - echo \"Aborted.\"; - exit; + echo \"\"; + update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_a!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; + echo \"\"; + echo \"\"; + update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_b!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + usb reset; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; + echo \"\"; + echo \"\"; + update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_a partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; + echo \"\"; + echo \"\"; + update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_b partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + else + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; + echo \"\"; + echo \"\"; + update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; + echo \"\"; + echo \"\"; + update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; + echo \"\"; + echo \"\"; + update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; fi; - echo \"\"; - setenv boot_recovery yes; - setenv recovery_command wipe_update; saveenv; echo \"\"; echo \"\"; - echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \">> Firmware installation complete.\"; + if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + echo \"Rebooting into recovery mode for final deployment.\"; + fi; echo \"\"; echo \"\"; sleep 1; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt index 7131e5476..798d0f77a 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt @@ -88,9 +88,16 @@ echo "" echo " PARTITION FILENAME" echo " --------- --------" echo " bootloader ${INSTALL_UBOOT_FILENAME}" -echo " linux ${INSTALL_LINUX_FILENAME}" -echo " recovery ${INSTALL_RECOVERY_FILENAME}" -echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +if test \"\$\{dualboot\}\" = yes; then + echo " linux_a ${INSTALL_LINUX_FILENAME}" + echo " linux_b ${INSTALL_LINUX_FILENAME}" + echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}" + echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}" +else + echo " linux ${INSTALL_LINUX_FILENAME}" + echo " recovery ${INSTALL_RECOVERY_FILENAME}" + echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +fi echo "" echo " Press CTRL+C now if you wish to abort or wait 10 seconds" echo " to continue." @@ -127,15 +134,19 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults +# - Restore 'dualboot' if previously set # - Save the environment # - Partition the eMMC user data area for Linux -# - Update the 'linux' partition -# - Update the 'recovery' partition -# - Update the 'rootfs' partition -# - Configure recovery to wipe 'update' partition -# - Run 'recovery' and let the system boot after +# - If Dual Boot +# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b +# - If Normal Boot: +# - Update the system partitions: linux, recovery, rootfs +# - Erase the 'update' partition +# - Configure recovery to wipe 'update' partition +# - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; + setenv dualboot ${dualboot}; saveenv; echo \"\"; echo \"\"; @@ -149,49 +160,103 @@ setenv bootcmd " echo \"Aborted.\"; exit; fi; - echo \"\"; - echo \"\"; - echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; - echo \"\"; - echo \"\"; - update linux mmc ${INSTALL_MMCDEV} fat ${INSTALL_LINUX_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update linux partition!\"; + if test \"\$\{dualboot\}\" = yes; then echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; - echo \"\"; - echo \"\"; - update recovery mmc ${INSTALL_MMCDEV} fat ${INSTALL_RECOVERY_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; - echo \"\"; - echo \"\"; - update rootfs mmc ${INSTALL_MMCDEV} fat ${INSTALL_ROOTFS_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update rootfs partition!\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; - echo \"Aborted.\"; - exit; + echo \"\"; + update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_a!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; + echo \"\"; + echo \"\"; + update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_b!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; + echo \"\"; + echo \"\"; + update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_a partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; + echo \"\"; + echo \"\"; + update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_b partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + else + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; + echo \"\"; + echo \"\"; + update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; + echo \"\"; + echo \"\"; + update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; + echo \"\"; + echo \"\"; + update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; fi; - echo \"\"; - setenv boot_recovery yes; - setenv recovery_command wipe_update; saveenv; echo \"\"; echo \"\"; - echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \">> Firmware installation complete.\"; + if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + echo \"Rebooting into recovery mode for final deployment.\"; + fi; echo \"\"; echo \"\"; sleep 1; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt index 5e2614777..42b76cc29 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt @@ -88,9 +88,16 @@ echo "" echo " PARTITION FILENAME" echo " --------- --------" echo " bootloader ${INSTALL_UBOOT_FILENAME}" -echo " linux ${INSTALL_LINUX_FILENAME}" -echo " recovery ${INSTALL_RECOVERY_FILENAME}" -echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +if test \"\$\{dualboot\}\" = yes; then + echo " linux_a ${INSTALL_LINUX_FILENAME}" + echo " linux_b ${INSTALL_LINUX_FILENAME}" + echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}" + echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}" +else + echo " linux ${INSTALL_LINUX_FILENAME}" + echo " recovery ${INSTALL_RECOVERY_FILENAME}" + echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +fi echo "" echo " Press CTRL+C now if you wish to abort or wait 10 seconds" echo " to continue." @@ -127,15 +134,20 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults +# - Restore 'dualboot' if previously set # - Save the environment # - Partition the eMMC user data area for Linux -# - Update the 'linux' partition -# - Update the 'recovery' partition -# - Update the 'rootfs' partition -# - Configure recovery to wipe 'update' partition -# - Run 'recovery' and let the system boot after +# - If Dual Boot +# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b +# - If Normal Boot: +# - Update the system partitions: linux, recovery, rootfs +# - Erase the 'update' partition +# - Configure recovery to wipe 'update' partition +# - Run 'recovery' and let the system boot after +# NOTE: insert some 'usb reset' commands to avoid EHCI timeouts setenv bootcmd " env default -a; + setenv dualboot ${dualboot}; saveenv; echo \"\"; echo \"\"; @@ -150,49 +162,104 @@ setenv bootcmd " exit; fi; usb start; - echo \"\"; - echo \"\"; - echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; - echo \"\"; - echo \"\"; - update linux usb ${INSTALL_USBDEV} fat ${INSTALL_LINUX_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update linux partition!\"; + if test \"\$\{dualboot\}\" = yes; then echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; - echo \"\"; - echo \"\"; - update recovery usb ${INSTALL_USBDEV} fat ${INSTALL_RECOVERY_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; - echo \"\"; - echo \"\"; - update rootfs usb ${INSTALL_USBDEV} fat ${INSTALL_ROOTFS_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update rootfs partition!\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; - echo \"Aborted.\"; - exit; + echo \"\"; + update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_a!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; + echo \"\"; + echo \"\"; + update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_b!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + usb reset; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; + echo \"\"; + echo \"\"; + update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_a partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; + echo \"\"; + echo \"\"; + update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_b partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + else + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; + echo \"\"; + echo \"\"; + update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; + echo \"\"; + echo \"\"; + update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; + echo \"\"; + echo \"\"; + update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; fi; - echo \"\"; - setenv boot_recovery yes; - setenv recovery_command wipe_update; saveenv; echo \"\"; echo \"\"; - echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \">> Firmware installation complete.\"; + if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + echo \"Rebooting into recovery mode for final deployment.\"; + fi; echo \"\"; echo \"\"; sleep 1; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt index ac0398c4c..e3fa6bad2 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt @@ -81,9 +81,16 @@ echo "" echo " PARTITION FILENAME" echo " --------- --------" echo " bootloader ${INSTALL_UBOOT_FILENAME}" -echo " linux ${INSTALL_LINUX_FILENAME}" -echo " recovery ${INSTALL_RECOVERY_FILENAME}" -echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +if test \"\$\{dualboot\}\" = yes; then + echo " linux_a ${INSTALL_LINUX_FILENAME}" + echo " linux_b ${INSTALL_LINUX_FILENAME}" + echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}" + echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}" +else + echo " linux ${INSTALL_LINUX_FILENAME}" + echo " recovery ${INSTALL_RECOVERY_FILENAME}" + echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +fi echo "" echo " Press CTRL+C now if you wish to abort or wait 10 seconds" echo " to continue." @@ -121,78 +128,146 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults -# - Restore 'ubisysvols' if previously set +# - Restore 'ubisysvols' and 'dualboot' if previously set # - Run 'partition_nand_linux' script to re-partition the NAND if needed # - Save the environment -# - Update the 'linux' partition -# - Update the 'recovery' partition -# - Update the 'rootfs' partition -# - Erase the 'update' partition -# - Configure recovery to wipe 'update' partition -# - Run 'recovery' and let the system boot after +# - If Dual Boot +# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b +# - If Normal Boot: +# - Update the system partitions: linux, recovery, rootfs +# - Erase the 'update' partition +# - Configure recovery to wipe 'update' partition +# - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; setenv ubisysvols ${ubisysvols}; + setenv dualboot ${dualboot}; run partition_nand_linux; saveenv; - if test -n \$\{ubisysvols\} && test \$\{ubisysvols\} = yes; then + if test \"\$\{ubisysvols\}\" = yes; then run ubivolscript; fi; - echo \"\"; - echo \"\"; - echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; - echo \"\"; - echo \"\"; - if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then - nand erase.part linux; - fi; - update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update linux partition!\"; + if test \"\$\{dualboot\}\" = yes; then echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; - echo \"\"; - echo \"\"; - if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then - nand erase.part recovery; - fi; - update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; - echo \"\"; - echo \"\"; - if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then - nand erase.part rootfs; - fi; - update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update rootfs partition!\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; - echo \"Aborted.\"; - exit; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part linux_a; + fi; + update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_a!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part linux_b; + fi; + update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_b!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part rootfs_a; + fi; + update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_a partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part rootfs_b; + fi; + update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_b partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + else + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part linux; + fi; + update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part recovery; + fi; + update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part rootfs; + fi; + update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part update; + fi; + setenv boot_recovery yes; + setenv recovery_command wipe_update; fi; - echo \"\"; - if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then - nand erase.part update; - fi; - setenv boot_recovery yes; - setenv recovery_command wipe_update; saveenv; echo \"\"; echo \"\"; - echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \">> Firmware installation complete.\"; + if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + echo \"Rebooting into recovery mode for final deployment.\"; + fi; echo \"\"; echo \"\"; sleep 1; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt index da5cda0b8..e9e7f4e91 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt @@ -81,9 +81,16 @@ echo "" echo " PARTITION FILENAME" echo " --------- --------" echo " bootloader ${INSTALL_UBOOT_FILENAME}" -echo " linux ${INSTALL_LINUX_FILENAME}" -echo " recovery ${INSTALL_RECOVERY_FILENAME}" -echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +if test \"\$\{dualboot\}\" = yes; then + echo " linux_a ${INSTALL_LINUX_FILENAME}" + echo " linux_b ${INSTALL_LINUX_FILENAME}" + echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}" + echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}" +else + echo " linux ${INSTALL_LINUX_FILENAME}" + echo " recovery ${INSTALL_RECOVERY_FILENAME}" + echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +fi echo "" echo " Press CTRL+C now if you wish to abort or wait 10 seconds" echo " to continue." @@ -110,7 +117,7 @@ echo "" update uboot usb ${INSTALL_USBDEV} ${INSTALL_UBOOT_FILENAME} if test $? -eq 1; then # Use old-style update with source file system argument - update uboot mmc ${INSTALL_USBDEV} fat ${INSTALL_UBOOT_FILENAME} + update uboot usb ${INSTALL_USBDEV} fat ${INSTALL_UBOOT_FILENAME} if test $? -eq 1; then echo "[ERROR] Failed to update U-Boot boot loader!"; echo ""; @@ -121,79 +128,147 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults -# - Restore 'ubisysvols' if previously set +# - Restore 'ubisysvols' and 'dualboot' if previously set # - Run 'partition_nand_linux' script to re-partition the NAND if needed # - Save the environment -# - Update the 'linux' partition -# - Update the 'recovery' partition -# - Update the 'rootfs' partition -# - Erase the 'update' partition -# - Configure recovery to wipe 'update' partition -# - Run 'recovery' and let the system boot after +# - If Dual Boot +# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b +# - If Normal Boot: +# - Update the system partitions: linux, recovery, rootfs +# - Erase the 'update' partition +# - Configure recovery to wipe 'update' partition +# - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; setenv ubisysvols ${ubisysvols}; + setenv dualboot ${dualboot}; run partition_nand_linux; saveenv; - if test -n \$\{ubisysvols\} && test \$\{ubisysvols\} = yes; then + if test \"\$\{ubisysvols\}\" = yes; then run ubivolscript; fi; usb start; - echo \"\"; - echo \"\"; - echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; - echo \"\"; - echo \"\"; - if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then - nand erase.part linux; - fi; - update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update linux partition!\"; + if test \"\$\{dualboot\}\" = yes; then echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; - echo \"\"; - echo \"\"; - if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then - nand erase.part recovery; - fi; - update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; - echo \"\"; - echo \"\"; - if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then - nand erase.part rootfs; - fi; - update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update rootfs partition!\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; - echo \"Aborted.\"; - exit; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part linux_a; + fi; + update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_a!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part linux_b; + fi; + update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_b!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part rootfs_a; + fi; + update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_a partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part rootfs_b; + fi; + update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_b partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + else + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part linux; + fi; + update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part recovery; + fi; + update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; + echo \"\"; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part rootfs; + fi; + update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + nand erase.part update; + fi; + setenv boot_recovery yes; + setenv recovery_command wipe_update; fi; - echo \"\"; - if test ! -n \$\{ubisysvols\} || test \$\{ubisysvols\} = no; then - nand erase.part update; - fi; - setenv boot_recovery yes; - setenv recovery_command wipe_update; saveenv; echo \"\"; echo \"\"; - echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \">> Firmware installation complete.\"; + if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + echo \"Rebooting into recovery mode for final deployment.\"; + fi; echo \"\"; echo \"\"; sleep 1; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt index 0c5fd88e2..59a2851f5 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt @@ -48,9 +48,16 @@ echo "" echo " PARTITION FILENAME" echo " --------- --------" echo " bootloader ${INSTALL_UBOOT_FILENAME}" -echo " linux ${INSTALL_LINUX_FILENAME}" -echo " recovery ${INSTALL_RECOVERY_FILENAME}" -echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +if test \"\$\{dualboot\}\" = yes; then + echo " linux_a ${INSTALL_LINUX_FILENAME}" + echo " linux_b ${INSTALL_LINUX_FILENAME}" + echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}" + echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}" +else + echo " linux ${INSTALL_LINUX_FILENAME}" + echo " recovery ${INSTALL_RECOVERY_FILENAME}" + echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +fi echo "" echo " Press CTRL+C now if you wish to abort or wait 10 seconds" echo " to continue." @@ -91,17 +98,20 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults +# - Restore 'dualboot' if previously set # - Save the environment # - Force on-the-fly updates to avoid possible verification errors # - Partition the eMMC user data area for Linux -# - Update the 'linux' partition -# - Update the 'recovery' partition -# - Update the 'rootfs' partition -# - Configure recovery to wipe 'update' partition -# - Disable on-the-fly updates -# - Run 'recovery' and let the system boot after +# - If Dual Boot +# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b +# - If Normal Boot: +# - Update the system partitions: linux, recovery, rootfs +# - Erase the 'update' partition +# - Configure recovery to wipe 'update' partition +# - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; + setenv dualboot ${dualboot}; saveenv; setenv otf-update yes; echo \"\"; @@ -116,50 +126,104 @@ setenv bootcmd " echo \"Aborted.\"; exit; fi; - echo \"\"; - echo \"\"; - echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; - echo \"\"; - echo \"\"; - update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update linux partition!\"; + if test \"\$\{dualboot\}\" = yes; then echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; - echo \"\"; - echo \"\"; - update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; - echo \"\"; - echo \"\"; - update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update rootfs partition!\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; - echo \"Aborted.\"; - exit; + echo \"\"; + update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_a!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; + echo \"\"; + echo \"\"; + update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_b!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; + echo \"\"; + echo \"\"; + update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_a partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; + echo \"\"; + echo \"\"; + update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_b partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + else + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; + echo \"\"; + echo \"\"; + update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; + echo \"\"; + echo \"\"; + update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; + echo \"\"; + echo \"\"; + update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; fi; - echo \"\"; - setenv boot_recovery yes; - setenv recovery_command wipe_update; setenv otf-update; saveenv; echo \"\"; echo \"\"; - echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \">> Firmware installation complete.\"; + if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + echo \"Rebooting into recovery mode for final deployment.\"; + fi; echo \"\"; echo \"\"; sleep 1; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt index 3da66fdb4..80b87ad27 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt @@ -48,9 +48,16 @@ echo "" echo " PARTITION FILENAME" echo " --------- --------" echo " bootloader ${INSTALL_UBOOT_FILENAME}" -echo " linux ${INSTALL_LINUX_FILENAME}" -echo " recovery ${INSTALL_RECOVERY_FILENAME}" -echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +if test \"\$\{dualboot\}\" = yes; then + echo " linux_a ${INSTALL_LINUX_FILENAME}" + echo " linux_b ${INSTALL_LINUX_FILENAME}" + echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}" + echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}" +else + echo " linux ${INSTALL_LINUX_FILENAME}" + echo " recovery ${INSTALL_RECOVERY_FILENAME}" + echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +fi echo "" echo " Press CTRL+C now if you wish to abort or wait 10 seconds" echo " to continue." @@ -80,7 +87,7 @@ echo "" update uboot usb ${INSTALL_USBDEV} ${INSTALL_UBOOT_FILENAME} if test $? -eq 1; then # Use old-style update with source file system argument - update uboot mmc ${INSTALL_USBDEV} fat ${INSTALL_UBOOT_FILENAME} + update uboot usb ${INSTALL_USBDEV} fat ${INSTALL_UBOOT_FILENAME} if test $? -eq 1; then echo "[ERROR] Failed to update U-Boot boot loader!"; echo ""; @@ -91,17 +98,20 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults +# - Restore 'dualboot' if previously set # - Save the environment # - Force on-the-fly updates to avoid possible verification errors # - Partition the eMMC user data area for Linux -# - Update the 'linux' partition -# - Update the 'recovery' partition -# - Update the 'rootfs' partition -# - Configure recovery to wipe 'update' partition -# - Disable on-the-fly updates -# - Run 'recovery' and let the system boot after +# - If Dual Boot +# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b +# - If Normal Boot: +# - Update the system partitions: linux, recovery, rootfs +# - Erase the 'update' partition +# - Configure recovery to wipe 'update' partition +# - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; + setenv dualboot ${dualboot}; saveenv; setenv otf-update yes; echo \"\"; @@ -117,50 +127,104 @@ setenv bootcmd " exit; fi; usb start; - echo \"\"; - echo \"\"; - echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; - echo \"\"; - echo \"\"; - update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update linux partition!\"; + if test \"\$\{dualboot\}\" = yes; then echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; - echo \"\"; - echo \"\"; - update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; - echo \"\"; - echo \"\"; - update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update rootfs partition!\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; - echo \"Aborted.\"; - exit; + echo \"\"; + update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_a!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; + echo \"\"; + echo \"\"; + update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_b!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; + echo \"\"; + echo \"\"; + update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_a partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; + echo \"\"; + echo \"\"; + update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_b partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + else + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; + echo \"\"; + echo \"\"; + update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; + echo \"\"; + echo \"\"; + update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; + echo \"\"; + echo \"\"; + update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; fi; - echo \"\"; - setenv boot_recovery yes; - setenv recovery_command wipe_update; setenv otf-update; saveenv; echo \"\"; echo \"\"; - echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \">> Firmware installation complete.\"; + if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + echo \"Rebooting into recovery mode for final deployment.\"; + fi; echo \"\"; echo \"\"; sleep 1; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt index 921dd2d81..61083e1d6 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt @@ -119,9 +119,16 @@ echo "" echo " PARTITION FILENAME" echo " --------- --------" echo " bootloader ${INSTALL_UBOOT_FILENAME}" -echo " linux ${INSTALL_LINUX_FILENAME}" -echo " recovery ${INSTALL_RECOVERY_FILENAME}" -echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +if test \"\$\{dualboot\}\" = yes; then + echo " linux_a ${INSTALL_LINUX_FILENAME}" + echo " linux_b ${INSTALL_LINUX_FILENAME}" + echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}" + echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}" +else + echo " linux ${INSTALL_LINUX_FILENAME}" + echo " recovery ${INSTALL_RECOVERY_FILENAME}" + echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +fi echo "" echo " Press CTRL+C now if you wish to abort or wait 10 seconds" echo " to continue." @@ -162,17 +169,20 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults +# - Restore 'dualboot' if previously set # - Save the environment # - Force on-the-fly updates to avoid possible verification errors # - Partition the eMMC user data area for Linux -# - Update the 'linux' partition -# - Update the 'recovery' partition -# - Update the 'rootfs' partition -# - Configure recovery to wipe 'update' partition -# - Disable on-the-fly updates -# - Run 'recovery' and let the system boot after +# - If Dual Boot +# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b +# - If Normal Boot: +# - Update the system partitions: linux, recovery, rootfs +# - Erase the 'update' partition +# - Configure recovery to wipe 'update' partition +# - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; + setenv dualboot ${dualboot}; saveenv; setenv otf-update yes; echo \"\"; @@ -187,50 +197,104 @@ setenv bootcmd " echo \"Aborted.\"; exit; fi; - echo \"\"; - echo \"\"; - echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; - echo \"\"; - echo \"\"; - update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update linux partition!\"; + if test \"\$\{dualboot\}\" = yes; then echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; - echo \"\"; - echo \"\"; - update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; - echo \"\"; - echo \"\"; - update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update rootfs partition!\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; - echo \"Aborted.\"; - exit; + echo \"\"; + update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_a!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; + echo \"\"; + echo \"\"; + update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_b!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; + echo \"\"; + echo \"\"; + update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_a partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; + echo \"\"; + echo \"\"; + update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_b partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + else + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; + echo \"\"; + echo \"\"; + update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; + echo \"\"; + echo \"\"; + update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; + echo \"\"; + echo \"\"; + update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; fi; - echo \"\"; - setenv boot_recovery yes; - setenv recovery_command wipe_update; setenv otf-update; saveenv; echo \"\"; echo \"\"; - echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \">> Firmware installation complete.\"; + if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + echo \"Rebooting into recovery mode for final deployment.\"; + fi; echo \"\"; echo \"\"; sleep 1; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt index 39f96a9f1..e7591bfb7 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt @@ -119,9 +119,16 @@ echo "" echo " PARTITION FILENAME" echo " --------- --------" echo " bootloader ${INSTALL_UBOOT_FILENAME}" -echo " linux ${INSTALL_LINUX_FILENAME}" -echo " recovery ${INSTALL_RECOVERY_FILENAME}" -echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +if test \"\$\{dualboot\}\" = yes; then + echo " linux_a ${INSTALL_LINUX_FILENAME}" + echo " linux_b ${INSTALL_LINUX_FILENAME}" + echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}" + echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}" +else + echo " linux ${INSTALL_LINUX_FILENAME}" + echo " recovery ${INSTALL_RECOVERY_FILENAME}" + echo " rootfs ${INSTALL_ROOTFS_FILENAME}" +fi echo "" echo " Press CTRL+C now if you wish to abort or wait 10 seconds" echo " to continue." @@ -151,7 +158,7 @@ echo "" update uboot usb ${INSTALL_USBDEV} ${INSTALL_UBOOT_FILENAME} if test $? -eq 1; then # Use old-style update with source file system argument - update uboot mmc ${INSTALL_USBDEV} fat ${INSTALL_UBOOT_FILENAME} + update uboot usb ${INSTALL_USBDEV} fat ${INSTALL_UBOOT_FILENAME} if test $? -eq 1; then echo "[ERROR] Failed to update U-Boot boot loader!"; echo ""; @@ -162,17 +169,21 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults +# - Restore 'dualboot' if previously set # - Save the environment # - Force on-the-fly updates to avoid possible verification errors # - Partition the eMMC user data area for Linux -# - Update the 'linux' partition -# - Update the 'recovery' partition -# - Update the 'rootfs' partition -# - Configure recovery to wipe 'update' partition -# - Disable on-the-fly updates -# - Run 'recovery' and let the system boot after +# - If Dual Boot +# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b +# - If Normal Boot: +# - Update the system partitions: linux, recovery, rootfs +# - Erase the 'update' partition +# - Configure recovery to wipe 'update' partition +# - Run 'recovery' and let the system boot after +# NOTE: insert some 'usb reset' commands to avoid EHCI timeouts setenv bootcmd " env default -a; + setenv dualboot ${dualboot}; saveenv; setenv otf-update yes; echo \"\"; @@ -188,50 +199,105 @@ setenv bootcmd " exit; fi; usb start; - echo \"\"; - echo \"\"; - echo \">> Installing linux image file ${INSTALL_LINUX_FILENAME}\"; - echo \"\"; - echo \"\"; - update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update linux partition!\"; + if test \"\$\{dualboot\}\" = yes; then echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing recovery file ${INSTALL_RECOVERY_FILENAME}\"; - echo \"\"; - echo \"\"; - update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; - echo \"Aborted.\"; - exit; - fi; - echo \"\"; - echo \"\"; - echo \">> Installing root file system file ${INSTALL_ROOTFS_FILENAME}\"; - echo \"\"; - echo \"\"; - update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; - if test \$? -eq 1; then - echo \"[ERROR] Failed to update rootfs partition!\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; - echo \"Aborted.\"; - exit; + echo \"\"; + update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_a!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; + echo \"\"; + echo \"\"; + update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux_b!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + usb reset; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; + echo \"\"; + echo \"\"; + update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_a partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; + echo \"\"; + echo \"\"; + update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs_b partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + else + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; + echo \"\"; + echo \"\"; + update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; + echo \"\"; + echo \"\"; + update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; + echo \"\"; + echo \"\"; + update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; fi; - echo \"\"; - setenv boot_recovery yes; - setenv recovery_command wipe_update; setenv otf-update; saveenv; echo \"\"; echo \"\"; - echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \">> Firmware installation complete.\"; + if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + echo \"Rebooting into recovery mode for final deployment.\"; + fi; echo \"\"; echo \"\"; sleep 1; From f3ae964d10ac0872b26c0fb4ed383fd883c94197 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 28 Sep 2021 12:08:53 +0200 Subject: [PATCH 41/70] uboot: cc6ul: force erase of partitions before update on install scripts Install scripts may rework the partition table basing on the value of env variables. Information of UBI volumes may remain on the NAND that could later not correspond to the new partition table. Make sure the MTD partitions are erased prior to updating: - For Multi-MTD, append '-e' option to the update command. - For Single-MTD, erase the system partition. Signed-off-by: Hector Palacios --- .../ccimx6ul/install_linux_fw_sd.txt | 37 +++++-------------- .../ccimx6ul/install_linux_fw_usb.txt | 37 +++++-------------- .../ccimx6ul/install_linux_fw_uuu.sh | 11 +++++- 3 files changed, 28 insertions(+), 57 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt index e3fa6bad2..9a8494f19 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt @@ -146,6 +146,8 @@ setenv bootcmd " saveenv; if test \"\$\{ubisysvols\}\" = yes; then run ubivolscript; + else + force_erase="-e" fi; if test \"\$\{dualboot\}\" = yes; then echo \"\"; @@ -153,10 +155,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux_a; - fi; - update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux_a!\"; echo \"\"; @@ -168,10 +167,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux_b; - fi; - update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux_b!\"; echo \"\"; @@ -183,10 +179,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs_a; - fi; - update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs_a partition!\"; echo \"\"; @@ -198,10 +191,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs_b; - fi; - update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs_b partition!\"; echo \"\"; @@ -214,10 +204,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux; - fi; - update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux!\"; echo \"\"; @@ -229,10 +216,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part recovery; - fi; - update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; + update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; @@ -244,10 +228,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs; - fi; - update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs partition!\"; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt index e9e7f4e91..7c7cf8c14 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt @@ -146,6 +146,8 @@ setenv bootcmd " saveenv; if test \"\$\{ubisysvols\}\" = yes; then run ubivolscript; + else + force_erase="-e" fi; usb start; if test \"\$\{dualboot\}\" = yes; then @@ -154,10 +156,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux_a; - fi; - update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux_a!\"; echo \"\"; @@ -169,10 +168,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux_b; - fi; - update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux_b!\"; echo \"\"; @@ -184,10 +180,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs_a; - fi; - update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs_a partition!\"; echo \"\"; @@ -199,10 +192,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs_b; - fi; - update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs_b partition!\"; echo \"\"; @@ -215,10 +205,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux; - fi; - update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux!\"; echo \"\"; @@ -230,10 +217,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part recovery; - fi; - update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; + update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; @@ -245,10 +229,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs; - fi; - update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs partition!\"; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh index 01b626663..ae286effe 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh @@ -58,8 +58,16 @@ part_update() echo "=====================================================================================" echo "\033[0m" + # When in Multi-MTD mode, pass -e to update command to force the erase + # of the MTD partition before programming. This is usually done by + # 'update' command except when a UBI volume is already found. + # On the install script, the MTD partition table may have changed, so + # we'd better clean the partition. + if [ "${UBISYSVOLS}" != true ]; then + ERASE="-e" + fi uuu fb: download -f "${2}" - uuu "fb[-t ${3}]:" ucmd update "${1}" ram \${fastboot_buffer} \${fastboot_bytes} + uuu "fb[-t ${3}]:" ucmd update "${1}" ram \${fastboot_buffer} \${fastboot_bytes} ${ERASE} } clear @@ -259,6 +267,7 @@ uuu "fb[-t 10000]:" ucmd run partition_nand_linux if [ "${UBISYSVOLS}" = true ]; then uuu "fb[-t 10000]:" ucmd run ubivolscript + nand erase.part system fi if [ "${DUALBOOT}" = true ]; then From fa3028a17e2305f4468f8461ac7f1143e122a501 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 28 Sep 2021 12:15:20 +0200 Subject: [PATCH 42/70] uboot: install sd/usb: convert double condition in a simpler single condition Signed-off-by: Hector Palacios --- .../u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt | 2 +- .../u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt | 2 +- .../u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt | 2 +- .../u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt | 2 +- .../u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt | 4 ++-- .../u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt | 4 ++-- .../u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt | 2 +- .../u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt | 2 +- .../u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt | 2 +- .../u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt index 95cdb1a8c..804b47eb4 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt @@ -243,7 +243,7 @@ setenv bootcmd " echo \"\"; echo \"\"; echo \">> Firmware installation complete.\"; - if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + if test \"\$\{dualboot\}\" != yes; then echo \"Rebooting into recovery mode for final deployment.\"; fi; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt index cb49d84fd..ac8b70021 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt @@ -246,7 +246,7 @@ setenv bootcmd " echo \"\"; echo \"\"; echo \">> Firmware installation complete.\"; - if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + if test \"\$\{dualboot\}\" != yes; then echo \"Rebooting into recovery mode for final deployment.\"; fi; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt index 798d0f77a..caec690ee 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt @@ -254,7 +254,7 @@ setenv bootcmd " echo \"\"; echo \"\"; echo \">> Firmware installation complete.\"; - if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + if test \"\$\{dualboot\}\" != yes; then echo \"Rebooting into recovery mode for final deployment.\"; fi; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt index 42b76cc29..371e26a92 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt @@ -257,7 +257,7 @@ setenv bootcmd " echo \"\"; echo \"\"; echo \">> Firmware installation complete.\"; - if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + if test \"\$\{dualboot\}\" != yes; then echo \"Rebooting into recovery mode for final deployment.\"; fi; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt index 9a8494f19..2f6f87610 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt @@ -236,7 +236,7 @@ setenv bootcmd " exit; fi; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + if test \"\$\{ubisysvols\}\" != yes; then nand erase.part update; fi; setenv boot_recovery yes; @@ -246,7 +246,7 @@ setenv bootcmd " echo \"\"; echo \"\"; echo \">> Firmware installation complete.\"; - if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + if test \"\$\{dualboot\}\" != yes; then echo \"Rebooting into recovery mode for final deployment.\"; fi; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt index 7c7cf8c14..2210bc23c 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt @@ -237,7 +237,7 @@ setenv bootcmd " exit; fi; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then + if test \"\$\{ubisysvols\}\" != yes; then nand erase.part update; fi; setenv boot_recovery yes; @@ -247,7 +247,7 @@ setenv bootcmd " echo \"\"; echo \"\"; echo \">> Firmware installation complete.\"; - if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + if test \"\$\{dualboot\}\" != yes; then echo \"Rebooting into recovery mode for final deployment.\"; fi; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt index 59a2851f5..d47c025e9 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt @@ -221,7 +221,7 @@ setenv bootcmd " echo \"\"; echo \"\"; echo \">> Firmware installation complete.\"; - if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + if test \"\$\{dualboot\}\" != yes; then echo \"Rebooting into recovery mode for final deployment.\"; fi; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt index 80b87ad27..0e9336b79 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt @@ -222,7 +222,7 @@ setenv bootcmd " echo \"\"; echo \"\"; echo \">> Firmware installation complete.\"; - if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + if test \"\$\{dualboot\}\" != yes; then echo \"Rebooting into recovery mode for final deployment.\"; fi; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt index 61083e1d6..5e2ec8b92 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt @@ -292,7 +292,7 @@ setenv bootcmd " echo \"\"; echo \"\"; echo \">> Firmware installation complete.\"; - if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + if test \"\$\{dualboot\}\" != yes; then echo \"Rebooting into recovery mode for final deployment.\"; fi; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt index e7591bfb7..ee1baa94c 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt @@ -295,7 +295,7 @@ setenv bootcmd " echo \"\"; echo \"\"; echo \">> Firmware installation complete.\"; - if test ! -n \$\{dualboot\} || test \$\{dualboot\} = no; then + if test \"\$\{dualboot\}\" != yes; then echo \"Rebooting into recovery mode for final deployment.\"; fi; echo \"\"; From cc2df395c57d471f897b5c3706dd40607ca5bac7 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 28 Sep 2021 17:17:52 +0200 Subject: [PATCH 43/70] uboot: ccimx6ul: rename variable for single MTD system partition Rename from 'ubisysvols' to 'singlemtdsys'. Signed-off-by: Hector Palacios --- .../ccimx6ul/install_linux_fw_sd.txt | 8 ++++---- .../ccimx6ul/install_linux_fw_usb.txt | 8 ++++---- .../ccimx6ul/install_linux_fw_uuu.sh | 20 +++++++++---------- .../recovery-initramfs-init | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt index 2f6f87610..0dca2475d 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt @@ -128,7 +128,7 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults -# - Restore 'ubisysvols' and 'dualboot' if previously set +# - Restore 'singlemtdsys' and 'dualboot' if previously set # - Run 'partition_nand_linux' script to re-partition the NAND if needed # - Save the environment # - If Dual Boot @@ -140,11 +140,11 @@ fi # - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; - setenv ubisysvols ${ubisysvols}; + setenv singlemtdsys ${singlemtdsys}; setenv dualboot ${dualboot}; run partition_nand_linux; saveenv; - if test \"\$\{ubisysvols\}\" = yes; then + if test \"\$\{singlemtdsys\}\" = yes; then run ubivolscript; else force_erase="-e" @@ -236,7 +236,7 @@ setenv bootcmd " exit; fi; echo \"\"; - if test \"\$\{ubisysvols\}\" != yes; then + if test \"\$\{singlemtdsys\}\" != yes; then nand erase.part update; fi; setenv boot_recovery yes; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt index 2210bc23c..e62cbc2e7 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt @@ -128,7 +128,7 @@ fi # Set 'bootcmd' to the second part of the script that will # - Reset environment to defaults -# - Restore 'ubisysvols' and 'dualboot' if previously set +# - Restore 'singlemtdsys' and 'dualboot' if previously set # - Run 'partition_nand_linux' script to re-partition the NAND if needed # - Save the environment # - If Dual Boot @@ -140,11 +140,11 @@ fi # - Run 'recovery' and let the system boot after setenv bootcmd " env default -a; - setenv ubisysvols ${ubisysvols}; + setenv singlemtdsys ${singlemtdsys}; setenv dualboot ${dualboot}; run partition_nand_linux; saveenv; - if test \"\$\{ubisysvols\}\" = yes; then + if test \"\$\{singlemtdsys\}\" = yes; then run ubivolscript; else force_erase="-e" @@ -237,7 +237,7 @@ setenv bootcmd " exit; fi; echo \"\"; - if test \"\$\{ubisysvols\}\" != yes; then + if test \"\$\{singlemtdsys\}\" != yes; then nand erase.part update; fi; setenv boot_recovery yes; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh index ae286effe..ca8305836 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh @@ -63,7 +63,7 @@ part_update() # 'update' command except when a UBI volume is already found. # On the install script, the MTD partition table may have changed, so # we'd better clean the partition. - if [ "${UBISYSVOLS}" != true ]; then + if [ "${SINGLEMTDSYS}" != true ]; then ERASE="-e" fi uuu fb: download -f "${2}" @@ -97,10 +97,10 @@ if [ "${dualboot}" = "yes" ]; then DUALBOOT=true; fi -# Check if ubisysvols variable is active -ubisysvols=$(getenv "ubisysvols") -if [ "${ubisysvols}" = "yes" ]; then - UBISYSVOLS=true; +# Check if singlemtdsys variable is active +singlemtdsys=$(getenv "singlemtdsys") +if [ "${singlemtdsys}" = "yes" ]; then + SINGLEMTDSYS=true; fi echo "" @@ -257,15 +257,15 @@ if [ "${DUALBOOT}" = true ]; then uuu fb: ucmd setenv dualboot yes fi -# Restore ubisysvols if previously active -if [ "${UBISYSVOLS}" = true ]; then - uuu fb: ucmd setenv ubisysvols yes +# Restore singlemtdsys if previously active +if [ "${SINGLEMTDSYS}" = true ]; then + uuu fb: ucmd setenv singlemtdsys yes fi # Create partition table uuu "fb[-t 10000]:" ucmd run partition_nand_linux -if [ "${UBISYSVOLS}" = true ]; then +if [ "${SINGLEMTDSYS}" = true ]; then uuu "fb[-t 10000]:" ucmd run ubivolscript nand erase.part system fi @@ -288,7 +288,7 @@ else part_update "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}" 90000 fi -if [ "${UBISYSVOLS}" != true ] && [ "${DUALBOOT}" != true ]; then +if [ "${SINGLEMTDSYS}" != true ] && [ "${DUALBOOT}" != true ]; then # Erase the 'Update' partition uuu fb: ucmd nand erase.part update fi diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init index a74ce2914..8bf44c037 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init @@ -231,10 +231,10 @@ format_ubi_volume() { psplash_message "Formatting '${1}' partition..." psplash_progress "0" - # Read the ubisysvols variable. - read_uboot_var ubisysvols ubisysvols + # Read the singlemtdsys variable. + read_uboot_var singlemtdsys singlemtdsys - if [ "${ubisysvols}" = "yes" ]; then + if [ "${singlemtdsys}" = "yes" ]; then # Find the volume number associated to the volume name for d in /dev/ubi0_*; do volname="$(ubinfo ${d} | grep ^Name | awk '{print $(2)}')" From 2e375b2e3fbcb6bfb1c0bf6724df21b1e5c711ec Mon Sep 17 00:00:00 2001 From: Gonzalo Ruiz Date: Wed, 29 Sep 2021 13:32:22 +0200 Subject: [PATCH 44/70] u-boot-dey: [cosmetic] change permissions for install_linux_fw_uuu.sh Signed-off-by: Gonzalo Ruiz --- .../u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh | 0 .../recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh mode change 100755 => 100644 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh old mode 100755 new mode 100644 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh old mode 100755 new mode 100644 From 1166981fa1a8f8caad41823420cb59d3fd6fd4e7 Mon Sep 17 00:00:00 2001 From: Gonzalo Ruiz Date: Wed, 29 Sep 2021 13:34:00 +0200 Subject: [PATCH 45/70] u-boot-dey: add install_linux_fw_uuu.sh for ccimx6/ccimx6qp Add initially as a copy of the script used on the ccimx8x platform. Signed-off-by: Gonzalo Ruiz --- .../ccimx6qpsbc/install_linux_fw_uuu.sh | 334 ++++++++++++++++++ .../ccimx6sbc/install_linux_fw_uuu.sh | 334 ++++++++++++++++++ 2 files changed, 668 insertions(+) create mode 100644 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh create mode 100644 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh new file mode 100644 index 000000000..8da80e9c5 --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh @@ -0,0 +1,334 @@ +#!/bin/sh +#=============================================================================== +# +# Copyright (C) 2020-2021 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# Description: +# Script to flash Yocto build artifacts over USB to the target. +#=============================================================================== +# set -x + +# +# U-Boot script for installing Linux images created by Yocto +# + +# Exit on any error +set -e + +# Parse uuu cmd output +getenv() +{ + uuu -v fb: ucmd printenv "${1}" | sed -ne "s,^${1}=,,g;T;p" +} + +show_usage() +{ + echo "Usage: $0 [options]" + echo "" + echo " Options:" + echo " -h Show this help." + echo " -i Image name that prefixes the image filenames, such as 'dey-image-qt', " + echo " 'dey-image-webkit', 'core-image-base'..." + echo " Defaults to '##DEFAULT_IMAGE_NAME##' if not provided." + echo " -n No wait. Skips 10 seconds delay to stop script." + echo " -u U-Boot filename." + echo " Auto-determined by variant if not provided." + exit 2 +} + +# Update a partition +# Params: +# 1. partition +# 2. file +part_update() +{ + echo "\033[36m" + echo "=====================================================================================" + echo "Updating '${1}' partition with file: ${2}" + echo "=====================================================================================" + echo "\033[0m" + + if [ "${1}" = "bootloader" ]; then + uuu fb: flash "${1}" "${2}" + else + uuu fb: flash -raw2sparse "${1}" "${2}" + fi +} + +clear +echo "############################################################" +echo "# Linux firmware install through USB OTG #" +echo "############################################################" + +# Command line admits the following parameters: +# -u +# -i +while getopts 'hi:nu:' c +do + case $c in + h) show_usage ;; + i) IMAGE_NAME=${OPTARG} ;; + n) NOWAIT=true ;; + u) INSTALL_UBOOT_FILENAME=${OPTARG} ;; + esac +done + +# Enable the redirect support to get u-boot variables values +uuu fb: ucmd setenv stdout serial,fastboot + +# Check if dualboot variable is active +dualboot=$(getenv "dualboot") +if [ "${dualboot}" = "yes" ]; then + DUALBOOT=true; +fi + +echo "" +echo "Determining image files to use..." + +# Determine U-Boot file to program basing on SOM's SOC type (linked to bus width) +if [ -z ${INSTALL_UBOOT_FILENAME} ]; then + # Since SOMs with the B0 SOC might have an older U-Boot that doesn't export the + # SOC revision to the environment, use B0 by default + soc_rev=$(getenv "soc_rev") + if [ -z "${soc_rev}" ]; then + soc_rev="B0" + fi + + bus_width="32bit" + soc_type=$(getenv "soc_type") + if [ "$soc_type" = "imx8dx" ]; then + bus_width="16bit" + fi + + module_ram=$(getenv "module_ram") + if [ -z "${module_ram}" ]; then + module_variant=$(getenv "module_variant") + # Determine U-Boot file to program basing on SOM's variant + if [ -n "$module_variant" ] || [ "$module_variant" = "0x00" ]; then + if [ "$module_variant" = "0x01" ] || \ + [ "$module_variant" = "0x04" ] || \ + [ "$module_variant" = "0x05" ]; then + module_ram="1GB" + elif [ "$module_variant" = "0x06" ] || \ + [ "$module_variant" = "0x09" ]; then + module_ram="512MB" + else + module_ram="2GB" + fi + INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" + fi + else + INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" + fi + + # remove redirect + uuu fb: ucmd setenv stdout serial + + # U-Boot when the checked value is empty. + if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then + true + else + echo "" + echo "[ERROR] Cannot determine U-Boot file for this module!" + echo "" + echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" + echo " - For a QuadXPlus CPU with 1GB LPDDR4, run:" + echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin" + echo " - For a QuadXPlus CPU with 2GB LPDDR4, run:" + echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin" + echo " - For a DualX CPU with 1GB LPDDR4, run:" + echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin" + echo " - For a DualX CPU with 512MB LPDDR4, run:" + echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin" + echo "" + echo "2. Run the install script again." + echo "" + echo "Aborted" + echo "" + exit + fi +fi + +# Determine linux, recovery, and rootfs image filenames to update +if [ -z "${IMAGE_NAME}" ]; then + IMAGE_NAME="##DEFAULT_IMAGE_NAME##" +fi +GRAPHICAL_IMAGES="##GRAPHICAL_IMAGES##" +for g in ${GRAPHICAL_IMAGES}; do + if [ "${IMAGE_NAME}" = "${g}" ]; then + BASEFILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##" + fi +done +if [ -z "${BASEFILENAME}" ]; then + BASEFILENAME="${IMAGE_NAME}" +fi +INSTALL_LINUX_FILENAME="${BASEFILENAME}-##MACHINE##.boot.vfat" +INSTALL_RECOVERY_FILENAME="${BASEFILENAME}-##MACHINE##.recovery.vfat" +INSTALL_ROOTFS_FILENAME="${BASEFILENAME}-##MACHINE##.ext4" + +COMPRESSED_ROOTFS_IMAGE="${INSTALL_ROOTFS_FILENAME}.gz" + +# If the rootfs image is compressed, make sure to decompress it before the update +if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ ! -f ${INSTALL_ROOTFS_FILENAME} ]; then + echo "\033[36m" + echo "=====================================================================================" + echo "Decompressing rootfs image '${COMPRESSED_ROOTFS_IMAGE}'" + echo "=====================================================================================" + echo "\033[0m" + gzip -d -k -f "${COMPRESSED_ROOTFS_IMAGE}" +fi + +# Verify existance of files before starting the update +FILES="${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_RECOVERY_FILENAME} ${INSTALL_ROOTFS_FILENAME}" +for f in ${FILES}; do + if [ ! -f ${f} ]; then + echo "\033[31m[ERROR] Could not find file '${f}'\033[0m" + ABORT=true + fi +done; + +[ "${ABORT}" = true ] && exit 1 + +# parts names +LINUX_NAME="linux" +RECOVERY_NAME="recovery" +ROOTFS_NAME="rootfs" +# Print warning about storage media being deleted +if [ "${NOWAIT}" != true ]; then + WAIT=10 + printf "\n" + printf " ====================\n" + printf " = IMPORTANT! =\n" + printf " ====================\n" + printf " This process will erase your eMMC and will install the following files\n" + printf " on the partitions of the eMMC.\n" + printf "\n" + printf " PARTITION\tFILENAME\n" + printf " ---------\t--------\n" + printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n" + if [ "${DUALBOOT}" = true ]; then + printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n" + printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n" + printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n" + printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n" + else + printf " ${LINUX_NAME}\t${INSTALL_LINUX_FILENAME}\n" + printf " ${RECOVERY_NAME}\t${INSTALL_RECOVERY_FILENAME}\n" + printf " ${ROOTFS_NAME}\t${INSTALL_ROOTFS_FILENAME}\n" + fi + printf "\n" + printf " Press CTRL+C now if you wish to abort.\n" + printf "\n" + while [ ${WAIT} -gt 0 ]; do + printf "\r Update process starts in %d " ${WAIT} + sleep 1 + WAIT=$(( ${WAIT} - 1 )) + done + printf "\r \n" + printf " Starting update process\n" +fi + +# Skip user confirmation for U-Boot update +uuu fb: ucmd setenv forced_update 1 + +# Update U-Boot +part_update "bootloader" "${INSTALL_UBOOT_FILENAME}" + +# Set MMC to boot from BOOT1 partition +uuu fb: ucmd mmc partconf 0 1 1 1 + +# Set 'bootcmd' for the second part of the script that will +# - Reset environment to defaults +# - Save the environment +# - Partition the eMMC user data area for Linux +# - Update the 'linux' partition +# - Update the 'recovery' partition +# - Update the 'rootfs' partition +uuu fb: ucmd setenv bootcmd " + env default -a; + saveenv; + echo \"\"; + echo \"\"; + echo \">> Creating Linux partition table on the eMMC\"; + echo \"\"; + echo \"\"; + run partition_mmc_linux; + if test \$? -eq 1; then + echo \"[ERROR] Failed to create Linux partition table!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Start installation Linux firmware files\"; + echo \"\"; + echo \"\"; + saveenv; + fastboot 1; +" + +uuu fb: ucmd saveenv +uuu fb: acmd reset + +# Wait for the target to reset +sleep 3 + +# Restart fastboot with the latest MMC partition configuration +uuu fb: ucmd setenv fastboot_dev sata +uuu fb: ucmd setenv fastboot_dev mmc + +# Set fastboot buffer address to $loadaddr, just in case +uuu fb: ucmd setenv fastboot_buffer \${loadaddr} + +# Restore dualboot if previously active +if [ "${DUALBOOT}" = true ]; then + uuu fb: ucmd setenv dualboot yes +fi + +if [ "${DUALBOOT}" = true ]; then + # Update Linux A + part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" + # Update Linux B + part_update "${LINUX_NAME}_b" "${INSTALL_LINUX_FILENAME}" + # Update Rootfs A + part_update "${ROOTFS_NAME}_a" "${INSTALL_ROOTFS_FILENAME}" + # Update Rootfs B + part_update "${ROOTFS_NAME}_b" "${INSTALL_ROOTFS_FILENAME}" +else + # Update Linux + part_update "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}" + # Update Recovery + part_update "${RECOVERY_NAME}" "${INSTALL_RECOVERY_FILENAME}" + # Update Rootfs + part_update "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}" +fi + +# If the rootfs image was originally compressed, remove the uncompressed image +if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then + rm -f "${INSTALL_ROOTFS_FILENAME}" +fi + +if [ "${DUALBOOT}" != true ]; then + # Configure u-boot to boot into recovery mode + uuu fb: ucmd setenv boot_recovery yes + uuu fb: ucmd setenv recovery_command wipe_update +fi +uuu fb: ucmd saveenv + +# Reset the target +uuu fb: acmd reset + +echo "\033[32m" +echo "=============================================================" +echo "Done! Wait for the target to complete first boot process." +echo "=============================================================" +echo "\033[0m" + +exit diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh new file mode 100644 index 000000000..8da80e9c5 --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh @@ -0,0 +1,334 @@ +#!/bin/sh +#=============================================================================== +# +# Copyright (C) 2020-2021 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# Description: +# Script to flash Yocto build artifacts over USB to the target. +#=============================================================================== +# set -x + +# +# U-Boot script for installing Linux images created by Yocto +# + +# Exit on any error +set -e + +# Parse uuu cmd output +getenv() +{ + uuu -v fb: ucmd printenv "${1}" | sed -ne "s,^${1}=,,g;T;p" +} + +show_usage() +{ + echo "Usage: $0 [options]" + echo "" + echo " Options:" + echo " -h Show this help." + echo " -i Image name that prefixes the image filenames, such as 'dey-image-qt', " + echo " 'dey-image-webkit', 'core-image-base'..." + echo " Defaults to '##DEFAULT_IMAGE_NAME##' if not provided." + echo " -n No wait. Skips 10 seconds delay to stop script." + echo " -u U-Boot filename." + echo " Auto-determined by variant if not provided." + exit 2 +} + +# Update a partition +# Params: +# 1. partition +# 2. file +part_update() +{ + echo "\033[36m" + echo "=====================================================================================" + echo "Updating '${1}' partition with file: ${2}" + echo "=====================================================================================" + echo "\033[0m" + + if [ "${1}" = "bootloader" ]; then + uuu fb: flash "${1}" "${2}" + else + uuu fb: flash -raw2sparse "${1}" "${2}" + fi +} + +clear +echo "############################################################" +echo "# Linux firmware install through USB OTG #" +echo "############################################################" + +# Command line admits the following parameters: +# -u +# -i +while getopts 'hi:nu:' c +do + case $c in + h) show_usage ;; + i) IMAGE_NAME=${OPTARG} ;; + n) NOWAIT=true ;; + u) INSTALL_UBOOT_FILENAME=${OPTARG} ;; + esac +done + +# Enable the redirect support to get u-boot variables values +uuu fb: ucmd setenv stdout serial,fastboot + +# Check if dualboot variable is active +dualboot=$(getenv "dualboot") +if [ "${dualboot}" = "yes" ]; then + DUALBOOT=true; +fi + +echo "" +echo "Determining image files to use..." + +# Determine U-Boot file to program basing on SOM's SOC type (linked to bus width) +if [ -z ${INSTALL_UBOOT_FILENAME} ]; then + # Since SOMs with the B0 SOC might have an older U-Boot that doesn't export the + # SOC revision to the environment, use B0 by default + soc_rev=$(getenv "soc_rev") + if [ -z "${soc_rev}" ]; then + soc_rev="B0" + fi + + bus_width="32bit" + soc_type=$(getenv "soc_type") + if [ "$soc_type" = "imx8dx" ]; then + bus_width="16bit" + fi + + module_ram=$(getenv "module_ram") + if [ -z "${module_ram}" ]; then + module_variant=$(getenv "module_variant") + # Determine U-Boot file to program basing on SOM's variant + if [ -n "$module_variant" ] || [ "$module_variant" = "0x00" ]; then + if [ "$module_variant" = "0x01" ] || \ + [ "$module_variant" = "0x04" ] || \ + [ "$module_variant" = "0x05" ]; then + module_ram="1GB" + elif [ "$module_variant" = "0x06" ] || \ + [ "$module_variant" = "0x09" ]; then + module_ram="512MB" + else + module_ram="2GB" + fi + INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" + fi + else + INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" + fi + + # remove redirect + uuu fb: ucmd setenv stdout serial + + # U-Boot when the checked value is empty. + if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then + true + else + echo "" + echo "[ERROR] Cannot determine U-Boot file for this module!" + echo "" + echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" + echo " - For a QuadXPlus CPU with 1GB LPDDR4, run:" + echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin" + echo " - For a QuadXPlus CPU with 2GB LPDDR4, run:" + echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin" + echo " - For a DualX CPU with 1GB LPDDR4, run:" + echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin" + echo " - For a DualX CPU with 512MB LPDDR4, run:" + echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin" + echo "" + echo "2. Run the install script again." + echo "" + echo "Aborted" + echo "" + exit + fi +fi + +# Determine linux, recovery, and rootfs image filenames to update +if [ -z "${IMAGE_NAME}" ]; then + IMAGE_NAME="##DEFAULT_IMAGE_NAME##" +fi +GRAPHICAL_IMAGES="##GRAPHICAL_IMAGES##" +for g in ${GRAPHICAL_IMAGES}; do + if [ "${IMAGE_NAME}" = "${g}" ]; then + BASEFILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##" + fi +done +if [ -z "${BASEFILENAME}" ]; then + BASEFILENAME="${IMAGE_NAME}" +fi +INSTALL_LINUX_FILENAME="${BASEFILENAME}-##MACHINE##.boot.vfat" +INSTALL_RECOVERY_FILENAME="${BASEFILENAME}-##MACHINE##.recovery.vfat" +INSTALL_ROOTFS_FILENAME="${BASEFILENAME}-##MACHINE##.ext4" + +COMPRESSED_ROOTFS_IMAGE="${INSTALL_ROOTFS_FILENAME}.gz" + +# If the rootfs image is compressed, make sure to decompress it before the update +if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ ! -f ${INSTALL_ROOTFS_FILENAME} ]; then + echo "\033[36m" + echo "=====================================================================================" + echo "Decompressing rootfs image '${COMPRESSED_ROOTFS_IMAGE}'" + echo "=====================================================================================" + echo "\033[0m" + gzip -d -k -f "${COMPRESSED_ROOTFS_IMAGE}" +fi + +# Verify existance of files before starting the update +FILES="${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_RECOVERY_FILENAME} ${INSTALL_ROOTFS_FILENAME}" +for f in ${FILES}; do + if [ ! -f ${f} ]; then + echo "\033[31m[ERROR] Could not find file '${f}'\033[0m" + ABORT=true + fi +done; + +[ "${ABORT}" = true ] && exit 1 + +# parts names +LINUX_NAME="linux" +RECOVERY_NAME="recovery" +ROOTFS_NAME="rootfs" +# Print warning about storage media being deleted +if [ "${NOWAIT}" != true ]; then + WAIT=10 + printf "\n" + printf " ====================\n" + printf " = IMPORTANT! =\n" + printf " ====================\n" + printf " This process will erase your eMMC and will install the following files\n" + printf " on the partitions of the eMMC.\n" + printf "\n" + printf " PARTITION\tFILENAME\n" + printf " ---------\t--------\n" + printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n" + if [ "${DUALBOOT}" = true ]; then + printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n" + printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n" + printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n" + printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n" + else + printf " ${LINUX_NAME}\t${INSTALL_LINUX_FILENAME}\n" + printf " ${RECOVERY_NAME}\t${INSTALL_RECOVERY_FILENAME}\n" + printf " ${ROOTFS_NAME}\t${INSTALL_ROOTFS_FILENAME}\n" + fi + printf "\n" + printf " Press CTRL+C now if you wish to abort.\n" + printf "\n" + while [ ${WAIT} -gt 0 ]; do + printf "\r Update process starts in %d " ${WAIT} + sleep 1 + WAIT=$(( ${WAIT} - 1 )) + done + printf "\r \n" + printf " Starting update process\n" +fi + +# Skip user confirmation for U-Boot update +uuu fb: ucmd setenv forced_update 1 + +# Update U-Boot +part_update "bootloader" "${INSTALL_UBOOT_FILENAME}" + +# Set MMC to boot from BOOT1 partition +uuu fb: ucmd mmc partconf 0 1 1 1 + +# Set 'bootcmd' for the second part of the script that will +# - Reset environment to defaults +# - Save the environment +# - Partition the eMMC user data area for Linux +# - Update the 'linux' partition +# - Update the 'recovery' partition +# - Update the 'rootfs' partition +uuu fb: ucmd setenv bootcmd " + env default -a; + saveenv; + echo \"\"; + echo \"\"; + echo \">> Creating Linux partition table on the eMMC\"; + echo \"\"; + echo \"\"; + run partition_mmc_linux; + if test \$? -eq 1; then + echo \"[ERROR] Failed to create Linux partition table!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Start installation Linux firmware files\"; + echo \"\"; + echo \"\"; + saveenv; + fastboot 1; +" + +uuu fb: ucmd saveenv +uuu fb: acmd reset + +# Wait for the target to reset +sleep 3 + +# Restart fastboot with the latest MMC partition configuration +uuu fb: ucmd setenv fastboot_dev sata +uuu fb: ucmd setenv fastboot_dev mmc + +# Set fastboot buffer address to $loadaddr, just in case +uuu fb: ucmd setenv fastboot_buffer \${loadaddr} + +# Restore dualboot if previously active +if [ "${DUALBOOT}" = true ]; then + uuu fb: ucmd setenv dualboot yes +fi + +if [ "${DUALBOOT}" = true ]; then + # Update Linux A + part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" + # Update Linux B + part_update "${LINUX_NAME}_b" "${INSTALL_LINUX_FILENAME}" + # Update Rootfs A + part_update "${ROOTFS_NAME}_a" "${INSTALL_ROOTFS_FILENAME}" + # Update Rootfs B + part_update "${ROOTFS_NAME}_b" "${INSTALL_ROOTFS_FILENAME}" +else + # Update Linux + part_update "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}" + # Update Recovery + part_update "${RECOVERY_NAME}" "${INSTALL_RECOVERY_FILENAME}" + # Update Rootfs + part_update "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}" +fi + +# If the rootfs image was originally compressed, remove the uncompressed image +if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then + rm -f "${INSTALL_ROOTFS_FILENAME}" +fi + +if [ "${DUALBOOT}" != true ]; then + # Configure u-boot to boot into recovery mode + uuu fb: ucmd setenv boot_recovery yes + uuu fb: ucmd setenv recovery_command wipe_update +fi +uuu fb: ucmd saveenv + +# Reset the target +uuu fb: acmd reset + +echo "\033[32m" +echo "=============================================================" +echo "Done! Wait for the target to complete first boot process." +echo "=============================================================" +echo "\033[0m" + +exit From 555be511a63a88b7e85b230b09cd420a76d6270b Mon Sep 17 00:00:00 2001 From: Gonzalo Ruiz Date: Wed, 29 Sep 2021 18:04:49 +0200 Subject: [PATCH 46/70] u-boot-dey: customize install_linux_fw_uuu script for ccimx6/ccimx6qp Also, set UBOOT_HAS_FASTBOOT = "true" for these platforms. Signed-off-by: Gonzalo Ruiz --- meta-digi-arm/conf/machine/include/ccimx6.inc | 1 + .../ccimx6qpsbc/install_linux_fw_uuu.sh | 59 +++++----------- .../ccimx6sbc/install_linux_fw_uuu.sh | 67 +++++++++---------- 3 files changed, 48 insertions(+), 79 deletions(-) diff --git a/meta-digi-arm/conf/machine/include/ccimx6.inc b/meta-digi-arm/conf/machine/include/ccimx6.inc index 65376765e..50090c284 100644 --- a/meta-digi-arm/conf/machine/include/ccimx6.inc +++ b/meta-digi-arm/conf/machine/include/ccimx6.inc @@ -11,6 +11,7 @@ include conf/machine/include/tune-cortexa9.inc # Platform u-boot settings UBOOT_PREFIX = "u-boot" UBOOT_SUFFIX = "imx" +UBOOT_HAS_FASTBOOT = "true" # Linux kernel configuration KERNEL_DEFCONFIG ?= "arch/arm/configs/ccimx6sbc_defconfig" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh index 8da80e9c5..99eed2520 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh @@ -1,7 +1,7 @@ #!/bin/sh #=============================================================================== # -# Copyright (C) 2020-2021 by Digi International Inc. +# Copyright (C) 2021 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -93,38 +93,16 @@ echo "Determining image files to use..." # Determine U-Boot file to program basing on SOM's SOC type (linked to bus width) if [ -z ${INSTALL_UBOOT_FILENAME} ]; then - # Since SOMs with the B0 SOC might have an older U-Boot that doesn't export the - # SOC revision to the environment, use B0 by default - soc_rev=$(getenv "soc_rev") - if [ -z "${soc_rev}" ]; then - soc_rev="B0" - fi - - bus_width="32bit" - soc_type=$(getenv "soc_type") - if [ "$soc_type" = "imx8dx" ]; then - bus_width="16bit" - fi - - module_ram=$(getenv "module_ram") - if [ -z "${module_ram}" ]; then - module_variant=$(getenv "module_variant") - # Determine U-Boot file to program basing on SOM's variant - if [ -n "$module_variant" ] || [ "$module_variant" = "0x00" ]; then - if [ "$module_variant" = "0x01" ] || \ - [ "$module_variant" = "0x04" ] || \ - [ "$module_variant" = "0x05" ]; then - module_ram="1GB" - elif [ "$module_variant" = "0x06" ] || \ - [ "$module_variant" = "0x09" ]; then - module_ram="512MB" - else - module_ram="2GB" - fi - INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" + module_variant=$(getenv "module_variant") + # Determine U-Boot file to program basing on SOM's variant + if [ -n "$module_variant" ] || [ "$module_variant" = "0x00" ]; then + if [ "$module_variant" = "0x01" ] || \ + [ "$module_variant" = "0x02" ]; then + module_ram="2GB" + else + module_ram="1GB" fi - else - INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" + INSTALL_UBOOT_FILENAME="u-boot-##MACHINE##${module_ram}.imx" fi # remove redirect @@ -137,15 +115,12 @@ if [ -z ${INSTALL_UBOOT_FILENAME} ]; then echo "" echo "[ERROR] Cannot determine U-Boot file for this module!" echo "" - echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" - echo " - For a QuadXPlus CPU with 1GB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin" - echo " - For a QuadXPlus CPU with 2GB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin" - echo " - For a DualX CPU with 1GB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin" - echo " - For a DualX CPU with 512MB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin" + echo "1. Set variable 'INSTALL_UBOOT_FILENAME' depending on your ConnectCore 6 QuadPlus variant:" + echo " - For a QuadPlus CPU with 2GB DDR3, run:" + echo " => setenv INSTALL_UBOOT_FILENAME u-boot-##MACHINE##2GB.imx" + echo " - For a DualPlus CPU with 1GB DDR3, run:" + echo " => setenv INSTALL_UBOOT_FILENAME u-boot-##MACHINE##1GB.imx" + echo "" echo "" echo "2. Run the install script again." echo "" @@ -271,7 +246,7 @@ uuu fb: ucmd setenv bootcmd " echo \"\"; echo \"\"; saveenv; - fastboot 1; + fastboot 0; " uuu fb: ucmd saveenv diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh index 8da80e9c5..aa7b88467 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh @@ -1,7 +1,7 @@ #!/bin/sh #=============================================================================== # -# Copyright (C) 2020-2021 by Digi International Inc. +# Copyright (C) 2021 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -93,38 +93,29 @@ echo "Determining image files to use..." # Determine U-Boot file to program basing on SOM's SOC type (linked to bus width) if [ -z ${INSTALL_UBOOT_FILENAME} ]; then - # Since SOMs with the B0 SOC might have an older U-Boot that doesn't export the - # SOC revision to the environment, use B0 by default - soc_rev=$(getenv "soc_rev") - if [ -z "${soc_rev}" ]; then - soc_rev="B0" - fi - - bus_width="32bit" - soc_type=$(getenv "soc_type") - if [ "$soc_type" = "imx8dx" ]; then - bus_width="16bit" - fi - - module_ram=$(getenv "module_ram") - if [ -z "${module_ram}" ]; then + soc_family=$(getenv "soc_family") + if [ -n "$soc_family" ]; then module_variant=$(getenv "module_variant") # Determine U-Boot file to program basing on SOM's variant if [ -n "$module_variant" ] || [ "$module_variant" = "0x00" ]; then - if [ "$module_variant" = "0x01" ] || \ - [ "$module_variant" = "0x04" ] || \ - [ "$module_variant" = "0x05" ]; then - module_ram="1GB" - elif [ "$module_variant" = "0x06" ] || \ - [ "$module_variant" = "0x09" ]; then - module_ram="512MB" + if [ "$module_variant" = "0x12" ]; then + INSTALL_UBOOT_FILENAME="u-boot-cc${soc_family}sbc2GB.imx" + elif [ "$module_variant" = "0x01" ] || \ + [ "$module_variant" = "0x02" ] || \ + [ "$module_variant" = "0x04" ] || \ + [ "$module_variant" = "0x05" ] || \ + [ "$module_variant" = "0x0b" ] || \ + [ "$module_variant" = "0x0d" ] || \ + [ "$module_variant" = "0x10" ] || \ + [ "$module_variant" = "0x11" ] || \ + [ "$module_variant" = "0x14" ] || \ + [ "$module_variant" = "0x15" ] || \ + [ "$module_variant" = "0x16" ]; then + INSTALL_UBOOT_FILENAME="u-boot-cc${soc_family}sbc.imx" else - module_ram="2GB" + INSTALL_UBOOT_FILENAME="u-boot-cc${soc_family}sbc512MB.imx" fi - INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" fi - else - INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" fi # remove redirect @@ -137,15 +128,17 @@ if [ -z ${INSTALL_UBOOT_FILENAME} ]; then echo "" echo "[ERROR] Cannot determine U-Boot file for this module!" echo "" - echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" - echo " - For a QuadXPlus CPU with 1GB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin" - echo " - For a QuadXPlus CPU with 2GB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin" - echo " - For a DualX CPU with 1GB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin" - echo " - For a DualX CPU with 512MB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin" + echo "1. Set variable 'INSTALL_UBOOT_FILENAME' depending on your ConnectCore 6 variant:" + echo " - For a Quad/Dual CPU with 2GB DDR3, run:" + echo " => setenv INSTALL_UBOOT_FILENAME u-boot-ccimx6qsbc2GB.imx" + echo " - For a Quad/Dual CPU with 1GB DDR3, run:" + echo " => setenv INSTALL_UBOOT_FILENAME u-boot-ccimx6qsbc.imx" + echo " - For a Quad/Dual CPU with 512MB DDR3, run:" + echo " => setenv INSTALL_UBOOT_FILENAME u-boot-ccimx6qsbc512MB.imx" + echo " - For a DualLite/Solo CPU with 1GB DDR3, run:" + echo " => setenv INSTALL_UBOOT_FILENAME u-boot-ccimx6dlsbc.imx" + echo " - For a DualLite/Solo CPU with 512MB DDR3, run:" + echo " => setenv INSTALL_UBOOT_FILENAME u-boot-ccimx6dlsbc512MB.imx" echo "" echo "2. Run the install script again." echo "" @@ -271,7 +264,7 @@ uuu fb: ucmd setenv bootcmd " echo \"\"; echo \"\"; saveenv; - fastboot 1; + fastboot 0; " uuu fb: ucmd saveenv From 825dd6a5553173b59d72912b1726db158e0a9453 Mon Sep 17 00:00:00 2001 From: Gonzalo Ruiz Date: Wed, 29 Sep 2021 18:09:47 +0200 Subject: [PATCH 47/70] install_linux_fw_uuu: remove redirection in every case Ensure stdout redirection to the USB interface is removed in every case. Otherwise, it would be left redirected when INSTALL_UBOOT_FILENAME is manually set. Signed-off-by: Gonzalo Ruiz --- .../u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh | 9 ++++++--- .../u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh | 9 ++++++--- .../u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh | 9 ++++++--- .../u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh | 9 ++++++--- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh index 99eed2520..0f1b6a86f 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh @@ -105,13 +105,13 @@ if [ -z ${INSTALL_UBOOT_FILENAME} ]; then INSTALL_UBOOT_FILENAME="u-boot-##MACHINE##${module_ram}.imx" fi - # remove redirect - uuu fb: ucmd setenv stdout serial - # U-Boot when the checked value is empty. if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then true else + # remove redirect + uuu fb: ucmd setenv stdout serial + echo "" echo "[ERROR] Cannot determine U-Boot file for this module!" echo "" @@ -130,6 +130,9 @@ if [ -z ${INSTALL_UBOOT_FILENAME} ]; then fi fi +# remove redirect +uuu fb: ucmd setenv stdout serial + # Determine linux, recovery, and rootfs image filenames to update if [ -z "${IMAGE_NAME}" ]; then IMAGE_NAME="##DEFAULT_IMAGE_NAME##" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh index aa7b88467..ebc509a67 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh @@ -118,13 +118,13 @@ if [ -z ${INSTALL_UBOOT_FILENAME} ]; then fi fi - # remove redirect - uuu fb: ucmd setenv stdout serial - # U-Boot when the checked value is empty. if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then true else + # remove redirect + uuu fb: ucmd setenv stdout serial + echo "" echo "[ERROR] Cannot determine U-Boot file for this module!" echo "" @@ -148,6 +148,9 @@ if [ -z ${INSTALL_UBOOT_FILENAME} ]; then fi fi +# remove redirect +uuu fb: ucmd setenv stdout serial + # Determine linux, recovery, and rootfs image filenames to update if [ -z "${IMAGE_NAME}" ]; then IMAGE_NAME="##DEFAULT_IMAGE_NAME##" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh index ca8305836..8e664d657 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh @@ -123,13 +123,13 @@ if [ -z "${INSTALL_UBOOT_FILENAME}" ]; then fi fi - # remove redirect - uuu fb: ucmd setenv stdout serial - # U-Boot when the checked value is empty. if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then true else + # remove redirect + uuu fb: ucmd setenv stdout serial + echo "" echo "[ERROR] Cannot determine U-Boot file for this module!" echo "" @@ -149,6 +149,9 @@ if [ -z "${INSTALL_UBOOT_FILENAME}" ]; then fi fi +# remove redirect +uuu fb: ucmd setenv stdout serial + # Determine linux, recovery, and rootfs image filenames to update if [ -z "${IMAGE_NAME}" ]; then IMAGE_NAME="##DEFAULT_IMAGE_NAME##" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh index 8da80e9c5..bae55fc32 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh @@ -127,13 +127,13 @@ if [ -z ${INSTALL_UBOOT_FILENAME} ]; then INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" fi - # remove redirect - uuu fb: ucmd setenv stdout serial - # U-Boot when the checked value is empty. if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then true else + # remove redirect + uuu fb: ucmd setenv stdout serial + echo "" echo "[ERROR] Cannot determine U-Boot file for this module!" echo "" @@ -155,6 +155,9 @@ if [ -z ${INSTALL_UBOOT_FILENAME} ]; then fi fi +# remove redirect +uuu fb: ucmd setenv stdout serial + # Determine linux, recovery, and rootfs image filenames to update if [ -z "${IMAGE_NAME}" ]; then IMAGE_NAME="##DEFAULT_IMAGE_NAME##" From e67ed06dd5f40fd311086fe7deca41f57c8a44c8 Mon Sep 17 00:00:00 2001 From: Francisco Gil Date: Fri, 8 Oct 2021 12:51:45 +0200 Subject: [PATCH 48/70] dualboot: move the logic of fallback boot to altbootcmd U-Boot has embedded support to handle bootcount tries. When the limit of tries is reached, U-Boot runs the script in `altbootcmd` rather than the usual `bootcmd`. This other script resides on meta-digi-dualboot layer. Signed-off-by: Hector Palacios Signed-off-by: Francisco Gil --- .../u-boot/u-boot-dey/ccimx6qpsbc/boot.txt | 24 ------------------- .../u-boot/u-boot-dey/ccimx6sbc/boot.txt | 24 ------------------- .../u-boot/u-boot-dey/ccimx6ulsbc/boot.txt | 17 ------------- .../u-boot-dey/ccimx6ulstarter/boot.txt | 17 ------------- .../u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt | 24 ------------------- .../u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt | 24 ------------------- .../u-boot-dey/ccimx8x-sbc-express/boot.txt | 24 ------------------- .../u-boot-dey/ccimx8x-sbc-pro/boot.txt | 24 ------------------- 8 files changed, 178 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt index fe794d0c6..f7f6cf7a8 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt @@ -11,30 +11,6 @@ if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then echo "Update detected; Booting new system (try ${bootcount})" - if test "${bootcount}" = "${bootlimit}"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - setenv active_system linux_b - else - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - setenv active_system linux_a - fi - setenv upgrade_available - saveenv - fi else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt index a88f10150..4970fc7f0 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt @@ -11,30 +11,6 @@ if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then echo "Update detected; Booting new system (try ${bootcount})" - if test "${bootcount}" = "${bootlimit}"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - setenv active_system linux_b - else - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - setenv active_system linux_a - fi - setenv upgrade_available - saveenv - fi else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt index 9b45affa5..aebfd6480 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt @@ -11,23 +11,6 @@ if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then echo "Update detected; Booting new system (try ${bootcount})" - if test "${bootcount}" = "${bootlimit}"; then - echo "## Update failed; Rolling back to previous version." - if test "${mtdbootpart}" = "linux_a"; then - setenv mtdbootpart linux_b - setenv mtdlinuxindex ${mtdlinux_b_index} - setenv mtdrootfsindex ${mtdrootfs_b_index} - setenv rootfsvol ${rootfsvol_b} - else - setenv mtdbootpart linux_a - setenv mtdlinuxindex ${mtdlinux_a_index} - setenv mtdrootfsindex ${mtdrootfs_a_index} - setenv rootfsvol ${rootfsvol_a} - fi - setenv active_system ${mtdbootpart} - setenv upgrade_available - saveenv - fi else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt index 3fe58e274..0d779540d 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt @@ -11,23 +11,6 @@ if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then echo "Update detected; Booting new system (try ${bootcount})" - if test "${bootcount}" = "${bootlimit}"; then - echo "## Update failed; Rolling back to previous version." - if test "${mtdbootpart}" = "linux_a"; then - setenv mtdbootpart linux_b - setenv mtdlinuxindex ${mtdlinux_b_index} - setenv mtdrootfsindex ${mtdrootfs_b_index} - setenv rootfsvol ${rootfsvol_b} - else - setenv mtdbootpart linux_a - setenv mtdlinuxindex ${mtdlinux_a_index} - setenv mtdrootfsindex ${mtdrootfs_a_index} - setenv rootfsvol ${rootfsvol_a} - fi - setenv active_system ${mtdbootpart} - setenv upgrade_available - saveenv - fi else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt index 121b71e07..bf886ba02 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt @@ -11,30 +11,6 @@ if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then echo "Update detected; Booting new system (try ${bootcount})" - if test "${bootcount}" = "${bootlimit}"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - setenv active_system linux_b - else - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - setenv active_system linux_a - fi - setenv upgrade_available - saveenv - fi else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt index f39b8cfc5..806ec894d 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt @@ -11,30 +11,6 @@ if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then echo "Update detected; Booting new system (try ${bootcount})" - if test "${bootcount}" = "${bootlimit}"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - setenv active_system linux_b - else - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - setenv active_system linux_a - fi - setenv upgrade_available - saveenv - fi else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt index 836310230..945da1eee 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt @@ -11,30 +11,6 @@ if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then echo "Update detected; Booting new system (try ${bootcount})" - if test "${bootcount}" = "${bootlimit}"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - setenv active_system linux_b - else - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - setenv active_system linux_a - fi - setenv upgrade_available - saveenv - fi else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt index 0a6968ea1..bffc67dad 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt @@ -11,30 +11,6 @@ if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then echo "Update detected; Booting new system (try ${bootcount})" - if test "${bootcount}" = "${bootlimit}"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - setenv active_system linux_b - else - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - setenv active_system linux_a - fi - setenv upgrade_available - saveenv - fi else if test "${active_system}" = "linux_a"; then echo "Booting from system A" From f7a1a484a62430c2b912820c9805b95f3391a11f Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 8 Oct 2021 14:15:13 +0200 Subject: [PATCH 49/70] conf: move BOOT_SCRIPTS variable to common include file Signed-off-by: Hector Palacios --- meta-digi-arm/conf/machine/ccimx6qpsbc.conf | 3 --- meta-digi-arm/conf/machine/ccimx6sbc.conf | 3 --- meta-digi-arm/conf/machine/ccimx6ulsbc.conf | 3 --- meta-digi-arm/conf/machine/ccimx6ulstarter.conf | 3 --- meta-digi-arm/conf/machine/ccimx8mm-dvk.conf | 3 --- meta-digi-arm/conf/machine/ccimx8mn-dvk.conf | 3 --- meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf | 3 --- meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf | 2 -- meta-digi-arm/conf/machine/include/digi-defaults.inc | 3 +++ 9 files changed, 3 insertions(+), 23 deletions(-) diff --git a/meta-digi-arm/conf/machine/ccimx6qpsbc.conf b/meta-digi-arm/conf/machine/ccimx6qpsbc.conf index b2fb3f108..c9afd118b 100644 --- a/meta-digi-arm/conf/machine/ccimx6qpsbc.conf +++ b/meta-digi-arm/conf/machine/ccimx6qpsbc.conf @@ -43,8 +43,5 @@ BT_TTY ?= "ttymxc1" # XBee XBEE_TTY ?= "ttymxc4" -# U-Boot script to be copied to the boot image -BOOT_SCRIPTS = "boot.scr:boot.scr" - # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" diff --git a/meta-digi-arm/conf/machine/ccimx6sbc.conf b/meta-digi-arm/conf/machine/ccimx6sbc.conf index 0bc0af470..9d76e4c37 100644 --- a/meta-digi-arm/conf/machine/ccimx6sbc.conf +++ b/meta-digi-arm/conf/machine/ccimx6sbc.conf @@ -43,8 +43,5 @@ BT_TTY ?= "ttymxc1" # XBee XBEE_TTY ?= "ttymxc4" -# U-Boot script to be copied to the boot image -BOOT_SCRIPTS = "boot.scr:boot.scr" - # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" diff --git a/meta-digi-arm/conf/machine/ccimx6ulsbc.conf b/meta-digi-arm/conf/machine/ccimx6ulsbc.conf index f11849f3c..4a926d3b0 100644 --- a/meta-digi-arm/conf/machine/ccimx6ulsbc.conf +++ b/meta-digi-arm/conf/machine/ccimx6ulsbc.conf @@ -39,8 +39,5 @@ BT_TTY ?= "ttymxc0" # XBee XBEE_TTY ?= "ttymxc1" -# U-Boot script to be copied to the boot image -BOOT_SCRIPTS = "boot.scr:boot.scr" - # Flash image types IMAGE_FSTYPES ?= "tar.bz2 ubifs boot.ubifs recovery.ubifs" diff --git a/meta-digi-arm/conf/machine/ccimx6ulstarter.conf b/meta-digi-arm/conf/machine/ccimx6ulstarter.conf index 3bb83e1cb..a4489d533 100644 --- a/meta-digi-arm/conf/machine/ccimx6ulstarter.conf +++ b/meta-digi-arm/conf/machine/ccimx6ulstarter.conf @@ -35,9 +35,6 @@ SERIAL_CONSOLES ?= "115200;ttymxc4" # Bluetooth tty BT_TTY ?= "ttymxc0" -# U-Boot script to be copied to the boot image -BOOT_SCRIPTS = "boot.scr:boot.scr" - # Flash image types IMAGE_FSTYPES ?= "tar.bz2 ubifs boot.ubifs recovery.ubifs" diff --git a/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf b/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf index 2628634d3..075d5e8c8 100644 --- a/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf +++ b/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf @@ -41,8 +41,5 @@ XBEE_RESET_N_GPIO ?= "mca-gpio@15,gpio1@8" XBEE_SLEEP_RQ_GPIO ?= "mca-gpio@11,gpio1@7" XBEE_TTY ?= "ttymxc3" -# U-Boot script to be copied to the boot image -BOOT_SCRIPTS = "boot.scr:boot.scr" - # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" diff --git a/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf b/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf index 1eb371574..7aaf86105 100644 --- a/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf +++ b/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf @@ -43,8 +43,5 @@ XBEE_RESET_N_GPIO ?= "mca-gpio@15,gpio1@8" XBEE_SLEEP_RQ_GPIO ?= "mca-gpio@11,gpio1@7" XBEE_TTY ?= "ttymxc3" -# U-Boot script to be copied to the boot image -BOOT_SCRIPTS = "boot.scr:boot.scr" - # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf index 209297c1f..9ce413d90 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf @@ -29,8 +29,5 @@ XBEE_RESET_N_GPIO ?= "gpio3@13" XBEE_SLEEP_RQ_GPIO ?= "gpio3@16" XBEE_TTY ?= "ttyLP0" -# U-Boot script to be copied to the boot image -BOOT_SCRIPTS = "boot.scr:boot.scr" - # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf index 7206a9a95..faa916d60 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf @@ -42,8 +42,6 @@ XBEE_RESET_N_GPIO ?= "mca-gpio@15" XBEE_SLEEP_RQ_GPIO ?= "mca-gpio@11" XBEE_TTY ?= "ttyMCA0" -# U-Boot script to be copied to the boot image -BOOT_SCRIPTS = "boot.scr:boot.scr" UBOOT_HAS_FASTBOOT = "true" # Flash image types diff --git a/meta-digi-arm/conf/machine/include/digi-defaults.inc b/meta-digi-arm/conf/machine/include/digi-defaults.inc index 8daf9a1f6..b2a6f9271 100644 --- a/meta-digi-arm/conf/machine/include/digi-defaults.inc +++ b/meta-digi-arm/conf/machine/include/digi-defaults.inc @@ -82,3 +82,6 @@ GRAPHICAL_IMAGES ?= "dey-image-qt dey-image-webkit" # Include DEY SELinux policy modifications by default DEY_SELINUX_POLICY ?= "1" + +# U-Boot scripts to include in 'linux' partition +BOOT_SCRIPTS = "boot.scr:boot.scr" From 13a46ed32359de3c1de6f6ba769c98cc986ee727 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 8 Oct 2021 14:20:22 +0200 Subject: [PATCH 50/70] conf: move UBOOT_HAS_FASTBOOT to ccimx8x common include The SBC Express also supports fastboot now. Signed-off-by: Hector Palacios --- meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf | 1 - meta-digi-arm/conf/machine/include/ccimx8x.inc | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf index faa916d60..490100f20 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf @@ -42,7 +42,6 @@ XBEE_RESET_N_GPIO ?= "mca-gpio@15" XBEE_SLEEP_RQ_GPIO ?= "mca-gpio@11" XBEE_TTY ?= "ttyMCA0" -UBOOT_HAS_FASTBOOT = "true" # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" diff --git a/meta-digi-arm/conf/machine/include/ccimx8x.inc b/meta-digi-arm/conf/machine/include/ccimx8x.inc index 7b42b6df2..8b2903ceb 100644 --- a/meta-digi-arm/conf/machine/include/ccimx8x.inc +++ b/meta-digi-arm/conf/machine/include/ccimx8x.inc @@ -11,6 +11,7 @@ include conf/machine/include/arm/arch-arm64.inc # Platform u-boot settings UBOOT_PREFIX = "imx-boot" UBOOT_SUFFIX = "bin" +UBOOT_HAS_FASTBOOT = "true" # The bootloader image that gets flashed consists of U-Boot and several fw binaries EXTRA_IMAGEDEPENDS = "imx-boot" From 3ab034074131e4a0f1e57cbbb0198df7008a799d Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Mon, 11 Oct 2021 11:36:00 +0200 Subject: [PATCH 51/70] u-boot: print what system is booting after update Signed-off-by: Hector Palacios --- .../recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt | 2 +- meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt | 2 +- .../recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt | 2 +- .../recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt | 2 +- .../recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt | 2 +- .../recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt | 2 +- .../recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt | 2 +- .../recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt index f7f6cf7a8..063af73d2 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt @@ -10,7 +10,7 @@ # Dual boot update verification if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system (try ${bootcount})" + echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt index 4970fc7f0..5a9fde245 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt @@ -10,7 +10,7 @@ # Dual boot update verification if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system (try ${bootcount})" + echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt index aebfd6480..315f0da9b 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt @@ -10,7 +10,7 @@ # Dual boot update verification if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system (try ${bootcount})" + echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt index 0d779540d..703d7ecb8 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt @@ -10,7 +10,7 @@ # Dual boot update verification if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system (try ${bootcount})" + echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt index bf886ba02..980500b91 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt @@ -10,7 +10,7 @@ # Dual boot update verification if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system (try ${bootcount})" + echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt index 806ec894d..73cfc63e8 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt @@ -10,7 +10,7 @@ # Dual boot update verification if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system (try ${bootcount})" + echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt index 945da1eee..33992d7c9 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt @@ -10,7 +10,7 @@ # Dual boot update verification if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system (try ${bootcount})" + echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" else if test "${active_system}" = "linux_a"; then echo "Booting from system A" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt index bffc67dad..840d7a098 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt @@ -10,7 +10,7 @@ # Dual boot update verification if test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system (try ${bootcount})" + echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" else if test "${active_system}" = "linux_a"; then echo "Booting from system A" From 9ac3bd46caed2062ee807dd46f95a41b7266c0de Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 14 Oct 2021 13:35:46 +0200 Subject: [PATCH 52/70] uboot: install-uuu: restore variables on bootcmd after 'env default -a' The variable 'dualboot' (and 'singlemtdsys' for CC6UL) was restored after the bootcmd that runs the first time after programming U-Boot runs fastboot again to resume the script. This is ok for the CC6UL but not for the rest of platforms, that run the partition script on the bootcmd, *before* running fastboot. Restore the variables for all platforms in the bootcmd right after resetting the environment. Signed-off-by: Hector Palacios --- .../u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh | 6 +----- .../u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh | 6 +----- .../u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh | 12 ++---------- .../u-boot-dey/ccimx8m/install_linux_fw_uuu.sh | 6 +----- .../u-boot-dey/ccimx8x/install_linux_fw_uuu.sh | 6 +----- 5 files changed, 6 insertions(+), 30 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh index 0f1b6a86f..f743bfbf1 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_uuu.sh @@ -230,6 +230,7 @@ uuu fb: ucmd mmc partconf 0 1 1 1 # - Update the 'rootfs' partition uuu fb: ucmd setenv bootcmd " env default -a; + setenv dualboot \${dualboot}; saveenv; echo \"\"; echo \"\"; @@ -265,11 +266,6 @@ uuu fb: ucmd setenv fastboot_dev mmc # Set fastboot buffer address to $loadaddr, just in case uuu fb: ucmd setenv fastboot_buffer \${loadaddr} -# Restore dualboot if previously active -if [ "${DUALBOOT}" = true ]; then - uuu fb: ucmd setenv dualboot yes -fi - if [ "${DUALBOOT}" = true ]; then # Update Linux A part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh index ebc509a67..0ca7a02ef 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_uuu.sh @@ -248,6 +248,7 @@ uuu fb: ucmd mmc partconf 0 1 1 1 # - Update the 'rootfs' partition uuu fb: ucmd setenv bootcmd " env default -a; + setenv dualboot \${dualboot}; saveenv; echo \"\"; echo \"\"; @@ -283,11 +284,6 @@ uuu fb: ucmd setenv fastboot_dev mmc # Set fastboot buffer address to $loadaddr, just in case uuu fb: ucmd setenv fastboot_buffer \${loadaddr} -# Restore dualboot if previously active -if [ "${DUALBOOT}" = true ]; then - uuu fb: ucmd setenv dualboot yes -fi - if [ "${DUALBOOT}" = true ]; then # Update Linux A part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh index 8e664d657..fad0cd070 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh @@ -237,6 +237,8 @@ part_update "uboot" "${INSTALL_UBOOT_FILENAME}" 5000 # - Erase the 'update' partition uuu fb: ucmd setenv bootcmd " env default -a; + setenv dualboot \${dualboot}; + setenv singlemtdsys \${singlemtdsys}; saveenv; echo \"\"; echo \"\"; @@ -255,16 +257,6 @@ sleep 3 # Set fastboot buffer address to $loadaddr uuu fb: ucmd setenv fastboot_buffer \${loadaddr} -# Restore dualboot if previously active -if [ "${DUALBOOT}" = true ]; then - uuu fb: ucmd setenv dualboot yes -fi - -# Restore singlemtdsys if previously active -if [ "${SINGLEMTDSYS}" = true ]; then - uuu fb: ucmd setenv singlemtdsys yes -fi - # Create partition table uuu "fb[-t 10000]:" ucmd run partition_nand_linux diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh index a723997f7..d580e5c02 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh @@ -199,6 +199,7 @@ uuu fb: ucmd mmc partconf 0 1 1 1 # - Update the 'rootfs' partition uuu fb: ucmd setenv bootcmd " env default -a; + setenv dualboot \${dualboot}; saveenv; echo \"\"; echo \"\"; @@ -234,11 +235,6 @@ uuu fb: ucmd setenv fastboot_dev mmc # Set fastboot buffer address to $loadaddr, just in case uuu fb: ucmd setenv fastboot_buffer \${loadaddr} -# Restore dualboot if previously active -if [ "${DUALBOOT}" = true ]; then - uuu fb: ucmd setenv dualboot yes -fi - if [ "${DUALBOOT}" = true ]; then # Update Linux A part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh index bae55fc32..3f019fa4e 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh @@ -255,6 +255,7 @@ uuu fb: ucmd mmc partconf 0 1 1 1 # - Update the 'rootfs' partition uuu fb: ucmd setenv bootcmd " env default -a; + setenv dualboot \${dualboot}; saveenv; echo \"\"; echo \"\"; @@ -290,11 +291,6 @@ uuu fb: ucmd setenv fastboot_dev mmc # Set fastboot buffer address to $loadaddr, just in case uuu fb: ucmd setenv fastboot_buffer \${loadaddr} -# Restore dualboot if previously active -if [ "${DUALBOOT}" = true ]; then - uuu fb: ucmd setenv dualboot yes -fi - if [ "${DUALBOOT}" = true ]; then # Update Linux A part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" From 2e35d16e0322cd64bb0409515589dd44fe1d7b8d Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 15 Oct 2021 13:57:07 +0200 Subject: [PATCH 53/70] linux-dey: fix apply of kernel configuration fragments - Add the '-m' parameter. Without it, the script doesn't generate the output merged configuration file, and the fragments are not applied. - Fix the if condition. The '*.cfg' expands to a list of files, but the '-f' only admits one parameter. Use instead the Python find_cfgs() function. Signed-off-by: Hector Palacios --- meta-digi-arm/recipes-kernel/linux/linux-dey_5.4.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey_5.4.bb b/meta-digi-arm/recipes-kernel/linux/linux-dey_5.4.bb index d3d620517..d194a6314 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey_5.4.bb +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey_5.4.bb @@ -93,8 +93,8 @@ do_configure_append() { # Only accept fragments ending in .cfg. If the fragments contain # something other than kernel configs, it will be filtered out # automatically. - if [ -f ${WORKDIR}/*.cfg ]; then - ${S}/scripts/kconfig/merge_config.sh -O ${B} ${B}/.config ${WORKDIR}/*.cfg + if [ -n "${@' '.join(find_cfgs(d))}" ]; then + ${S}/scripts/kconfig/merge_config.sh -m -O ${B} ${B}/.config ${@" ".join(find_cfgs(d))} fi } From 899f89eb33043d76fda4c226cba1b903f87ad486 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 19 Oct 2021 12:23:28 +0200 Subject: [PATCH 54/70] digi-defaults: use '+=' operator in assignment of BOOT_SCRIPTS Other layers, such as meta-digi-dualboot, may add scripts to this list on their layer.conf file. Depending on the order and priority of layers, using a strict '=' here completely overrides previous values, which is not desired. Reported-by: Francisco Gil Signed-off-by: Hector Palacios --- meta-digi-arm/conf/machine/include/digi-defaults.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta-digi-arm/conf/machine/include/digi-defaults.inc b/meta-digi-arm/conf/machine/include/digi-defaults.inc index b2a6f9271..f6921088d 100644 --- a/meta-digi-arm/conf/machine/include/digi-defaults.inc +++ b/meta-digi-arm/conf/machine/include/digi-defaults.inc @@ -84,4 +84,5 @@ GRAPHICAL_IMAGES ?= "dey-image-qt dey-image-webkit" DEY_SELINUX_POLICY ?= "1" # U-Boot scripts to include in 'linux' partition -BOOT_SCRIPTS = "boot.scr:boot.scr" +# (use the '+=' operator, since other layers may append scripts to this list) +BOOT_SCRIPTS += "boot.scr:boot.scr" From 4a54512d64d791ef2a7b2fbb54a97a36331b34ce Mon Sep 17 00:00:00 2001 From: Arturo Buzarra Date: Fri, 29 Oct 2021 09:35:53 +0200 Subject: [PATCH 55/70] recovery-initramfs-init: fix psplash communication FIFO path The latest version of psplash changed the default path to store the communication FIFO with other processes to "/run" to allow keeping the information between reboots, however we are using this tool from an initramfs where "/run" does not exist, producing multiple errors trying to write to a nonexistent path, delaying the update process. This commit forces psplash to use an existing path like "/tmp" to handle the communication FIFO, because we don't need to maintain the update information. https://onedigi.atlassian.net/browse/CC8X-318 Signed-off-by: Arturo Buzarra --- .../recovery/recovery-initramfs/recovery-initramfs-init | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init index 8bf44c037..7bd485637 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init @@ -520,6 +520,9 @@ mkdir -p /var/lock # Set kernel console loglevel. sysctl -q -w kernel.printk=4 +# Set path for psplash communication FIFO +export PSPLASH_FIFO_DIR="/tmp" + # Start psplash. psplash & From 7ea02c26aa17d6e49a6553a645a323b551e96f3d Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Thu, 16 Sep 2021 09:44:12 +0200 Subject: [PATCH 56/70] qualcomm: adapt firmware and module recipes to be compatible with the ccimx6sbc This allows the packages to be included in the ccimx6sbc images. While at it, include the Qualcomm bluez patches in ccimx6 builds. These patches aren't destructive, they simply add functionality required by the Qualcomm chip, so they shouldn't have any secondary effects when using the Atheros chip. https://onedigi.atlassian.net/browse/DEL-7661 https://onedigi.atlassian.net/browse/DEL-7666 Signed-off-by: Gabriel Valcazar --- .../firmware-qualcomm/firmware-qualcomm.bb | 6 +++--- .../{ccimx6qpsbc => ccimx6}/bdwlan30_US.bin | Bin .../kernel-module-qualcomm.bb | 4 ++-- .../recipes-connectivity/bluez/bluez5_5.41.bbappend | 4 ++-- .../recipes-connectivity/bluez/bluez5_5.55.bbappend | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) rename meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/{ccimx6qpsbc => ccimx6}/bdwlan30_US.bin (100%) diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm.bb b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm.bb index 9bd3028a9..917147706 100644 --- a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm.bb +++ b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2020 Digi International. +# Copyright (C) 2016-2021 Digi International. SUMMARY = "Qualcomm firmware files for Digi's platforms." SECTION = "base" @@ -11,7 +11,7 @@ QUALCOMM_WIFI_DRIVER ?= "proprietary" # Selects whether to apply the "Deep Sleep + Internal Clock" workaround BT_INTCLOCK_WORKAROUND ?= "0" BT_INTCLOCK_WORKAROUND_ccimx6ul = "1" -BT_INTCLOCK_WORKAROUND_ccimx6qpsbc = "1" +BT_INTCLOCK_WORKAROUND_ccimx6 = "1" # Bluetooth 5.0 firmware files FW_QUALCOMM_BT_5 = " \ @@ -115,4 +115,4 @@ FILES_${PN}-${QCA_MODEL}-bt = "/lib/firmware/qca" FILES_${PN}-${QCA_MODEL}-wifi = "/lib/firmware" PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x|ccimx8m)" +COMPATIBLE_MACHINE = "(ccimx6$|ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx6qpsbc/bdwlan30_US.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx6/bdwlan30_US.bin similarity index 100% rename from meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx6qpsbc/bdwlan30_US.bin rename to meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx6/bdwlan30_US.bin diff --git a/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb b/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb index d3543ea9c..7240a332d 100644 --- a/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb +++ b/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2020 Digi International. +# Copyright (C) 2016-2021 Digi International. SUMMARY = "Qualcomm's wireless driver for qca65xx" DESCRIPTION = "qcacld-2.0 module" @@ -82,4 +82,4 @@ FILES_${PN} += " \ ${base_libdir}/firmware/wlan/qcom_cfg.ini \ " -COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x|ccimx8m)" +COMPATIBLE_MACHINE = "(ccimx6$|ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend index d188cd039..114a8f963 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2019 Digi International. +# Copyright (C) 2015-2021 Digi International. SRC_URI += " \ file://bluetooth-init \ @@ -27,7 +27,7 @@ QCA65XX_COMMON_PATCHES = " \ " SRC_URI_append_ccimx6ul = " ${QCA65XX_COMMON_PATCHES}" -SRC_URI_append_ccimx6qpsbc = " ${QCA65XX_COMMON_PATCHES}" +SRC_URI_append_ccimx6 = " ${QCA65XX_COMMON_PATCHES}" inherit update-rc.d diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.55.bbappend b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.55.bbappend index 64f5d498f..f94752b63 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.55.bbappend +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.55.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2020 Digi International. +# Copyright (C) 2015-2021 Digi International. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:${THISDIR}/${BP}:" @@ -20,7 +20,7 @@ QCA65XX_COMMON_PATCHES = " \ " SRC_URI_append_ccimx6ul = " ${QCA65XX_COMMON_PATCHES}" -SRC_URI_append_ccimx6qpsbc = " ${QCA65XX_COMMON_PATCHES}" +SRC_URI_append_ccimx6 = " ${QCA65XX_COMMON_PATCHES}" SRC_URI_append_ccimx8x = " ${QCA65XX_COMMON_PATCHES}" SRC_URI_append_ccimx8m = " ${QCA65XX_COMMON_PATCHES}" From dcd97799c99a548444e2994eee9efee91ccb4e9b Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Thu, 16 Sep 2021 11:14:25 +0200 Subject: [PATCH 57/70] ccimx6sbc: install Qualcomm-related packages along with the Atheros ones The idea is to have the support for both chips co-exist in the same image, then have the system detect which chip is being used during runtime. https://onedigi.atlassian.net/browse/DEL-7661 https://onedigi.atlassian.net/browse/DEL-7666 Signed-off-by: Gabriel Valcazar --- meta-digi-arm/conf/machine/ccimx6sbc.conf | 8 +++++--- .../packagegroups/packagegroup-dey-wireless.bb | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/meta-digi-arm/conf/machine/ccimx6sbc.conf b/meta-digi-arm/conf/machine/ccimx6sbc.conf index 9d76e4c37..c10b3fd6a 100644 --- a/meta-digi-arm/conf/machine/ccimx6sbc.conf +++ b/meta-digi-arm/conf/machine/ccimx6sbc.conf @@ -5,11 +5,13 @@ # Contains the ConnectCore 6 module. include conf/machine/include/ccimx6.inc -HAS_WIFI_VIRTWLANS = "false" +# Wireless external module +WIRELESS_MODULE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'kernel-module-qualcomm', '', d)}" +HAS_WIFI_VIRTWLANS = "true" # Firmware -MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_BT', '1' , 'firmware-atheros-ar3k', '', d)}" -MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1' , 'firmware-atheros-ath6kl', '', d)}" +MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_BT', '1' , 'firmware-atheros-ar3k firmware-qualcomm-qca6564-bt', '', d)}" +MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1' , 'firmware-atheros-ath6kl firmware-qualcomm-qca6564-wifi', '', d)}" PREFERRED_PROVIDER_virtual/libg2d_mx6 = "imx-gpu-g2d" diff --git a/meta-digi-dey/recipes-connectivity/packagegroups/packagegroup-dey-wireless.bb b/meta-digi-dey/recipes-connectivity/packagegroups/packagegroup-dey-wireless.bb index 98c66489d..5b53bf943 100644 --- a/meta-digi-dey/recipes-connectivity/packagegroups/packagegroup-dey-wireless.bb +++ b/meta-digi-dey/recipes-connectivity/packagegroups/packagegroup-dey-wireless.bb @@ -16,4 +16,3 @@ RDEPENDS_${PN} = "\ " RDEPENDS_${PN}_append_ccimx6sbc = " ath-prop-tools" -RDEPENDS_${PN}_remove_ccimx6sbc = "hostapd" From f3210db348ae23155e00131603a8b3bcbd54396e Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Mon, 20 Sep 2021 13:11:28 +0200 Subject: [PATCH 58/70] ccimx6sbc: adapt recipes to support Atheros and Qualcomm wireless chips Some packages require different scripts, configuration files or installations depending on the wireless chip assembled on the target. In general, the way to support both chips in one image is to have the recipes install both versions of the aforementioned files, then leave only the strictly necessary version once the wireless chip can be deduced. In the case of the init-ifupdown recipe, this involves installing temporary configuration fragments that are later erased. In the case of the standby script, the logic can be implemented in a single file. https://onedigi.atlassian.net/browse/DEL-7661 https://onedigi.atlassian.net/browse/DEL-7666 Signed-off-by: Gabriel Valcazar --- .../{ccimx6qpsbc => ccimx6}/bluetooth-init | 0 ...{bluetooth-init => bluetooth-init_atheros} | 0 .../{main.conf => main.conf_atheros} | 0 .../bluez/bluez5_5.41.bbappend | 33 ++++++++- .../bluez/bluez5_5.55.bbappend | 33 ++++++++- ...p.conf => wpa_supplicant_p2p.conf_atheros} | 0 .../wpa-supplicant/wpa-supplicant_%.bbappend | 27 ++++++- .../busybox/busybox/ccimx6sbc/standby | 7 +- .../busybox/busybox/ccimx6sbc/standby-actions | 8 ++- ...example => interfaces.br0.atheros.example} | 0 .../init-ifupdown/init-ifupdown_1.0.bbappend | 70 +++++++++++++++---- 11 files changed, 151 insertions(+), 27 deletions(-) rename meta-digi-dey/recipes-connectivity/bluez/bluez5/{ccimx6qpsbc => ccimx6}/bluetooth-init (100%) rename meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6sbc/{bluetooth-init => bluetooth-init_atheros} (100%) rename meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6sbc/{main.conf => main.conf_atheros} (100%) rename meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6sbc/{wpa_supplicant_p2p.conf => wpa_supplicant_p2p.conf_atheros} (100%) rename meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/{interfaces.br0.example => interfaces.br0.atheros.example} (100%) diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6qpsbc/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6/bluetooth-init similarity index 100% rename from meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6qpsbc/bluetooth-init rename to meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6/bluetooth-init diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6sbc/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6sbc/bluetooth-init_atheros similarity index 100% rename from meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6sbc/bluetooth-init rename to meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6sbc/bluetooth-init_atheros diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6sbc/main.conf b/meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6sbc/main.conf_atheros similarity index 100% rename from meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6sbc/main.conf rename to meta-digi-dey/recipes-connectivity/bluez/bluez5/ccimx6sbc/main.conf_atheros diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend index 114a8f963..4cdee0959 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend @@ -29,6 +29,11 @@ QCA65XX_COMMON_PATCHES = " \ SRC_URI_append_ccimx6ul = " ${QCA65XX_COMMON_PATCHES}" SRC_URI_append_ccimx6 = " ${QCA65XX_COMMON_PATCHES}" +SRC_URI_append_ccimx6sbc = " \ + file://bluetooth-init_atheros \ + file://main.conf_atheros \ +" + inherit update-rc.d PACKAGECONFIG_append = " experimental" @@ -47,10 +52,34 @@ do_install_append() { fi } +do_install_append_ccimx6sbc() { + install -m 0755 ${WORKDIR}/bluetooth-init_atheros ${D}${sysconfdir}/bluetooth-init_atheros + install -m 0644 ${WORKDIR}/main.conf_atheros ${D}${sysconfdir}/bluetooth/ + sed -i -e "s,##BT_DEVICE_NAME##,${BT_DEVICE_NAME},g" \ + ${D}${sysconfdir}/bluetooth/main.conf_atheros +} + +pkg_postinst_ontarget_${PN}_ccimx6sbc() { + # Only execute the script on wireless ccimx6 platforms + if [ -e "/proc/device-tree/bluetooth/mac-address" ]; then + for id in $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio); do + if [[ "$id" == "sdio:c00v0271d0301" ]] ; then + mv /etc/bluetooth-init_atheros /etc/bluetooth-init + mv /etc/bluetooth/main.conf_atheros /etc/bluetooth/main.conf + break + elif [[ "$id" == "sdio:c00v0271d050A" ]] ; then + rm /etc/bluetooth-init_atheros + rm /etc/bluetooth/main.conf_atheros + break + fi + done + fi +} + PACKAGES =+ "${PN}-init" -FILES_${PN} += " ${sysconfdir}/bluetooth/main.conf" -FILES_${PN}-init = " ${sysconfdir}/bluetooth-init \ +FILES_${PN} += " ${sysconfdir}/bluetooth/main.conf*" +FILES_${PN}-init = " ${sysconfdir}/bluetooth-init* \ ${sysconfdir}/init.d/bluetooth-init \ ${systemd_unitdir}/system/bluetooth-init.service \ " diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.55.bbappend b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.55.bbappend index f94752b63..b6cd5411b 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.55.bbappend +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.55.bbappend @@ -24,6 +24,11 @@ SRC_URI_append_ccimx6 = " ${QCA65XX_COMMON_PATCHES}" SRC_URI_append_ccimx8x = " ${QCA65XX_COMMON_PATCHES}" SRC_URI_append_ccimx8m = " ${QCA65XX_COMMON_PATCHES}" +SRC_URI_append_ccimx6sbc = " \ + file://bluetooth-init_atheros \ + file://main.conf_atheros \ +" + inherit update-rc.d do_install_append() { @@ -47,14 +52,38 @@ do_install_append() { sed -i -e '/#include/{s,src/shared/,,g}' ${D}${includedir}/bluetooth-internal/att.h } +do_install_append_ccimx6sbc() { + install -m 0755 ${WORKDIR}/bluetooth-init_atheros ${D}${sysconfdir}/bluetooth-init_atheros + install -m 0644 ${WORKDIR}/main.conf_atheros ${D}${sysconfdir}/bluetooth/ + sed -i -e "s,##BT_DEVICE_NAME##,${BT_DEVICE_NAME},g" \ + ${D}${sysconfdir}/bluetooth/main.conf_atheros +} + +pkg_postinst_ontarget_${PN}_ccimx6sbc() { + # Only execute the script on wireless ccimx6 platforms + if [ -e "/proc/device-tree/bluetooth/mac-address" ]; then + for id in $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio); do + if [[ "$id" == "sdio:c00v0271d0301" ]] ; then + mv /etc/bluetooth-init_atheros /etc/bluetooth-init + mv /etc/bluetooth/main.conf_atheros /etc/bluetooth/main.conf + break + elif [[ "$id" == "sdio:c00v0271d050A" ]] ; then + rm /etc/bluetooth-init_atheros + rm /etc/bluetooth/main.conf_atheros + break + fi + done + fi +} + PACKAGES =+ "${PN}-init" PACKAGECONFIG_append = " health-profiles \ mesh \ btpclient \ " -FILES_${PN} += " ${sysconfdir}/bluetooth/main.conf" -FILES_${PN}-init = " ${sysconfdir}/bluetooth-init \ +FILES_${PN} += " ${sysconfdir}/bluetooth/main.conf*" +FILES_${PN}-init = " ${sysconfdir}/bluetooth-init* \ ${sysconfdir}/init.d/bluetooth-init \ ${systemd_unitdir}/system/bluetooth-init.service \ " diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6sbc/wpa_supplicant_p2p.conf b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6sbc/wpa_supplicant_p2p.conf_atheros similarity index 100% rename from meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6sbc/wpa_supplicant_p2p.conf rename to meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6sbc/wpa_supplicant_p2p.conf_atheros diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend index 91594a3d5..d11f5531d 100644 --- a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend +++ b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 Digi International. +# Copyright (C) 2013-2021 Digi International. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" @@ -11,6 +11,8 @@ SRC_URI += " \ file://wpa_supplicant_p2p.conf \ " +SRC_URI_append_ccimx6sbc = " file://wpa_supplicant_p2p.conf_atheros" + do_install_append() { install -m 600 ${WORKDIR}/wpa_supplicant_p2p.conf ${D}${sysconfdir}/wpa_supplicant_p2p.conf sed -i -e "s,##WLAN_P2P_DEVICE_NAME##,${WLAN_P2P_DEVICE_NAME},g" \ @@ -18,8 +20,19 @@ do_install_append() { } do_install_append_ccimx6sbc() { - # Customize supplicant file - cat <>${D}${sysconfdir}/wpa_supplicant.conf + # Install atheros variant of the p2p .conf file + install -m 600 ${WORKDIR}/wpa_supplicant_p2p.conf_atheros ${D}${sysconfdir}/wpa_supplicant_p2p.conf_atheros + sed -i -e "s,##WLAN_P2P_DEVICE_NAME##,${WLAN_P2P_DEVICE_NAME},g" \ + ${D}${sysconfdir}/wpa_supplicant_p2p.conf_atheros +} + +pkg_postinst_ontarget_${PN}_ccimx6sbc() { + # Only execute the script on wireless ccimx6 platforms + if [ -e "/proc/device-tree/wireless/mac-address" ]; then + for id in $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio); do + if [[ "$id" == "sdio:c00v0271d0301" ]] ; then + # Customize supplicant file + cat <>/etc/wpa_supplicant.conf # -- SoftAP mode # ap_scan=2 @@ -34,6 +47,14 @@ do_install_append_ccimx6sbc() { # } EOF + mv /etc/wpa_supplicant_p2p.conf_atheros /etc/wpa_supplicant_p2p.conf + break + elif [[ "$id" == "sdio:c00v0271d050A" ]] ; then + rm /etc/wpa_supplicant_p2p.conf_atheros + break + fi + done + fi } PACKAGE_ARCH = "${MACHINE_ARCH}" diff --git a/meta-digi-dey/recipes-core/busybox/busybox/ccimx6sbc/standby b/meta-digi-dey/recipes-core/busybox/busybox/ccimx6sbc/standby index 89d57d3c4..897402db1 100755 --- a/meta-digi-dey/recipes-core/busybox/busybox/ccimx6sbc/standby +++ b/meta-digi-dey/recipes-core/busybox/busybox/ccimx6sbc/standby @@ -3,7 +3,7 @@ # # standby # -# Copyright (C) 2009-2019 by Digi International Inc. +# Copyright (C) 2009-2021 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -40,7 +40,8 @@ suspend_interfaces() { for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}" done - grep -qs '^ath6kl_sdio' /proc/modules && rmmod ath6kl_sdio ath6kl_core + [ -e /sys/module/ath6kl_sdio ] && rmmod ath6kl_sdio ath6kl_core && wlan_device_id="301" + [ -e /sys/module/wlan ] && rmmod wlan && wlan_device_id="50A" fi # Suspend bluetooth interface @@ -55,7 +56,7 @@ resume_interfaces() { # Resume wireless interfaces if [ -d "/proc/device-tree/wireless" ]; then # Trigger wireless module loading event, and wait until the interface exists - udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d0301" + udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d0${wlan_device_id}" timeout 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null # Bring up the interfaces that were bring down on suspend diff --git a/meta-digi-dey/recipes-core/busybox/busybox/ccimx6sbc/standby-actions b/meta-digi-dey/recipes-core/busybox/busybox/ccimx6sbc/standby-actions index 9c8d5d1f0..0cc258048 100644 --- a/meta-digi-dey/recipes-core/busybox/busybox/ccimx6sbc/standby-actions +++ b/meta-digi-dey/recipes-core/busybox/busybox/ccimx6sbc/standby-actions @@ -3,7 +3,7 @@ # # standby-actions # -# Copyright (C) 2019 by Digi International Inc. +# Copyright (C) 2019-2021 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -27,7 +27,8 @@ if [ "${1}" == "pre" ]; then done echo ${RESUME_IFACES} > /tmp/suspend_wlan_ifaces - grep -qs '^ath6kl_sdio' /proc/modules && rmmod ath6kl_sdio ath6kl_core + [ -e /sys/module/ath6kl_sdio ] && rmmod ath6kl_sdio ath6kl_core && echo "301" > /tmp/suspend_wlan_device_id + [ -e /sys/module/wlan ] && rmmod wlan && echo "50A" > /tmp/suspend_wlan_device_id fi # Suspend bluetooth interface @@ -40,7 +41,8 @@ elif [ "${1}" == "post" ]; then # Resume wireless interfaces if [ -d "/proc/device-tree/wireless" ]; then # Trigger wireless module loading event, and wait until the interface exists - udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d0301" + udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d0$(cat /tmp/suspend_wlan_device_id)" + rm -rf /tmp/suspend_wlan_driver timeout 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null # Bring up the interfaces that were brought down on suspend diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.example b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.atheros.example similarity index 100% rename from meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.example rename to meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.atheros.example diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend index 9ca62c4d4..22dbe697e 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 Digi International Inc. +# Copyright (C) 2013-2021 Digi International Inc. FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:" @@ -22,10 +22,15 @@ SRC_URI_append = " \ ${@oe.utils.conditional('HAS_WIFI_VIRTWLANS', 'true', '${WIFI_VIRTWLANS_FILES}', '', d)} \ " +SRC_URI_append_ccimx6sbc = " file://interfaces.br0.atheros.example" + SYSTEMD_SERVICE_${PN} = "ifupdown.service" WPA_DRIVER ?= "nl80211" +IS_CCIMX6 ?= "0" +IS_CCIMX6_ccimx6sbc = "1" + do_install_append() { # Install 'ifupdown' scripts install -m 0755 ${WORKDIR}/p2plink ${D}${sysconfdir}/network/if-up.d/ @@ -63,7 +68,15 @@ do_install_append() { install_wlan1 fi - cat ${WORKDIR}/interfaces.br0.example >> ${D}${sysconfdir}/network/interfaces + # On ccimx6, install the two possible br0 fragments in the filesystem + # so we can decide which one to use during runtime depending on the + # wireless MAC used on the SOM. + if [ "${IS_CCIMX6}" = "1" ]; then + install -m 0644 ${WORKDIR}/interfaces.br0.example ${D}${sysconfdir} + install -m 0644 ${WORKDIR}/interfaces.br0.atheros.example ${D}${sysconfdir} + else + cat ${WORKDIR}/interfaces.br0.example >> ${D}${sysconfdir}/network/interfaces + fi } install_virtwlans() { @@ -76,24 +89,34 @@ WLAN1_POST_UP_ACTION = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'syst WLAN1_PRE_DOWN_ACTION = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemctl stop hostapd@wlan1.service', '/etc/init.d/hostapd stop', d)}" install_wlan1() { + TARGET_WLAN1_FILE="${D}${sysconfdir}/network/interfaces" + if [ -n "${HAVE_WIFI}" ]; then - cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${D}${sysconfdir}/network/interfaces - [ -n "${WLAN1_AUTO}" ] && sed -i -e 's/^#auto wlan1/auto wlan1/g' ${D}${sysconfdir}/network/interfaces + # On the ccimx6, install the wlan1 fragment in the filesystem + # so we can decide if we want to incorporate it or not + # depending on the wireless MAC used on the SOM. + if [ "${IS_CCIMX6}" = "1" ]; then + TARGET_WLAN1_FILE="${D}${sysconfdir}/interfaces.wlan1.example" + install -m 0644 ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} ${TARGET_WLAN1_FILE} + else + cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${TARGET_WLAN1_FILE} + fi + [ -n "${WLAN1_AUTO}" ] && sed -i -e 's/^#auto wlan1/auto wlan1/g' ${TARGET_WLAN1_FILE} fi # Remove config entries if corresponding variable is not defined - [ -z "${WLAN1_STATIC_DNS}" ] && sed -i -e "/##WLAN1_STATIC_DNS##/d" ${D}${sysconfdir}/network/interfaces - [ -z "${WLAN1_STATIC_GATEWAY}" ] && sed -i -e "/##WLAN1_STATIC_GATEWAY##/d" ${D}${sysconfdir}/network/interfaces - [ -z "${WLAN1_STATIC_IP}" ] && sed -i -e "/##WLAN1_STATIC_IP##/d" ${D}${sysconfdir}/network/interfaces - [ -z "${WLAN1_STATIC_NETMASK}" ] && sed -i -e "/##WLAN1_STATIC_NETMASK##/d" ${D}${sysconfdir}/network/interfaces + [ -z "${WLAN1_STATIC_DNS}" ] && sed -i -e "/##WLAN1_STATIC_DNS##/d" ${TARGET_WLAN1_FILE} + [ -z "${WLAN1_STATIC_GATEWAY}" ] && sed -i -e "/##WLAN1_STATIC_GATEWAY##/d" ${TARGET_WLAN1_FILE} + [ -z "${WLAN1_STATIC_IP}" ] && sed -i -e "/##WLAN1_STATIC_IP##/d" ${TARGET_WLAN1_FILE} + [ -z "${WLAN1_STATIC_NETMASK}" ] && sed -i -e "/##WLAN1_STATIC_NETMASK##/d" ${TARGET_WLAN1_FILE} # Replace interface parameters - sed -i -e "s,##WLAN1_STATIC_IP##,${WLAN1_STATIC_IP},g" ${D}${sysconfdir}/network/interfaces - sed -i -e "s,##WLAN1_STATIC_NETMASK##,${WLAN1_STATIC_NETMASK},g" ${D}${sysconfdir}/network/interfaces - sed -i -e "s,##WLAN1_STATIC_GATEWAY##,${WLAN1_STATIC_GATEWAY},g" ${D}${sysconfdir}/network/interfaces - sed -i -e "s,##WLAN1_STATIC_DNS##,${WLAN1_STATIC_DNS},g" ${D}${sysconfdir}/network/interfaces - sed -i -e "s,##WLAN1_POST_UP_ACTION##,${WLAN1_POST_UP_ACTION},g" ${D}${sysconfdir}/network/interfaces - sed -i -e "s,##WLAN1_PRE_DOWN_ACTION##,${WLAN1_PRE_DOWN_ACTION},g" ${D}${sysconfdir}/network/interfaces + sed -i -e "s,##WLAN1_STATIC_IP##,${WLAN1_STATIC_IP},g" ${TARGET_WLAN1_FILE} + sed -i -e "s,##WLAN1_STATIC_NETMASK##,${WLAN1_STATIC_NETMASK},g" ${TARGET_WLAN1_FILE} + sed -i -e "s,##WLAN1_STATIC_GATEWAY##,${WLAN1_STATIC_GATEWAY},g" ${TARGET_WLAN1_FILE} + sed -i -e "s,##WLAN1_STATIC_DNS##,${WLAN1_STATIC_DNS},g" ${TARGET_WLAN1_FILE} + sed -i -e "s,##WLAN1_POST_UP_ACTION##,${WLAN1_POST_UP_ACTION},g" ${TARGET_WLAN1_FILE} + sed -i -e "s,##WLAN1_PRE_DOWN_ACTION##,${WLAN1_PRE_DOWN_ACTION},g" ${TARGET_WLAN1_FILE} } # Disable wireless interfaces on first boot for non-wireless variants @@ -107,5 +130,24 @@ pkg_postinst_ontarget_${PN}() { update-rc.d ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} fi + COMPAT="/proc/device-tree/compatible" + WIFI_MAC="/proc/device-tree/wireless/mac-address" + + # Only execute the script on wireless ccimx6 platforms + if [ -e ${WIFI_MAC} -a $(grep fsl,imx6dl ${COMPAT} || grep fsl,imx6q ${COMPAT} | grep -v fsl,imx6qp) ]; then + for id in $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio); do + if [[ "$id" == "sdio:c00v0271d0301" ]] ; then + cat /etc/interfaces.br0.atheros.example >> /etc/network/interfaces + rm /etc/network/if-pre-up.d/virtwlans /etc/network/if-post-down.d/virtwlans + break + elif [[ "$id" == "sdio:c00v0271d050A" ]] ; then + cat /etc/interfaces.wlan1.example >> /etc/network/interfaces + cat /etc/interfaces.br0.example >> /etc/network/interfaces + break + fi + done + rm /etc/interfaces.*.example + fi + exit 0 } From a93176815df0af8c6ad19ae0ea4e7e870004b336 Mon Sep 17 00:00:00 2001 From: Arturo Buzarra Date: Thu, 4 Nov 2021 12:27:34 +0100 Subject: [PATCH 59/70] sdk: remove framebuffer from ccimx6ulsbc platform Framebuffer support has been removed for all platforms, however it was missing from the ccimx6ulsbc configuration notes. Signed-off-by: Arturo Buzarra --- sdk/config/ccimx6ulsbc/conf-notes.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sdk/config/ccimx6ulsbc/conf-notes.txt b/sdk/config/ccimx6ulsbc/conf-notes.txt index 027ac1216..383eb9731 100644 --- a/sdk/config/ccimx6ulsbc/conf-notes.txt +++ b/sdk/config/ccimx6ulsbc/conf-notes.txt @@ -5,11 +5,6 @@ Digi Embedded Yocto provides the following image recipes: By default the image is X11-based so it provides a full SATO theme desktop environment. - To compile the image for the framebuffer (instead of X11) add the - following line to the project's conf/local.conf: - - DISTRO_FEATURES_remove = "x11" - * core-image-base: a console-only image Expansion of native core-image-base by including all the support for the From c89a66480bb0a091ee7becb19e18a779ab41f826 Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Wed, 27 Oct 2021 13:51:21 +0200 Subject: [PATCH 60/70] meta-digi: remove postinst on target when using read-only-rootfs image feature Signed-off-by: Javier Viguera --- meta-digi-arm/classes/remove-pkg-postinst-ontarget.bbclass | 2 ++ meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend | 2 ++ meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend | 2 ++ .../recipes-core/base-files/base-files_3.0.14.bbappend | 2 ++ .../recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend | 2 ++ 5 files changed, 10 insertions(+) create mode 100644 meta-digi-arm/classes/remove-pkg-postinst-ontarget.bbclass diff --git a/meta-digi-arm/classes/remove-pkg-postinst-ontarget.bbclass b/meta-digi-arm/classes/remove-pkg-postinst-ontarget.bbclass new file mode 100644 index 000000000..b30e168ce --- /dev/null +++ b/meta-digi-arm/classes/remove-pkg-postinst-ontarget.bbclass @@ -0,0 +1,2 @@ +pkg_postinst_ontarget_${PN}() { +} diff --git a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend index ad7129acb..1c7c122d0 100644 --- a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend +++ b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend @@ -61,3 +61,5 @@ pkg_postinst_ontarget_${PN}() { ${CONFIG_FILE} fi } + +inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)} diff --git a/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend b/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend index 00b57b508..d38caa54e 100644 --- a/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend +++ b/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend @@ -46,3 +46,5 @@ pkg_postinst_ontarget_${PN}() { update-rc.d -f ${INITSCRIPT_NAME} remove fi } + +inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)} diff --git a/meta-digi-dey/recipes-core/base-files/base-files_3.0.14.bbappend b/meta-digi-dey/recipes-core/base-files/base-files_3.0.14.bbappend index 4adb075d2..ff135697a 100644 --- a/meta-digi-dey/recipes-core/base-files/base-files_3.0.14.bbappend +++ b/meta-digi-dey/recipes-core/base-files/base-files_3.0.14.bbappend @@ -54,4 +54,6 @@ pkg_postinst_ontarget_${PN}() { fi } +inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)} + CONFFILES_${PN} += "${sysconfdir}/sysctl.conf" diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend index 22dbe697e..7faf9e811 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend @@ -151,3 +151,5 @@ pkg_postinst_ontarget_${PN}() { exit 0 } + +inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)} From 7cd57a40e3680e0b1b17b9e623673066b65fc0e8 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Wed, 27 Oct 2021 18:51:25 +0200 Subject: [PATCH 61/70] libubootenv: adapt recipe for read-only-rootfs The config file /etc/fw_env.config is generated dynamically basing on the partition table and, in the case of NAND-based SOMs, on the NAND geometry. This is done on a postinst script that modifies the file on the first boot of the target. Since this is not allowed on read-only-rootfs, this commit adds a default fw_env.config file to use instead when read-only-rootfs is enabled. Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7708 --- .../libubootenv/mtd/fw_env.config_default | 9 +++++++++ .../recipes-bsp/libubootenv/libubootenv_%.bbappend | 13 +++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 meta-digi-arm/recipes-bsp/libubootenv/libubootenv/mtd/fw_env.config_default diff --git a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/mtd/fw_env.config_default b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/mtd/fw_env.config_default new file mode 100644 index 000000000..cfcbc90db --- /dev/null +++ b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/mtd/fw_env.config_default @@ -0,0 +1,9 @@ +# Configuration file for fw_(printenv/setenv) utility. +# Up to two entries are valid, in this case the redundant +# environment sector is assumed present. +# If both copies are set to the same offset, an automatic mechanism will +# determine the first good sectors where each copy lives, skipping bad blocks. + +# Device name Offset Size Erase-size No.Blocks +/dev/mtd1 0x0 0x20000 0x20000 8 +/dev/mtd1 0x0 0x20000 0x20000 8 diff --git a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend index 1c7c122d0..a19985d6e 100644 --- a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend +++ b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend @@ -2,8 +2,17 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" +# Chose a between a default hard-coded config file (for read-only rootfs) +# or a dynamically generated one (with a postinst script) +FW_CONFIG_FILE = "${@bb.utils.contains('STORAGE_MEDIA', 'mtd', \ + bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', \ + '${STORAGE_MEDIA}/fw_env.config_default', \ + '${STORAGE_MEDIA}/fw_env.config', d), \ + '${STORAGE_MEDIA}/fw_env.config', \ + d)}" + SRC_URI += " \ - file://${STORAGE_MEDIA}/fw_env.config \ + file://${FW_CONFIG_FILE} \ file://0001-Implement-support-for-environment-encryption-by-CAAM.patch \ file://0002-Implement-U-Boot-environment-access-functions.patch \ file://0003-tools-env-add-support-to-set-dynamic-location-of-env.patch \ @@ -11,7 +20,7 @@ SRC_URI += " \ do_install_append() { install -d ${D}${sysconfdir} - install -m 0644 ${WORKDIR}/${STORAGE_MEDIA}/fw_env.config ${D}${sysconfdir}/ + install -m 0644 ${WORKDIR}/${FW_CONFIG_FILE} ${D}${sysconfdir}/fw_env.config } pkg_postinst_ontarget_${PN}() { From 0ba9b85574d6492e87bce7d92e1f528a5901b211 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 28 Oct 2021 08:59:20 +0200 Subject: [PATCH 62/70] hostapd: adapt recipe for read-only-rootfs The access point configuration files are dynamically modified on a post install script to generate an SSID name based on the last digits of the MAC address (physical or virtual) assigned to a wlanX interface. On read-only file systems, this is not possible, so add some conditional code to the do_install() to use instead the $DIGI_FAMILY name. Caveat: if several identical SOMs with read-only-rootfs co-exist on the same network as APs, they will identify with the same SSID. Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7708 --- .../recipes-connectivity/hostapd/hostapd_%.bbappend | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend b/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend index d38caa54e..765fcdbec 100644 --- a/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend +++ b/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2020 Digi International. +# Copyright (C) 2016-2021 Digi International. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" @@ -23,6 +23,12 @@ do_install_append() { # Install custom hostapd_IFACE.conf file install -m 0644 ${WORKDIR}/hostapd_wlan1.conf ${D}${sysconfdir} fi + + # Read-only rootfs: actions that substitute postinst script + # - append the ${DIGI_FAMILY} string to SSID + if [ -n "${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', '1', '', d)}" ]; then + sed -i -e "s,##MAC##,${DIGI_FAMILY},g" ${D}${sysconfdir}/hostapd_wlan?.conf + fi } pkg_postinst_ontarget_${PN}() { From bc88451131349455d20f94ff7088fe3d3f56c9ce Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 28 Oct 2021 13:42:39 +0200 Subject: [PATCH 63/70] machines: add SQUASFS to IMAGE_FSTYPES for read-only-rootfs Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7708 --- meta-digi-arm/conf/machine/ccimx6qpsbc.conf | 2 ++ meta-digi-arm/conf/machine/ccimx6sbc.conf | 2 ++ meta-digi-arm/conf/machine/ccimx6ulsbc.conf | 2 ++ meta-digi-arm/conf/machine/ccimx6ulstarter.conf | 2 ++ meta-digi-arm/conf/machine/ccimx8mm-dvk.conf | 2 ++ meta-digi-arm/conf/machine/ccimx8mn-dvk.conf | 2 ++ meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf | 2 ++ meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf | 2 ++ 8 files changed, 16 insertions(+) diff --git a/meta-digi-arm/conf/machine/ccimx6qpsbc.conf b/meta-digi-arm/conf/machine/ccimx6qpsbc.conf index c9afd118b..600c3de96 100644 --- a/meta-digi-arm/conf/machine/ccimx6qpsbc.conf +++ b/meta-digi-arm/conf/machine/ccimx6qpsbc.conf @@ -45,3 +45,5 @@ XBEE_TTY ?= "ttymxc4" # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" +# Add SQUASHFS if read-only-rootfs is enabled +IMAGE_FSTYPES += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "squashfs", "", d)}' diff --git a/meta-digi-arm/conf/machine/ccimx6sbc.conf b/meta-digi-arm/conf/machine/ccimx6sbc.conf index c10b3fd6a..fbfa29d65 100644 --- a/meta-digi-arm/conf/machine/ccimx6sbc.conf +++ b/meta-digi-arm/conf/machine/ccimx6sbc.conf @@ -47,3 +47,5 @@ XBEE_TTY ?= "ttymxc4" # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" +# Add SQUASHFS if read-only-rootfs is enabled +IMAGE_FSTYPES += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "squashfs", "", d)}' diff --git a/meta-digi-arm/conf/machine/ccimx6ulsbc.conf b/meta-digi-arm/conf/machine/ccimx6ulsbc.conf index 4a926d3b0..0d2f75472 100644 --- a/meta-digi-arm/conf/machine/ccimx6ulsbc.conf +++ b/meta-digi-arm/conf/machine/ccimx6ulsbc.conf @@ -41,3 +41,5 @@ XBEE_TTY ?= "ttymxc1" # Flash image types IMAGE_FSTYPES ?= "tar.bz2 ubifs boot.ubifs recovery.ubifs" +# Add SQUASHFS if read-only-rootfs is enabled +IMAGE_FSTYPES += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "squashfs", "", d)}' diff --git a/meta-digi-arm/conf/machine/ccimx6ulstarter.conf b/meta-digi-arm/conf/machine/ccimx6ulstarter.conf index a4489d533..f09e2b233 100644 --- a/meta-digi-arm/conf/machine/ccimx6ulstarter.conf +++ b/meta-digi-arm/conf/machine/ccimx6ulstarter.conf @@ -37,6 +37,8 @@ BT_TTY ?= "ttymxc0" # Flash image types IMAGE_FSTYPES ?= "tar.bz2 ubifs boot.ubifs recovery.ubifs" +# Add SQUASHFS if read-only-rootfs is enabled +IMAGE_FSTYPES += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "squashfs", "", d)}' # Default image for install scripts DEFAULT_IMAGE_NAME ?= "core-image-base" diff --git a/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf b/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf index 075d5e8c8..4baf8830a 100644 --- a/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf +++ b/meta-digi-arm/conf/machine/ccimx8mm-dvk.conf @@ -43,3 +43,5 @@ XBEE_TTY ?= "ttymxc3" # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" +# Add SQUASHFS if read-only-rootfs is enabled +IMAGE_FSTYPES += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "squashfs", "", d)}' diff --git a/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf b/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf index 7aaf86105..b4c8cb281 100644 --- a/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf +++ b/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf @@ -45,3 +45,5 @@ XBEE_TTY ?= "ttymxc3" # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" +# Add SQUASHFS if read-only-rootfs is enabled +IMAGE_FSTYPES += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "squashfs", "", d)}' diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf index 9ce413d90..ff455a55a 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf @@ -31,3 +31,5 @@ XBEE_TTY ?= "ttyLP0" # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" +# Add SQUASHFS if read-only-rootfs is enabled +IMAGE_FSTYPES += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "squashfs", "", d)}' diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf index 490100f20..5b061b9aa 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf @@ -45,3 +45,5 @@ XBEE_TTY ?= "ttyMCA0" # Flash image types IMAGE_FSTYPES ?= "boot.vfat ext4.gz sdcard.gz tar.bz2 recovery.vfat" +# Add SQUASHFS if read-only-rootfs is enabled +IMAGE_FSTYPES += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "squashfs", "", d)}' From 71b3623b59b3e2cc2618dc682af9e54c3307769c Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 4 Nov 2021 09:20:02 +0100 Subject: [PATCH 64/70] init-ifupdown: adapt recipe for read-only-rootfs This recipe had a post install script to do the following: - create runlevel symlinks. - comment the 'auto' lines of /etc/network/interfaces if running on a non-Wi-Fi variant. - add Atheros or QCA bridge examples depending on the detected chip. - add wlan1 interface only if QCA chip is detected. This post install cannot run on a read-only-rootfs so the recipe has been reworked to do the same things at build time: - the runlevel symlinks have been removed because they are taken care of by a poky class. - add a pre-up condition (the existance of a wireless entry on the device tree) so that the interface is not brought up if the condition is not met. - for the cc6/cc6n, since the Wi-Fi chip can be Atheros or QCA, add specific wlan1 and br0 fragments with a pre-up condition basing on the detected ID of the Wi-Fi chip Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7708 --- .../ccimx6sbc/interfaces.br0.atheros.example | 3 +- .../ccimx6sbc/interfaces.br0.example | 8 ++ .../ccimx6sbc/interfaces.wlan1.atheros.dhcp | 8 ++ .../ccimx6sbc/interfaces.wlan1.atheros.static | 11 +++ .../ccimx6sbc/interfaces.wlan1.dhcp | 8 ++ .../ccimx6sbc/interfaces.wlan1.static | 11 +++ .../init-ifupdown-1.0/interfaces.br0.example | 3 +- .../init-ifupdown-1.0/interfaces.p2p | 1 + .../init-ifupdown-1.0/interfaces.wlan1.dhcp | 2 + .../init-ifupdown-1.0/interfaces.wlan1.static | 2 + .../init-ifupdown/init-ifupdown_1.0.bbappend | 92 +++++-------------- 11 files changed, 79 insertions(+), 70 deletions(-) create mode 100644 meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.example create mode 100644 meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.dhcp create mode 100644 meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.static create mode 100644 meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.dhcp create mode 100644 meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.static diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.atheros.example b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.atheros.example index 6244da561..4b78aaca9 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.atheros.example +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.atheros.example @@ -1,5 +1,5 @@ -## Example bridge between eth0 and wlan0 +## Example bridge between eth0 and wlan0 (Atheros AR6233) #auto br0 #iface br0 inet static # bridge_ports eth0 wlan0 @@ -7,3 +7,4 @@ # netmask 255.255.255.0 # bridge_wpa_driver nl80211 # bridge_wpa_conf /etc/wpa_supplicant.conf +# pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d0301) ] diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.example b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.example new file mode 100644 index 000000000..34545bee0 --- /dev/null +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.example @@ -0,0 +1,8 @@ + +## Example bridge between eth0 and wlan1 (Qualcomm QCA65x4) +#auto br0 +#iface br0 inet static +# bridge_ports eth0 wlan1 +# address 192.168.42.50 +# netmask 255.255.255.0 +# pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d050A) ] diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.dhcp b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.dhcp new file mode 100644 index 000000000..e6f114131 --- /dev/null +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.dhcp @@ -0,0 +1,8 @@ + +# Wi-Fi AP interface (Atheros AR6233) +#auto wlan1 +iface wlan1 inet dhcp + udhcpc_opts -S -b >/dev/null & + pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d0301) ] + wpa-driver nl80211 + wpa-conf /etc/wpa_supplicant.conf diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.static b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.static new file mode 100644 index 000000000..eb8af110e --- /dev/null +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.static @@ -0,0 +1,11 @@ + +# Wi-Fi AP interface (Atheros AR6233) +#auto wlan1 +iface wlan1 inet static + address ##WLAN1_STATIC_IP## + netmask ##WLAN1_STATIC_NETMASK## + gateway ##WLAN1_STATIC_GATEWAY## + dns-nameservers ##WLAN1_STATIC_DNS## + pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d0301) ] + wpa-driver nl80211 + wpa-conf /etc/wpa_supplicant.conf diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.dhcp b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.dhcp new file mode 100644 index 000000000..3f35e5aa4 --- /dev/null +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.dhcp @@ -0,0 +1,8 @@ + +# Wi-Fi AP interface (Qualcomm QCA65x4) +#auto wlan1 +iface wlan1 inet dhcp + udhcpc_opts -S -b >/dev/null & + pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d050A) ] + post-up ##WLAN1_POST_UP_ACTION## + pre-down ##WLAN1_PRE_DOWN_ACTION## diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.static b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.static new file mode 100644 index 000000000..aa6bd09ea --- /dev/null +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.static @@ -0,0 +1,11 @@ + +# Wi-Fi AP interface (Qualcomm QCA65x4) +#auto wlan1 +iface wlan1 inet static + address ##WLAN1_STATIC_IP## + netmask ##WLAN1_STATIC_NETMASK## + gateway ##WLAN1_STATIC_GATEWAY## + dns-nameservers ##WLAN1_STATIC_DNS## + pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d050A) ] + post-up ##WLAN1_POST_UP_ACTION## + pre-down ##WLAN1_PRE_DOWN_ACTION## diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.br0.example b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.br0.example index 60e05fe52..1a0ffdf42 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.br0.example +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.br0.example @@ -1,7 +1,8 @@ -## Example bridge between eth0 and wlan1 +## Example bridge between eth0 and wlan1 (Qualcomm QCA65x4) #auto br0 #iface br0 inet static # bridge_ports eth0 wlan1 # address 192.168.42.50 # netmask 255.255.255.0 +# pre-up [ -d /proc/device-tree/wireless ] diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.p2p b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.p2p index 18a4503cc..7d828005c 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.p2p +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.p2p @@ -8,3 +8,4 @@ iface ##WLAN_P2P_INTERFACE## inet static dns-nameservers ##P2P0_STATIC_DNS## wpa-driver ##WPA_DRIVER## wpa-conf /etc/wpa_supplicant_p2p.conf + pre-up [ -d /proc/device-tree/wireless ] diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.dhcp b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.dhcp index 887f3034a..cc42c3377 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.dhcp +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.dhcp @@ -1,6 +1,8 @@ +# Wi-Fi AP interface (Qualcomm QCA65x4) #auto wlan1 iface wlan1 inet dhcp udhcpc_opts -S -b >/dev/null & + pre-up [ -d /proc/device-tree/wireless ] post-up ##WLAN1_POST_UP_ACTION## pre-down ##WLAN1_PRE_DOWN_ACTION## diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.static b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.static index 17e4a1090..35f5b29c6 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.static +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.static @@ -1,9 +1,11 @@ +# Wi-Fi AP interface (Qualcomm QCA65x4) #auto wlan1 iface wlan1 inet static address ##WLAN1_STATIC_IP## netmask ##WLAN1_STATIC_NETMASK## gateway ##WLAN1_STATIC_GATEWAY## dns-nameservers ##WLAN1_STATIC_DNS## + pre-up [ -d /proc/device-tree/wireless ] post-up ##WLAN1_POST_UP_ACTION## pre-down ##WLAN1_PRE_DOWN_ACTION## diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend index 7faf9e811..31139edbf 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend @@ -22,15 +22,16 @@ SRC_URI_append = " \ ${@oe.utils.conditional('HAS_WIFI_VIRTWLANS', 'true', '${WIFI_VIRTWLANS_FILES}', '', d)} \ " -SRC_URI_append_ccimx6sbc = " file://interfaces.br0.atheros.example" +SRC_URI_append_ccimx6sbc = " \ + file://interfaces.wlan1.atheros.static \ + file://interfaces.wlan1.atheros.dhcp \ + file://interfaces.br0.atheros.example \ +" SYSTEMD_SERVICE_${PN} = "ifupdown.service" WPA_DRIVER ?= "nl80211" -IS_CCIMX6 ?= "0" -IS_CCIMX6_ccimx6sbc = "1" - do_install_append() { # Install 'ifupdown' scripts install -m 0755 ${WORKDIR}/p2plink ${D}${sysconfdir}/network/if-up.d/ @@ -68,14 +69,11 @@ do_install_append() { install_wlan1 fi - # On ccimx6, install the two possible br0 fragments in the filesystem - # so we can decide which one to use during runtime depending on the - # wireless MAC used on the SOM. - if [ "${IS_CCIMX6}" = "1" ]; then - install -m 0644 ${WORKDIR}/interfaces.br0.example ${D}${sysconfdir} - install -m 0644 ${WORKDIR}/interfaces.br0.atheros.example ${D}${sysconfdir} - else - cat ${WORKDIR}/interfaces.br0.example >> ${D}${sysconfdir}/network/interfaces + cat ${WORKDIR}/interfaces.br0.example >> ${D}${sysconfdir}/network/interfaces + if [ "${MACHINE}" = "ccimx6sbc" ]; then + # On ccimx6, append also the Atheros fragments so the user can + # decide which one to use depending on the wireless MAC used on the SOM. + cat ${WORKDIR}/interfaces.br0.atheros.example >> ${D}${sysconfdir}/network/interfaces fi } @@ -89,67 +87,25 @@ WLAN1_POST_UP_ACTION = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'syst WLAN1_PRE_DOWN_ACTION = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemctl stop hostapd@wlan1.service', '/etc/init.d/hostapd stop', d)}" install_wlan1() { - TARGET_WLAN1_FILE="${D}${sysconfdir}/network/interfaces" - if [ -n "${HAVE_WIFI}" ]; then - # On the ccimx6, install the wlan1 fragment in the filesystem - # so we can decide if we want to incorporate it or not - # depending on the wireless MAC used on the SOM. - if [ "${IS_CCIMX6}" = "1" ]; then - TARGET_WLAN1_FILE="${D}${sysconfdir}/interfaces.wlan1.example" - install -m 0644 ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} ${TARGET_WLAN1_FILE} - else - cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${TARGET_WLAN1_FILE} + cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${D}${sysconfdir}/network/interfaces + if [ "${MACHINE}" = "ccimx6sbc" ]; then + cat ${WORKDIR}/interfaces.wlan1.atheros.${WLAN1_MODE} >> ${D}${sysconfdir}/network/interfaces fi - [ -n "${WLAN1_AUTO}" ] && sed -i -e 's/^#auto wlan1/auto wlan1/g' ${TARGET_WLAN1_FILE} + [ -n "${WLAN1_AUTO}" ] && sed -i -e 's/^#auto wlan1/auto wlan1/g' ${D}${sysconfdir}/network/interfaces fi # Remove config entries if corresponding variable is not defined - [ -z "${WLAN1_STATIC_DNS}" ] && sed -i -e "/##WLAN1_STATIC_DNS##/d" ${TARGET_WLAN1_FILE} - [ -z "${WLAN1_STATIC_GATEWAY}" ] && sed -i -e "/##WLAN1_STATIC_GATEWAY##/d" ${TARGET_WLAN1_FILE} - [ -z "${WLAN1_STATIC_IP}" ] && sed -i -e "/##WLAN1_STATIC_IP##/d" ${TARGET_WLAN1_FILE} - [ -z "${WLAN1_STATIC_NETMASK}" ] && sed -i -e "/##WLAN1_STATIC_NETMASK##/d" ${TARGET_WLAN1_FILE} + [ -z "${WLAN1_STATIC_DNS}" ] && sed -i -e "/##WLAN1_STATIC_DNS##/d" ${D}${sysconfdir}/network/interfaces + [ -z "${WLAN1_STATIC_GATEWAY}" ] && sed -i -e "/##WLAN1_STATIC_GATEWAY##/d" ${D}${sysconfdir}/network/interfaces + [ -z "${WLAN1_STATIC_IP}" ] && sed -i -e "/##WLAN1_STATIC_IP##/d" ${D}${sysconfdir}/network/interfaces + [ -z "${WLAN1_STATIC_NETMASK}" ] && sed -i -e "/##WLAN1_STATIC_NETMASK##/d" ${D}${sysconfdir}/network/interfaces # Replace interface parameters - sed -i -e "s,##WLAN1_STATIC_IP##,${WLAN1_STATIC_IP},g" ${TARGET_WLAN1_FILE} - sed -i -e "s,##WLAN1_STATIC_NETMASK##,${WLAN1_STATIC_NETMASK},g" ${TARGET_WLAN1_FILE} - sed -i -e "s,##WLAN1_STATIC_GATEWAY##,${WLAN1_STATIC_GATEWAY},g" ${TARGET_WLAN1_FILE} - sed -i -e "s,##WLAN1_STATIC_DNS##,${WLAN1_STATIC_DNS},g" ${TARGET_WLAN1_FILE} - sed -i -e "s,##WLAN1_POST_UP_ACTION##,${WLAN1_POST_UP_ACTION},g" ${TARGET_WLAN1_FILE} - sed -i -e "s,##WLAN1_PRE_DOWN_ACTION##,${WLAN1_PRE_DOWN_ACTION},g" ${TARGET_WLAN1_FILE} + sed -i -e "s,##WLAN1_STATIC_IP##,${WLAN1_STATIC_IP},g" ${D}${sysconfdir}/network/interfaces + sed -i -e "s,##WLAN1_STATIC_NETMASK##,${WLAN1_STATIC_NETMASK},g" ${D}${sysconfdir}/network/interfaces + sed -i -e "s,##WLAN1_STATIC_GATEWAY##,${WLAN1_STATIC_GATEWAY},g" ${D}${sysconfdir}/network/interfaces + sed -i -e "s,##WLAN1_STATIC_DNS##,${WLAN1_STATIC_DNS},g" ${D}${sysconfdir}/network/interfaces + sed -i -e "s,##WLAN1_POST_UP_ACTION##,${WLAN1_POST_UP_ACTION},g" ${D}${sysconfdir}/network/interfaces + sed -i -e "s,##WLAN1_PRE_DOWN_ACTION##,${WLAN1_PRE_DOWN_ACTION},g" ${D}${sysconfdir}/network/interfaces } - -# Disable wireless interfaces on first boot for non-wireless variants -pkg_postinst_ontarget_${PN}() { - if [ ! -d "/proc/device-tree/wireless" ]; then - sed -i -e '/^auto wlan/{s,^,#,g};/^auto p2p/{s,^,#,g}' /etc/network/interfaces - fi - - # Create the symlinks in the different runlevels - if type update-rc.d >/dev/null 2>/dev/null; then - update-rc.d ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} - fi - - COMPAT="/proc/device-tree/compatible" - WIFI_MAC="/proc/device-tree/wireless/mac-address" - - # Only execute the script on wireless ccimx6 platforms - if [ -e ${WIFI_MAC} -a $(grep fsl,imx6dl ${COMPAT} || grep fsl,imx6q ${COMPAT} | grep -v fsl,imx6qp) ]; then - for id in $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio); do - if [[ "$id" == "sdio:c00v0271d0301" ]] ; then - cat /etc/interfaces.br0.atheros.example >> /etc/network/interfaces - rm /etc/network/if-pre-up.d/virtwlans /etc/network/if-post-down.d/virtwlans - break - elif [[ "$id" == "sdio:c00v0271d050A" ]] ; then - cat /etc/interfaces.wlan1.example >> /etc/network/interfaces - cat /etc/interfaces.br0.example >> /etc/network/interfaces - break - fi - done - rm /etc/interfaces.*.example - fi - - exit 0 -} - -inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)} From 4e303ab542037e66e476f1d2bc38c715af6a1dec Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Fri, 5 Nov 2021 11:22:05 +0100 Subject: [PATCH 65/70] swu-images: remove ccimx6ul preinstallation script Since commit bf8c73322b880198f8ef5b4c3f62b923bd654356, the script is no longer used, so remove it. Signed-off-by: Gabriel Valcazar --- .../files/ccimx6ul/preinstall_swu.sh | 119 ------------------ 1 file changed, 119 deletions(-) delete mode 100644 meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/preinstall_swu.sh diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/preinstall_swu.sh b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/preinstall_swu.sh deleted file mode 100644 index 292e6f518..000000000 --- a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/preinstall_swu.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/sh -#=============================================================================== -# -# pre-install_swu.sh -# -# Copyright (C) 2017 by Digi International Inc. -# All rights reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# -# !Description: SWUpdate pre-install script to remove the encryption flag from -# rootfs -# -# SWUpdate calls this script before installing the image. -# -#=============================================================================== - -# Variables. -#------------------------------------------------------------------------------ -ENV_MTDPARTS="mtdparts" - -# Functions. -#------------------------------------------------------------------------------ -# Function - psplash_message -# -# Shows the given message in the psplash screen. -# -# @param ${1} - Message to show. -#------------------------------------------------------------------------------ -psplash_message() { - echo "MSG ${1}" > /tmp/psplash_fifo - sleep 0.2 -} - -#------------------------------------------------------------------------------ -# Function - psplash_progress -# -# Sets the psplash progress bar percentage to the given one. -# -# @param ${1} - Progress percentage. -#------------------------------------------------------------------------------ -psplash_progress() { - echo "PROGRESS ${1}" > /tmp/psplash_fifo - sleep 0.2 -} - -#------------------------------------------------------------------------------ -# Function - log -# -# Prints the given text in the console. -# -# @param ${1} - Text to print. -#------------------------------------------------------------------------------ -log() { - echo "[FW UPDATE] ${1}" -} - -#------------------------------------------------------------------------------ -# Function - log_error -# -# Prints the given text in the console as an error. -# -# @param ${1} - Error text to print. -#------------------------------------------------------------------------------ -log_error() { - log "[ERROR] ${1}" - psplash_message "ERROR: ${1}" - psplash_progress "0" -} - -#------------------------------------------------------------------------------ -# Function - read_uboot_var -# -# Reads the given U-Boot variable. -# -# @param ${1} - U-Boot variable to read. -# @param ${2} - Where to store the value of the read variable. -#------------------------------------------------------------------------------ -read_uboot_var() { - eval "${2}=\"$(fw_printenv -n ${1} 2>/dev/null)\"" -} - -#------------------------------------------------------------------------------ -# Function - set_uboot_var -# -# Sets the given U-Boot variable. -# -# @param ${1} - U-Boot variable to set. -# @param ${2} - Value to set. -#------------------------------------------------------------------------------ -set_uboot_var() { - fw_setenv ${1} ${2} 2>/dev/null -} - -# Main -#------------------------------------------------------------------------------ -# Read the mtdparts variable. -read_uboot_var "${ENV_MTDPARTS}" MTDPARTS - -# Check if there is any command. -if [ -z "${MTDPARTS}" ]; then - log_error "No mtdparts found" - exit 1 -fi - -# Parse the mtdparts value. -case "${MTDPARTS}" in - *\(rootfs\)enc*) - # Remove the flag from the rootfs partition. - NEW_MTDPARTS=$(echo "${MTDPARTS}" | sed -e "s/(rootfs)enc/(rootfs)/g") - set_uboot_var "${ENV_MTDPARTS}" "${NEW_MTDPARTS}" - sync && reboot -f - ;; - *) -esac - From b03a2af5b2ffacf78b8d4981900d4d12eddb98bf Mon Sep 17 00:00:00 2001 From: Arturo Buzarra Date: Mon, 8 Nov 2021 08:22:11 +0100 Subject: [PATCH 66/70] recovery-initramfs-init: fix support to identify encrypted rootfs images Since we added support for compressing rootfs images, we need to manage SWU packages with a regular rootfs image and with compressed images. That support was missing in the identification process when the SWU packet was verified. This commit fixes the identification of compressed rootfs images. https://onedigi.atlassian.net/browse/CC8X-320 Signed-off-by: Arturo Buzarra --- .../recovery/recovery-initramfs/recovery-initramfs-init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init index 7bd485637..740739c4a 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init @@ -409,7 +409,7 @@ check_swu_package() { grep "Found Image" "${SWUPDATE_OUTPUT}" | grep -qs "rootfs for handler" && ROOTFS_IMAGE_IN_PACKAGE="yes" else # For eMMC packages, check for a *.ext4 image, which is very likely intended for the rootfs partition - grep "Found Image" "${SWUPDATE_OUTPUT}" | grep -qs "\.ext4 in device" && ROOTFS_IMAGE_IN_PACKAGE="yes" + grep -E "Found( compressed){0,1} Image" "${SWUPDATE_OUTPUT}" | grep -Eqs "\.ext4(\.gz){0,1} in device" && ROOTFS_IMAGE_IN_PACKAGE="yes" fi # Check if the rootfs is meant to be encrypted From d81444a57489e3e5c3564e32906d20c82bb05885 Mon Sep 17 00:00:00 2001 From: Arturo Buzarra Date: Mon, 8 Nov 2021 08:39:18 +0100 Subject: [PATCH 67/70] swu-images: fix support to preinstallation script in swu update package Since commit 11558352 ("swu-images: add "installed-directly" flag to sw-description") the swu package images are streamed into the target without any temporary copy to support devices with low memory available, that forces a different order according with the swupdate documentation because scripts should packed before the rest. This means that all the pre, post and shell scripts will be executed after the images will be installed. This behavior breaks the current support to mount the cryptorootfs node before install an encrypted rootfs. This commit moves the shell script to mount the cryptorootfs node to the recovery initramfs and modifies the swupdate command line to call the shell script before the images installation. https://onedigi.atlassian.net/browse/CC8X-320 Signed-off-by: Arturo Buzarra --- meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb | 4 ++++ .../recovery/recovery-initramfs/mount_cryptrootfs.sh} | 0 .../recovery/recovery-initramfs/recovery-initramfs-init | 3 ++- meta-digi-dey/recipes-digi/swu-images/files/sw-description | 3 +-- meta-digi-dey/recipes-digi/swu-images/swu.inc | 7 ------- 5 files changed, 7 insertions(+), 10 deletions(-) rename meta-digi-dey/{recipes-digi/swu-images/files/preinstall_swu.sh => recipes-core/recovery/recovery-initramfs/mount_cryptrootfs.sh} (100%) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb b/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb index a05db3d71..34e1c5607 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb @@ -16,6 +16,7 @@ SRC_URI = " \ file://automount_block.sh \ file://automount_mtd.sh \ file://mdev.conf \ + ${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'file://mount_cryptrootfs.sh', '', d)} \ " S = "${WORKDIR}" @@ -24,6 +25,9 @@ do_install() { install -d ${D}${sysconfdir} install -m 0755 ${WORKDIR}/recovery-initramfs-init ${D}/init install -m 0644 ${WORKDIR}/swupdate.cfg ${D}${sysconfdir} + if [ "${STORAGE_MEDIA}" = "mmc" ]; then + install -m 0755 ${WORKDIR}/mount_cryptrootfs.sh ${D}${sysconfdir} + fi install -d ${D}${base_libdir}/mdev install -m 0755 ${WORKDIR}/automount_block.sh ${D}${base_libdir}/mdev/automount_block.sh install -m 0755 ${WORKDIR}/automount_mtd.sh ${D}${base_libdir}/mdev/automount_mtd.sh diff --git a/meta-digi-dey/recipes-digi/swu-images/files/preinstall_swu.sh b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/mount_cryptrootfs.sh similarity index 100% rename from meta-digi-dey/recipes-digi/swu-images/files/preinstall_swu.sh rename to meta-digi-dey/recipes-core/recovery/recovery-initramfs/mount_cryptrootfs.sh diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init index 740739c4a..a092bfcc8 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init @@ -833,7 +833,8 @@ if [ -n "${update_package_bool}" ]; then progress -wp & # Execute the software update. if [ -f "${PUBLIC_KEY}" ]; then - swupdate -e "${SWUPDATE_IMAGE_SET}" -f "${SW_CONFIG}" -i "${update_package}" -k "${PUBLIC_KEY}" + [ "${ENCRYPT_ROOTFS}" = "yes" ] && SWUPDATE_PREUPDATE_CMD="-P /etc/mount_cryptrootfs.sh" + swupdate -e "${SWUPDATE_IMAGE_SET}" -f "${SW_CONFIG}" -i "${update_package}" -k "${PUBLIC_KEY}" ${SWUPDATE_PREUPDATE_CMD} else swupdate -e "${SWUPDATE_IMAGE_SET}" -f "${SW_CONFIG}" -i "${update_package}" fi diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description b/meta-digi-dey/recipes-digi/swu-images/files/sw-description index 498ac549b..447de9884 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/sw-description +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description @@ -22,8 +22,7 @@ software = installed-directly = true; } ); - } - ##PREINSTALL_SCRIPT## + }; }; mtd = { platform: { diff --git a/meta-digi-dey/recipes-digi/swu-images/swu.inc b/meta-digi-dey/recipes-digi/swu-images/swu.inc index 78aa76d3f..7559903b1 100644 --- a/meta-digi-dey/recipes-digi/swu-images/swu.inc +++ b/meta-digi-dey/recipes-digi/swu-images/swu.inc @@ -5,9 +5,6 @@ LICENSE = "GPL-2.0" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" SRC_URI = "file://sw-description" -SRC_URI_append_ccimx6 = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS', True) == '1', 'file://preinstall_swu.sh', '')}" -SRC_URI_append_ccimx8x = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS', True) == '1', 'file://preinstall_swu.sh', '')}" -SRC_URI_append_ccimx8m = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS', True) == '1', 'file://preinstall_swu.sh', '')}" inherit swupdate @@ -32,9 +29,6 @@ ROOTFS_DEV_NAME_ccimx6ul ?= "rootfs" ROOTFS_ENC_DEV = "/dev/mapper/cryptrootfs" ROOTFS_ENC_DEV_ccimx6ul = "${ROOTFS_DEV_NAME}" ROOTFS_DEV_NAME_FINAL = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS', True) == '1', '${ROOTFS_ENC_DEV}', '${ROOTFS_DEV_NAME}')}" -PREINST_SCRIPT_TEMPLATE = "scripts: ( { filename = \\"preinstall_swu.sh\\"; type = \\"preinstall\\"; sha256 = \\"@preinstall_swu.sh\\"; \\x7D );" -PREINST_SCRIPT_DESC = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS', True) == '1', '${PREINST_SCRIPT_TEMPLATE}', '')}" -PREINST_SCRIPT_DESC_ccimx6ul = "" python () { img_fstypes = d.getVar('BOOTFS_EXT', True) + " " + d.getVar('ROOTFS_EXT', True) @@ -61,5 +55,4 @@ fill_description() { sed -i -e "s,##ROOTFS_DEV##,${ROOTFS_DEV_NAME_FINAL},g" "${WORKDIR}/sw-description" sed -i -e "s,##SW_VERSION##,${SOFTWARE_VERSION},g" "${WORKDIR}/sw-description" sed -i -e "s,##DESCRIPTION##,${DESCRIPTION},g" "${WORKDIR}/sw-description" - sed -i -e "s/##PREINSTALL_SCRIPT##/${PREINST_SCRIPT_DESC}/g" "${WORKDIR}/sw-description" } From 75fca73cc5ff3114ce48271fa55ba5b3f08b4526 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Wed, 10 Nov 2021 16:22:38 +0100 Subject: [PATCH 68/70] u-boot: cc6ul: fix script adding missing call to 'uuu' Add missing call to 'uuu' and erase the partition before creating the UBI volumes. Also add larger timeouts to erase operations. Signed-off-by: Hector Palacios --- .../u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh index fad0cd070..fe346999c 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh @@ -261,8 +261,8 @@ uuu fb: ucmd setenv fastboot_buffer \${loadaddr} uuu "fb[-t 10000]:" ucmd run partition_nand_linux if [ "${SINGLEMTDSYS}" = true ]; then + uuu "fb[-t 30000]:" ucmd nand erase.part system uuu "fb[-t 10000]:" ucmd run ubivolscript - nand erase.part system fi if [ "${DUALBOOT}" = true ]; then @@ -285,7 +285,7 @@ fi if [ "${SINGLEMTDSYS}" != true ] && [ "${DUALBOOT}" != true ]; then # Erase the 'Update' partition - uuu fb: ucmd nand erase.part update + uuu "fb[-t 20000]:" ucmd nand erase.part update fi if [ "${DUALBOOT}" != true ]; then From eb730358e57ceade6be1fe04d79b6d0c28a61ba4 Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Fri, 29 Oct 2021 10:38:10 +0200 Subject: [PATCH 69/70] trustfence: add read only rootfs signing option to signing script Signed-off-by: Mike Engel --- .../trustfence-sign-tools/trustfence-sign-artifact.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact.sh b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact.sh index 9c49347e2..2a977eff4 100755 --- a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact.sh +++ b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact.sh @@ -33,13 +33,14 @@ done SCRIPT_NAME="$(basename ${0})" SCRIPT_PATH="$(cd $(dirname ${0}) && pwd)" -while getopts "bdilop:" c; do +while getopts "bdilorp:" c; do case "${c}" in b) ARTIFACT_BOOTSCRIPT="y";; d) ARTIFACT_DTB="y";; i) ARTIFACT_INITRAMFS="y";; l) ARTIFACT_KERNEL="y";; o) ARTIFACT_DTB_OVERLAY="y";; + r) ARTIFACT_ROOTFS="y";; p) PLATFORM="${OPTARG}";; esac done @@ -56,6 +57,7 @@ Usage: ${SCRIPT_NAME} [OPTIONS] input-unsigned-image output-signed-image -o sign/encrypt DTB overlay -i sign/encrypt initramfs -l sign/encrypt Linux image + -r sign read-only rootfs image Supported platforms: ccimx6, ccimx6ul, ccimx8x, ccimx8mn, ccimx8mm @@ -88,20 +90,24 @@ if [ "${PLATFORM}" = "ccimx6" ]; then CONFIG_FDT_LOADADDR="0x18000000" CONFIG_RAMDISK_LOADADDR="0x19000000" CONFIG_KERNEL_LOADADDR="0x12000000" + CONFIG_ROOTFS_LOADADDR="0x19800000" CONFIG_CSF_SIZE="0x4000" elif [ "${PLATFORM}" = "ccimx6ul" ]; then CONFIG_FDT_LOADADDR="0x83000000" CONFIG_RAMDISK_LOADADDR="0x83800000" CONFIG_KERNEL_LOADADDR="0x80800000" + CONFIG_ROOTFS_LOADADDR="0x84000000" CONFIG_CSF_SIZE="0x4000" elif [ "${PLATFORM}" = "ccimx8x" ]; then CONFIG_FDT_LOADADDR="0x82000000" CONFIG_RAMDISK_LOADADDR="0x82100000" CONFIG_KERNEL_LOADADDR="0x80280000" + CONFIG_ROOTFS_LOADADDR="0x82900000" elif [ "${PLATFORM}" = "ccimx8mn" ] || [ "${PLATFORM}" = "ccimx8mm" ]; then CONFIG_FDT_LOADADDR="0x43000000" CONFIG_RAMDISK_LOADADDR="0x43800000" CONFIG_KERNEL_LOADADDR="0x40480000" + CONFIG_ROOTFS_LOADADDR="0x44000000" CONFIG_CSF_SIZE="0x2000" else echo "Invalid platform: ${PLATFORM}" @@ -116,9 +122,10 @@ fi [ "${ARTIFACT_BOOTSCRIPT}" = "y" ] && CONFIG_RAM_START="${CONFIG_KERNEL_LOADADDR}" # DTB overlays are loaded to $initrd_addr, just like the ramdisk [ "${ARTIFACT_DTB_OVERLAY}" = "y" ] && CONFIG_RAM_START="${CONFIG_RAMDISK_LOADADDR}" +[ "${ARTIFACT_ROOTFS}" = "y" ] && CONFIG_RAM_START="${CONFIG_ROOTFS_LOADADDR}" if [ -z "${CONFIG_RAM_START}" ]; then - echo "Specify the type of image to process (-b, -i, -d, -l, or -o)" + echo "Specify the type of image to process (-b, -i, -d, -l, -r, or -o)" exit 1 fi From 214561472472116ffbd9d12abb833531c9797cae Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Fri, 29 Oct 2021 11:48:06 +0200 Subject: [PATCH 70/70] images: add function to sign read only rootfs when Trustfence is enabled Signed-off-by: Mike Engel --- .../classes/image_types_digi.bbclass | 23 +++++++++++++++++++ meta-digi-dey/classes/dey-image.bbclass | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/meta-digi-arm/classes/image_types_digi.bbclass b/meta-digi-arm/classes/image_types_digi.bbclass index 38e08b3d4..a57ff3462 100644 --- a/meta-digi-arm/classes/image_types_digi.bbclass +++ b/meta-digi-arm/classes/image_types_digi.bbclass @@ -219,6 +219,28 @@ CONVERSION_CMD_tf = "trustence_sign_cpio ${IMAGE_NAME}.rootfs.${type}" CONVERSION_DEPENDS_tf = "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'trustfence-sign-tools-native', '', d)}" IMAGE_TYPES += "cpio.gz.u-boot.tf" +# +# Sign read-only rootfs +# +do_image_squashfs[postfuncs] += "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'rootfs_sign', '', d)}" + +rootfs_sign() { + # Set environment variables for trustfence configuration + export CONFIG_SIGN_KEYS_PATH="${TRUSTFENCE_SIGN_KEYS_PATH}" + [ -n "${CONFIG_KEY_INDEX}" ] && export CONFIG_KEY_INDEX="${TRUSTFENCE_KEY_INDEX}" + [ -n "${CONFIG_SIGN_MODE}" ] && export CONFIG_SIGN_MODE="${TRUSTFENCE_SIGN_MODE}" + + ROOTFS_IMAGE="${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.squashfs" + TMP_ROOTFS_IMAGE_SIGNED="$(mktemp ${ROOTFS_IMAGE}-signed.XXXXXX)" + # Sign rootfs read-only image + trustfence-sign-artifact.sh -p "${DIGI_FAMILY}" -r "${ROOTFS_IMAGE}" "${TMP_ROOTFS_IMAGE_SIGNED}" + mv "${TMP_ROOTFS_IMAGE_SIGNED}" "${ROOTFS_IMAGE}" +} + +rootfs_sign[dirs] = "${DEPLOY_DIR_IMAGE}" + +do_image_squashfs[vardeps] += "TRUSTFENCE_SIGN_KEYS_PATH TRUSTFENCE_KEY_INDEX" + ################################################################################ # SDCARD IMAGES # ################################################################################ @@ -305,3 +327,4 @@ IMAGE_CMD_sdcard() { # The sdcard image requires the boot and rootfs images to be built before IMAGE_TYPEDEP_sdcard = "${SDIMG_BOOTFS_TYPE} ${SDIMG_ROOTFS_TYPE}.gz" + diff --git a/meta-digi-dey/classes/dey-image.bbclass b/meta-digi-dey/classes/dey-image.bbclass index b9c9cd3f2..e4bbea96a 100644 --- a/meta-digi-dey/classes/dey-image.bbclass +++ b/meta-digi-dey/classes/dey-image.bbclass @@ -56,3 +56,7 @@ fakeroot toolchain_create_sdk_dey_version() { } toolchain_create_sdk_dey_version[vardepsexclude] = "DATETIME" +# +# Add dependency for read-only signed rootfs +# +DEPENDS += "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'trustfence-sign-tools-native', '', d)}"