From patchwork Sun Sep 22 00:03:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 1165663 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Jz4/Xhy1"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46bSNL3CpFz9sCJ for ; Sun, 22 Sep 2019 10:03:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A09F585B9D; Sun, 22 Sep 2019 00:03:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hjZfc34N9lEn; Sun, 22 Sep 2019 00:03:40 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id C0EC28583C; Sun, 22 Sep 2019 00:03:40 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 975EB1BF95E for ; Sun, 22 Sep 2019 00:03:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 838ED85B9D for ; Sun, 22 Sep 2019 00:03:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 06wH2zab4qVf for ; Sun, 22 Sep 2019 00:03:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by whitealder.osuosl.org (Postfix) with ESMTPS id 6B9248583C for ; Sun, 22 Sep 2019 00:03:37 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id w14so8589953qto.9 for ; Sat, 21 Sep 2019 17:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=r/oMk05NxdiJaE0FJhWE5Zp2ikRttl/hamJWkvGniro=; b=Jz4/Xhy1uusy5motXY1PSybnduzXziifRt+PEecMUpYLrpm9Q85bL4kzZwC4iGdrtH vBABqOTsugYlUR4c1yZ2De2wdX1HA9cTl85PsvhYN4HdumYa/0mw6GQKLvPXuBeWj1xn YX4wvRZn+XWHNwa253+ql2RdyWseaog7DmpdweSjEKszIWDjHMKK161SnWlHZbA8PEfu gULiNKpgKP5NZLXbIVkjR2r9okAfZB7g6gVSYYeA5EQiCD9iBqlgjQOd29wBjM5+uc7O ub6RgI8mqtFmk5mZ31gToxJ+gj8F9+9zsh8ZGhNbg1jZPKzAE1DVXHL3dkF9ifcoi/i2 6d6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=r/oMk05NxdiJaE0FJhWE5Zp2ikRttl/hamJWkvGniro=; b=gVwD1pxIKMF0XzKAEQlITLRub/SbFotXn2uc8ltmRqGeXMHGnaUXqgW31dgCqLGg9P 3VD7pHM+JNe6Aj2Z1pIVfu/fFaJQTQ/kcOp5QlxXvHILVV4E7TV4nnewmv8cmYQraSn6 4Zou0Ww/FBDk65uyLWTC+eqn0m8n0tfmiHqBlykRBfit5isIl34O17i+f2u6Be08U7Xu DEFdt28grjui2rf6JJD7Oq8Q4vFmpII7Rd7wO0/RfGvVD8Me/SgHXEX/C+pmLiAYqRUm bMmm7few8OU2BdSwTA1ub5ItWsmi6qDj5gyvotMl/ZnPj8sqsyhKqwTuxdaCcx5TzFUJ ajWA== X-Gm-Message-State: APjAAAViNoFur1lvkKreLVt/dzEb/1oWw+SYFg9N/mXB8sD1MtQNw65Z QwwgJ64DfaXhSI58ijBJRPa20V6+ X-Google-Smtp-Source: APXvYqyS0Kkmc5BVgAbJxDJqCA3mC6u1HCSGkm8HctfF5c4R1NBMFrIpJR+FsZ9GnKEymwvi4sOw+A== X-Received: by 2002:a0c:f091:: with SMTP id g17mr19250620qvk.181.1569110615917; Sat, 21 Sep 2019 17:03:35 -0700 (PDT) Received: from casantos.remote.csb ([177.156.134.210]) by smtp.gmail.com with ESMTPSA id k2sm2934784qtm.42.2019.09.21.17.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 17:03:34 -0700 (PDT) From: unixmania@gmail.com To: buildroot@buildroot.org Date: Sat, 21 Sep 2019 21:03:23 -0300 Message-Id: <20190922000323.12025-1-unixmania@gmail.com> X-Mailer: git-send-email 2.18.1 Subject: [Buildroot] [PATCH v2] configs/pc_x86_64_efi: add GPT partition table support. X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Carlos Santos , Alexandre PAYEN MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Alexandre PAYEN Commit fee29b05bb7db25e37c8a5175ce00dc712554edf replaced the use of genimage by a shell script to use GPT partitioning on pc_x86_64_efi. Since version 11, genimage supports GPT, so add a corresponding config file ad update the post-image script to use genimage again. Keep using the UUID to identify the root partition. Signed-off-by: Alexandre PAYEN Signed-off-by: Carlos Santos --- Changes v1->v2 - Simplify post-image script. - Update the commit message. --- board/pc/genimage-efi.cfg | 39 +++++++++++++++++++++ board/pc/grub-efi.cfg | 6 ++++ board/pc/post-build.sh | 14 ++++++-- board/pc/post-image-efi-gpt.sh | 62 --------------------------------- board/pc/post-image-efi.sh | 9 +++++ configs/pc_x86_64_efi_defconfig | 4 ++- 6 files changed, 69 insertions(+), 65 deletions(-) create mode 100644 board/pc/genimage-efi.cfg create mode 100644 board/pc/grub-efi.cfg delete mode 100755 board/pc/post-image-efi-gpt.sh create mode 100755 board/pc/post-image-efi.sh diff --git a/board/pc/genimage-efi.cfg b/board/pc/genimage-efi.cfg new file mode 100644 index 0000000000..6079178235 --- /dev/null +++ b/board/pc/genimage-efi.cfg @@ -0,0 +1,39 @@ +image efi-part.vfat { + vfat { + file startup.nsh { + image = "efi-part/startup.nsh" + } + file EFI { + image = "efi-part/EFI" + } + file bzImage { + image = "bzImage" + } + } + size = 16777216 +} + +image disk.img { + + + hdimage { + gpt = true + } + + partition boot { + image = "efi-part.vfat" + partition-type-uuid = c12a7328-f81f-11d2-ba4b-00a0c93ec93b + offset = 32768 + size = 16777216 + bootable = true + } + + partition root { + partition-type-uuid = 44479540-f297-41b2-9af7-d131d5f0458a + partition-uuid = UUID_TMP + image = "rootfs.ext2" + offset = 16809984 + } + + +} \ No newline at end of file diff --git a/board/pc/grub-efi.cfg b/board/pc/grub-efi.cfg new file mode 100644 index 0000000000..bd44666404 --- /dev/null +++ b/board/pc/grub-efi.cfg @@ -0,0 +1,6 @@ +set default="0" +set timeout="5" + +menuentry "Buildroot" { + linux /bzImage root=PARTUUID=UUID_TMP rootwait console=tty1 +} diff --git a/board/pc/post-build.sh b/board/pc/post-build.sh index b245cc00c6..425fccbe30 100755 --- a/board/pc/post-build.sh +++ b/board/pc/post-build.sh @@ -4,7 +4,17 @@ set -e BOARD_DIR=$(dirname "$0") -cp -f "$BOARD_DIR/grub-bios.cfg" "$TARGET_DIR/boot/grub/grub.cfg" +# Detect boot strategy, EFI or BIOS +if [ -f "$BINARIES_DIR/efi-part/startup.nsh" ]; then + cp -f "$BOARD_DIR/grub-efi.cfg" "$BINARIES_DIR/efi-part/EFI/BOOT/grub.cfg" +else + cp -f "$BOARD_DIR/grub-bios.cfg" "$TARGET_DIR/boot/grub/grub.cfg" + + # Copy grub 1st stage to binaries, required for genimage + cp -f "$HOST_DIR/lib/grub/i387-pc/boot.img" "$BINARIES_DIR" +fi + +#cp -f "$BOARD_DIR/grub-bios.cfg" "$TARGET_DIR/boot/grub/grub.cfg" # Copy grub 1st stage to binaries, required for genimage -cp -f "$HOST_DIR/lib/grub/i386-pc/boot.img" "$BINARIES_DIR" +#cp -f "$HOST_DIR/lib/grub/i386-pc/boot.img" "$BINARIES_DIR" diff --git a/board/pc/post-image-efi-gpt.sh b/board/pc/post-image-efi-gpt.sh deleted file mode 100755 index d2acd8f852..0000000000 --- a/board/pc/post-image-efi-gpt.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -set -e - -cd ${BINARIES_DIR} - -# GPT partition type UUIDs -esp_type=c12a7328-f81f-11d2-ba4b-00a0c93ec93b -linux_type=44479540-f297-41b2-9af7-d131d5f0458a - -# Partition UUIDs -efi_part_uuid=$(uuidgen) -root_part_uuid=$(uuidgen) - -# Boot partition offset and size, in 512-byte sectors -efi_part_start=64 -efi_part_size=32768 - -# Rootfs partition offset and size, in 512-byte sectors -root_part_start=$(( efi_part_start + efi_part_size )) -root_part_size=$(( $(stat -c %s rootfs.ext2) / 512 )) - -first_lba=34 -last_lba=$(( root_part_start + root_part_size )) - -# Disk image size in 512-byte sectors -image_size=$(( last_lba + first_lba )) - -cat > efi-part/EFI/BOOT/grub.cfg </dev/null | sed -n 's/^Filesystem UUID: *\(.*\)/\1/p') +sed -i "s/UUID_TMP/$UUID/g" "$BINARIES_DIR/efi-part/EFI/BOOT/grub.cfg" +sed "s/UUID_TMP/$UUID/g" board/pc/genimage-efi.cfg > "$BINARIES_DIR/genimage-efi.cfg" +support/scripts/genimage.sh -c "$BINARIES_DIR/genimage-efi.cfg" diff --git a/configs/pc_x86_64_efi_defconfig b/configs/pc_x86_64_efi_defconfig index 324de35dff..984fc8f92f 100644 --- a/configs/pc_x86_64_efi_defconfig +++ b/configs/pc_x86_64_efi_defconfig @@ -10,6 +10,7 @@ BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y # Required tools to create bootable media BR2_PACKAGE_HOST_DOSFSTOOLS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_MTOOLS=y # Bootloader @@ -21,7 +22,8 @@ BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_ROOTFS_EXT2_SIZE="120M" # BR2_TARGET_ROOTFS_TAR is not set -BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image-efi-gpt.sh" +BR2_ROOTFS_POST_BUILD_SCRIPT="board/pc/post-build.sh" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image-efi.sh" # Linux headers same as kernel, a 4.18 series BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_18=y