blob: 905e51d91a33231505b5a585db2d1ca5478b4e91 [file] [log] [blame]
developer56a5c542022-03-31 04:13:40 +08001diff --git a/scripts/mkits.sh b/scripts/mkits.sh
2index 547a4eb..1075367 100755
3--- a/scripts/mkits.sh
4+++ b/scripts/mkits.sh
5@@ -17,6 +17,7 @@
6 usage() {
7 printf "Usage: %s -A arch -C comp -a addr -e entry" "$(basename "$0")"
8 printf " -v version -k kernel [-D name -n address -d dtb] -o its_file"
9+ printf " [-s script] [-S key_name_hint] [-r ar_ver]"
10
11 printf "\n\t-A ==> set architecture to 'arch'"
12 printf "\n\t-C ==> set compression type 'comp'"
13@@ -28,13 +29,16 @@ usage() {
14 printf "\n\t-D ==> human friendly Device Tree Blob 'name'"
15 printf "\n\t-n ==> fdt unit-address 'address'"
16 printf "\n\t-d ==> include Device Tree Blob 'dtb'"
17- printf "\n\t-o ==> create output file 'its_file'\n"
18+ printf "\n\t-o ==> create output file 'its_file'"
19+ printf "\n\t-s ==> include u-boot script 'script'"
20+ printf "\n\t-S ==> add signature at configurations and assign its key_name_hint by 'key_name_hint'"
21+ printf "\n\t-r ==> set anti-rollback version to 'fw_ar_ver' (dec)\n"
22 exit 1
23 }
24
25 FDTNUM=1
26
27-while getopts ":A:a:c:C:D:d:e:k:n:o:v:" OPTION
28+while getopts ":A:a:c:C:D:d:e:k:n:o:v:s:S:r:" OPTION
29 do
30 case $OPTION in
31 A ) ARCH=$OPTARG;;
32@@ -48,6 +52,9 @@ do
33 n ) FDTNUM=$OPTARG;;
34 o ) OUTPUT=$OPTARG;;
35 v ) VERSION=$OPTARG;;
36+ s ) UBOOT_SCRIPT=$OPTARG;;
37+ S ) KEY_NAME_HINT=$OPTARG;;
38+ r ) AR_VER=$OPTARG;;
39 * ) echo "Invalid option passed to '$0' (options:$*)"
40 usage;;
41 esac
42@@ -82,6 +89,56 @@ if [ -n "${DTB}" ]; then
43 FDT_PROP="fdt = \"fdt-$FDTNUM\";"
44 fi
45
46+# Conditionally create script information
47+if [ -n "${UBOOT_SCRIPT}" ]; then
48+ SCRIPT="\
49+ script-1 {
50+ description = \"U-Boot Script\";
51+ data = /incbin/(\"${UBOOT_SCRIPT}\");
52+ type = \"script\";
53+ arch = \"${ARCH}\";
54+ os = \"linux\";
55+ load = <0>;
56+ entry = <0>;
57+ compression = \"none\";
58+ hash-1 {
59+ algo = \"crc32\";
60+ };
61+ hash-2 {
62+ algo = \"sha1\";
63+ };
64+ };\
65+"
66+ LOADABLES="\
67+ loadables = \"script-1\";\
68+"
69+ SIGN_IMAGES="\
70+ sign-images = \"fdt\", \"kernel\", \"loadables\";\
71+"
72+else
73+ SIGN_IMAGES="\
74+ sign-images = \"fdt\", \"kernel\";\
75+"
76+fi
77+
78+# Conditionally create signature information
79+if [ -n "${KEY_NAME_HINT}" ]; then
80+ SIGNATURE="\
81+ signature {
82+ algo = \"sha1,rsa2048\";
83+ key-name-hint = \"${KEY_NAME_HINT}\";
84+${SIGN_IMAGES}
85+ };\
86+"
87+fi
88+
89+# Conditionally create anti-rollback version information
90+if [ -n "${AR_VER}" ]; then
91+ FW_AR_VER="\
92+ fw_ar_ver = <${AR_VER}>;\
93+"
94+fi
95+
96 # Create a default, fully populated DTS file
97 DATA="/dts-v1/;
98
99@@ -107,14 +164,18 @@ DATA="/dts-v1/;
100 };
101 };
102 ${FDT_NODE}
103+${SCRIPT}
104 };
105
106 configurations {
107 default = \"${CONFIG}\";
108 ${CONFIG} {
109 description = \"OpenWrt\";
110+${FW_AR_VER}
111+${LOADABLES}
112 kernel = \"kernel-1\";
113 ${FDT_PROP}
114+${SIGNATURE}
115 };
116 };
117 };"