[8/9] Add support for the BeaglePlay board

Message ID f158b7531b4384421203602a186e6ff0c349cf49.1704632056.git.jan.kiszka@siemens.com
State Superseded, archived
Headers show
Series Add support for BeaglePlay | expand

Commit Message

Jan Kiszka Jan. 7, 2024, 12:54 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

This creates a minimal image for the BeaglePlay board [1], using UEFI as
boot method.

That is requiring some extra work so that the image can also be used on
SD cards: The ROM loader only supports legacy DOS partition tables, but
UEFI needs GPT. We address this by creating a hybrid image with both
partition tables in place, first allowing wic to generate a GPT table,
then using fdisk to add a DOS partition entry at least for the UEFI boot
partition.

[1] https://www.beagleboard.org/boards/beagleplay

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 kas/machine/Kconfig                           |  5 ++++
 kas/machine/beagleplay.yaml                   |  9 +++++++
 .../imagetypes_beagleplay_hybrid.bbclass      | 25 +++++++++++++++++++
 meta-isar/conf/machine/beagleplay.conf        | 24 ++++++++++++++++++
 meta-isar/conf/mc.conf                        |  1 +
 .../conf/multiconfig/beagleplay-bookworm.conf |  7 ++++++
 .../lib/wic/canned-wks/beagleplay.wks.in      | 11 ++++++++
 7 files changed, 82 insertions(+)
 create mode 100644 kas/machine/beagleplay.yaml
 create mode 100644 meta-isar/classes/imagetypes_beagleplay_hybrid.bbclass
 create mode 100644 meta-isar/conf/machine/beagleplay.conf
 create mode 100644 meta-isar/conf/multiconfig/beagleplay-bookworm.conf
 create mode 100644 meta-isar/scripts/lib/wic/canned-wks/beagleplay.wks.in

Comments

