From patchwork Mon Aug 12 21:12:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 47707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBFB9C52D7C for ; Mon, 12 Aug 2024 21:15:07 +0000 (UTC) Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by mx.groups.io with SMTP id smtpd.web10.57869.1723497301852059218 for ; Mon, 12 Aug 2024 14:15:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ULTEueWu; spf=pass (domain: gmail.com, ip: 209.85.218.50, mailfrom: adrian.freihofer@gmail.com) Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a7a8a4f21aeso518891566b.2 for ; Mon, 12 Aug 2024 14:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723497300; x=1724102100; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JWlKp6oE7NKmNWSnBHLyptMjfMOa+gQBgdxYK8BopFE=; b=ULTEueWuocrAxN14YAEGx5zW0+5udNq/ez6kwAPzuCug5RJJ0iEDSbnwYf61x3N+Tr e5oPSFcXOAVOWHvdPYLCTw9ANEFPAqlcBuFCb7CC17csiCK1qRO/Eq8grU54YyJZyLQ5 yJDdwSQ+P+t73EsnRX+4Jo7Dfj+J7+4Z2EAiubWbATr7QwFGMzhd3eZHWGU9FTwO440o dub17dtyHdWX1BAAgEoctt+G4y+e1y6Aiy3UtVAngoq9kVebJqY2u6Eh1LEHXQF25ovm lZvXMybc9f2cYiwy97MzSBBeidLOox/qvRoae85c4Uquz9VoaBuKU4OtFqO2p0402Q+I nJxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723497300; x=1724102100; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JWlKp6oE7NKmNWSnBHLyptMjfMOa+gQBgdxYK8BopFE=; b=eDb3/57CqGvHy8Nm2NGL+tyHXHSgp6m6F9mvKyb8cyURMINDTixWQRUo9f0mBcNNnf wIjqAmpVoJ24nJKHUO/Pk86AVC6yDJcSPY2gKcdua+KlL5zYNXRWWBtdC2HG6sGduvxB 3ch8xl6yrVEMqBhI3pBbD6TOow+WOb1Dna9DPwscy7CAsgBKrtrHwO69zbQVOthT9Lpi X/L3sWA3irmGC3rL0DS0gsQ3OEQk1Jzz4VQyoMvkMOT0lVtL+ulySQszKLtMANcqdViq 2MKBFrJ6NoH8JJ7RWFC08AOvaTgKcMce9yfm+k/T1w1q990LyjQvNm+YSKAkiKr6MMPf VTRg== X-Gm-Message-State: AOJu0YxQneq+eV3M/oRT89M8Cgf9kkEsBlGnuOgK7ZePjTBqg7BtOvTY IvJZIGqHTKMwRrultQD8up8jZoG8aLy1NeEnJ+TgkzmqtWOtF1/0cdru1w== X-Google-Smtp-Source: AGHT+IFUEU9oZKBBRV4++66f/3aSWsJ1vxIHN63Od3I27bMG36drThnyuQVAIlyEYQ9nT0q8TyIvbg== X-Received: by 2002:a17:907:f753:b0:a7a:9954:1fc1 with SMTP id a640c23a62f3a-a80ed1d69edmr114858366b.24.1723497299586; Mon, 12 Aug 2024 14:14:59 -0700 (PDT) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f3fb069dsm10828366b.80.2024.08.12.14.14.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 14:14:59 -0700 (PDT) From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 1/4] kernel: refactor linux compression Date: Mon, 12 Aug 2024 23:12:54 +0200 Message-ID: <20240812211437.2736977-2-adrian.freihofer@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240812211437.2736977-1-adrian.freihofer@gmail.com> References: <20240812211437.2736977-1-adrian.freihofer@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 12 Aug 2024 21:15:07 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/203236 From: Adrian Freihofer This is a step to avoid unecessary kernel rebuilds when the initramfs changes but not the kernel itself. In case of an unbundled fitImage the kernel should be staged in the sstate instead of re-compiled. The uboot_prep_kimage function generates the kernel binary which gets included into the fitImage. It also defines the variable linux_comp which is used by the fitimage_assemble function later on. To make the fitimage_assemble function working with kernel binaries from sstate it must be decoupled from calling uboot_prep_kimage in ${B} by: - refactoring uboot_prep_kimage to write the result into files (linux.bin, linux.comp). - calling the uboot_prep_kimage before the artifacts are used or cached. - refactoring the fitimage_assemble function to use files rather than calling the uboot_prep_kimage function which depends on ${B}. Signed-off-by: Adrian Freihofer --- meta/classes-recipe/kernel-fitimage.bbclass | 5 ++--- meta/classes-recipe/kernel-uboot.bbclass | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass index 67c98adb232..02b5fd8e3f5 100644 --- a/meta/classes-recipe/kernel-fitimage.bbclass +++ b/meta/classes-recipe/kernel-fitimage.bbclass @@ -579,9 +579,7 @@ fitimage_assemble() { # Step 1: Prepare a kernel image section. # fitimage_emit_section_maint $1 imagestart - - uboot_prep_kimage - fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp" + fitimage_emit_section_kernel $1 $kernelcount linux.bin "$(cat linux.comp)" # # Step 2: Prepare a DTB image section @@ -764,6 +762,7 @@ fitimage_assemble() { do_assemble_fitimage() { if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then cd ${B} + uboot_prep_kimage fitimage_assemble fit-image.its fitImage-none "" if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then ln -sf fitImage-none ${B}/${KERNEL_OUTPUT_DIR}/fitImage diff --git a/meta/classes-recipe/kernel-uboot.bbclass b/meta/classes-recipe/kernel-uboot.bbclass index 30a85ccc287..50be7962d46 100644 --- a/meta/classes-recipe/kernel-uboot.bbclass +++ b/meta/classes-recipe/kernel-uboot.bbclass @@ -45,5 +45,6 @@ uboot_prep_kimage() { mv -f "linux.bin${linux_suffix}" linux.bin fi + [ -n "${vmlinux_path}" ] && echo "${linux_comp}" > linux.comp echo "${linux_comp}" } From patchwork Mon Aug 12 21:12:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 47709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5E99C531DD for ; Mon, 12 Aug 2024 21:15:07 +0000 (UTC) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by mx.groups.io with SMTP id smtpd.web10.57872.1723497302706416282 for ; Mon, 12 Aug 2024 14:15:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jV+EF5wg; spf=pass (domain: gmail.com, ip: 209.85.167.47, mailfrom: adrian.freihofer@gmail.com) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5314c6dbaa5so3959163e87.2 for ; Mon, 12 Aug 2024 14:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723497300; x=1724102100; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6ladx8L9nqOXtaOZBWO7bu+2AnNG4HnjVyFfCcSGOdI=; b=jV+EF5wgLHDXIsqCRyX65HsILdwKBQg7uPNOeCHlbikPZsj2ABWgMJXVAq+CLsfPOY liHZOKfiRM+zKcG6nSCOuoR9+UxtOBbwl2k31X81mwLMEzOo7ZEb46DyM9I28/uud4MF ELLrGP0fl0p4rvcUmHHdiCZp5vNO4AMZTy7YT62b9itegFy/SUaKr7GP3g8cj1PMM3o/ jRzVxVPK6+5SyI7/HP4cu/hb0TAPSD/Qq4r5Nd0XVxKA16THyS1EIfmC/NuNNLJk5Apo g3+j5f8pPWvCtO6LJrynJEFfFJ2TKG+Ko3Kch5ZvXFUnnKbSmiIW63MRkvVt8nIKLLQJ rbNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723497300; x=1724102100; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6ladx8L9nqOXtaOZBWO7bu+2AnNG4HnjVyFfCcSGOdI=; b=vNd3Q9GY/rvBI1fh3RGk9xNN78KzKC4oBMFY0ypS76Yps1y9Im4lDq5ICwzzCNSzqS Tcv9rBsjpDlrBBaZrb+/+Wi/6at6r3JHeELnW34unmXwEfRITjIGPOKsqQYgqQs1+2m3 9OVa2bxpj1Xgt+QJOCsNQl8xMESD0KjiBXfmNhzk8DuLXAveHqOLxkhopHBiGhv9x3ZU glBecC8bWtyETw7nspdkYzajiGn0Wu0rcr6ZgWg7VuO3WtNvYUPvb2Zt+6XjxkkTfXTV Y+Hjd2KSEUJ+dtRWL2wVB71szjYNK6Z+uyeKsQcVDukW11oBnS37QAteC8Bj91MtNJZ1 wcow== X-Gm-Message-State: AOJu0YyiUj+hXT3maU+2qcrXpOv52IL9htZlRlAgU+PA1DXczN9XvXy2 AeP9xC1cx38waMEL8YTVYlw4lAITaNnEK1RwiOboXpEaGDTUdr7LxDXv5Q== X-Google-Smtp-Source: AGHT+IEF9P6am4u0ranQTIzLgLr+DyOxnfXvA7d2xQX/Y5pqiQ77mQYvsWgVRlERRMIdczPSMzuVwg== X-Received: by 2002:a05:6512:1296:b0:52c:d819:517e with SMTP id 2adb3069b0e04-53213659efemr911653e87.30.1723497300203; Mon, 12 Aug 2024 14:15:00 -0700 (PDT) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f3fb069dsm10828366b.80.2024.08.12.14.14.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 14:14:59 -0700 (PDT) From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 2/4] kernel-fitimage: refactor fitimage_assemble Date: Mon, 12 Aug 2024 23:12:55 +0200 Message-ID: <20240812211437.2736977-3-adrian.freihofer@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240812211437.2736977-1-adrian.freihofer@gmail.com> References: <20240812211437.2736977-1-adrian.freihofer@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 12 Aug 2024 21:15:07 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/203237 From: Adrian Freihofer Make the fitimage_assemble function usable with absolute paths for the generated its and the fitImage file. Later on this will allow to take the linux.bin and the DTB files from the sstated deploy derectory and write the generated files to a separate folder with independent sstate-cache handling. Signed-off-by: Adrian Freihofer --- meta/classes-recipe/kernel-fitimage.bbclass | 32 +++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass index 02b5fd8e3f5..705b3ab657f 100644 --- a/meta/classes-recipe/kernel-fitimage.bbclass +++ b/meta/classes-recipe/kernel-fitimage.bbclass @@ -169,8 +169,9 @@ fitimage_emit_section_kernel() { ENTRYPOINT="${UBOOT_ENTRYPOINT}" if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then + kernel_base=$(basename $3) ENTRYPOINT=`${HOST_PREFIX}nm vmlinux | \ - awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'` + awk '$kernel_base=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'` fi cat << EOF >> $1 @@ -567,7 +568,7 @@ fitimage_assemble() { setupcount="" bootscr_id="" default_dtb_image="" - rm -f $1 arch/${ARCH}/boot/$2 + rm -f "$1" "arch/${ARCH}/boot/$(basename $2)" if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then bbfatal "Keys used to sign images and configuration nodes must be different." @@ -608,6 +609,17 @@ fitimage_assemble() { DTB=`basename $DTB` fi + # Find DTBs without sub-folders when running in deploy folder + if [ ! -e "$DTB_PATH" ]; then + DTB=$(basename $DTB) + DTB_PATH=$(readlink -f $DTB) + fi + + # Fail as early as possible if there is still no DTB file found + if [ ! -e "$DTB_PATH" ]; then + bberror "Cannot find the DTB file at $DTB_PATH" + fi + # Set the default dtb image if it exists in the devicetree. if [ "${FIT_CONF_DEFAULT_DTB}" = "$DTB" ];then default_dtb_image=$(echo "$DTB" | tr '/' '_') @@ -658,9 +670,8 @@ fitimage_assemble() { if [ -n "${UBOOT_ENV}" ] && [ -d "${STAGING_DIR_HOST}/boot" ]; then if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then - cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B} bootscr_id="${UBOOT_ENV_BINARY}" - fitimage_emit_section_boot_script $1 "$bootscr_id" ${UBOOT_ENV_BINARY} + fitimage_emit_section_boot_script $1 "$bootscr_id" "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" else bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found." fi @@ -669,9 +680,14 @@ fitimage_assemble() { # # Step 4: Prepare a setup section. (For x86) # + # Run from kernel build folder (bundled mode) if [ -e ${KERNEL_OUTPUT_DIR}/setup.bin ]; then setupcount=1 fitimage_emit_section_setup $1 $setupcount ${KERNEL_OUTPUT_DIR}/setup.bin + # Run from deploy folder (unbundled mode) + elif [ -e setup.bin ]; then + setupcount=1 + fitimage_emit_section_setup $1 $setupcount "$(readlink -f setup.bin)" fi # @@ -744,8 +760,8 @@ fitimage_assemble() { # ${UBOOT_MKIMAGE} \ ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ - -f $1 \ - ${KERNEL_OUTPUT_DIR}/$2 + -f "$1" \ + "$2" # # Step 8: Sign the image @@ -754,7 +770,7 @@ fitimage_assemble() { ${UBOOT_MKIMAGE_SIGN} \ ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ -F -k "${UBOOT_SIGN_KEYDIR}" \ - -r ${KERNEL_OUTPUT_DIR}/$2 \ + -r "$2" \ ${UBOOT_MKIMAGE_SIGN_ARGS} fi } @@ -763,7 +779,7 @@ do_assemble_fitimage() { if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then cd ${B} uboot_prep_kimage - fitimage_assemble fit-image.its fitImage-none "" + fitimage_assemble fit-image.its ${KERNEL_OUTPUT_DIR}/fitImage-none "" if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then ln -sf fitImage-none ${B}/${KERNEL_OUTPUT_DIR}/fitImage fi From patchwork Mon Aug 12 21:12:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 47708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E07AEC3DA7F for ; Mon, 12 Aug 2024 21:15:07 +0000 (UTC) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by mx.groups.io with SMTP id smtpd.web10.57873.1723497303486849460 for ; Mon, 12 Aug 2024 14:15:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=njQjrcw2; spf=pass (domain: gmail.com, ip: 209.85.167.46, mailfrom: adrian.freihofer@gmail.com) Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-52efdf02d13so8162311e87.2 for ; Mon, 12 Aug 2024 14:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723497301; x=1724102101; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gM/2royk0+DJpgWF11nXfcfYnBj/DcoSqF4xiIBxJEI=; b=njQjrcw2hO/NCjSAiEE8pAZHEZGfE9R/Pvhffg7LYpOMn4WqkR1G1ybKopFPKuv232 jNaMpMmhKhwfPyGSHCfq+utBD+a3hnbvVgCH/bFEwXQeCF1cJxa6biwBIWlWDc+qqQJg KiP0cfNFWcDwok5REX+9lJHBnG9VsMhlwUvB4TqRUebT+44T7CBJbvDjnTEsNvSwLBdJ FhvapnfApxtaOyIwqQ/GD+KLAyyhn1YKbo4TO0hJSowlTi/qNVUrGwv7x+wL6UrKnPjk 3nJrMWTZkilp2myt6naIiifWtfEroHmcSSvaE4g5fTBrBrbIGj7m2X/V5SRDMZgLEmtb c5mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723497301; x=1724102101; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gM/2royk0+DJpgWF11nXfcfYnBj/DcoSqF4xiIBxJEI=; b=osgWCC0XzXy65O0s7uyfoe/ixvnV12l2HyX48k7Rp/aOmUBVPpdUPdijZp1BsAXEB7 QF+hC0scsi3/Q/KFJvIaZietlkfvQAucG+VUDQmAQ4vHWyZ7ZlNYy0XxqkrktEHVnyhc MtIJg6FWMEpOEXqh7wniV3n9i9D7DlgE+J//tF+DFO91dBbhrMO+hF/eFdalelHifeYs qNTzp4Zt0YG1n8XcaXUMU6oshxlSCHYztz5hnqAjMkIlcantjEmglAQEmtF9Ltx6Dis5 eUWCsbLbOanBIGghCPiIPJFTg7tpKRdvIZEXqBk71qGaAxkpnnQh6kdeMUrGQ3yp5F6R YyXw== X-Gm-Message-State: AOJu0Yxo/Ox2v4uBGv09Moj0RqvQSTW+VmJHEJ+LagpDeh+YKUi3ni17 PGyDlBMiT8NIhKfK4EeVhgXQFqbF045kmmWTKqepx+4nohe47PtVHuFSUA== X-Google-Smtp-Source: AGHT+IFpukN/OLjDXXf52ObVo9n8sgPQicV2bzJW6Tc+QKykOEsiLzcACO32viOKPzDpsMMDg0qxDA== X-Received: by 2002:a05:6512:230c:b0:52c:dd94:bda9 with SMTP id 2adb3069b0e04-53213692e16mr1021657e87.56.1723497300965; Mon, 12 Aug 2024 14:15:00 -0700 (PDT) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f3fb069dsm10828366b.80.2024.08.12.14.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 14:15:00 -0700 (PDT) From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 3/4] kernel: refactor fitimage Date: Mon, 12 Aug 2024 23:12:56 +0200 Message-ID: <20240812211437.2736977-4-adrian.freihofer@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240812211437.2736977-1-adrian.freihofer@gmail.com> References: <20240812211437.2736977-1-adrian.freihofer@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 12 Aug 2024 21:15:07 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/203238 From: Adrian Freihofer * do_bundle_initramfs only when needed With INITRAMFS_IMAGE_BUNDLE = "1" the kernel Makefile is used to bundle the kernel binary and the initramfs. This works only when the build folder of the kernel is available. Building with sstate but with an empty TMPDIR requires to rebuild the kernel from scratch whenever something in the initramfs changes. With INITRAMFS_IMAGE_BUNDLE = "" the fitImage generation is basically independent from the kernel Makefile and could therefore work with kernel binaries and tools provided by the sstate. But the dependency on the do_bundle_initramfs tasks does not allow this. However, if the INTIRAMFS_IMAGE is set but the INITRAMFS_IMAGE_BUNDLE is set to 0 the do_bundle_initramfs does nothing. There is no real argument for running this tasks. As a first step towards getting the kernel from sstate when building an unbundled fitImage, the task dependencies need to be simplified. The do_bundle_initramfs task is now scheduled only when needed. Removing the do_bundle_initramfs also removes these task dependencies do_deploy --> do_bundle_initramfs --> do_install. But the dependency do_deploy --> do_install must be kept because the do_deploy task needs the build folder when deploying the kernel artifacts. Therefore the do_install depedency is added. There is also a dependendency like do_deploy --> do_populate_sysroot --> do_install. However since the do_populate_sysroot task is sstate cached, the build folder is not available for the do_deploy task if the do_populate_sysroot setscene tasks runs. * If KERNEL_IMAGETYPES does not contain fitImage and INITRAMFS_IMAGE is not set, the do_assemble_fitimage_initramfs ends up as an empty task. Add the do_assemble_fitimage_initramfs only if a fitImage with initramfs needs to be built. * cd in bitbake task is easy to break e.g. by bbappend. Replace the cd by defining the task's dirs variable flag. * Add 3 comments which are helpful for the next commits. * Since the tasks and task dependencies are anyway created by an anonymous function, align and make the DEPENDS code more specific too. This refactoring is not very valuable on its own. But it simplifies the task dependencies which is helpful for the next commit. Signed-off-by: Adrian Freihofer --- meta/classes-recipe/kernel-fitimage.bbclass | 57 ++++++++++++--------- meta/classes-recipe/kernel.bbclass | 29 ++++++----- 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass index 705b3ab657f..2dda5aec056 100644 --- a/meta/classes-recipe/kernel-fitimage.bbclass +++ b/meta/classes-recipe/kernel-fitimage.bbclass @@ -26,20 +26,8 @@ def get_fit_replacement_type(d): return replacementtype KERNEL_IMAGETYPE_REPLACEMENT ?= "${@get_fit_replacement_type(d)}" -DEPENDS:append = " ${@'u-boot-tools-native dtc-native' if 'fitImage' in (d.getVar('KERNEL_IMAGETYPES') or '').split() else ''}" python __anonymous () { - # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal - # to kernel.bbclass . We have to override it, since we pack zImage - # (at least for now) into the fitImage . - typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE") or "" - if 'fitImage' in typeformake.split(): - d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('fitImage', d.getVar('KERNEL_IMAGETYPE_REPLACEMENT'))) - - image = d.getVar('INITRAMFS_IMAGE') - if image: - d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') - ubootenv = d.getVar('UBOOT_ENV') if ubootenv: d.appendVarFlag('do_assemble_fitimage', 'depends', ' virtual/bootloader:do_populate_sysroot') @@ -48,8 +36,31 @@ python __anonymous () { providerdtb = d.getVar("PREFERRED_PROVIDER_virtual/dtb") if providerdtb: d.appendVarFlag('do_assemble_fitimage', 'depends', ' virtual/dtb:do_populate_sysroot') - d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' virtual/dtb:do_populate_sysroot') d.setVar('EXTERNAL_KERNEL_DEVICETREE', "${RECIPE_SYSROOT}/boot/devicetree") + + typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE") or "" + if 'fitImage' in typeformake.split(): + # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal + # to kernel.bbclass . We have to override it, since we pack zImage + # (at least for now) into the fitImage . + d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('fitImage', d.getVar('KERNEL_IMAGETYPE_REPLACEMENT'))) + + # mkimage and dtc are required by the fitimage_assemble function + d.appendVarFlag('do_assemble_fitimage', 'depends', + ' u-boot-tools-native:do_populate_sysroot dtc-native:do_populate_sysroot') + + initramfs_image = d.getVar('INITRAMFS_IMAGE') + bundled = bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')) + if initramfs_image: + if bundled: + bb.build.addtask('do_assemble_fitimage_initramfs', 'do_deploy', 'do_bundle_initramfs', d) + else: + bb.build.addtask('do_assemble_fitimage_initramfs', 'do_deploy', 'do_install', d) + + d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', + ' u-boot-tools-native:do_populate_sysroot dtc-native:do_populate_sysroot ${INITRAMFS_IMAGE}:do_image_complete') + if providerdtb: + d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' virtual/dtb:do_populate_sysroot') } @@ -797,19 +808,14 @@ do_install:append() { } do_assemble_fitimage_initramfs() { - if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage" && \ - test -n "${INITRAMFS_IMAGE}" ; then - cd ${B} - if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then - fitimage_assemble fit-image-${INITRAMFS_IMAGE}.its fitImage-bundle "" - ln -sf fitImage-bundle ${B}/${KERNEL_OUTPUT_DIR}/fitImage - else - fitimage_assemble fit-image-${INITRAMFS_IMAGE}.its fitImage-${INITRAMFS_IMAGE} 1 - fi + if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then + fitimage_assemble "fit-image-${INITRAMFS_IMAGE}.its" "${KERNEL_OUTPUT_DIR}/fitImage-bundle" "" + ln -sf fitImage-bundle "${B}/${KERNEL_OUTPUT_DIR}/fitImage" + else + fitimage_assemble "fit-image-${INITRAMFS_IMAGE}.its" "${KERNEL_OUTPUT_DIR}/fitImage-${INITRAMFS_IMAGE}" 1 fi } - -addtask assemble_fitimage_initramfs before do_deploy after do_bundle_initramfs +do_assemble_fitimage_initramfs[dirs] = "${B}" do_kernel_generate_rsa_keys() { if [ "${UBOOT_SIGN_ENABLE}" = "0" ] && [ "${FIT_GENERATE_KEYS}" = "1" ]; then @@ -864,6 +870,7 @@ kernel_do_deploy:append() { if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then + # deploy the artifacts of do_assemble_fitimage bbnote "Copying fit-image.its source file..." install -m 0644 ${B}/fit-image.its "$deployDir/fitImage-its-${KERNEL_FIT_NAME}.its" if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then @@ -878,12 +885,14 @@ kernel_do_deploy:append() { fi if [ -n "${INITRAMFS_IMAGE}" ]; then + # deploy the artifacts of do_assemble_fitimage_initramfs for bundled as well as un-bundled mode bbnote "Copying fit-image-${INITRAMFS_IMAGE}.its source file..." install -m 0644 ${B}/fit-image-${INITRAMFS_IMAGE}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its" if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then ln -snf fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}" fi + # deploy the artifacts of do_assemble_fitimage_initramfs for bundled mode only if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then bbnote "Copying fitImage-${INITRAMFS_IMAGE} file..." install -m 0644 ${B}/${KERNEL_OUTPUT_DIR}/fitImage-${INITRAMFS_IMAGE} "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT}" diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass index 4464155b730..217f42b4f4f 100644 --- a/meta/classes-recipe/kernel.bbclass +++ b/meta/classes-recipe/kernel.bbclass @@ -139,18 +139,23 @@ fi set -e """ % (type, type, type)) - image = d.getVar('INITRAMFS_IMAGE') - # If the INTIRAMFS_IMAGE is set but the INITRAMFS_IMAGE_BUNDLE is set to 0, - # the do_bundle_initramfs does nothing, but the INITRAMFS_IMAGE is built - # standalone for use by wic and other tools. if image: - if d.getVar('INITRAMFS_MULTICONFIG'): - d.appendVarFlag('do_bundle_initramfs', 'mcdepends', ' mc::${INITRAMFS_MULTICONFIG}:${INITRAMFS_IMAGE}:do_image_complete') + # If the INTIRAMFS_IMAGE is set but the INITRAMFS_IMAGE_BUNDLE is set to 0, + # the do_bundle_initramfs is not needed, but the INITRAMFS_IMAGE is built + # standalone for use by wic and other tools. + def add_initramfs_dep_task(initramfs_dep_task, d): + if d.getVar('INITRAMFS_MULTICONFIG'): + d.appendVarFlag(initramfs_dep_task, 'mcdepends', ' mc::${INITRAMFS_MULTICONFIG}:${INITRAMFS_IMAGE}:do_image_complete') + else: + d.appendVarFlag(initramfs_dep_task, 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') + + if bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')): + bb.build.addtask('do_bundle_initramfs', 'do_deploy', 'do_install', d) + add_initramfs_dep_task('do_bundle_initramfs', d) + bb.build.addtask('do_transform_bundled_initramfs', 'do_deploy', 'do_bundle_initramfs', d) else: - d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') - if image and bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')): - bb.build.addtask('do_transform_bundled_initramfs', 'do_deploy', 'do_bundle_initramfs', d) + add_initramfs_dep_task('do_deploy', d) # NOTE: setting INITRAMFS_TASK is for backward compatibility # The preferred method is to set INITRAMFS_IMAGE, because @@ -330,6 +335,8 @@ do_bundle_initramfs () { mv -f ${KERNEL_OUTPUT_DIR}/$imageType.bak ${KERNEL_OUTPUT_DIR}/$imageType fi done + else + bbwarn "Calling do_bundle_initramfs with INITRAMFS_IMAGE_BUNDLE=1 is deprecated" fi } do_bundle_initramfs[dirs] = "${B}" @@ -350,8 +357,6 @@ python do_devshell:prepend () { os.environ["LDFLAGS"] = '' } -addtask bundle_initramfs after do_install before do_deploy - KERNEL_DEBUG_TIMESTAMPS ??= "0" kernel_do_compile() { @@ -873,7 +878,7 @@ kernel_do_deploy() { # ensure we get the right values for both do_deploy[prefuncs] += "read_subpackage_metadata" -addtask deploy after do_populate_sysroot do_packagedata +addtask deploy after do_install do_populate_sysroot do_packagedata EXPORT_FUNCTIONS do_deploy From patchwork Mon Aug 12 21:12:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 47710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0889DC52D7F for ; Mon, 12 Aug 2024 21:15:08 +0000 (UTC) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by mx.groups.io with SMTP id smtpd.web11.57825.1723497304259117747 for ; Mon, 12 Aug 2024 14:15:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KHY6uRsJ; spf=pass (domain: gmail.com, ip: 209.85.167.51, mailfrom: adrian.freihofer@gmail.com) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-52f0277daa5so6595724e87.0 for ; Mon, 12 Aug 2024 14:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723497302; x=1724102102; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9AWnEbStua4FzcY211D78tYTDqjXKLyXl5XUmtGWtIM=; b=KHY6uRsJsQihaqEyc2eKJLmVzdbCWTdQX8Ft6YrEd/azAHLrTQ7KzaFHfwYrPQGgOB 4gdlYtrtIaRn/TJdZgLULBsHJgmAlv3LUkICua+KrNPhW/bteGZHCKsQmuw9gzfwjoKD YszRHqQo3fG9wUrxqI8A+jgT1h4hOLvQjVTSCo9AHotf7v+inN1+cwpbaD7ovx6/x6xR WpsxxZS36G+epS6b+9wxSbtTLWVdUWozVDKM+emp8jnCS/pIExV7ULoT2D62bue3wVfr is+Hdt8AvTyfn3aMzJM8AUX+/xj4F4cARRInFSE3pWAwnCKL+SKgCCUuoirJ+oP6RdgH kmIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723497302; x=1724102102; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9AWnEbStua4FzcY211D78tYTDqjXKLyXl5XUmtGWtIM=; b=s+XpDr4y+90LdFC5//BHU+dTqxep0iDr3EC7RA4xC/WMghk7Yr9Yi/iAUU+xyd6Mya nMWCju/NP1HqC4xk1oZfG9nfsBlkvqikX204R4BFXoJboMvHhZAonSr5i5lOWtbrQTic iXPJdo7EQALqxcKVq4GQcrVb5aIXla13TzWt4KDonLMNvHcYt5jiqsAtn+3ZQOh/TO9b kjaqxjSCWOyGftOoNXnPxBUs6JAq6bIhvtpZ/gKh6Rjw2Gby4s2dmpJ2VPP0efL/jWEX 8r0HGHm4tpYHgTEpwedVD5AZ9OUV8Oy4fUUobtJoJ6Hk2z2InH2BqDFq5TVIxfKvJgF1 1FLw== X-Gm-Message-State: AOJu0Yy+G8fa1N9ZkgPiIlwwiUvBDq+fcCN819/cbO3hhl7Cu6uMr7hf 6FLvOAX3zb1cvfD9u/Uk+dvo09qOaq2JxJltClHzsnmoCuYoBWOJQp7H2A== X-Google-Smtp-Source: AGHT+IEcxuzNyrk5CyCnBiN3ul8XXNOF2TI1AFzXN8r1paVYjS11O0EQD1spv2/N7ht4OWAKS+cnAQ== X-Received: by 2002:a05:6512:10c7:b0:51a:f689:b4df with SMTP id 2adb3069b0e04-53213684382mr1028044e87.44.1723497301682; Mon, 12 Aug 2024 14:15:01 -0700 (PDT) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f3fb069dsm10828366b.80.2024.08.12.14.15.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 14:15:01 -0700 (PDT) From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 4/4] kernel-fitimage: run unbundled fitimage after deploy Date: Mon, 12 Aug 2024 23:12:57 +0200 Message-ID: <20240812211437.2736977-5-adrian.freihofer@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240812211437.2736977-1-adrian.freihofer@gmail.com> References: <20240812211437.2736977-1-adrian.freihofer@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 12 Aug 2024 21:15:08 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/203239 From: Adrian Freihofer Without this change, the kernel is always rebuilt if something changes in the initramfs. If the kernel is rebuilt with an empty TMPDIR, the process starts by fetching the large kernel git repository and recompiling it from scratch. This is very inefficient. This cannot be improved if INITRAMFS_IMAGE_BUNDLE = "1". If the kernel Makefile is needed to generate the initramfs bundle the kernel build folder is required. For this cases nothing changes. But for a build configuration with INITRAMFS_IMAGE_BUNDLE = "" the build folder is not needed. Creating the initramfs bundle requires: linux.bin, DTBs and the initramfs. These artifacts are all available in the deploy folder which is also sstate cached. Therefore do_assemble_fitimage_initramfs gets split into two tasks: - do_assemble_fitimage_initramfs creates the bundled fitImage which runs before do_deploy. This is without sstate and therefore the do_deploy task still deploys the artifacts generated by this task. - do_deploy_fitimage_unbundled creates the fitImage in unbundled mode. This task runs after do_deploy. It uses the linux.bin artifact from do_deploy to create the fitImage with initramfs. This task is done with SSTATE_SKIP_CREATION, because this also works with the eSDK installer (oe-selftest -r esdk is successful). It is also more effective to quickly create the fit image instead of handling it via sstate. Unfortunately, this change is not 100% backward compatible. Previously, a dependency on do_deploy deployed all types of fit images. With this change, deploying the unbundled fit image requires a dependency on do_deploy_fitimage_unbundled. To address this the image.bbclass gets improved to handle both cases with the KERNEL_DEPLOY_DEPEND variable. Signed-off-by: Adrian Freihofer --- meta/classes-recipe/image.bbclass | 12 ++- meta/classes-recipe/kernel-fitimage.bbclass | 86 +++++++++++++-------- meta/classes-recipe/kernel.bbclass | 3 +- 3 files changed, 67 insertions(+), 34 deletions(-) diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass index 32bafcdbbc3..f5754fb6fd9 100644 --- a/meta/classes-recipe/image.bbclass +++ b/meta/classes-recipe/image.bbclass @@ -147,7 +147,17 @@ do_rootfs[vardeps] += "${@rootfs_variables(d)}" # This follows many common usecases and user expectations. # But if you are building an image which doesn't need the kernel image at all, # you can unset this variable manually. -KERNEL_DEPLOY_DEPEND ?= "virtual/kernel:do_deploy" +def get_kernel_do_deploy(d): + kerneltypes = d.getVar('KERNEL_IMAGETYPES') or "" + kerneltype = d.getVar('KERNEL_IMAGETYPE') or "" + fitimage = kerneltype == 'fitImage' or 'fitImage' in kerneltypes.split() + initramfs_image = d.getVar('INITRAMFS_IMAGE') or "" + bundled = d.getVar('INITRAMFS_IMAGE_BUNDLE') == '1' + if fitimage and initramfs_image and not bundled: + return "virtual/kernel:do_deploy_fitimage_unbundled" + return "virtual/kernel:do_deploy" + +KERNEL_DEPLOY_DEPEND ?= "${@get_kernel_do_deploy(d)}" do_build[depends] += "${KERNEL_DEPLOY_DEPEND}" diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass index 2dda5aec056..390d5ebcdbf 100644 --- a/meta/classes-recipe/kernel-fitimage.bbclass +++ b/meta/classes-recipe/kernel-fitimage.bbclass @@ -49,18 +49,28 @@ python __anonymous () { d.appendVarFlag('do_assemble_fitimage', 'depends', ' u-boot-tools-native:do_populate_sysroot dtc-native:do_populate_sysroot') + # A fitImage with the initramfs bundled in the kernel Image is deployed by do_deploy. + # In case of a build from an empty TMPDIR a clean kernel re-build is required just because creating the bundled + # kernel image requires the kernel Makefile and therefore the kernel's populated build directory. + # In case of an unbundled fitImage assembling the fitImage works independenly from the kernel build framework. + # This allow to take the kernel binary from the sstated deploy directory. But it requires to assemble the + # fitImage in a separate task (do_deploy_fitimage_unbundled) running after do_deploy. initramfs_image = d.getVar('INITRAMFS_IMAGE') bundled = bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')) if initramfs_image: if bundled: - bb.build.addtask('do_assemble_fitimage_initramfs', 'do_deploy', 'do_bundle_initramfs', d) + fit_assemble_task = 'do_assemble_fitimage_initramfs' + bb.build.addtask(fit_assemble_task, 'do_deploy', 'do_bundle_initramfs', d) else: - bb.build.addtask('do_assemble_fitimage_initramfs', 'do_deploy', 'do_install', d) + fit_assemble_task = 'do_deploy_fitimage_unbundled' + bb.build.addtask(fit_assemble_task, 'do_build', 'do_deploy', d) + bb.build.addtask(fit_assemble_task + '_setscene', '', '', d) + d.appendVar('SSTATETASKS', fit_assemble_task) - d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', + d.appendVarFlag(fit_assemble_task, 'depends', ' u-boot-tools-native:do_populate_sysroot dtc-native:do_populate_sysroot ${INITRAMFS_IMAGE}:do_image_complete') if providerdtb: - d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' virtual/dtb:do_populate_sysroot') + d.appendVarFlag(fit_assemble_task, 'depends', ' virtual/dtb:do_populate_sysroot') } @@ -579,7 +589,7 @@ fitimage_assemble() { setupcount="" bootscr_id="" default_dtb_image="" - rm -f "$1" "arch/${ARCH}/boot/$(basename $2)" + rm -f "$1" "$2" if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then bbfatal "Keys used to sign images and configuration nodes must be different." @@ -808,15 +818,30 @@ do_install:append() { } do_assemble_fitimage_initramfs() { - if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then - fitimage_assemble "fit-image-${INITRAMFS_IMAGE}.its" "${KERNEL_OUTPUT_DIR}/fitImage-bundle" "" - ln -sf fitImage-bundle "${B}/${KERNEL_OUTPUT_DIR}/fitImage" - else - fitimage_assemble "fit-image-${INITRAMFS_IMAGE}.its" "${KERNEL_OUTPUT_DIR}/fitImage-${INITRAMFS_IMAGE}" 1 - fi + fitimage_assemble "fit-image-${INITRAMFS_IMAGE}.its" "${KERNEL_OUTPUT_DIR}/fitImage-bundle" "" + ln -sf fitImage-bundle "${B}/${KERNEL_OUTPUT_DIR}/fitImage" } do_assemble_fitimage_initramfs[dirs] = "${B}" +do_deploy_fitimage_unbundled() { + fitimage_assemble "${DEPLOY_DIR_IMAGE}/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its"\ + "${DEPLOY_DIR_IMAGE}/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT}" 1 + if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then + ln -snf "fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT}" "${DEPLOY_DIR_IMAGE}/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}" + ln -snf fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its "${DEPLOY_DIR_IMAGE}/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}" + fi +} +DEPLOYDIR_FITIMAGE_UNBUNDLED = "${WORKDIR}/deploy-fitimage-unbundled-${PN}" +SSTATE_SKIP_CREATION:task-deploy-fitimage-unbundled = '1' +do_deploy_fitimage_unbundled[sstate-inputdirs] = "${DEPLOYDIR_FITIMAGE_UNBUNDLED}" +do_deploy_fitimage_unbundled[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" +python do_deploy_fitimage_unbundled_setscene () { + sstate_setscene(d) +} +do_deploy_fitimage_unbundled[dirs] = "${DEPLOY_DIR_IMAGE}" +do_deploy_fitimage_unbundled[cleandirs] = "${DEPLOYDIR_FITIMAGE_UNBUNDLED}" +do_deploy_fitimage_unbundled[stamp-extra-info] = "${MACHINE_ARCH}" + do_kernel_generate_rsa_keys() { if [ "${UBOOT_SIGN_ENABLE}" = "0" ] && [ "${FIT_GENERATE_KEYS}" = "1" ]; then bbwarn "FIT_GENERATE_KEYS is set to 1 even though UBOOT_SIGN_ENABLE is set to 0. The keys will not be generated as they won't be used." @@ -868,9 +893,24 @@ kernel_do_deploy[vardepsexclude] = "DATETIME" kernel_do_deploy:append() { # Update deploy directory if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then - - if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then - # deploy the artifacts of do_assemble_fitimage + if [ -n "${INITRAMFS_IMAGE}" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then + # do_deploy_fitimage_unbundled needs the linux.bin file for the unbundled fitImage deployment + bbnote "Deploying linux.bin and linux.comp file for do_deploy_fitimage_unbundled..." + uboot_prep_kimage + install -m 0644 ${B}/linux.bin $deployDir/linux.bin + install -m 0644 ${B}/linux.comp $deployDir/linux.comp + if [ -e "${B}/${KERNEL_OUTPUT_DIR}/setup.bin" ]; then + install -m 0644 "${B}/${KERNEL_OUTPUT_DIR}/setup.bin" "$deployDir/setup.bin" + fi + elif [ -n "${INITRAMFS_IMAGE}" ]; then + # deploy the artifacts created by do_assemble_fitimage_initramfs for bundled mode + bbnote "Copying fit-image-${INITRAMFS_IMAGE}.its source file..." + install -m 0644 ${B}/fit-image-${INITRAMFS_IMAGE}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its" + if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then + ln -snf fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}" + fi + else + # deploy the artifacts of do_assemble_fitimage (fitImage without initramfs) bbnote "Copying fit-image.its source file..." install -m 0644 ${B}/fit-image.its "$deployDir/fitImage-its-${KERNEL_FIT_NAME}.its" if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then @@ -883,23 +923,5 @@ kernel_do_deploy:append() { ln -snf fitImage-linux.bin-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT} "$deployDir/fitImage-linux.bin-${KERNEL_FIT_LINK_NAME}" fi fi - - if [ -n "${INITRAMFS_IMAGE}" ]; then - # deploy the artifacts of do_assemble_fitimage_initramfs for bundled as well as un-bundled mode - bbnote "Copying fit-image-${INITRAMFS_IMAGE}.its source file..." - install -m 0644 ${B}/fit-image-${INITRAMFS_IMAGE}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its" - if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then - ln -snf fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}" - fi - - # deploy the artifacts of do_assemble_fitimage_initramfs for bundled mode only - if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then - bbnote "Copying fitImage-${INITRAMFS_IMAGE} file..." - install -m 0644 ${B}/${KERNEL_OUTPUT_DIR}/fitImage-${INITRAMFS_IMAGE} "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT}" - if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then - ln -snf fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT} "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}" - fi - fi - fi fi } diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass index 217f42b4f4f..9c125ff0731 100644 --- a/meta/classes-recipe/kernel.bbclass +++ b/meta/classes-recipe/kernel.bbclass @@ -490,7 +490,8 @@ kernel_do_install() { # So, at the level of the install task we should not try to install the fitImage. fitImage is still not # generated yet. # After the generation of the fitImage, the deploy task copies the fitImage from the build directory to - # the deploy folder. + # the deploy folder. If INITRAMFS_IMAGE_BUNDLE != 1 the fitImage with initramfs is deployed after the + # deploy task. # for imageType in ${KERNEL_IMAGETYPES} ; do