• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/bash
2# Copyright (C) 2017 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16SRCDIR="data"
17DTS_LIST="
18  board1v1.dts
19  board1v1_1.dts
20  board2v1.dts
21"
22DTB_LIST=(
23  "board1v1.dts.dtb"
24  "board1v1_1.dts.dtb"
25  "board2v1.dts.dtb"
26  "board1v1.dts.dtb"
27)
28CONFIG="${SRCDIR}/mkdtimg.cfg"
29PYCONFIG="${SRCDIR}/mkdtboimg.cfg"
30
31ALIGN=4
32
33OUTDIR="out"
34MKDTIMG_OUT="${OUTDIR}/mkdtimg_out"
35MKDTIMG_DUMP="${MKDTIMG_OUT}"/dump.dtb
36
37MKDTBOIMG_OUT="${OUTDIR}/mkdtboimg_out"
38MKDTBOIMG_OUTCREATE="${MKDTBOIMG_OUT}/create"
39MKDTBOIMG_OUTCFG="${MKDTBOIMG_OUT}/cfg_create"
40MKDTBOIMG_CREATEDUMP="${MKDTBOIMG_OUTCREATE}"/dump.dtb
41MKDTBOIMG_CFGDUMP="${MKDTBOIMG_OUTCFG}"/dump.dtb
42
43mkdir -p "$MKDTIMG_OUT"
44mkdir -p "$MKDTBOIMG_OUTCREATE"
45mkdir -p "$MKDTBOIMG_OUTCFG"
46
47for dts in ${DTS_LIST}; do
48  echo "Building $dts..."
49  src_dts="${SRCDIR}/${dts}"
50  out_dtb="${OUTDIR}/${dts}.dtb"
51  dtc -O dtb -@ -qq -a "$ALIGN" -o "$out_dtb" "$src_dts"
52done
53
54echo "Creating dtbo image with mkdtbimg"
55mkdtimg create ${MKDTIMG_OUT}/create.img --page_size=4096 --id=0x100 --version=1\
56    --rev=0x100 --custom0=0xabc "${OUTDIR}/board1v1.dts.dtb" "${OUTDIR}/board1v1_1.dts.dtb" \
57    --id=0xddccbbaa --rev=0x01000100 "${OUTDIR}/board2v1.dts.dtb" --id=0x200 \
58    --rev=0x201 "${OUTDIR}/board1v1.dts.dtb" --custom0=0xdef \
59    "${OUTDIR}/board1v1.dts.dtb" --custom0=0xdef > /dev/null
60
61echo "Creating dtbo image with mkdtboimg"
62../src/mkdtboimg.py create  ${MKDTBOIMG_OUTCREATE}/create.img --page_size=4096 \
63    --id=0x100 --rev=0x100 --flags=0xabc0 --version=1 "${OUTDIR}/board1v1.dts.dtb" \
64    "${OUTDIR}/board1v1_1.dts.dtb" --id=0xddccbbaa --rev=0x01000100 \
65    "${OUTDIR}/board2v1.dts.dtb" --id=0x200 --rev=0x201 \
66    "${OUTDIR}/board1v1.dts.dtb" --flags=0xd01 \
67    "${OUTDIR}/board1v1.dts.dtb" --flags=0xd02 > /dev/null
68
69echo "Creating dtbo image with ${PYCONFIG} config file"
70../src/mkdtboimg.py cfg_create ${MKDTBOIMG_OUTCFG}/create.img ${PYCONFIG} --dtb-dir "${OUTDIR}"
71
72echo "Dumping fragments from mkdtimg tool image"
73mkdtimg dump ${MKDTIMG_OUT}/create.img -b "${MKDTIMG_DUMP}"| grep -v 'FDT' > ${MKDTIMG_OUT}/create.dump
74
75echo "Dumping fragments from mkdtboimg.py tool for image generated with 'create'"
76../src/mkdtboimg.py dump ${MKDTBOIMG_OUTCREATE}/create.img --output ${MKDTBOIMG_OUTCREATE}/create.dump -b "${MKDTBOIMG_CREATEDUMP}" --decompress
77
78echo "Dumping fragments from mkdtboimg.py tool for image generated with 'cfg_create'"
79../src/mkdtboimg.py dump ${MKDTBOIMG_OUTCFG}/create.img --output ${MKDTBOIMG_OUTCFG}/create.dump -b "${MKDTBOIMG_CFGDUMP}" --decompress
80
81echo "======================================================================================"
82echo "Testing differences between image created by 'create' for 'mkdtimg' and 'mkdtboimg.py'"
83echo "======================================================================================"
84for x in `ls -1 ${MKDTIMG_DUMP}.*`
85do
86    file=`basename $x`
87    if [ ! -e ${MKDTBOIMG_OUTCREATE}/$file ]
88    then
89        continue
90    fi
91    echo "diff $x vs ${MKDTBOIMG_OUTCREATE}/$file"
92    diff $x ${MKDTBOIMG_OUTCREATE}/$file
93done
94echo "=========================================================================================="
95echo "Testing differences between image created by 'cfg_create' for 'mkdtimg' and 'mkdtboimg.py'"
96echo "=========================================================================================="
97for x in `ls -1 ${MKDTIMG_DUMP}.*`
98do
99    file=`basename $x`
100    if [ ! -e ${MKDTBOIMG_OUTCFG}/$file ]
101    then
102        continue
103    fi
104    echo "diff $x vs ${MKDTBOIMG_OUTCFG}/$file"
105    diff $x ${MKDTBOIMG_OUTCFG}/$file
106done
107