Jan Kiszka Jan. 7, 2024, 4:40 p.m. UTC | #1
On 07.01.24 13:54, 'Jan Kiszka' via isar-users wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> This creates a minimal image for the BeaglePlay board [1], using UEFI as
> boot method.
> 
> That is requiring some extra work so that the image can also be used on
> SD cards: The ROM loader only supports legacy DOS partition tables, but
> UEFI needs GPT. We address this by creating a hybrid image with both
> partition tables in place, first allowing wic to generate a GPT table,
> then using fdisk to add a DOS partition entry at least for the UEFI boot
> partition.
> 
> [1] https://www.beagleboard.org/boards/beagleplay
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  kas/machine/Kconfig                           |  5 ++++
>  kas/machine/beagleplay.yaml                   |  9 +++++++
>  .../imagetypes_beagleplay_hybrid.bbclass      | 25 +++++++++++++++++++
>  meta-isar/conf/machine/beagleplay.conf        | 24 ++++++++++++++++++
>  meta-isar/conf/mc.conf                        |  1 +
>  .../conf/multiconfig/beagleplay-bookworm.conf |  7 ++++++
>  .../lib/wic/canned-wks/beagleplay.wks.in      | 11 ++++++++
>  7 files changed, 82 insertions(+)
>  create mode 100644 kas/machine/beagleplay.yaml
>  create mode 100644 meta-isar/classes/imagetypes_beagleplay_hybrid.bbclass
>  create mode 100644 meta-isar/conf/machine/beagleplay.conf
>  create mode 100644 meta-isar/conf/multiconfig/beagleplay-bookworm.conf
>  create mode 100644 meta-isar/scripts/lib/wic/canned-wks/beagleplay.wks.in
> 
> diff --git a/kas/machine/Kconfig b/kas/machine/Kconfig
> index d0e3963a..b06cddf1 100644
> --- a/kas/machine/Kconfig
> +++ b/kas/machine/Kconfig
> @@ -14,6 +14,10 @@ config MACHINE_BANANAPI
>  	bool "bananapi"
>  	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
>  
> +config MACHINE_BEAGLEPLAY
> +	bool "beagleplay"
> +	depends on DEBIAN_BOOKWORM
> +
>  config MACHINE_CONTAINER_AMD64
>  	bool "container-amd64"
>  	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
> @@ -111,6 +115,7 @@ endchoice
>  config KAS_INCLUDE_MACHINE
>  	string
>  	default "kas/machine/bananapi.yaml" if MACHINE_BANANAPI
> +	default "kas/machine/beagleplay.yaml" if MACHINE_BEAGLEPLAY
>  	default "kas/machine/container-amd64.yaml" if MACHINE_CONTAINER_AMD64
>  	default "kas/machine/de0-nano-soc.yaml" if MACHINE_DE0_NANO_SOC
>  	default "kas/machine/hikey.yaml" if MACHINE_HIKEY
> diff --git a/kas/machine/beagleplay.yaml b/kas/machine/beagleplay.yaml
> new file mode 100644
> index 00000000..81fc4c32
> --- /dev/null
> +++ b/kas/machine/beagleplay.yaml
> @@ -0,0 +1,9 @@
> +# This software is a part of ISAR.
> +# Copyright (c) Siemens AG, 2023
> +#
> +# SPDX-License-Identifier: MIT
> +
> +header:
> +  version: 14
> +
> +machine: beagleplay
> diff --git a/meta-isar/classes/imagetypes_beagleplay_hybrid.bbclass b/meta-isar/classes/imagetypes_beagleplay_hybrid.bbclass
> new file mode 100644
> index 00000000..00631082
> --- /dev/null
> +++ b/meta-isar/classes/imagetypes_beagleplay_hybrid.bbclass
> @@ -0,0 +1,25 @@
> +#
> +# Copyright (c) Siemens AG, 2023
> +#
> +# SPDX-License-Identifier: MIT
> +
> +IMAGE_TYPEDEP:beagleplay_hybrid = "wic"
> +
> +IMAGER_INSTALL:beagleplay_hybrid += "gdisk fdisk bmap-tools"
> +
> +IMAGE_CMD:beagleplay_hybrid() {
> +    ln -sf "${IMAGE_FULLNAME}.wic" "${IMAGE_FILE_HOST}"
> +    ${SUDO_CHROOT} sh -c '
> +        sgdisk "${IMAGE_FILE_CHROOT}" --hybrid 1:EE
> +        fdisk "${IMAGE_FILE_CHROOT}" << EOF
> +M
> +t
> +1
> +c
> +a
> +1
> +w
> +q
> +EOF
> +        bmaptool create ${IMAGE_FILE_CHROOT} -o ${PP_DEPLOY}/${IMAGE_FULLNAME}.wic.bmap'
> +}
> diff --git a/meta-isar/conf/machine/beagleplay.conf b/meta-isar/conf/machine/beagleplay.conf
> new file mode 100644
> index 00000000..8b1a088c
> --- /dev/null
> +++ b/meta-isar/conf/machine/beagleplay.conf
> @@ -0,0 +1,24 @@
> +#
> +# Copyright (c) Siemens AG, 2023
> +#
> +# SPDX-License-Identifier: MIT
> +
> +DISTRO_ARCH ?= "arm64"
> +
> +KERNEL_NAME ?= "mainline"
> +
> +DTB_BEAGLEPLAY = "k3-am625-beagleplay.dtb"
> +DTB_FILES ?= "${DTB_BEAGLEPLAY}"
> +
> +IMAGE_CLASSES += "imagetypes_beagleplay_hybrid"
> +IMAGE_FSTYPES ?= "wic beagleplay_hybrid"
> +WKS_FILE ?= "beagleplay.wks.in"
> +IMAGER_INSTALL += "${SYSTEMD_BOOTLOADER_INSTALL} u-boot-beagleplay"
> +IMAGER_BUILD_DEPS += "u-boot-beagleplay"
> +
> +IMAGE_BOOT_FILES = " \
> +    /usr/lib/u-boot/beagleplay/tiboot3-am62x-gp-evm.bin;tiboot3.bin \
> +    /usr/lib/u-boot/beagleplay/tispl.bin_unsigned;tispl.bin \
> +    /usr/lib/u-boot/beagleplay/u-boot.img_unsigned;u-boot.img"
> +
> +IMAGE_PREINSTALL += "firmware-ti-connectivity"
> diff --git a/meta-isar/conf/mc.conf b/meta-isar/conf/mc.conf
> index d16f54b5..f1fb50c6 100644
> --- a/meta-isar/conf/mc.conf
> +++ b/meta-isar/conf/mc.conf
> @@ -28,6 +28,7 @@ BBMULTICONFIG = " \
>      qemuriscv64-sid \
>      bananapi-buster \
>      bananapi-bullseye \
> +    beagleplay-bookworm \
>      de0-nano-soc-buster \
>      de0-nano-soc-bullseye \
>      hikey-bullseye \
> diff --git a/meta-isar/conf/multiconfig/beagleplay-bookworm.conf b/meta-isar/conf/multiconfig/beagleplay-bookworm.conf
> new file mode 100644
> index 00000000..1720cf5d
> --- /dev/null
> +++ b/meta-isar/conf/multiconfig/beagleplay-bookworm.conf
> @@ -0,0 +1,7 @@
> +#
> +# Copyright (c) Siemens AG, 2023
> +#
> +# SPDX-License-Identifier: MIT
> +
> +MACHINE ?= "beagleplay"
> +DISTRO ?= "debian-bookworm"
> diff --git a/meta-isar/scripts/lib/wic/canned-wks/beagleplay.wks.in b/meta-isar/scripts/lib/wic/canned-wks/beagleplay.wks.in
> new file mode 100644
> index 00000000..4a437e89
> --- /dev/null
> +++ b/meta-isar/scripts/lib/wic/canned-wks/beagleplay.wks.in
> @@ -0,0 +1,11 @@
> +#
> +# Copyright (c) Siemens AG, 2023
> +#
> +# SPDX-License-Identifier: MIT
> +
> +part /boot/firmware --source bootimg-partition --fstype=vfat --label firmware --active --align 1024 --size 16M --overhead-factor 1 --extra-space 0 --use-uuid
> +part /boot --source bootimg-efi-isar --sourceparams "loader=systemd-boot,dtb=${DTB_BEAGLEPLAY}" --label efi --part-type EF00 --align 1024 --use-uuid

