From patchwork Thu Feb 6 22:56:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 56824 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 244D0C02194 for ; Thu, 6 Feb 2025 22:57:28 +0000 (UTC) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mx.groups.io with SMTP id smtpd.web11.56263.1738882637877900264 for ; Thu, 06 Feb 2025 14:57:18 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mVq9jFbQ; spf=pass (domain: gmail.com, ip: 209.85.128.52, mailfrom: adrian.freihofer@gmail.com) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-436ce2ab251so9625855e9.1 for ; Thu, 06 Feb 2025 14:57:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738882636; x=1739487436; 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=64Z6q2cKPGaNbZmPQNjbqmPD1L2TZj6R8px/bcYV8dM=; b=mVq9jFbQ45RixTymmQNDofLN+YOIwnEzvIfz634zOXR9DZJlKiVhnuTb/RnwzUeG2t vsERgZqhFALF0W5zpITFEyrPu8LPrR8drlR4Qn+ANBAZEJpghcfqYzFdUHg/KAnOKpoU CBZdQnKuIU3/WiNu8Opt5QYSsDwlVvqjsNyyeLP+DDARvhviu2xu+kmF4OAwPxDfSXj7 i8ecPjAPMqPLHwbk3LINI7B3bi6eyF91JMD5aT9vEPl8o4PCsSggZsv0ZXyHOAXlWV2u 4Cv+4+jT7+6sCdK55aUAFD6BVdNOIgudHHfrbpGPRyydbl2sowoXLDtlfzXHxoQavyGO UB1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738882636; x=1739487436; 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=64Z6q2cKPGaNbZmPQNjbqmPD1L2TZj6R8px/bcYV8dM=; b=wql9rTqc4/f7fN0yQDNwqcSm6p/RZ2R06CHqRpemekLFutQQc9ev0TSthC6sXNpwfY nRjIt3DaL7X5ngvadtQU7smIlDTMDu8xT+kLiiu8qDgfn8xJ9fhv8ir0OAmXpIOXjNR0 VtGTnJzfwnmPQm6et3V26goFG+/FCc6qLG11TDiFJq7Vp80h9CXpGm9GcMyDJEGaG1jF zMh7eQSI9s4P+RPAuW3kSKsKpd4xq0CYUswMBMV+sajqH6IGV4bUfa7jcIQKgkAeQbaD kCVLqbUqdK/SHDuWQSw2tzhiIZIyp/mEABiybPhbokqyXQ1CMRDU5K6EarkEdo2q3blQ namA== X-Gm-Message-State: AOJu0YyhRKhuuNMly6JPRAYd1euDMcjAokYQSoodQkkDEvFAlEL5BRYS x3DUvN878MM7Qy9gq9rt6nFDIutCJGQ4nZO8KZvETOgGkf5AowcWWya3BQ== X-Gm-Gg: ASbGncvoJL6bDHOm4BR1c+Un5W6Rt/joz+IgD0lB4rzDoGHr8V+pen3mxZ49h8KaP2R 9/YDT1wFEHqcDWPLoR23pKvddfdC682BsSq2kPCFVIh4CMtS9AcTHhBEEL8JoFvKbhyWSfLD1Up 2X0BJvJmVb7INcoRycjxMPOhv1XFLBABBRF0ecJM7H8ZFYK6QwD95G5/Vx5F+38l1Rl8SqFzuFD OFtbG0MRYn0vTsHzPuIl/p2wvBPZOWV7tlmtjweuvWwzViIeRrYKlo9MYJq763VYYnZgKQHE3H7 1t49HkVQk+Iu7QUYoS8gQ12hRmZPQyEkJM3WJg== X-Google-Smtp-Source: AGHT+IHfqv6A3pCwTJrfNYM8xyxVFJwHUBCy/10ZEpZmB0ff3Dfp8OpjBeElCXAlv4SA3/PaAHVluw== X-Received: by 2002:a05:600c:1549:b0:434:f0df:a14 with SMTP id 5b1f17b1804b1-4392496ec4amr9455555e9.2.1738882635710; Thu, 06 Feb 2025 14:57:15 -0800 (PST) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390d896d70sm68737535e9.0.2025.02.06.14.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 14:57:14 -0800 (PST) From: Adrian Freihofer X-Google-Original-From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 1/4] kernel-fitimage.bbclass: introduce FIT_UBOOT_ENV Date: Thu, 6 Feb 2025 23:56:04 +0100 Message-ID: <20250206225654.1660760-2-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250206225654.1660760-1-adrian.freihofer@siemens.com> References: <20250206225654.1660760-1-adrian.freihofer@siemens.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 ; Thu, 06 Feb 2025 22:57:28 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/210963 Introduce a new variable FIT_UBOOT_ENV, which allows to add a u-boot script as a text file to the fitImage. Such a script can be sourced from the u-boot shell, as documented here: https://docs.u-boot.org/en/latest/usage/cmd/source.html#fit-image The kernel-fitimage.bbclass also evaluates the existing UBOOT_ENV variable and adds the corresponding script to the fitImage. However, the UBOOT_ENV variable is also used to install the script as an old u-boot image, usually named boot.scr into the /boot directory of the target device. These are different use cases which should be handled independently. Appending the script to the u-boot recipe and then hand it over to the kernel recipe via the staged /boot directory leads to complicated task dependencies. Decoupling the two use cases will also allow to simplify the implementation by dropping the evaluation of the UBOOT_ENV variable in the kernel-fitimage.bbclass. But this commit is supposed to be backward compatible. Signed-off-by: Adrian Freihofer --- meta/classes-recipe/kernel-fitimage.bbclass | 5 +++++ meta/conf/image-fitimage.conf | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass index fe076badfa5..bd2e371b63a 100644 --- a/meta/classes-recipe/kernel-fitimage.bbclass +++ b/meta/classes-recipe/kernel-fitimage.bbclass @@ -616,6 +616,11 @@ fitimage_assemble() { bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found." fi fi + if [ -n "${FIT_UBOOT_ENV}" ]; then + cp ${UNPACKDIR}/${FIT_UBOOT_ENV} ${B} + bootscr_id="${FIT_UBOOT_ENV}" + fitimage_emit_section_boot_script $1 "$bootscr_id" ${FIT_UBOOT_ENV} + fi # # Step 4: Prepare a setup section. (For x86) diff --git a/meta/conf/image-fitimage.conf b/meta/conf/image-fitimage.conf index be9ae301346..9be7e452384 100644 --- a/meta/conf/image-fitimage.conf +++ b/meta/conf/image-fitimage.conf @@ -51,3 +51,10 @@ FIT_ADDRESS_CELLS ?= "1" # Then the images signature checking will not be mandatory and no error will be # raised in case of failure. # UBOOT_SIGN_IMG_KEYNAME = "dev2" # keys name in keydir (eg. "dev2.crt", "dev2.key") + +# Additional environment variables or a script which can be sourced by u-boot +# can be packaged into the fitImage. An example is documented here: +# https://docs.u-boot.org/en/latest/usage/cmd/source.html#fit-image +# Machine configurations needing such a script file should include it in the +# SRC_URI of the kernel recipe and set the FIT_UBOOT_ENV parameter. +FIT_UBOOT_ENV ?= "" From patchwork Thu Feb 6 22:56:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 56823 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 25AC7C02196 for ; Thu, 6 Feb 2025 22:57:28 +0000 (UTC) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mx.groups.io with SMTP id smtpd.web10.55905.1738882640077668629 for ; Thu, 06 Feb 2025 14:57:20 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Pn+4viOF; spf=pass (domain: gmail.com, ip: 209.85.128.52, mailfrom: adrian.freihofer@gmail.com) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-43634b570c1so10240995e9.0 for ; Thu, 06 Feb 2025 14:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738882638; x=1739487438; 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=7iD2MlcjQq8m+1Pf0zfao/O63G6kdcG83cOFMS+Zvrc=; b=Pn+4viOFs0PPgI0nsy7XOb+UBgmSsPhyl2ux7QTOP1sJBpNywIOaT96jGB+dtl1wGJ OVIxHKWJkspXj+Xida7Zpm//C/WAd4qNB79IZ/3WgI+VHA2PDiROZiUsXXcCkr97MYxI IIRZIc8ss2I1eAUJqB+SM9DsbUBhS3wpgX0wKWBUcuPSglOo5piSUMov5kpqc81hRFQo lAXct3DxQruhaU7yfiMTZ8UwN8yHcPgNt3rIvIZ/SpAm8Bybt1EB3b+XntW9xFwcIgOU cEMZFSOhnBKwwKI0vBs4CqRL6fTO60ZJMBgQppabWNJzwSyWudxVbi1ARI4pIqdNPZEW AiYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738882638; x=1739487438; 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=7iD2MlcjQq8m+1Pf0zfao/O63G6kdcG83cOFMS+Zvrc=; b=IZxtDWo7P9IJkP/JJwKnY/VbdOIc4iNjXmflwxB6PuZqyMqrS0gJUwUzOJhofchH3t HSTUPmm2yeTYsIUQTbAMZMrjj7veJ0j8tKRyawW3wB2zT3WGertiUZi0+VSYF5q9eXNX vPPjEBWq2JicNn2B3iCF5nQlEPpvQsGYFsuUmC79evZ/EKD33L1XzF6CifEwRpH6FxbJ ENoitFnAkr4Tm+q86enrXFQiXLHf5eKRxuM5jyZlYs5vaiI9uct+U9u/xKzwgUytaEa1 pJq4IKT2RMNPacqkoLoSTMDhOIAxPL3DsXZnWwB+DMOCmcN1fk9j38Uy4TNySUkY22Rh FbxA== X-Gm-Message-State: AOJu0YyAgP1487eDpWVS5Htg67gvb4X3AhESkCYwIfEBQIFt7Q19sLmU 5dvtcHszG5evccSHPxKomDd0D1FHKNGUoalYBZOaOYGMWT6hUJbFqkZMDQ== X-Gm-Gg: ASbGncuQUnjLo3ZbsxQtEmCesvrLqV8FrStDoL9nZBg8P9ZaYPpjMZ+YH1MATM/nuoG GbDuTKUbx2zaCuTuqo8Vxhxhe1ZGq4BdDdsIexV6GLmYWoUzv5OCmsSoCi2ntM5RNHJObWMMcfs FQINtQytWNEI8XTGG53fOBpivSvMUxVyPq7zzbDY+o3yH9bdHsteJdj3G5e/xAFR20QYwGPoOyB Rc2Q80yvze+juA4OZaCUw9D2lT9vQsiBmCljC/hgV0wISbqgGaloyyw56UGKtLUYUhTjm9yYYZ2 5uOGAcfYYfI+xIkkVfHznu3YK90Y2Rf00D5AFw== X-Google-Smtp-Source: AGHT+IEmrXCyzzi/Ez/MfbW/uxqJpjy6kFxQ3xGIHlbkdRGD1jJcZghffxNrnmOfOiZ9zlT+srBvuw== X-Received: by 2002:a05:600c:1c9f:b0:436:1c0c:bfb6 with SMTP id 5b1f17b1804b1-439249c0324mr7904285e9.27.1738882637855; Thu, 06 Feb 2025 14:57:17 -0800 (PST) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390d896d70sm68737535e9.0.2025.02.06.14.57.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 14:57:16 -0800 (PST) From: Adrian Freihofer X-Google-Original-From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 2/4] kernel-fitimage.bbclass: do not use the UBOOT_ENV variable Date: Thu, 6 Feb 2025 23:56:05 +0100 Message-ID: <20250206225654.1660760-3-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250206225654.1660760-1-adrian.freihofer@siemens.com> References: <20250206225654.1660760-1-adrian.freihofer@siemens.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 ; Thu, 06 Feb 2025 22:57:28 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/210964 The kernel-fitimage.bbclass evaluates the UBOOT_ENV variable from the u-boot recipe. Based on this variable an u-boot script might be added to the fitImage. However, the UBOOT_ENV variable is also used to install the script as an old u-boot image, usually named boot.scr into the /boot directory of the target device. This dual usage of one variable leads to several strange side effects. Some examples: - If UBOOT_ENV_SUFFIX is set to the default value scr, the boot.cmd script gets added as a legacy uImage to the fitImage. That does not look useful. - If the UBOOT_ENV_SUFFIX is set to e.g. txt the script is not converted into a legacy uImage and a usable plain text script gets added to the fitImage. But the same script ends up redundant in /boot. Another strange detail is that the UBOOT_ENV_BINARY gets set to e.g. boot.txt for this configuration. - Appending the script to the u-boot recipe and then hand it over to the kernel recipe via the staged /boot directory looks like over complicated. Such kind of over complications and u-boot kernel inter-dependencies lead to an almost unmaintainable kernel-fitimage.bbclass. - A single variable does not allow you to add a text file to the fitImage and at the same time place boot.scr file in the /boot directory of the target device. - It is not documented or obvious how the UBOOT_ENV variable should be used together with the kernel-fitimage.bbclass. The commit which introduced this feature (among other features...) is: https://git.yoctoproject.org/poky/commit/?id=8a2f4e143b52109fbd0ee8d792e327d460b8c1e6 This commit is going to remove the u-boot script part of it. The removal of this function requires a note in the migration guide. The migration should be straightforward: If UBOOT_ENV and the kernel-fitimage.bbclass are used, the u-boot script must now be appended to the kernel recipe and the new FIT_UBOOT_ENV variable must be used. Signed-off-by: Adrian Freihofer --- meta/classes-recipe/kernel-fitimage.bbclass | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass index bd2e371b63a..22356fe5678 100644 --- a/meta/classes-recipe/kernel-fitimage.bbclass +++ b/meta/classes-recipe/kernel-fitimage.bbclass @@ -41,10 +41,6 @@ python __anonymous () { 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') - #check if there are any dtb providers providerdtb = d.getVar("PREFERRED_PROVIDER_virtual/dtb") if providerdtb: @@ -607,15 +603,6 @@ fitimage_assemble() { # Step 3: Prepare a u-boot script section # - 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} - else - bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found." - fi - fi if [ -n "${FIT_UBOOT_ENV}" ]; then cp ${UNPACKDIR}/${FIT_UBOOT_ENV} ${B} bootscr_id="${FIT_UBOOT_ENV}" From patchwork Thu Feb 6 22:56:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 56826 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 2EC6FC0219C for ; Thu, 6 Feb 2025 22:57:28 +0000 (UTC) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mx.groups.io with SMTP id smtpd.web11.56266.1738882642478513465 for ; Thu, 06 Feb 2025 14:57:22 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HTqjB4B+; spf=pass (domain: gmail.com, ip: 209.85.128.44, mailfrom: adrian.freihofer@gmail.com) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4363dc916ceso15738995e9.0 for ; Thu, 06 Feb 2025 14:57:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738882640; x=1739487440; 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=Es0zDfGRnvLnPMFjEgMuaNjRfqo97h19Wm6c1IVZ268=; b=HTqjB4B+g9cZDeKYPn3wC90DNpKd9eRXhLudmnjc94Ac3ptZwrrnSco31nosYgsweO gBjkMY/F9hmcNU0A3Nyici61d2xZO5mqHU3nqT2+gL9zJbQICMba5xuZa2/2rMJCflAC xlG7d8bEGG45LVZ489DU1wdvezIj8KmJP8V0R2U/qj3y5eFCvsyPg2/OHabzFnGJbicl EZOd8CRvzlwUPXU/e4xZ6a+W9XgDF5hOD7zlttJFSe8fdYAvO90ic2KQeNd+n5K6MbV6 cVpuUweUag/z4Nbq3Ir2NBPXs8Hqpmo9n6GWSmQRdV6/o0l6PKQKFEpZmG8KSn9ppH/Z roEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738882640; x=1739487440; 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=Es0zDfGRnvLnPMFjEgMuaNjRfqo97h19Wm6c1IVZ268=; b=oH2KeCS4ENwcKmdUfc8Q4dOjg+MI4/6tYUbPyVkdX/jahxBhzzJbEGWrw+qLGIr3Rq iPhMPE9Chc8MaYDkObWi8OdpQBoMLLVAHMOmcsZvHWDnlRVbwkHT9S4jJnt8XtOQJKa/ P2Ckd1cC34olqGxJNbTUk59YTCmYQYDWCJyAsQC3Vj17XIrtYGOnB/R8r66KXmeFE2UI ffDiJZIhSpwhDSbdCpgFzRX4MiqsDS2XFIDmvh3QC/Ua4H2pR99qNAOIIP7boNB/vbJ3 Ov0pPOlSeaLyiHPhMT/9HEJVT/XKvBpVKvPFcFXahPyHpcpI6Ml+Xq++m0dZGhW/6bCq lvAQ== X-Gm-Message-State: AOJu0YzeyHxkuT8sq7jvRnpUeHcyOIzmLBkwgFrcjFMf57WJ4OPtS2gB OtzvomA4aDlWRDXpqZSJdtnLCCsg9vg+0jpX3p444I3uZMEKOMCAJnPeRQ== X-Gm-Gg: ASbGnct0wXcboNvxQtsDgJIfGlYH+P4V/kjpKaa/NOhe/R5C6V97MsVuXWrVyM0F6uN pva7rDc1UE6WYSR9FjksTy9dkqKMLjcxZ2vkE0wnMGofdyTslbKibiINGZiKdSojG9MDhHqPavr k4PrIlorBiP1k2kXbxhyH8J76tiGPULOwDh4/YST1R87Mz9QkhYcY0Xxee6ZxBcs1XZklwytw3/ S6LY5iVWdwbf0uWcjWq/SV1PCAU+y8CuBozvK9UuJeiDkQ4Q5V531HtQwAM+rYIzFBldG2qDEii t5lDt+rylUDmvRtrWgLEB4T1v+xmO2a0k8tlIg== X-Google-Smtp-Source: AGHT+IH9kDBg8OE07HjjwVSzNXzovW4173PqpJvXyJ/oZHLrxPtcWabi+I059DNEDE0T75eRTYWSfg== X-Received: by 2002:a7b:c049:0:b0:434:ea1a:e30c with SMTP id 5b1f17b1804b1-43912d49923mr39801275e9.13.1738882640055; Thu, 06 Feb 2025 14:57:20 -0800 (PST) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390d896d70sm68737535e9.0.2025.02.06.14.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 14:57:18 -0800 (PST) From: Adrian Freihofer X-Google-Original-From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 3/4] oe-selftest: fitimage split run_dumpimage function Date: Thu, 6 Feb 2025 23:56:06 +0100 Message-ID: <20250206225654.1660760-4-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250206225654.1660760-1-adrian.freihofer@siemens.com> References: <20250206225654.1660760-1-adrian.freihofer@siemens.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 ; Thu, 06 Feb 2025 22:57:28 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/210965 Provide a re-usable function which calls the dumpimage utiliy. This is a refactoring. Signed-off-by: Adrian Freihofer --- meta/lib/oeqa/selftest/cases/fitimage.py | 44 +++++++++++++----------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index 0b5f4602fbc..a0ec406a0eb 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py @@ -12,17 +12,22 @@ import re class FitImageTests(OESelftestTestCase): def _setup_uboot_tools_native(self): - """build u-boot-tools-native and return RECIPE_SYSROOT_NATIVE""" + """build u-boot-tools-native and return ${RECIPE_SYSROOT_NATIVE}/${bindir}""" bitbake("u-boot-tools-native -c addto_recipe_sysroot") - return get_bb_var('RECIPE_SYSROOT_NATIVE', 'u-boot-tools-native') + vars = get_bb_vars(['RECIPE_SYSROOT_NATIVE', 'bindir'], 'u-boot-tools-native') + return os.path.join(vars['RECIPE_SYSROOT_NATIVE'], vars['bindir']) - def _verify_fit_image_signature(self, uboot_tools_sysroot_native, fitimage_path, dtb_path, conf_name=None): + def _run_dumpimage(self, fitimage_path, uboot_tools_bindir): + dumpimage_path = os.path.join(uboot_tools_bindir, 'dumpimage') + return runCmd('%s -l %s' % (dumpimage_path, fitimage_path)) + + def _verify_fit_image_signature(self, uboot_tools_bindir, fitimage_path, dtb_path, conf_name=None): """Verify the signature of a fit contfiguration The fit_check_sign utility from u-boot-tools-native is called. uboot-fit_check_sign -f fitImage -k $dtb_name -c conf-$dtb_name """ - fit_check_sign_path = os.path.join(uboot_tools_sysroot_native, 'usr', 'bin', 'uboot-fit_check_sign') + fit_check_sign_path = os.path.join(uboot_tools_bindir, 'uboot-fit_check_sign') cmd = '%s -f %s -k %s' % (fit_check_sign_path, fitimage_path, dtb_path) if conf_name: cmd += ' -c %s' % conf_name @@ -238,12 +243,11 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'" self.assertEqual(value, reqvalue) # Dump the image to see if it really got signed - uboot_tools_sysroot_native = self._setup_uboot_tools_native() - dumpimage_path = os.path.join(uboot_tools_sysroot_native, 'usr', 'bin', 'dumpimage') - result = runCmd('%s -l %s' % (dumpimage_path, fitimage_path)) + uboot_tools_bindir = self._setup_uboot_tools_native() + dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir) in_signed = None signed_sections = {} - for line in result.output.splitlines(): + for line in dumpimage_result.output.splitlines(): if line.startswith((' Configuration', ' Image')): in_signed = re.search(r'\((.*)\)', line).groups()[0] elif re.match('^ *', line) in (' ', ''): @@ -272,7 +276,7 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'" # Verify the signature for all configurations = DTBs for dtb in ['am335x-bone.dtb', 'am335x-boneblack.dtb', 'am335x-bonegreen.dtb']: - self._verify_fit_image_signature(uboot_tools_sysroot_native, fitimage_path, + self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], dtb), 'conf-' + dtb) def test_uboot_fit_image(self): @@ -548,12 +552,11 @@ UBOOT_FIT_HASH_ALG = "sha256" self.assertEqual(value, reqvalue) # Dump the image to see if it really got signed - uboot_tools_sysroot_native = self._setup_uboot_tools_native() - dumpimage_path = os.path.join(uboot_tools_sysroot_native, 'usr', 'bin', 'dumpimage') - result = runCmd('%s -l %s' % (dumpimage_path, fitimage_path)) + uboot_tools_bindir = self._setup_uboot_tools_native() + dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir) in_signed = None signed_sections = {} - for line in result.output.splitlines(): + for line in dumpimage_result.output.splitlines(): if line.startswith((' Image')): in_signed = re.search(r'\((.*)\)', line).groups()[0] elif re.match(' \w', line): @@ -577,7 +580,7 @@ UBOOT_FIT_HASH_ALG = "sha256" self.assertEqual(found_comments, 2, "Expected 2 signed and commented section in the fitImage.") # Verify the signature - self._verify_fit_image_signature(uboot_tools_sysroot_native, fitimage_path, + self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, os.path.join(deploy_dir_image, 'u-boot-spl.dtb')) @@ -696,12 +699,11 @@ FIT_SIGN_INDIVIDUAL = "1" self.assertEqual(value, reqvalue) # Dump the image to see if it really got signed - uboot_tools_sysroot_native = self._setup_uboot_tools_native() - dumpimage_path = os.path.join(uboot_tools_sysroot_native, 'usr', 'bin', 'dumpimage') - result = runCmd('%s -l %s' % (dumpimage_path, fitimage_path)) + uboot_tools_bindir = self._setup_uboot_tools_native() + dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir) in_signed = None signed_sections = {} - for line in result.output.splitlines(): + for line in dumpimage_result.output.splitlines(): if line.startswith((' Image')): in_signed = re.search(r'\((.*)\)', line).groups()[0] elif re.match(' \w', line): @@ -725,7 +727,7 @@ FIT_SIGN_INDIVIDUAL = "1" self.assertEqual(found_comments, 2, "Expected 2 signed and commented section in the fitImage.") # Verify the signature - self._verify_fit_image_signature(uboot_tools_sysroot_native, fitimage_path, + self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, os.path.join(deploy_dir_image, 'u-boot-spl.dtb')) @@ -850,5 +852,5 @@ FIT_HASH_ALG = "sha256" self.assertEqual(len(list(filter(rx_sign_line.match, node))), 1, "kernel hash not signed") # Verify the signature - uboot_tools_sysroot_native = self._setup_uboot_tools_native() - self._verify_fit_image_signature(uboot_tools_sysroot_native, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'am335x-bone.dtb')) + uboot_tools_bindir = self._setup_uboot_tools_native() + self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'am335x-bone.dtb')) From patchwork Thu Feb 6 22:56:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 56825 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 3358BC0219B for ; Thu, 6 Feb 2025 22:57:28 +0000 (UTC) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by mx.groups.io with SMTP id smtpd.web11.56267.1738882643523308417 for ; Thu, 06 Feb 2025 14:57:23 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VNGNUq4x; spf=pass (domain: gmail.com, ip: 209.85.128.45, mailfrom: adrian.freihofer@gmail.com) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-436a39e4891so9980335e9.1 for ; Thu, 06 Feb 2025 14:57:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738882642; x=1739487442; 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=k+hc5ofnBj6jCXKT2DEqcJygZMjZJOOZpMl6o5R6IZg=; b=VNGNUq4xg2hBzEM3MRnwHRKOoCDkCP8IfHXUPTx5Hz6cJzDZXvX/RSD6Hx9bu7FGy/ qYo5q6g70O9yyyKNQEEsXqktKY6QPyIOB0YHqcChqj3ZnyJsQHmytUz1m8ypaR0RHbLR p8o+25R7UkDH/BZSQmTLBkgPhz34iHy6zY65iMrmh/pyzLHc/MIGbQC2n/EV7CrmAm3g ejPnluVVpTVEQbTCTi1BkcpqrB1o/ack4S8Wgr7yQ6aBOWJWSiTTncsHYIf6ehFf2V8W tOhf+pc+Q3v0nIWTr5gpVhVHSVVuVXo0Q9fK4Z19Hz4kC29vBalMHrKxp4CtyOBo4eAs ql2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738882642; x=1739487442; 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=k+hc5ofnBj6jCXKT2DEqcJygZMjZJOOZpMl6o5R6IZg=; b=rtH44kmtESfaJpCu1aIzO8IxIIm+py+bo4RsDUqHBIxfzZzHfR0hL0gJd/rCYqb/xw AWz0a6mFaZjrpdtbyOj6hr9Upc5le5GtoKC0ywxbDEMg4GySscwwRnnr1I2Wnhae7k91 HmAG4hoUaAuF63WRvRA0ON3iKrvbhehsMtKh87SYlaAzwlQdrK8FOQff8SkeqnrPSpL5 X4QmK4dNz9GXL5GqiiKKjEDsxBhGe4xFK+r4AGn4qeux8Mcm02jWWlou2nPShOaCfjOh chRFqPyWitdWHq8lfmHl53R1M94l3RJue7rnKSITCaFCUBOhm7XApV0zkCHpLel3xxJV ixGQ== X-Gm-Message-State: AOJu0YwR0EW5/RkhAh3lzYvzFSZHuioHB9/Lqb+HvZxouSNWhhP3ZHmQ cqIUv26kdqi8+Q9epwJuzT+6iU3vAqA3+FiOrJGEBUgDOqEXiUu2Ui7BRA== X-Gm-Gg: ASbGncuClV2KWzQ3HeAJ2ijqlMEDyvSTuVwf2RTY9GQZYAlVcwCHn2JSSZxmwk2E/rV 6S4DCyfUT/YmHdftEOCI+J08LuwUapBU0yF9MriVR/v+Bj26J2rG6zLTeyjhchfGtAsvDn9sABT OkgMmYctxRRoDdvbSnojUM2d7u+7VW9qdQpDaZsZqh0zkmHv8KsfP8t2ySrckhzikO4+Q8BKNeI zwkGPfCLH70wRUpslIOolSidHDf8Zch8Y7u4Szn34mo5t8KU+VLF9wNDY4MoKl4PoQtxC0bPgcc DiggYvZBCCsVkGQuQLA4QjmmWI4GkWnoiCu2iw== X-Google-Smtp-Source: AGHT+IG3d3N/IkUekCwgaGZNBXkbb33heBgO9CuDEq3Xuom9WueVczxqTLYNmPgsYdYhISwsKd/gaQ== X-Received: by 2002:a05:6000:1a8d:b0:38d:b5e8:310a with SMTP id ffacd0b85a97d-38dc8fe5357mr438599f8f.28.1738882641456; Thu, 06 Feb 2025 14:57:21 -0800 (PST) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390d896d70sm68737535e9.0.2025.02.06.14.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 14:57:20 -0800 (PST) From: Adrian Freihofer X-Google-Original-From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 4/4] oe-selftest: fitimage add u-boot env script Date: Thu, 6 Feb 2025 23:56:07 +0100 Message-ID: <20250206225654.1660760-5-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250206225654.1660760-1-adrian.freihofer@siemens.com> References: <20250206225654.1660760-1-adrian.freihofer@siemens.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 ; Thu, 06 Feb 2025 22:57:28 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/210966 Extend all kernel-fitimage tests to add a boot.cmd script to the fitImage and verify the script ends up in the fitImage. The test covers the use case which is documented here: https://docs.u-boot.org/en/latest/usage/cmd/source.html#fit-image. But instead of adding the sctip inline a script file is generated. Signed-off-by: Adrian Freihofer --- meta/lib/oeqa/selftest/cases/fitimage.py | 44 ++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index a0ec406a0eb..5a400c200fc 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py @@ -60,6 +60,32 @@ class FitImageTests(OESelftestTestCase): byte = file.read(1) return found_positions + def _config_add_uboot_env(self, config): + """Generate an u-boot environment + + Create a boot.cmd file that is packed into the FitImage as a source-able text file. + """ + fit_uenv_file = "boot.cmd" + test_files_dir = "test-files" + fit_uenv_path = os.path.join(self.builddir, test_files_dir, fit_uenv_file) + + config += '# Add an u-boot script to the fitImage' + os.linesep + config += 'FIT_UBOOT_ENV = "%s"' % fit_uenv_file + os.linesep + config += 'FILESEXTRAPATHS:prepend := "${TOPDIR}/%s:"' % test_files_dir + os.linesep + config += 'SRC_URI:append:pn-linux-yocto = " file://${FIT_UBOOT_ENV}"' + os.linesep + + if not os.path.isdir(test_files_dir): + os.mkdir(test_files_dir) + self.logger.debug("Writing to: %s" % fit_uenv_path) + with open(fit_uenv_path, "w") as f: + f.write('echo "hello world"') + + return config + + def _verify_fitimage_uboot_env(self, dumpimage_result): + """Check if the boot.cmd script is part of the fitImage""" + num_scr_images = len(re.findall(r"^ *Image +[0-9]+ +\(bootscr-boot\.cmd\)$", dumpimage_result.output, re.MULTILINE)) + self.assertEqual(1, num_scr_images, msg="Expected exactly 1 bootscr-boot.cmd image section in the fitImage") def test_fit_image(self): """ @@ -91,6 +117,7 @@ UBOOT_LOADADDRESS = "0x80080000" UBOOT_ENTRYPOINT = "0x80080000" FIT_DESC = "A model description" """ + config = self._config_add_uboot_env(config) self.write_config(config) # fitImage is created as part of linux recipe @@ -137,6 +164,10 @@ FIT_DESC = "A model description" "Fields in Image Tree Source File %s did not match, error in finding %s" % (fitimage_its_path, its_field_check[field_index])) + uboot_tools_bindir = self._setup_uboot_tools_native() + dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir) + self._verify_fitimage_uboot_env(dumpimage_result) + def test_sign_fit_image(self): """ @@ -171,6 +202,7 @@ FIT_SIGN_INDIVIDUAL = "1" UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'" """ % a_comment + config = self._config_add_uboot_env(config) self.write_config(config) # fitImage is created as part of linux recipe @@ -228,7 +260,7 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'" reqsigvalues_config = { 'algo': '"sha256,rsa2048"', 'key-name-hint': '"cfg-oe-selftest"', - 'sign-images': '"kernel", "fdt"', + 'sign-images': '"kernel", "fdt", "bootscr"', } for itspath, values in sigs.items(): @@ -269,10 +301,13 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'" value = values.get('Sign value', None) self.assertEqual(len(value), 512, 'Signature value for section %s not expected length' % signed_section) + # Check if the u-boot boot.scr script is in the fitImage + self._verify_fitimage_uboot_env(dumpimage_result) + # Search for the string passed to mkimage: 1 kernel + 3 DTBs + config per DTB = 7 sections # Looks like mkimage supports to add a comment but does not support to read it back. found_comments = FitImageTests._find_string_in_bin_file(fitimage_path, a_comment) - self.assertEqual(found_comments, 7, "Expected 7 signed and commented section in the fitImage.") + self.assertEqual(found_comments, 8, "Expected 8 signed and commented section in the fitImage.") # Verify the signature for all configurations = DTBs for dtb in ['am335x-bone.dtb', 'am335x-boneblack.dtb', 'am335x-bonegreen.dtb']: @@ -771,6 +806,7 @@ KERNEL_IMAGETYPE_REPLACEMENT = "zImage" FIT_KERNEL_COMP_ALG = "none" FIT_HASH_ALG = "sha256" """ + config = self._config_add_uboot_env(config) self.write_config(config) # fitImage is created as part of linux recipe @@ -854,3 +890,7 @@ FIT_HASH_ALG = "sha256" # Verify the signature uboot_tools_bindir = self._setup_uboot_tools_native() self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'am335x-bone.dtb')) + + # Check if the u-boot boot.scr script is in the fitImage + dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir) + self._verify_fitimage_uboot_env(dumpimage_result)