From patchwork Wed Oct 11 21:31:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohamed Belouarga X-Patchwork-Id: 1847005 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=Ayj5K9IX; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=cU+sCTbe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23a; helo=mail-lj1-x23a.google.com; envelope-from=swupdate+bncbcior6fiyqjbbovitsuqmgqerobb5vq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23a.google.com (mail-lj1-x23a.google.com [IPv6:2a00:1450:4864:20::23a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S5QvQ6Nhyz1yqZ for ; Thu, 12 Oct 2023 08:31:45 +1100 (AEDT) Received: by mail-lj1-x23a.google.com with SMTP id 38308e7fff4ca-2c12bb1f751sf2932601fa.2 for ; Wed, 11 Oct 2023 14:31:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697059900; cv=pass; d=google.com; s=arc-20160816; b=qIQ7CL4Y2FSa1tAv+Kiddm+MhG6iqJAgLOS6qcTuhyajWH8qKYxVN6SFjk1VxFwzrH a2/dlzdFsez4YL9KMjRoD8JOQwbwYEmnIzyEXMP0gRvW1Jx3Juaqm8wUM8Po3H37C+4f ssKQraqbjd8sqku/3ZwQx3/iy1OUPvCNmmJ3RkGyox5RsyVx7sfiuSKaNvw/dw9HojJ5 1jMSvaQkx4AM3F6EUFzhKASy+bJ67HCdr3FoqOjLw5A2F5Y5fXyztEBpmOIQWqBNwwjl Wh6mGVluj1mRfjjGhcM/wFOgdPRz4kKHdHgIm2W3raN6jiKLuKC3l+Cby18MUmDE6+EJ CvwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature:dkim-signature; bh=9A+bs6L7cw9MxycRa6jOZqXZ6nYGAxAMQN6YQ54XOHE=; fh=o966QMgx0LdDyY55szUoyqTUEeNdULCJtax9wyYFyss=; b=0XMz3USCdycSXxStMKcQx8z/p9bkfA1bZKnGf6NDLIqJo/llIdGKGJluoL3KtOsEpB /dzBZaYxwXntm6FidXNLzcmPDJSQxPQD6QaDBoZ0FzQv7wxM+oEfCH+fyvnD6vbWHrI2 xitFy01I0VtUAYpZBsnVH1N7rKscQsvv3NrCiCzyBcyWebN7zD1eJNoERuZTd/T3L2PE zQ//42HimVErBkFB/YkHJ/xxUvqrPjL/FnNgwkjfuTJCtjZuvtn3+aXmw6VaxF7/IumG 0nAU3CsWP7XR6r8MyJEWbBhqdl3PTcdefKTfKcVqMyb4SHVWuhTaHlS7DoLxjez/nSW5 /Lhg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Ixtp9n1/"; spf=pass (google.com: domain of belouargamohamed@gmail.com designates 2a00:1450:4864:20::42e as permitted sender) smtp.mailfrom=belouargamohamed@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1697059900; x=1697664700; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=9A+bs6L7cw9MxycRa6jOZqXZ6nYGAxAMQN6YQ54XOHE=; b=Ayj5K9IXYXR9ZKSRQkBpMixaQwYk41edi+gk6FNdcf1cA82CeE88bmQtSDP2yozzp0 VFrq/7pK1cAIkbIKNOhBRguhwpf4NdlQy2soVQd3VHwqGDD6LyCJ0RhZZD0RKsJ66Upz 3rVxM1zJJTDBdQtXdX42s4Uzzbo6WCa5RWJIDjTF8FJ3HWT9NBQtYEnEnTQqsS52zd++ P4NDSxhWSa5Sw8lQ0/rLRfkvim6y4ZkMV+QlWTlKSDn7qwONa1kvQTiWlgLmZTIOt9ZD HXtxJEGIvc+qP2mJHZTihvEma1MXhRvuDy0OiDvqX8HWboWLiAXF4WzQvKotgolSlSvP gh3g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697059900; x=1697664700; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=9A+bs6L7cw9MxycRa6jOZqXZ6nYGAxAMQN6YQ54XOHE=; b=cU+sCTbecNr/J8IzPs4QJXVRniRPWs9KzAOlsv3EiA2nW5U7s4T22xwbEEBfudUdr7 BHKzKm2QwQ6up9YxCahb9m4hizXSDfMzZYJ1i5BWt+UJclcURJDELqVG41izoE3DsWPw F7EOYLzt2CLjwlOZ/qyJTxNded8DWq6j9XvfzgPgb30Ub30yC4nTizbU0OsqsO3kZEPc m0fPYySA87LpSOtHi6xjeJa+yAzxcq1FRaoknhmyGBsmDVYotjrzFEB6x7CSlb049FR3 aS5naJffVHBK0/q0eX5H8xcYfBlWyOoG/PwjnnfckdEm9JQv/vwfCBGu0Z8/O7qpVuzN 6Kew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697059900; x=1697664700; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :sender:from:to:cc:subject:date:message-id:reply-to; bh=9A+bs6L7cw9MxycRa6jOZqXZ6nYGAxAMQN6YQ54XOHE=; b=T24xOCHsdnXbciZqbD4uJVY+o8BaoyH/clEOBF5qNiUwj/B9gNrrZkRvD0c39VmjZt c0K5V7b17OD6HFW7iO9Vj4hp+asY+ZhgsN1dIjc3zYi2SBADfRNrniavC3VJb3LpY6WR ST/GAb3FLonoAK0yvtnLJZ5VHJv1kaTeZOQPVX4Uj99mJ3zRPOw/ljBSiFPXrW7wxxcM l0YvRbDy3HUQAYv6N2zhBPpaNS56sqyGWbnUKKjvgm+NqG7KEAB+H3cpjcjWx4RvObaT aMrgEuIhgzNLIQgs9Osm6ntYvCBeU9aTSWWDrusUlyaVfTWjSNCyssxIuYcCC0Uk/L6q 8VwA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YyoEnllKYpmDmRpJGOPYjHh1eXvd2xEI64JqZoZw8Xm+o4R15li ebIB7t+ws1iS3OnRM48beoo= X-Google-Smtp-Source: AGHT+IGz2z6a68acdVhyfBpVsHoL1AphJUU304oODUS0YZVdwCdcm7rD9hw+bKIgHEaY8UbomNjFcg== X-Received: by 2002:a2e:98d0:0:b0:2c2:8f22:d9c2 with SMTP id s16-20020a2e98d0000000b002c28f22d9c2mr21883288ljj.22.1697059899445; Wed, 11 Oct 2023 14:31:39 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:8644:0:b0:2bf:c704:bca1 with SMTP id i4-20020a2e8644000000b002bfc704bca1ls230429ljj.0.-pod-prod-04-eu; Wed, 11 Oct 2023 14:31:37 -0700 (PDT) X-Received: by 2002:a05:651c:22d:b0:2bc:ed80:46e with SMTP id z13-20020a05651c022d00b002bced80046emr18395075ljn.31.1697059897319; Wed, 11 Oct 2023 14:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697059897; cv=none; d=google.com; s=arc-20160816; b=V8GpLDpOIcgJFD0yNmZdVdwBwWuwvEbtr0Xx5fBwapoGyiByRQPUw1uTzlLPrZxPWh dGtTGHvOOJycEVYBxI4Ppq+7IVVU0Tb2wXaFV7ksRrpwVFFYkxxa2sFrneXzz6GAuTXh F0IEobRlBmeRIbRl5M8sw4svT7dCOx64MAJgv1cZzqoaCmcjHKi6vTZb+8400MkEfvPS owBLvv/ud2/P25JQWfPC1fudJ1fk4LVf8PuNhIc2yPtby2m2ACPRz4i8kAS7QikhlITK rFhqFnbHWzQcaalDrPC+Ei7qRlHU5d9Nz1VJgSfYV3KWseK9tBWR5k2Bhqm5VPFUCC7d tPWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=YMmz3ulgJO/4xFBECM9SiMlMdznhkWH+6FEzcayUtUU=; fh=o966QMgx0LdDyY55szUoyqTUEeNdULCJtax9wyYFyss=; b=hle0bvwDijv4ehLSgjgycJbjG1W+Pw4AlFMN1+lfv+mza6TrcwPq/JnyZGf4T0DMwl Z5K/BmYEJTuYmxDfMfJSkkuM5+QqC2pKwNA1O3seFIWn05uQASMT344X1EuwVpUsCQpQ ePO4locU6SvgWuKk+6TQ6EK7hgxc92xB1tx9BvibAUWVkQZqHqBM00jvaLYJKHC3nKRD OqfjRcy2sew0E+uB7IX6hiUdOLIzGGZLe1hH+LOlwxx1rt6ppPzMju5g1bhq6PFzxYIW PwFS0LgrQG2mMN/5Nq2QV6fJLd0hNgMwXOpQYuXau4ukE37m0xzGxfg5TKatn03xQncL NVXg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Ixtp9n1/"; spf=pass (google.com: domain of belouargamohamed@gmail.com designates 2a00:1450:4864:20::42e as permitted sender) smtp.mailfrom=belouargamohamed@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com. [2a00:1450:4864:20::42e]) by gmr-mx.google.com with ESMTPS id b28-20020a2ebc1c000000b002c29b97d5f2si797920ljf.1.2023.10.11.14.31.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Oct 2023 14:31:37 -0700 (PDT) Received-SPF: pass (google.com: domain of belouargamohamed@gmail.com designates 2a00:1450:4864:20::42e as permitted sender) client-ip=2a00:1450:4864:20::42e; Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3296b3f03e5so256342f8f.2 for ; Wed, 11 Oct 2023 14:31:37 -0700 (PDT) X-Received: by 2002:a5d:500b:0:b0:31f:f753:5897 with SMTP id e11-20020a5d500b000000b0031ff7535897mr18896207wrt.59.1697059896063; Wed, 11 Oct 2023 14:31:36 -0700 (PDT) Received: from localhost.localdomain ([2a02:8440:d204:b271:41bf:48b6:db1a:da08]) by smtp.gmail.com with ESMTPSA id p11-20020a5d638b000000b00317a04131c5sm16344821wru.57.2023.10.11.14.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 14:31:35 -0700 (PDT) From: belouargamohamed@gmail.com To: swupdate@googlegroups.com Cc: BELOUARGA Mohamed Subject: [swupdate] [PATCH] Add documentation of grub Date: Wed, 11 Oct 2023 23:31:31 +0200 Message-Id: <20231011213131.27792-1-m.belouarga@technologyandstrategy.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: belouargamohamed@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Ixtp9n1/"; spf=pass (google.com: domain of belouargamohamed@gmail.com designates 2a00:1450:4864:20::42e as permitted sender) smtp.mailfrom=belouargamohamed@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , From: BELOUARGA Mohamed Add documentation of how to use swupdate with grub, and how to include an environment file grubenv. Signed-off-by: BELOUARGA Mohamed --- doc/source/building-with-yocto.rst | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/doc/source/building-with-yocto.rst b/doc/source/building-with-yocto.rst index 49830de..d76bc46 100644 --- a/doc/source/building-with-yocto.rst +++ b/doc/source/building-with-yocto.rst @@ -287,3 +287,51 @@ In the simple way, your recipe looks like SWUPDATE_IMAGES_FSTYPES[] = inherit swupdate-image + +What about grub ? +================= +In order to use swupdate with grub, swupdate needs to be configured to use grub. Some of +the imporatant configurations are **CONFIG_GRUBENV_PATH="/path/to/grubenv"**, +where **"/path/to/grubenv"** is thepath to grub environment. +Example: "/boot/EFI/BOOT/grubenv". + +The grubenv file should be created using grub-editenv tool, because it is a **1024-byte file**, therefore, +any modification using nano or vim will only corrupt the file, and grub will not be able to use it. + +You can create a grubenv file using these commands for instance: +:: + GRUBENV="/path/to/grubenv" + grub-editenv $GRUBENV create + grub-editenv $GRUBENV set rootfs=2 + grub-editenv $GRUBENV set kernel=2 + +grub-editenv is a tool that is integrated to yocto. + +When the grubenv file is created, grub should be configured to use it. +This configuration should be in the configuration file grub.cfg. +Here is an example of grub.cfg that loads the environment file before booting: +:: + # Take a kernel and a rootfs by default in case grubenv is corrupted + rootfs=1 + kernel=1 + serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 + default=boot + # set timeout to zero to boot without timeout + timeout=0 + # load grubenv the environment file that contains the value of rootfs and kernel variables + load_env -f "/path/to/grubenv" + # detect which memory contains 5 partitions + for i in 1 2 3 4 5; do if [ -d (hd${i},gpt5)/ ]; then drive=${i};fi ; done + # detect which rootfs should we boot with + if [ ${rootfs} = "1" ]; then rootfs_part=4 ; elif [ ${rootfs} = "2" ]; then rootfs_part=5 ; fi + # detect which kernel should we boot with + if [ ${kernel} = "1" ]; then kernel_part="(hd${drive},gpt2)" ; elif [ ${kernel} = "2" ]; then kernel_part="(hd${drive},gpt3)" ; fi + + # The menuentry that is used to boot (more can be added if it is wanted) + menuentry 'boot'{ + linux ${kernel_part}/bzImage root=/dev/mmcblk1p${rootfs_part} rw rootwait quiet console=ttyS2,115200 console=tty0 panic=5 + } + +The grub.cfg above is merely an example, and can be modified as the user wants to, +as long as it loads the environment variables,and it boots correctly using these environment +variables.