In fact, we are fine with the firmware provided DTB by now. I'll drop
DTB_BEAGLEPLAY in a v2, just waiting for more feedback first.

Jan

> +
> +part / --source rootfs --fstype ext4 --mkfs-extraopts "-T default" --label platform --align 1024 --use-uuid --exclude-path boot/
> +
> +bootloader --ptable gpt --timeout=0 --append "rootwait rw"

Patch

diff --git a/kas/machine/Kconfig b/kas/machine/Kconfig
index d0e3963a..b06cddf1 100644
--- a/kas/machine/Kconfig
+++ b/kas/machine/Kconfig
@@ -14,6 +14,10 @@  config MACHINE_BANANAPI
 	bool "bananapi"
 	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
 
+config MACHINE_BEAGLEPLAY
+	bool "beagleplay"
+	depends on DEBIAN_BOOKWORM
+
 config MACHINE_CONTAINER_AMD64
 	bool "container-amd64"
 	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
@@ -111,6 +115,7 @@  endchoice
 config KAS_INCLUDE_MACHINE
 	string
 	default "kas/machine/bananapi.yaml" if MACHINE_BANANAPI
+	default "kas/machine/beagleplay.yaml" if MACHINE_BEAGLEPLAY
 	default "kas/machine/container-amd64.yaml" if MACHINE_CONTAINER_AMD64
 	default "kas/machine/de0-nano-soc.yaml" if MACHINE_DE0_NANO_SOC
 	default "kas/machine/hikey.yaml" if MACHINE_HIKEY
