From nobody Wed Feb 14 15:17:26 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TZhdL5Vkpz5B74y; Wed, 14 Feb 2024 15:17:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TZhdL47nhz3yB8; Wed, 14 Feb 2024 15:17:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707923846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PoRF1HI5IDoI+CEnAbhwpvOhMsf29bEsPBp6uDT10fo=; b=Pfs7buIACO0Mv3szMAfizVdEEeMv3ap962r765xL8oB1JS9uE2pyf0YW3BuUHCRPTAWoX/ kwfxiOEo4QJnBNNiw8KXWN7k6Kz6lwToRSz1AkuyQSmpANo3vKzJ5JrrImCXs+wxGSiBya Ql1c1wsh+j+g6RDNTAkbpDqK2er8YiaPzxwuc4+RAfsxGBLVM7PPbB/cSrR6mnLao4whEW YBmbzs4KYh6HOh2Fs/PLeufi+Kgvl9Gu4ytpFVT0Ah/ex4gXHC0Bjk/hJ8xNnYwkU6NDh4 3IbF6iInxKtj8pJ5rmrqVl7rSUo3RViFaBo9pf+AsJRyVDqkHUp/zHK9iKd+rA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707923846; a=rsa-sha256; cv=none; b=XaifzDaR1NxDN2E9oscMaVg2Nb9fcK2OzQsxZC9qVtaId2ynZgh3tuWYXzTkDgMgDrcwsS 9ZzLcmlv48C6ZMACWKank6E0ih6djbPAmaf6r7Cz2Dsl+ccUB0ocnsDgyT1neCULDOrLmL F8QcBf2rTa7s7BgiMIYob249W/woxQJXiy0XDI2bdC1iK8ZVdwKe/jTIsTMm2E0C5eNRFI jPZ0C9uhWBaUEAAC4ITWU2CkHAeROqSh/X1wY4ZqEy3GdSIgDidzPqNoZmuj03QJnf5wB0 T1is/6yMGW8osXVexGJPFpOsem0Cb6J1uvaAAZV4Y5MtsSoTVYotJz2ZdqR9Sw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707923846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PoRF1HI5IDoI+CEnAbhwpvOhMsf29bEsPBp6uDT10fo=; b=dOqaLuhRWFIIx5dm6QChDkGtoWZ5qRSdmUWtGh1Ts43ZBX6FpCXfQzJFvZIDaS/RlyczQA wtN0a2ylBkJCiw5qA1H6nG9Dy/cycOt/Ar3jgivlDRBsLtpYidGGRpmJsp3ALuE4lqEYdf k4RxFqBapvCWe+AfMFxRIp9TeGORHvelafOKH1YFdEHdvJRIkvyHz5MnE6eEPChyf4Og1z EN2fRWZWYVnHe1RB/3za9tQYiQGLuWvPw1/sK7WN8Xiapkp0cMJUyVwwRLnTpBXDDtksnD 9WR2g7iRCudO0xIb7mxG+Cb4/53UOXTcg4C3w5QAa+ETPK20l8+RMhLruzip4w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TZhdL2wVlz13N2; Wed, 14 Feb 2024 15:17:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41EFHQSH015240; Wed, 14 Feb 2024 15:17:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41EFHQRx015237; Wed, 14 Feb 2024 15:17:26 GMT (envelope-from git) Date: Wed, 14 Feb 2024 15:17:26 GMT Message-Id: <202402141517.41EFHQRx015237@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 2af03ebfb853 - main - release: make SD card partition layout more flexible List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2af03ebfb853e918554e86ee0e37cf4b30a93bd0 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=2af03ebfb853e918554e86ee0e37cf4b30a93bd0 commit 2af03ebfb853e918554e86ee0e37cf4b30a93bd0 Author: Mitchell Horne AuthorDate: 2024-02-14 15:12:29 +0000 Commit: Mitchell Horne CommitDate: 2024-02-14 15:16:54 +0000 release: make SD card partition layout more flexible Currently the partition layout is hardcoded to create an EFI/FAT partition and a UFS root partition, with some logic to handle GPT/MBR differences. On RISC-V platforms we are seeing the emerging pattern that firmware should be placed in a partition of a known type, rather than just a known sector of the disk. Thus, some functionality is needed to customize the layout for SD card images. Add a hook, arm_create_partitions(), which can be overridden to insert additional platform-specific partitions, possibly preceding the standard EFI and UFS ones. A couple of new variables are added to track the indices, e.g. ROOTFSPART_SUFFIX=p2. In a couple places this de-duplicates the GPT/MBR logic. Reviewed by: manu, karels, imp MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D43848 --- release/tools/arm.subr | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/release/tools/arm.subr b/release/tools/arm.subr index 6c53724ed52f..983c3ea75dc7 100644 --- a/release/tools/arm.subr +++ b/release/tools/arm.subr @@ -67,22 +67,25 @@ arm_create_disk() { # Create the target raw file and temporary work directory. chroot ${CHROOTDIR} gpart create -s ${PART_SCHEME} ${mddev} + + arm_create_partitions + if [ "${PART_SCHEME}" = "GPT" ]; then chroot ${CHROOTDIR} gpart add -t efi -l efi -a 512k -s ${FAT_SIZE} ${mddev} - chroot ${CHROOTDIR} newfs_msdos -L efi -F ${FAT_TYPE} /dev/${mddev}p1 chroot ${CHROOTDIR} gpart add -t freebsd-ufs -l rootfs -a 64k ${mddev} - chroot ${CHROOTDIR} newfs -U -L rootfs /dev/${mddev}p2 fi if [ "${PART_SCHEME}" = "MBR" ]; then chroot ${CHROOTDIR} gpart add -t '!12' -a 512k -s ${FAT_SIZE} ${mddev} chroot ${CHROOTDIR} gpart set -a active -i 1 ${mddev} - chroot ${CHROOTDIR} newfs_msdos -L efi -F ${FAT_TYPE} /dev/${mddev}s1 chroot ${CHROOTDIR} gpart add -t freebsd ${mddev} - chroot ${CHROOTDIR} gpart create -s bsd ${mddev}s2 - chroot ${CHROOTDIR} gpart add -t freebsd-ufs -a 64k -b 64k ${mddev}s2 - chroot ${CHROOTDIR} newfs -U -L rootfs /dev/${mddev}s2a + chroot ${CHROOTDIR} gpart create -s bsd ${mddev}${BSDLABEL_SUFFIX} + chroot ${CHROOTDIR} gpart add -t freebsd-ufs -a 64k -b 64k ${mddev}${BSDLABEL_SUFFIX} fi + # Create the EFI and UFS filesystems + chroot ${CHROOTDIR} newfs_msdos -L efi -F ${FAT_TYPE} /dev/${mddev}${EFIPART_SUFFIX} + chroot ${CHROOTDIR} newfs -U -L rootfs /dev/${mddev}${ROOTFSPART_SUFFIX} + return 0 } @@ -171,12 +174,7 @@ arm_setup_minimal_loader() { } arm_install_base() { - if [ "${PART_SCHEME}" = "GPT" ]; then - chroot ${CHROOTDIR} mount /dev/${mddev}p2 ${DESTDIR} - fi - if [ "${PART_SCHEME}" = "MBR" ]; then - chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${DESTDIR} - fi + chroot ${CHROOTDIR} mount /dev/${mddev}${ROOTFSPART_SUFFIX} ${DESTDIR} _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U) REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION) BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH) @@ -230,14 +228,8 @@ arm_install_boot() { FATMOUNT="${DESTDIR%${KERNEL}}/fat" UFSMOUNT="${DESTDIR%${KERNEL}}/ufs" chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}" - if [ "${PART_SCHEME}" = "GPT" ]; then - dospart="/dev/${mddev}p1" - ufspart="/dev/${mddev}p2" - fi - if [ "${PART_SCHEME}" = "MBR" ]; then - dospart="/dev/${mddev}s1" - ufspart="/dev/${mddev}s2a" - fi + dospart="/dev/${mddev}${EFIPART_SUFFIX}" + ufspart="/dev/${mddev}${ROOTFSPART_SUFFIX}" chroot ${CHROOTDIR} mount_msdosfs ${dospart} ${FATMOUNT} chroot ${CHROOTDIR} mount ${ufspart} ${UFSMOUNT} @@ -271,3 +263,20 @@ arm_install_uboot() { arm_do_quirk() { # Override in the ${EMBEDDED_TARGET}/${BOARDNAME}.conf file. } + +arm_create_partitions() { + # Override in the ${EMBEDDED_TARGET}/${BOARDNAME}.conf file. + + # Set defaults for EFIPART_SUFFIX, ROOTFSPART_SUFFIX, and + # BSDLABEL_SUFFIX (MBR only), needed elsewhere. + + if [ "${PART_SCHEME}" = "GPT" ]; then + export EFIPART_SUFFIX=p1 + export ROOTFSPART_SUFFIX=p2 + fi + if [ "${PART_SCHEME}" = "MBR" ]; then + export EFIPART_SUFFIX=s1 + export BSDLABEL_SUFFIX=s2 + export ROOTFSPART_SUFFIX=s2a + fi +}