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-v ==> set kernel version to 'version'"
27 printf "\n\t-k ==> include kernel image 'kernel'"
28 printf "\n\t-D ==> human friendly Device Tree Blob 'name'"
29 printf "\n\t-n ==> fdt unit-address 'address'"
30 printf "\n\t-d ==> include Device Tree Blob 'dtb'"
31 printf "\n\t-o ==> create output file 'its_file'\n"
37 while getopts ":A:a:c:C:D:d:e:k:n:o:v:" OPTION
41 a
) LOAD_ADDR
=$OPTARG;;
43 C
) COMPRESS
=$OPTARG;;
46 e
) ENTRY_ADDR
=$OPTARG;;
51 * ) echo "Invalid option passed to '$0' (options:$*)"
56 # Make sure user entered all required parameters
57 if [ -z "${ARCH}" ] || [ -z "${COMPRESS}" ] || [ -z "${LOAD_ADDR}" ] || \
58 [ -z "${ENTRY_ADDR}" ] || [ -z "${VERSION}" ] || [ -z "${KERNEL}" ] || \
59 [ -z "${OUTPUT}" ] ||
[ -z "${CONFIG}" ]; then
63 ARCH_UPPER
=$
(echo "$ARCH" |
tr '[:lower:]' '[:upper:]')
65 # Conditionally create fdt information
66 if [ -n "${DTB}" ]; then
69 description = \"${ARCH_UPPER} OpenWrt ${DEVICE} device tree blob\";
70 data = /incbin/(\"${DTB}\");
73 compression = \"none\";
82 FDT_PROP
="fdt = \"fdt@$FDTNUM\";"
85 # Create a default, fully populated DTS file
89 description = \"${ARCH_UPPER} OpenWrt FIT (Flattened Image Tree)\";
94 description = \"${ARCH_UPPER} OpenWrt Linux-${VERSION}\";
95 data = /incbin/(\"${KERNEL}\");
99 compression = \"${COMPRESS}\";
100 load = <${LOAD_ADDR}>;
101 entry = <${ENTRY_ADDR}>;
113 default = \"${CONFIG}\";
115 description = \"OpenWrt\";
116 kernel = \"kernel@1\";
122 # Write .its file to disk
123 echo "$DATA" > "${OUTPUT}"