From patchwork Wed Nov 18 20:57:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Tyser X-Patchwork-Id: 61183 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAIL6eqd006930 for ; Wed, 18 Nov 2009 21:06:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757883AbZKRVGl (ORCPT ); Wed, 18 Nov 2009 16:06:41 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757923AbZKRVGk (ORCPT ); Wed, 18 Nov 2009 16:06:40 -0500 Received: from xes-mad.com ([216.165.139.218]:38352 "EHLO xes-mad.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757883AbZKRVGk (ORCPT ); Wed, 18 Nov 2009 16:06:40 -0500 X-Greylist: delayed 556 seconds by postgrey-1.27 at vger.kernel.org; Wed, 18 Nov 2009 16:06:33 EST Received: from localhost.localdomain (petert.xes-mad.com [10.52.0.62]) by xes-mad.com (8.13.8/8.13.8) with ESMTP id nAIKvFSU020637; Wed, 18 Nov 2009 14:57:17 -0600 From: Peter Tyser To: linuxppc-dev@ozlabs.org Cc: linux-kbuild@vger.kernel.org, Peter Tyser Subject: [PATCH 2/3] powerpc: Add support for creating FIT uImages Date: Wed, 18 Nov 2009 14:57:13 -0600 Message-Id: <1258577834-26006-3-git-send-email-ptyser@xes-inc.com> X-Mailer: git-send-email 1.6.2.1 In-Reply-To: <1258577834-26006-1-git-send-email-ptyser@xes-inc.com> References: <1258577834-26006-1-git-send-email-ptyser@xes-inc.com> X-Virus-Scanned: ClamAV 0.94.2/10038/Tue Nov 17 23:41:45 2009 on mail.xes-mad.com X-Virus-Status: Clean X-Spam-Status: No, score=-6.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, XES_TECH_DRIVER,XES_TECH_LINUX autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail.xes-mad.com Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 1a54a3b..459aed5 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -158,7 +158,8 @@ drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/ # Default to zImage, override when needed all: zImage -BOOT_TARGETS = zImage zImage.initrd uImage zImage% dtbImage% treeImage.% cuImage.% simpleImage.% +BOOT_TARGETS = zImage zImage.initrd uImage uImage.fit.% zImage% dtbImage% \ + treeImage.% cuImage.% simpleImage.% PHONY += $(BOOT_TARGETS) @@ -185,6 +186,7 @@ define archhelp @echo '* zImage - Build default images selected by kernel config' @echo ' zImage.* - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)' @echo ' uImage - U-Boot native image format' + @echo ' uImage.fit.
- U-Boot Flattened Image Tree image format' @echo ' cuImage.
- Backwards compatible U-Boot image for older' @echo ' versions which do not support device trees' @echo ' dtbImage.
- zImage with an embedded device tree blob' diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore index 3d80c3e..a443f1c 100644 --- a/arch/powerpc/boot/.gitignore +++ b/arch/powerpc/boot/.gitignore @@ -19,6 +19,7 @@ kernel-vmlinux.strip.c kernel-vmlinux.strip.gz mktree uImage +uImage.fit.* cuImage.* dtbImage.* treeImage.* diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index 7bfc8ad..57e4eee 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -307,6 +307,9 @@ $(obj)/zImage.iseries: vmlinux $(obj)/uImage: vmlinux $(wrapperbits) $(call if_changed,wrap,uboot) +$(obj)/uImage.fit.%: vmlinux $(obj)/%.dtb $(wrapperbits) + $(call if_changed,wrap,uboot.fit,,$(obj)/$*.dtb) + $(obj)/cuImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) $(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) @@ -346,7 +349,7 @@ install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y)) # anything not in $(targets) clean-files += $(image-) $(initrd-) cuImage.* dtbImage.* treeImage.* \ - zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \ + uImage.* zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \ zImage.iseries zImage.miboot zImage.pmac zImage.pseries \ simpleImage.* otheros.bld *.dtb diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index 1ee9448..26a971e 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper @@ -46,6 +46,9 @@ CROSS= # mkimage wrapper script MKIMAGE=$srctree/scripts/mkuboot.sh +# script to generate an .its file for uImage.fit.* images +MKITS=$srctree/scripts/mkits.sh + # directory for object and other files used by this script object=arch/powerpc/boot objbin=$object @@ -157,7 +160,7 @@ coff) lds=$object/zImage.coff.lds link_address='0x500000' ;; -miboot|uboot) +miboot|uboot|uboot.fit) # miboot and U-boot want just the bare bits, not an ELF binary ext=bin objflags="-O binary" @@ -273,6 +276,17 @@ uboot) fi exit 0 ;; +uboot.fit) + rm -f "$ofile" + ${MKITS} -A ppc -C gzip -a $membase -e $membase -v $version \ + -d "$srctree/$dtb" -k "$srctree/$vmz" -o "$object/uImage.its" + ${MKIMAGE} -f "$object/uImage.its" "$ofile" + rm "$object/uImage.its" + if [ -z "$cacheit" ]; then + rm -f "$vmz" + fi + exit 0 + ;; esac addsec() { diff --git a/scripts/mkits.sh b/scripts/mkits.sh new file mode 100755 index 0000000..a438cac --- /dev/null +++ b/scripts/mkits.sh @@ -0,0 +1,113 @@ +#!/bin/bash +# +# Licensed under the terms of the GNU GPL License version 2 or later. +# +# Author: Peter Tyser +# +# U-Boot firmware supports the booting of images in the Flattened Image +# Tree (FIT) format. The FIT format uses a device tree structure to +# describe a kernel image, device tree blob, ramdisk, etc. This script +# creates an Image Tree Source (.its file) which can be passed to the +# 'mkimage' utility to generate an Image Tree Blob (.itb file). The .itb +# file can then be booted by U-Boot (or other bootloaders which support +# FIT images). See doc/uImage.FIT/howto.txt in U-Boot source code for +# additional information on FIT images. +# + +usage() { + echo "Usage: `basename $0` -A arch -C comp -a addr -e entry" \ + "-v version -k kernel [-d dtb] -o its_file" + echo -e "\t-A ==> set architecture to 'arch'" + echo -e "\t-C ==> set compression type 'comp'" + echo -e "\t-a ==> set load address to 'addr' (hex)" + echo -e "\t-e ==> set entry point to 'entry' (hex)" + echo -e "\t-v ==> set kernel version to 'version'" + echo -e "\t-k ==> include kernel image 'kernel'" + echo -e "\t-d ==> include Device Tree Blob 'dtb'" + echo -e "\t-o ==> create output file 'its_file'" + exit 1 +} + +while getopts ":A:C:a:d:e:k:o:v:" OPTION +do + case $OPTION in + A ) ARCH=$OPTARG;; + C ) COMPRESS=$OPTARG;; + a ) LOAD_ADDR=$OPTARG;; + d ) DTB=$OPTARG;; + e ) ENTRY_ADDR=$OPTARG;; + k ) KERNEL=$OPTARG;; + o ) OUTPUT=$OPTARG;; + v ) VERSION=$OPTARG;; + * ) echo "Invalid option passed to '$0' (options:$@)" + usage;; + esac +done + +# Make sure user entered all required parameters +if [ -z "${ARCH}" ] || [ -z "${COMPRESS}" ] || [ -z "${LOAD_ADDR}" ] || \ + [ -z "${ENTRY_ADDR}" ] || [ -z "${VERSION}" ] || [ -z "${KERNEL}" ] || \ + [ -z "${OUTPUT}" ]; then + usage +fi + +# Device trees need the leading '0x' stripped for hex numbers +LOAD_ADDR=`echo $LOAD_ADDR | sed 's/0x//'` +ENTRY_ADDR=`echo $ENTRY_ADDR | sed 's/0x//'` + +# Create a default, fully populated DTS file +DATA="/ { + description = \"Linux kernel ${VERSION}\"; + #address-cells = <1>; + + images { + kernel@1 { + description = \"Linux Kernel ${VERSION}\"; + data = /incbin/(\"${KERNEL}\"); + type = \"kernel\"; + arch = \"${ARCH}\"; + os = \"linux\"; + compression = \"${COMPRESS}\"; + load = <${LOAD_ADDR}>; + entry = <${ENTRY_ADDR}>; + hash@1 { + algo = \"crc32\"; + }; + hash@2 { + algo = \"sha1\"; + }; + }; + + fdt@1 { /* start fdt */ + description = \"Flattened Device Tree blob\"; + data = /incbin/(\"${DTB}\"); + type = \"flat_dt\"; + arch = \"${ARCH}\"; + compression = \"none\"; + hash@1 { + algo = \"crc32\"; + }; + hash@2 { + algo = \"sha1\"; + }; + }; /* end fdt */ + + configurations { + default = \"config@1\"; + config@1 { + description = \"Default Linux kernel\"; + kernel = \"kernel@1\"; + fdt = \"fdt@1\"; + ramdisk = \"ramdisk@1\"; + }; + }; +};" + +# Conditionally strip fdt information out of tree +if [ -z "${DTB}" ]; then + DATA=`echo "$DATA" | sed '/start fdt/,/end fdt/d'` + DATA=`echo "$DATA" | sed '/fdt/d'` +fi + +# Write .its file to disk +echo "$DATA" > ${OUTPUT}