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 echo "Usage: $(basename $0) -A arch -C comp -a addr -e entry" \
19 "-v version -k kernel [-D name -d dtb] -o its_file"
20 echo -e "\t-A ==> set architecture to 'arch'"
21 echo -e "\t-C ==> set compression type 'comp'"
22 echo -e "\t-c ==> set config name 'config'"
23 echo -e "\t-a ==> set load address to 'addr' (hex)"
24 echo -e "\t-e ==> set entry point to 'entry' (hex)"
25 echo -e "\t-v ==> set kernel version to 'version'"
26 echo -e "\t-k ==> include kernel image 'kernel'"
27 echo -e "\t-D ==> human friendly Device Tree Blob 'name'"
28 echo -e "\t-d ==> include Device Tree Blob 'dtb'"
29 echo -e "\t-o ==> create output file 'its_file'"
33 while getopts ":A:a:c:C:D:d:e:k:o:v:" OPTION
37 a ) LOAD_ADDR=$OPTARG;;
39 C ) COMPRESS=$OPTARG;;
42 e ) ENTRY_ADDR=$OPTARG;;
46 * ) echo "Invalid option passed to '$0' (options:$@)"
51 # Make sure user entered all required parameters
52 if [ -z "${ARCH}" ] || [ -z "${COMPRESS}" ] || [ -z "${LOAD_ADDR}" ] || \
53 [ -z "${ENTRY_ADDR}" ] || [ -z "${VERSION}" ] || [ -z "${KERNEL}" ] || \
54 [ -z "${OUTPUT}" ] || [ -z "${CONFIG}" ]; then
58 ARCH_UPPER=$(echo $ARCH | tr '[:lower:]' '[:upper:]')
60 # Conditionally create fdt information
61 if [ -n "${DTB}" ]; then
64 description = \"${ARCH_UPPER} OpenWrt ${DEVICE} device tree blob\";
65 data = /incbin/(\"${DTB}\");
68 compression = \"none\";
77 FDT_PROP="fdt = \"fdt@1\";"
80 # Create a default, fully populated DTS file
84 description = \"${ARCH_UPPER} OpenWrt FIT (Flattened Image Tree)\";
89 description = \"${ARCH_UPPER} OpenWrt Linux-${VERSION}\";
90 data = /incbin/(\"${KERNEL}\");
94 compression = \"${COMPRESS}\";
95 load = <${LOAD_ADDR}>;
96 entry = <${ENTRY_ADDR}>;
108 default = \"${CONFIG}\";
110 description = \"OpenWrt\";
111 kernel = \"kernel@1\";
117 # Write .its file to disk
118 echo "$DATA" > ${OUTPUT}