diff --git a/kas/machine/beagleplay.yaml b/kas/machine/beagleplay.yaml
new file mode 100644
index 00000000..81fc4c32
--- /dev/null
+++ b/kas/machine/beagleplay.yaml
@@ -0,0 +1,9 @@ 
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2023
+#
+# SPDX-License-Identifier: MIT
+
+header:
+  version: 14
+
+machine: beagleplay
diff --git a/meta-isar/classes/imagetypes_beagleplay_hybrid.bbclass b/meta-isar/classes/imagetypes_beagleplay_hybrid.bbclass
new file mode 100644
index 00000000..00631082
--- /dev/null
+++ b/meta-isar/classes/imagetypes_beagleplay_hybrid.bbclass
@@ -0,0 +1,25 @@ 
+#
+# Copyright (c) Siemens AG, 2023
+#
+# SPDX-License-Identifier: MIT
+
+IMAGE_TYPEDEP:beagleplay_hybrid = "wic"
+
+IMAGER_INSTALL:beagleplay_hybrid += "gdisk fdisk bmap-tools"
+
+IMAGE_CMD:beagleplay_hybrid() {
+    ln -sf "${IMAGE_FULLNAME}.wic" "${IMAGE_FILE_HOST}"
+    ${SUDO_CHROOT} sh -c '
+        sgdisk "${IMAGE_FILE_CHROOT}" --hybrid 1:EE
+        fdisk "${IMAGE_FILE_CHROOT}" << EOF
+M
+t
+1
+c
+a
+1
+w
+q
+EOF
+        bmaptool create ${IMAGE_FILE_CHROOT} -o ${PP_DEPLOY}/${IMAGE_FULLNAME}.wic.bmap'
+}
diff --git a/meta-isar/conf/machine/beagleplay.conf b/meta-isar/conf/machine/beagleplay.conf
new file mode 100644
index 00000000..8b1a088c
--- /dev/null
+++ b/meta-isar/conf/machine/beagleplay.conf
@@ -0,0 +1,24 @@ 
+#
+# Copyright (c) Siemens AG, 2023
+#
+# SPDX-License-Identifier: MIT
+
+DISTRO_ARCH ?= "arm64"
+
+KERNEL_NAME ?= "mainline"
+
+DTB_BEAGLEPLAY = "k3-am625-beagleplay.dtb"
+DTB_FILES ?= "${DTB_BEAGLEPLAY}"
+
+IMAGE_CLASSES += "imagetypes_beagleplay_hybrid"
+IMAGE_FSTYPES ?= "wic beagleplay_hybrid"
+WKS_FILE ?= "beagleplay.wks.in"
+IMAGER_INSTALL += "${SYSTEMD_BOOTLOADER_INSTALL} u-boot-beagleplay"
+IMAGER_BUILD_DEPS += "u-boot-beagleplay"
+
+IMAGE_BOOT_FILES = " \
+    /usr/lib/u-boot/beagleplay/tiboot3-am62x-gp-evm.bin;tiboot3.bin \
+    /usr/lib/u-boot/beagleplay/tispl.bin_unsigned;tispl.bin \
+    /usr/lib/u-boot/beagleplay/u-boot.img_unsigned;u-boot.img"
+
+IMAGE_PREINSTALL += "firmware-ti-connectivity"
diff --git a/meta-isar/conf/mc.conf b/meta-isar/conf/mc.conf
index d16f54b5..f1fb50c6 100644
--- a/meta-isar/conf/mc.conf
+++ b/meta-isar/conf/mc.conf
@@ -28,6 +28,7 @@  BBMULTICONFIG = " \
     qemuriscv64-sid \
     bananapi-buster \
     bananapi-bullseye \
+    beagleplay-bookworm \
     de0-nano-soc-buster \
     de0-nano-soc-bullseye \
     hikey-bullseye \
diff --git a/meta-isar/conf/multiconfig/beagleplay-bookworm.conf b/meta-isar/conf/multiconfig/beagleplay-bookworm.conf
new file mode 100644
index 00000000..1720cf5d
--- /dev/null
+++ b/meta-isar/conf/multiconfig/beagleplay-bookworm.conf
@@ -0,0 +1,7 @@ 
+#
+# Copyright (c) Siemens AG, 2023
+#
+# SPDX-License-Identifier: MIT
+
+MACHINE ?= "beagleplay"
+DISTRO ?= "debian-bookworm"
diff --git a/meta-isar/scripts/lib/wic/canned-wks/beagleplay.wks.in b/meta-isar/scripts/lib/wic/canned-wks/beagleplay.wks.in
new file mode 100644
index 00000000..4a437e89
--- /dev/null
+++ b/meta-isar/scripts/lib/wic/canned-wks/beagleplay.wks.in
@@ -0,0 +1,11 @@ 
+#
+# Copyright (c) Siemens AG, 2023
+#
+# SPDX-License-Identifier: MIT
+
+part /boot/firmware --source bootimg-partition --fstype=vfat --label firmware --active --align 1024 --size 16M --overhead-factor 1 --extra-space 0 --use-uuid
+part /boot --source bootimg-efi-isar --sourceparams "loader=systemd-boot,dtb=${DTB_BEAGLEPLAY}" --label efi --part-type EF00 --align 1024 --use-uuid
+
+part / --source rootfs --fstype ext4 --mkfs-extraopts "-T default" --label platform --align 1024 --use-uuid --exclude-path boot/
+
+bootloader --ptable gpt --timeout=0 --append "rootwait rw"