From patchwork Wed Aug 7 13:54:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre PAYEN X-Patchwork-Id: 1143502 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=none (p=none dis=none) header.from=smile.fr Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=smile-fr.20150623.gappssmtp.com header.i=@smile-fr.20150623.gappssmtp.com header.b="GnuqyhLv"; 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 463Y0s537jz9s3Z for ; Wed, 7 Aug 2019 23:55:09 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 3A41287680; Wed, 7 Aug 2019 13:55:07 +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 DPN6i4GoTsTV; Wed, 7 Aug 2019 13:55:04 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 5D32287673; Wed, 7 Aug 2019 13:55:04 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 561C91BF306 for ; Wed, 7 Aug 2019 13:55:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5384F2283A for ; Wed, 7 Aug 2019 13:55:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O-f2I+8bfuWM for ; Wed, 7 Aug 2019 13:55:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by silver.osuosl.org (Postfix) with ESMTPS id 637D122844 for ; Wed, 7 Aug 2019 13:55:01 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id v15so158743wml.0 for ; Wed, 07 Aug 2019 06:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile-fr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cv81RJOzRG+I0Klbr+wKbrrogObX9FUWcASs1oLCoMg=; b=GnuqyhLvsYmfFwJYyadxtRKGK8lAZB4CG4DXx+pIdF7+IamK2na7tkRKej8syNU+x4 pSSplbkHBm4zAyquyllhe/Sf9TB3PAkBFwuaNJ6ehbX+7DX+pyq4V6E3tLOt4SfonPfq +3lSK5hL5PIpMTDhKNvHHuWRdlxIZKKqbBkhiKoJmIbi171d9t1C6m/kzdrsEdPQelZ3 or810y3SI4lhl/99WlX6oRJA53wLPt/DNNCG2CbcDeCFGdrZVHuj8OhloU206KlY7oye Gd3vquf0wdZsQU/EErhpRVyOIIaTC4SpSuah2U0zz1FBmLrwr3hPvUiN8XtF/ZWKK76o eVEQ== 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:mime-version :content-transfer-encoding; bh=cv81RJOzRG+I0Klbr+wKbrrogObX9FUWcASs1oLCoMg=; b=aX+3ujNnoggjGv3L2vFGAU2Ex+T6fhL1zPPQMeq+cw4XuhQLn3fvg1rMQKr55I8OS3 6MZJI3IoP46pHawiNuJbcmGQMWBIHDU+IbYWof/veBNESQk8xFL8YUP12cp75UruILMN tDZw0F/+haLIPrnzRG7ZUTMuO2jxI2PRnCLALIMvVPBfgTyZ1zcueAFx0mvYkbOnq6uH hIo1mzHrl9gXMWyR3Ua6m2lchzr/EbBXzn8d3XrlepzAVlHZnYOZ16xxnwFZbXlQ34fs 2TNSjfDDVZHz3kuF+8JyrhEVFd3ZoCLnM2ilTGPTN6QxIP5mJBvCJ3rRk492o9ni/28u jb2Q== X-Gm-Message-State: APjAAAWmrAugAMHLG2ODZyt02KhizaELrfk/nmkhwsWnAXRrwaiVgkP7 OtcaM7qqtLla2+JCRxKxOVHDt7JinD8= X-Google-Smtp-Source: APXvYqwf2/tt176tCP7nlXKz4BmjG0ByVfLAot9htTuOpDbJLjZopOnvmh+vQ4e+pdb9lmQwX8fc7g== X-Received: by 2002:a1c:4d01:: with SMTP id o1mr91278wmh.55.1565186099748; Wed, 07 Aug 2019 06:54:59 -0700 (PDT) Received: from P-NAN-GEORGETOWN.nantes.intranet (static-css-ccs-204145.business.bouyguestelecom.com. [176.157.204.145]) by smtp.gmail.com with ESMTPSA id 91sm187713852wrp.3.2019.08.07.06.54.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 07 Aug 2019 06:54:58 -0700 (PDT) From: Aalx To: buildroot@buildroot.org Date: Wed, 7 Aug 2019 15:54:57 +0200 Message-Id: <20190807135457.6201-1-alexandre.payen@smile.fr> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] 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: Alexandre PAYEN , Carlos Santos , Thomas Petazzoni Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Alexandre PAYEN Based on commit fee29b05bb7db25e37c8a5175ce00dc712554edf[1]. It add the use of GPT partition table on pc_x86_64_efi. This commit removed the use of genimage and replace it with a shell script. Since version 11, genimage support GPT partition table. Tested in QEMU, not on a physical device. So: - revert commit fee29b05bb7db25e37c8a5175ce00dc712554edf[1] - add GPT support - tweak shell script to add the correct UUID in genimage config. [1]: https://git.buildroot.net/buildroot/commit/?id=fee29b05bb7db25e37c8a5175ce00dc712554edf [2]: https://git.buildroot.net/buildroot/commit/?id=79b8540d624ac4846ba341b1b9691eccacf0bc05 Signed-off-by: Alexandre PAYEN Cc: Carlos Santos Cc: Thomas Petazzoni --- I hope it's the proper way to do it. Actually, just adding `gpt = true` in the genimage-efi.cfg work also. But, doing so, the UUID will not be the same in grub bootloader and disk image ... --- 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 | 6 ++++ configs/pc_x86_64_efi_defconfig | 5 ++- 6 files changed, 67 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 < $BINARIES_DIR/genimage-efi.cfg +sh support/scripts/genimage.sh $2 $BINARIES_DIR/genimage-efi.cfg diff --git a/configs/pc_x86_64_efi_defconfig b/configs/pc_x86_64_efi_defconfig index 324de35dff..b6445bb5e4 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,9 @@ 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" +BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/pc/genimage-efi.cfg" # Linux headers same as kernel, a 4.18 series BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_18=y