summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--platforms/blspec-entry.in4
-rw-r--r--platforms/kernel-fit.in35
-rw-r--r--rules/blspec-entry.make8
-rw-r--r--rules/kernel-fit.make56
-rw-r--r--rules/post/ptxd_make_image_fit.make25
-rw-r--r--scripts/lib/ptxd_make_fit_image.sh132
6 files changed, 257 insertions, 3 deletions
diff --git a/platforms/blspec-entry.in b/platforms/blspec-entry.in
index 3eb354202..e97d56b0c 100644
--- a/platforms/blspec-entry.in
+++ b/platforms/blspec-entry.in
@@ -3,7 +3,7 @@
menuconfig BLSPEC_ENTRY
tristate
select KERNEL
- select KERNEL_INSTALL
+ select KERNEL_INSTALL if !KERNEL_FIT
select DTC_INSTALL_OFTREE if DTC
prompt "default bootloader spec entry "
@@ -11,7 +11,7 @@ if BLSPEC_ENTRY
config BLSPEC_ENTRY_DEVICETREE
bool
- default DTC
+ default DTC && !KERNEL_FIT
config BLSPEC_ENTRY_CMDLINE
string
diff --git a/platforms/kernel-fit.in b/platforms/kernel-fit.in
new file mode 100644
index 000000000..8cbc1a85a
--- /dev/null
+++ b/platforms/kernel-fit.in
@@ -0,0 +1,35 @@
+## SECTION=image
+
+menuconfig KERNEL_FIT
+ tristate
+ select KERNEL
+ select HOST_DTC
+ select HOST_U_BOOT_TOOLS
+ select DTC
+ select CODE_SIGNING if KERNEL_FIT_SIGNED
+ select IMAGE_ROOT_CPIO if KERNEL_FIT_INITRAMFS
+ prompt "Generate images/linuximage.fit"
+ help
+ Generate a FIT image from the kernel image. This will contain
+ the Kernel image and all device trees in PTXCONF_DTC_OFTREE_DTS.
+ Configurations are provided for each device tree together witt
+ the Kernel image.
+
+if KERNEL_FIT
+
+config KERNEL_FIT_SIGNED
+ bool
+ prompt "sign FIT image"
+ help
+ If enabled a signed FIT image will be generated.
+
+config KERNEL_FIT_INITRAMFS
+ bool
+ depends on !KERNEL_FIT_INSTALL
+ prompt "include root filesystem as initramfs"
+
+config KERNEL_FIT_INSTALL
+ bool
+ prompt "install kernel into /boot"
+
+endif
diff --git a/rules/blspec-entry.make b/rules/blspec-entry.make
index be5b9fdda..1a222dff9 100644
--- a/rules/blspec-entry.make
+++ b/rules/blspec-entry.make
@@ -29,6 +29,12 @@ blspec/devicetree =
endif
BLSPEC_ENTRY_LICENSE = ignore
+ifdef PTXCONF_KERNEL_FIT
+BLSPEC_KERNEL_IMAGE = /boot/linux.fit
+else
+BLSPEC_KERNEL_IMAGE = $(KERNEL_IMAGE)
+endif
+
$(STATEDIR)/blspec-entry.targetinstall:
@$(call targetinfo)
@@ -48,7 +54,7 @@ $(STATEDIR)/blspec-entry.targetinstall:
$(call install_replace, blspec-entry, /loader/entries/$(name).conf, \
@CMDLINE@,$(PTXCONF_BLSPEC_ENTRY_CMDLINE))$(ptx/nl) \
$(call install_replace, blspec-entry, /loader/entries/$(name).conf, \
- @KERNEL@,'/boot/$(KERNEL_IMAGE)')$(ptx/nl) \
+ @KERNEL@,'/boot/$(BLSPEC_KERNEL_IMAGE)')$(ptx/nl) \
$(call install_replace, blspec-entry, /loader/entries/$(name).conf, \
@DEVICETREE@,'$(call blspec/devicetree,$(name))')$(ptx/nl))
diff --git a/rules/kernel-fit.make b/rules/kernel-fit.make
new file mode 100644
index 000000000..42237c9b8
--- /dev/null
+++ b/rules/kernel-fit.make
@@ -0,0 +1,56 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2019 by Sascha Hauer <s.hauer@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+ifdef PTXCONF_KERNEL_FIT_INSTALL
+PACKAGES-$(PTXCONF_KERNEL_FIT) += kernel-fit
+else
+EXTRA_PACKAGES-$(PTXCONF_KERNEL_FIT) += kernel-fit
+endif
+
+#
+# Paths and names
+#
+KERNEL_FIT_VERSION := $(KERNEL_VERSION)
+KERNEL_FIT_IMAGE := $(IMAGEDIR)/linuximage.fit
+ifdef PTXCONF_KERNEL_FIT_SIGNED
+KERNEL_FIT_SIGN_ROLE := image-kernel-fit
+KERNEL_FIT_KEY_NAME_HINT := image-kernel-fit
+endif
+KERNEL_FIT_KERNEL = $(KERNEL_IMAGE_PATH_y)
+ifdef PTXCONF_KERNEL_FIT_INITRAMFS
+KERNEL_FIT_INITRAMFS := $(IMAGEDIR)/root.cpio
+endif
+KERNEL_FIT_DTB = $(DTC_DTB)
+
+# ----------------------------------------------------------------------------
+# Target-Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/kernel-fit.targetinstall:
+ @$(call targetinfo)
+
+ @$(call world/image-fit, KERNEL_FIT)
+
+ifdef PTXCONF_KERNEL_FIT_INSTALL
+ @$(call install_init, kernel-fit)
+ @$(call install_fixup,kernel-fit,PRIORITY,optional)
+ @$(call install_fixup,kernel-fit,SECTION,base)
+ @$(call install_fixup,kernel-fit,AUTHOR,Sascha Hauer <s.hauer@pengutronix.de>)
+ @$(call install_fixup,kernel-fit,DESCRIPTION,missing)
+
+ @$(call install_copy, kernel-fit, 0, 0, 0644, $(KERNEL_FIT_IMAGE), /boot/linux.fit)
+
+ @$(call install_finish,kernel-fit)
+endif
+
+ @$(call touch)
+
+# vim: syntax=make
diff --git a/rules/post/ptxd_make_image_fit.make b/rules/post/ptxd_make_image_fit.make
new file mode 100644
index 000000000..2dd5bce9e
--- /dev/null
+++ b/rules/post/ptxd_make_image_fit.make
@@ -0,0 +1,25 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2019 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+world/image-fit/env/impl = \
+ $(call world/image/env, $(1)) \
+ $(CODE_SIGNING_ENV) \
+ image_sign_role="$(call ptx/escape,$($(1)_SIGN_ROLE))" \
+ image_key_name_hint="$(call ptx/escape,$($(1)_KEY_NAME_HINT))" \
+ image_kernel="$(call ptx/escape,$($(1)_KERNEL))" \
+ image_initramfs="$(call ptx/escape,$($(1)_INITRAMFS))" \
+ image_dtb="$(call ptx/escape,$($(1)_DTB))"
+
+world/image-fit/env = \
+ $(call world/image-fit/env/impl,$(strip $(1)))
+
+world/image-fit = \
+ $(call world/image-fit/env, $(1)) \
+ ptxd_make_image_fit
+
+# vim: syntax=make
diff --git a/scripts/lib/ptxd_make_fit_image.sh b/scripts/lib/ptxd_make_fit_image.sh
new file mode 100644
index 000000000..761d6bf1e
--- /dev/null
+++ b/scripts/lib/ptxd_make_fit_image.sh
@@ -0,0 +1,132 @@
+#!/bin/bash
+#
+# Copyright (C) 2019 Sascha Hauer <s.hauer@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+ptxd_make_image_fit_its() {
+ local model compatible
+
+ cat << EOF
+/dts-v1/;
+/ {
+ description = "Kernel Image";
+ #address-cells = <1>;
+
+ images {
+ kernel {
+ description = "kernel";
+ data = /incbin/("${image_kernel}");
+ type = "kernel";
+ compression = "none";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+EOF
+ if [ -n "${image_initramfs}" ]; then
+ cat << EOF
+ initramfs {
+ description = "initramfs";
+ data = /incbin/("${image_initramfs}");
+ type = "ramdisk";
+ compression = "none";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+EOF
+ fi
+ for i in ${image_dtb}; do
+ model=$(fdtget "${i}" / model)
+ compatible=$(set -- $(fdtget "${i}" / compatible); echo ${1})
+ cat << EOF
+ fdt-${compatible} {
+ data = /incbin/("${i}");
+ compression = "none";
+ type = "flat_dt";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+EOF
+ done
+ cat << EOF
+ };
+ configurations {
+EOF
+ for i in ${image_dtb}; do
+ model=$(fdtget "${i}" / model)
+ compatible=$(set -- $(fdtget "${i}" / compatible); echo ${1})
+ cat << EOF
+ conf-${compatible} {
+ compatible = "${compatible}";
+ kernel = "kernel";
+EOF
+ if [ -n "${image_initramfs}" ]; then
+ cat << EOF
+ ramdisk = "initramfs";
+EOF
+ fi
+ cat << EOF
+ fdt = "fdt-${compatible}";
+EOF
+ if [ -n "${image_sign_role}" ]; then
+ cat << EOF
+ signature-1 {
+ algo = "sha256,rsa4096";
+ key-name-hint = "${image_key_name_hint}";
+ sign-images = "fdt", "kernel";
+ };
+EOF
+ fi
+ cat << EOF
+ };
+EOF
+ done
+ cat << EOF
+ };
+};
+EOF
+}
+export -f ptxd_make_image_fit_its
+
+ptxd_make_image_fit() {
+ local pkcs11_uri
+ local its=$(mktemp ${PTXDIST_TEMPDIR}/fitimage.XXXXXXXX)
+ local -a sign_args
+
+ ptxd_make_image_init || return
+
+ if [ -n "${image_sign_role}" ]; then
+ pkcs11_uri=$(cs_get_uri "${image_sign_role}")
+
+ #
+ # It would have been too simple for mkimage to just take a
+ # PKCS#11 URI. We must drop the "pkcs11:" prefix which U-Boot
+ # then adds again. Also mkimage adds "object=<key_name_hint>"
+ # to the URI which our URI already has. Well having it twice
+ # doesn't seem to hurt at least SoftHSM.
+ #
+ pkcs11_uri=$(echo "${pkcs11_uri}" | sed "s/pkcs11://")
+ sign_args=( -k "${pkcs11_uri}" )
+ fi
+
+ if [ -z "${image_image}" ]; then
+ ptxd_bailout "ptxd_make_image_fit: image_image not given"
+ fi
+
+ if [ -z "${image_kernel}" ]; then
+ ptxd_bailout "ptxd_make_image_fit: image_kernel not given"
+ fi
+
+ ptxd_make_image_fit_its > "${its}" &&
+ if [ "${PTXDIST_VERBOSE}" == "1" ]; then
+ echo "Generated device-tree for the fit image:"
+ cat "${its}"
+ fi &&
+ mkimage -N pkcs11 -f "${its}" "${image_image}" -r "${sign_args[@]}"
+}
+export -f ptxd_make_image_fit