summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-ti-bsp/classes/kernel-fitimage-ti-u-boot.bbclass214
1 files changed, 0 insertions, 214 deletions
diff --git a/meta-ti-bsp/classes/kernel-fitimage-ti-u-boot.bbclass b/meta-ti-bsp/classes/kernel-fitimage-ti-u-boot.bbclass
deleted file mode 100644
index 503c6d25..00000000
--- a/meta-ti-bsp/classes/kernel-fitimage-ti-u-boot.bbclass
+++ /dev/null
@@ -1,214 +0,0 @@
1
2inherit ti-secdev
3
4# The TI u-boot requires that the kernel image is signed. To not overload the
5# entire kernel-fitimage.bbclass from oe-core, we just overwrite one function
6# and do the signing in there.
7
8#
9# Assemble fitImage
10#
11# $1 ... .its filename
12# $2 ... fitImage name
13# $3 ... include ramdisk
14fitimage_assemble() {
15 kernelcount=1
16 dtbcount=""
17 DTBS=""
18 ramdiskcount=$3
19 setupcount=""
20 bootscr_id=""
21 rm -f $1 arch/${ARCH}/boot/$2
22
23 if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
24 bbfatal "Keys used to sign images and configuration nodes must be different."
25 fi
26
27 fitimage_emit_fit_header $1
28
29 #
30 # Step 1: Prepare a kernel image section.
31 #
32 fitimage_emit_section_maint $1 imagestart
33
34 uboot_prep_kimage
35 fitimage_ti_secure linux.bin linux.bin.sec
36 fitimage_emit_section_kernel $1 $kernelcount linux.bin.sec "$linux_comp"
37
38 #
39 # Step 2: Prepare a DTB image section
40 #
41
42 if [ -n "${KERNEL_DEVICETREE}" ]; then
43 dtbcount=1
44 for DTB in ${KERNEL_DEVICETREE}; do
45 if echo $DTB | grep -q '/dts/'; then
46 bbwarn "$DTB contains the full path to the the dts file, but only the dtb name should be used."
47 DTB=`basename $DTB | sed 's,\.dts$,.dtb,g'`
48 fi
49
50 # Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE}
51 if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ] && [ -s ${EXTERNAL_KERNEL_DEVICETREE}/${DTB} ]; then
52 continue
53 fi
54
55 DTB_PATH="arch/${ARCH}/boot/dts/$DTB"
56 if [ ! -e "$DTB_PATH" ]; then
57 DTB_PATH="arch/${ARCH}/boot/$DTB"
58 fi
59
60 DTB=$(echo "$DTB" | tr '/' '_')
61
62 # Skip DTB if we've picked it up previously
63 echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue
64
65 fitimage_ti_secure ${DTB_PATH} ${DTB_PATH}.sec
66
67 DTBS="$DTBS $DTB"
68 fitimage_emit_section_dtb $1 $DTB ${DTB_PATH}.sec
69 done
70 fi
71
72 if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
73 dtbcount=1
74 for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" -name '*.dtb' -printf '%P\n' | sort) \
75 $(find "${EXTERNAL_KERNEL_DEVICETREE}" -name '*.dtbo' -printf '%P\n' | sort); do
76 DTB=$(echo "$DTB" | tr '/' '_')
77
78 # Skip DTB/DTBO if we've picked it up previously
79 echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue
80
81 fitimage_ti_secure ${EXTERNAL_KERNEL_DEVICETREE}/${DTB} ${EXTERNAL_KERNEL_DEVICETREE}/${DTB}.sec
82
83 DTBS="$DTBS $DTB"
84 fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/${DTB}.sec"
85 done
86 fi
87
88 #
89 # Step 3: Prepare a u-boot script section
90 #
91
92 if [ -n "${UBOOT_ENV}" ] && [ -d "${STAGING_DIR_HOST}/boot" ]; then
93 if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then
94 cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B}
95 bootscr_id="${UBOOT_ENV_BINARY}"
96 fitimage_emit_section_boot_script $1 "$bootscr_id" ${UBOOT_ENV_BINARY}
97 else
98 bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found."
99 fi
100 fi
101
102 #
103 # Step 4: Prepare a setup section. (For x86)
104 #
105 if [ -e arch/${ARCH}/boot/setup.bin ]; then
106 setupcount=1
107 fitimage_emit_section_setup $1 $setupcount arch/${ARCH}/boot/setup.bin
108 fi
109
110 #
111 # Step 5: Prepare a ramdisk section.
112 #
113 if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
114 # Find and use the first initramfs image archive type we find
115 found=
116 for img in ${FIT_SUPPORTED_INITRAMFS_FSTYPES}; do
117 initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img"
118 initramfs_local="usr/${INITRAMFS_IMAGE_NAME}.$img"
119 if [ -e "$initramfs_path" ]; then
120 bbnote "Found initramfs image: $initramfs_path"
121 found=true
122 fitimage_ti_secure ${initramfs_path} ${initramfs_local}.sec
123
124 fitimage_emit_section_ramdisk $1 "$ramdiskcount" "${initramfs_local}.sec"
125 break
126 else
127 bbnote "Did not find initramfs image: $initramfs_path"
128 fi
129 done
130
131 if [ -z "$found" ]; then
132 bbfatal "Could not find a valid initramfs type for ${INITRAMFS_IMAGE_NAME}, the supported types are: ${FIT_SUPPORTED_INITRAMFS_FSTYPES}"
133 fi
134 fi
135
136 fitimage_emit_section_maint $1 sectend
137
138 # Force the first Kernel and DTB in the default config
139 kernelcount=1
140 if [ -n "$dtbcount" ]; then
141 dtbcount=1
142 fi
143
144 #
145 # Step 6: Prepare a configurations section
146 #
147 fitimage_emit_section_maint $1 confstart
148
149 # kernel-fitimage.bbclass currently only supports a single kernel (no less or
150 # more) to be added to the FIT image along with 0 or more device trees and
151 # 0 or 1 ramdisk.
152 # It is also possible to include an initramfs bundle (kernel and rootfs in one binary)
153 # When the initramfs bundle is used ramdisk is disabled.
154 # If a device tree is to be part of the FIT image, then select
155 # the default configuration to be used is based on the dtbcount. If there is
156 # no dtb present than select the default configuation to be based on
157 # the kernelcount.
158 if [ -n "$DTBS" ]; then
159 i=1
160 for DTB in ${DTBS}; do
161 dtb_ext=${DTB##*.}
162 if [ "$dtb_ext" = "dtbo" ]; then
163 fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`"
164 else
165 fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`"
166 fi
167 i=`expr $i + 1`
168 done
169 else
170 defaultconfigcount=1
171 fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id" "$setupcount" $defaultconfigcount
172 fi
173
174 fitimage_emit_section_maint $1 sectend
175
176 fitimage_emit_section_maint $1 fitend
177
178 #
179 # Step 7: Assemble the image
180 #
181 ${UBOOT_MKIMAGE} \
182 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
183 -f $1 \
184 arch/${ARCH}/boot/$2
185
186 #
187 # Step 8: Sign the image and add public key to U-Boot dtb
188 #
189 if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then
190 add_key_to_u_boot=""
191 if [ -n "${UBOOT_DTB_BINARY}" ]; then
192 # The u-boot.dtb is a symlink to UBOOT_DTB_IMAGE, so we need copy
193 # both of them, and don't dereference the symlink.
194 cp -P ${STAGING_DATADIR}/u-boot*.dtb ${B}
195 add_key_to_u_boot="-K ${B}/${UBOOT_DTB_BINARY}"
196 fi
197 ${UBOOT_MKIMAGE_SIGN} \
198 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
199 -F -k "${UBOOT_SIGN_KEYDIR}" \
200 $add_key_to_u_boot \
201 -r arch/${ARCH}/boot/$2 \
202 ${UBOOT_MKIMAGE_SIGN_ARGS}
203 fi
204}
205
206fitimage_ti_secure() {
207 if test -n "${TI_SECURE_DEV_PKG}"; then
208 export TI_SECURE_DEV_PKG=${TI_SECURE_DEV_PKG}
209 ${TI_SECURE_DEV_PKG}/scripts/secure-binary-image.sh $1 $2
210 else
211 cp $1 $2
212 fi
213}
214