3 # Licensed under the terms of the GNU GPL License version 2 or later.
5 # Author: Peter Tyser <ptyser@xes-inc.com>
7 # U-Boot firmware supports the booting of images in the Flattened Image
8 # Tree (FIT) format. The FIT format uses a device tree structure to
9 # describe a kernel image, device tree blob, ramdisk, etc. This script
10 # creates an Image Tree Source (.its file) which can be passed to the
11 # 'mkimage' utility to generate an Image Tree Blob (.itb file). The .itb
12 # file can then be booted by U-Boot (or other bootloaders which support
13 # FIT images). See doc/uImage.FIT/howto.txt in U-Boot source code for
14 # additional information on FIT images.
18 printf "Usage: %s -A arch -C comp -a addr -e entry" "$(basename "$0")"
19 printf " -v version -k kernel [-D name -n address -d dtb] -o its_file"
21 printf "\n\t-A ==> set architecture to 'arch'"
22 printf "\n\t-C ==> set compression type 'comp'"
23 printf "\n\t-c ==> set config name 'config'"
24 printf "\n\t-a ==> set load address to 'addr' (hex)"
25 printf "\n\t-e ==> set entry point to 'entry' (hex)"
26 printf "\n\t-f ==> set device tree compatible string"
27 printf "\n\t-v ==> set kernel version to 'version'"
28 printf "\n\t-k ==> include kernel image 'kernel'"
29 printf "\n\t-D ==> human friendly Device Tree Blob 'name'"
30 printf "\n\t-n ==> fdt unit-address 'address'"
31 printf "\n\t-d ==> include Device Tree Blob 'dtb'"
32 printf "\n\t-r ==> include RootFS blob 'rootfs'"
33 printf "\n\t-H ==> specify hash algo instead of SHA1"
34 printf "\n\t-o ==> create output file 'its_file'\n"
43 while getopts ":A:a:c:C:D:d:e:f:k:n:o:v:r:S" OPTION
47 a
) LOAD_ADDR
=$OPTARG;;
49 C
) COMPRESS
=$OPTARG;;
52 e
) ENTRY_ADDR
=$OPTARG;;
53 f
) COMPATIBLE
=$OPTARG;;
60 * ) echo "Invalid option passed to '$0' (options:$*)"
65 # Make sure user entered all required parameters
66 if [ -z "${ARCH}" ] || [ -z "${COMPRESS}" ] || [ -z "${LOAD_ADDR}" ] || \
67 [ -z "${ENTRY_ADDR}" ] || [ -z "${VERSION}" ] || [ -z "${KERNEL}" ] || \
68 [ -z "${OUTPUT}" ] ||
[ -z "${CONFIG}" ]; then
72 ARCH_UPPER
=$
(echo "$ARCH" |
tr '[:lower:]' '[:upper:]')
74 if [ -n "${COMPATIBLE}" ]; then
75 COMPATIBLE_PROP
="compatible = \"${COMPATIBLE}\";"
78 # Conditionally create fdt information
79 if [ -n "${DTB}" ]; then
82 description = \"${ARCH_UPPER} OpenWrt ${DEVICE} device tree blob\";
84 data = /incbin/(\"${DTB}\");
87 compression = \"none\";
96 FDT_PROP
="fdt = \"fdt@$FDTNUM\";"
99 if [ -n "${ROOTFS}" ]; then
100 dd if="${ROOTFS}" of
="${ROOTFS}.pagesync" bs
=4096 conv
=sync
103 description = \"${ARCH_UPPER} OpenWrt ${DEVICE} rootfs\";
105 data = /incbin/(\"${ROOTFS}.pagesync\");
106 type = \"filesystem\";
108 compression = \"none\";
117 LOADABLES
="${LOADABLES:+$LOADABLES, }\"rootfs@${ROOTFSNUM}\""
120 # Create a default, fully populated DTS file
124 description = \"${ARCH_UPPER} OpenWrt FIT (Flattened Image Tree)\";
125 #address-cells = <1>;
129 description = \"${ARCH_UPPER} OpenWrt Linux-${VERSION}\";
130 data = /incbin/(\"${KERNEL}\");
134 compression = \"${COMPRESS}\";
135 load = <${LOAD_ADDR}>;
136 entry = <${ENTRY_ADDR}>;
149 default = \"${CONFIG}\";
151 description = \"OpenWrt ${DEVICE}\";
152 kernel = \"kernel@1\";
154 ${LOADABLES:+loadables = ${LOADABLES};}
160 # Write .its file to disk
161 echo "$DATA" > "${OUTPUT}"