summaryrefslogtreecommitdiff
path: root/target/linux/mpc83xx
diff options
context:
space:
mode:
authorkaloz <kaloz@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-01-10 18:14:23 +0000
committerkaloz <kaloz@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-01-10 18:14:23 +0000
commitd7fbd60e8ef9911b95a92b78704a65cddf2bf593 (patch)
tree7eb8281cfc687bae9dc3d7c1da13d3cbf26884e7 /target/linux/mpc83xx
parentab2cda2f104e2692a6493eac779a03cda48533ff (diff)
[mpc83xx]: FIT uImage support for the MPC8377-WLAN
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19094 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/mpc83xx')
-rw-r--r--target/linux/mpc83xx/config-default1
-rwxr-xr-xtarget/linux/mpc83xx/files/scripts/mkits.sh111
-rw-r--r--target/linux/mpc83xx/image/Makefile11
-rw-r--r--target/linux/mpc83xx/patches/005-powerpc_mkuboot.patch30
-rw-r--r--target/linux/mpc83xx/patches/006-powerpc_create_fit_uImages.patch94
5 files changed, 240 insertions, 7 deletions
diff --git a/target/linux/mpc83xx/config-default b/target/linux/mpc83xx/config-default
index 955ad9a746..bbb69d5c6b 100644
--- a/target/linux/mpc83xx/config-default
+++ b/target/linux/mpc83xx/config-default
@@ -38,6 +38,7 @@ CONFIG_DTC=y
CONFIG_EARLY_PRINTK=y
# CONFIG_EDAC is not set
# CONFIG_EMBEDDED6xx is not set
+CONFIG_EXTRA_TARGETS="uImage.fit.mpc8377_wlan"
CONFIG_FORCE_MAX_ZONEORDER=11
# CONFIG_FSL_EMB_PERFMON is not set
CONFIG_FSL_PCI=y
diff --git a/target/linux/mpc83xx/files/scripts/mkits.sh b/target/linux/mpc83xx/files/scripts/mkits.sh
new file mode 100755
index 0000000000..3b02b6950a
--- /dev/null
+++ b/target/linux/mpc83xx/files/scripts/mkits.sh
@@ -0,0 +1,111 @@
+#!/bin/bash
+#
+# Licensed under the terms of the GNU GPL License version 2 or later.
+#
+# Author: Peter Tyser <ptyser@xes-inc.com>
+#
+# 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
+
+# Create a default, fully populated DTS file
+DATA="/dts-v1/;
+
+/ {
+ 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\";
+ };
+ };
+};"
+
+# 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}
diff --git a/target/linux/mpc83xx/image/Makefile b/target/linux/mpc83xx/image/Makefile
index 8004f746b5..ed00128999 100644
--- a/target/linux/mpc83xx/image/Makefile
+++ b/target/linux/mpc83xx/image/Makefile
@@ -9,7 +9,6 @@ include $(INCLUDE_DIR)/image.mk
define Image/Prepare
- $(LINUX_DIR)/scripts/dtc/dtc -O dtb -R 4 -S 0x20000 $(LINUX_DIR)/arch/powerpc/boot/dts/mpc8377_wlan.dts > $(KDIR)/openwrt-mpc8377_wlan.dtb
endef
define Image/BuildKernel
@@ -22,12 +21,10 @@ endef
define Image/Build/squashfs
$(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
-# We'll do FIT here
-# ( \
-# dd if=$(LINUX_DIR)/arch/powerpc/boot/uImage bs=1920k conv=sync; \
-# dd if=$(KDIR)/openwrt-mpc8377_wlan.dtb bs=128k conv=sync; \
-# dd if=$(KDIR)/root.$(1) bs=256k conv=sync; \
-# ) > $(BIN_DIR)/openwrt-$(BOARD)-mpc8377_wlan-$(1).img
+ ( \
+ dd if=$(LINUX_DIR)/arch/powerpc/boot/uImage.fit.mpc8377_wlan bs=3072k conv=sync; \
+ dd if=$(KDIR)/root.$(1) bs=256k conv=sync; \
+ ) > $(BIN_DIR)/openwrt-$(BOARD)-mpc8377_wlan-$(1).img
endef
$(eval $(call BuildImage))
diff --git a/target/linux/mpc83xx/patches/005-powerpc_mkuboot.patch b/target/linux/mpc83xx/patches/005-powerpc_mkuboot.patch
new file mode 100644
index 0000000000..8e200b1a65
--- /dev/null
+++ b/target/linux/mpc83xx/patches/005-powerpc_mkuboot.patch
@@ -0,0 +1,30 @@
+--- a/arch/powerpc/boot/wrapper
++++ b/arch/powerpc/boot/wrapper
+@@ -43,6 +43,9 @@ gzip=.gz
+ # cross-compilation prefix
+ CROSS=
+
++# mkimage wrapper script
++MKIMAGE=$srctree/scripts/mkuboot.sh
++
+ # directory for object and other files used by this script
+ object=arch/powerpc/boot
+ objbin=$object
+@@ -262,7 +265,7 @@ membase=`${CROSS}objdump -p "$kernel" |
+ case "$platform" in
+ uboot)
+ rm -f "$ofile"
+- mkimage -A ppc -O linux -T kernel -C gzip -a $membase -e $membase \
++ ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a $membase -e $membase \
+ $uboot_version -d "$vmz" "$ofile"
+ if [ -z "$cacheit" ]; then
+ rm -f "$vmz"
+@@ -322,7 +325,7 @@ coff)
+ ;;
+ cuboot*)
+ gzip -f -9 "$ofile"
+- mkimage -A ppc -O linux -T kernel -C gzip -a "$base" -e "$entry" \
++ ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a "$base" -e "$entry" \
+ $uboot_version -d "$ofile".gz "$ofile"
+ ;;
+ treeboot*)
diff --git a/target/linux/mpc83xx/patches/006-powerpc_create_fit_uImages.patch b/target/linux/mpc83xx/patches/006-powerpc_create_fit_uImages.patch
new file mode 100644
index 0000000000..d553c675dc
--- /dev/null
+++ b/target/linux/mpc83xx/patches/006-powerpc_create_fit_uImages.patch
@@ -0,0 +1,94 @@
+--- a/arch/powerpc/Makefile
++++ b/arch/powerpc/Makefile
+@@ -157,7 +157,8 @@ drivers-$(CONFIG_OPROFILE) += arch/power
+ # 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)
+
+@@ -173,6 +174,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.<dt> - U-Boot Flattened Image Tree image format'
+ @echo ' cuImage.<dt> - Backwards compatible U-Boot image for older'
+ @echo ' versions which do not support device trees'
+ @echo ' dtbImage.<dt> - zImage with an embedded device tree blob'
+--- 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.*
+--- a/arch/powerpc/boot/Makefile
++++ b/arch/powerpc/boot/Makefile
+@@ -306,6 +306,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)
+
+@@ -345,7 +348,7 @@ install: $(CONFIGURE) $(addprefix $(obj)
+
+ # 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
+
+--- 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
+@@ -156,7 +159,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"
+@@ -272,6 +275,21 @@ 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 calls dtc for FIT images so use kernel dtc if necessary
++ export PATH=$PATH:$srctree/scripts/dtc
++
++ ${MKIMAGE} -f "$object/uImage.its" "$ofile"
++ rm "$object/uImage.its"
++ if [ -z "$cacheit" ]; then
++ rm -f "$vmz"
++ fi
++ exit 0
++ ;;
+ esac
+
+ addsec() {