diff options
-rw-r--r-- | meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx-blob.inc | 156 | ||||
-rw-r--r-- | meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx.inc | 5 |
2 files changed, 158 insertions, 3 deletions
diff --git a/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx-blob.inc b/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx-blob.inc new file mode 100644 index 00000000..717b8dd3 --- /dev/null +++ b/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx-blob.inc | |||
@@ -0,0 +1,156 @@ | |||
1 | # U-boot fitimage/blob generator | ||
2 | |||
3 | UBOOT_IMAGE_BLOB ?= "" | ||
4 | DT_BLOB_DIR ?= "${B}/arch/arm/dts/dt-blob" | ||
5 | UBOOT_BLOB_NAME ?= "${MACHINE}-fit-dtb${IMAGE_VERSION_SUFFIX}.blob" | ||
6 | |||
7 | IMPORT_CC_DTBS ?= "" | ||
8 | CC_DTBS_DUP ?= "" | ||
9 | |||
10 | MKIMAGE_DTBLOB_OPTS ?= "-E -B 0x8" | ||
11 | |||
12 | # Everything is swtiched on with UBOOT_IMAGE_BLOB = '1' | ||
13 | inherit ${@'image-artifact-names' if d.getVar('UBOOT_IMAGE_BLOB') == "1" else ''} | ||
14 | |||
15 | python() { | ||
16 | if d.getVar('UBOOT_IMAGE_BLOB') == "1": | ||
17 | d.appendVarFlag('do_compile', 'postfuncs', ' do_blob_generate') | ||
18 | d.appendVarFlag('do_compile', 'cleandirs', ' ${DT_BLOB_DIR}') | ||
19 | d.appendVar('PROVIDES', ' u-boot-xlnx-fit-blob') | ||
20 | d.appendVar('DEPENDS', ' u-boot-mkimage-native') | ||
21 | } | ||
22 | |||
23 | dtblob_emit_its_section() { | ||
24 | case $2 in | ||
25 | header) | ||
26 | cat << EOF > $1 | ||
27 | /dts-v1/; | ||
28 | |||
29 | / { | ||
30 | description = "DT Blob Creation"; | ||
31 | EOF | ||
32 | ;; | ||
33 | imagestart) | ||
34 | cat << EOF >> $1 | ||
35 | |||
36 | images { | ||
37 | EOF | ||
38 | ;; | ||
39 | confstart) | ||
40 | cat << EOF >> $1 | ||
41 | |||
42 | configurations { | ||
43 | EOF | ||
44 | ;; | ||
45 | sectend) | ||
46 | cat << EOF >> $1 | ||
47 | }; | ||
48 | EOF | ||
49 | ;; | ||
50 | fitend) | ||
51 | cat << EOF >> $1 | ||
52 | }; | ||
53 | EOF | ||
54 | ;; | ||
55 | esac | ||
56 | } | ||
57 | |||
58 | dtblob_emit_dtb () { | ||
59 | dtb_csum="md5" | ||
60 | cat << EOF >> $1 | ||
61 | fdt-$2 { | ||
62 | description = "$(basename $3 .dtb)"; | ||
63 | data = /incbin/("$3"); | ||
64 | type = "flat_dt"; | ||
65 | arch = "arm64"; | ||
66 | compression = "none"; | ||
67 | hash-1 { | ||
68 | algo = "$dtb_csum"; | ||
69 | }; | ||
70 | }; | ||
71 | EOF | ||
72 | } | ||
73 | |||
74 | #1.file name | ||
75 | #2.config node | ||
76 | #3.config node description | ||
77 | #4.DTB count | ||
78 | dtblob_emit_config () { | ||
79 | default_dtb=1 | ||
80 | if [ $4 -eq $default_dtb ]; then | ||
81 | cat << EOF >> $1 | ||
82 | default = "config_$4"; | ||
83 | EOF | ||
84 | fi | ||
85 | cat << EOF >> $1 | ||
86 | config_$4 { | ||
87 | description = "$3"; | ||
88 | fdt = "fdt-$2"; | ||
89 | }; | ||
90 | EOF | ||
91 | } | ||
92 | |||
93 | do_blob_generate () { | ||
94 | oe_runmake -C ${S} O=${B} dtbs | ||
95 | install -d ${DT_BLOB_DIR} | ||
96 | for CC_DTB in ${IMPORT_CC_DTBS}; do | ||
97 | DTBO=$(echo $CC_DTB | cut -d: -f1) | ||
98 | DTB=$(echo $CC_DTB | cut -d: -f2) | ||
99 | bbnote "fdtoverlay -o ${DT_BLOB_DIR}/${DTB} -i ${RECIPE_SYSROOT}/${DTB_PATH}/${DTB_NAME} ${B}/arch/arm/dts/${DTBO}" | ||
100 | if [ -f ${B}/arch/arm/dts/${DTBO} ]; then | ||
101 | fdtoverlay -o ${DT_BLOB_DIR}/${DTB} \ | ||
102 | -i ${RECIPE_SYSROOT}/${DTB_PATH}/${DTB_NAME} ${B}/arch/arm/dts/${DTBO} | ||
103 | fi | ||
104 | done | ||
105 | |||
106 | cd ${DT_BLOB_DIR} | ||
107 | its_filename="dtblob.its" | ||
108 | dtblob_emit_its_section "${its_filename}" "header" | ||
109 | dtblob_emit_its_section "${its_filename}" "imagestart" | ||
110 | for dtb in ${RECIPE_SYSROOT}/${DTB_PATH}/${DTB_NAME} $(find ${DT_BLOB_DIR} -name '*.dtb' | sort); do | ||
111 | dtblob_emit_dtb "${its_filename}" "$(basename $dtb .dtb)" "$dtb" | ||
112 | done | ||
113 | dtblob_emit_its_section "${its_filename}" "sectend" | ||
114 | dtblob_emit_its_section "${its_filename}" "confstart" | ||
115 | dtbcount=1 | ||
116 | for dtb in ${RECIPE_SYSROOT}/${DTB_PATH}/${DTB_NAME} $(find ${DT_BLOB_DIR} -name '*.dtb' | sort); do | ||
117 | dtblob_emit_config "${its_filename}" "$(basename $dtb .dtb)" "$(basename $dtb .dtb)" "$dtbcount" | ||
118 | dtbcount=`expr $dtbcount + 1` | ||
119 | done | ||
120 | |||
121 | for CC_DTB_DUP in ${CC_DTBS_DUP}; do | ||
122 | DTB=$(echo $CC_DTB_DUP | cut -d: -f1) | ||
123 | DUP_DTB=$(echo $CC_DTB_DUP | cut -d: -f2) | ||
124 | if [ -f ${DT_BLOB_DIR}/${DTB}.dtb ]; then | ||
125 | bbnote "Node ${DT_BLOB_DIR}/${DTB} with ${DT_BLOB_DIR}/${DUP_DTB}" | ||
126 | dtblob_emit_config "${its_filename}" "$DTB" "$DUP_DTB" "$dtbcount" | ||
127 | dtbcount=`expr $dtbcount + 1` | ||
128 | fi | ||
129 | done | ||
130 | |||
131 | dtblob_emit_its_section "${its_filename}" "sectend" | ||
132 | dtblob_emit_its_section "${its_filename}" "fitend" | ||
133 | |||
134 | mkimage ${MKIMAGE_DTBLOB_OPTS} -f "${its_filename}" "${UBOOT_BLOB_NAME}" | ||
135 | } | ||
136 | |||
137 | do_install:append() { | ||
138 | ( | ||
139 | cd ${B} | ||
140 | |||
141 | if [ -e "${DT_BLOB_DIR}/${UBOOT_BLOB_NAME}" ]; then | ||
142 | install -d ${D}/boot | ||
143 | install -m 0644 ${DT_BLOB_DIR}/${UBOOT_BLOB_NAME} ${D}/boot | ||
144 | ln -sf `basename ${UBOOT_BLOB_NAME}` ${D}/boot/fit-dtb.blob | ||
145 | fi | ||
146 | ) | ||
147 | } | ||
148 | |||
149 | do_deploy:prepend() { | ||
150 | cd ${B} | ||
151 | |||
152 | if [ -e "${DT_BLOB_DIR}/${UBOOT_BLOB_NAME}" ]; then | ||
153 | install -m 0644 ${DT_BLOB_DIR}/${UBOOT_BLOB_NAME} ${DEPLOYDIR}/ | ||
154 | ln -sf `basename ${UBOOT_BLOB_NAME}` ${DEPLOYDIR}/fit-dtb.blob | ||
155 | fi | ||
156 | } | ||
diff --git a/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx.inc b/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx.inc index f0ea2ca3..909dd72a 100644 --- a/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx.inc +++ b/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx.inc | |||
@@ -32,11 +32,10 @@ python __anonymous () { | |||
32 | d.appendVarFlag('do_configure', 'depends', ' virtual/dtb:do_populate_sysroot') | 32 | d.appendVarFlag('do_configure', 'depends', ' virtual/dtb:do_populate_sysroot') |
33 | if d.getVar("DTB_NAME") is not None: | 33 | if d.getVar("DTB_NAME") is not None: |
34 | d.setVar('DTB_NAME', d.getVar('BASE_DTS')+ '.dtb') | 34 | d.setVar('DTB_NAME', d.getVar('BASE_DTS')+ '.dtb') |
35 | |||
36 | if d.getVar('UBOOT_IMAGE_BLOB') == "1": | ||
37 | d.appendVarFlag('do_compile', 'postfuncs', ' do_blob_generate') | ||
38 | } | 35 | } |
39 | 36 | ||
37 | require u-boot-xlnx-blob.inc | ||
38 | |||
40 | UBOOTELF_NODTB_IMAGE ?= "u-boot-nodtb.elf" | 39 | UBOOTELF_NODTB_IMAGE ?= "u-boot-nodtb.elf" |
41 | UBOOTELF_NODTB_BINARY ?= "u-boot" | 40 | UBOOTELF_NODTB_BINARY ?= "u-boot" |
42 | do_deploy:prepend() { | 41 | do_deploy:prepend() { |