Home | History | Annotate | Download | only in tests
      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 
     16 SRCDIR="data"
     17 DTS_LIST="
     18   board1v1.dts
     19   board1v1_1.dts
     20   board2v1.dts
     21 "
     22 DTB_LIST=(
     23   "board1v1.dts.dtb"
     24   "board1v1_1.dts.dtb"
     25   "board2v1.dts.dtb"
     26   "board1v1.dts.dtb"
     27 )
     28 CONFIG="${SRCDIR}/mkdtimg.cfg"
     29 
     30 ALIGN=4
     31 
     32 OUTDIR="out"
     33 OUTDTB_CFG="${OUTDIR}/dump_cfg.dtb"
     34 OUTDTB="${OUTDIR}/dump.dtb"
     35 
     36 mkdir -p "$OUTDIR"
     37 for dts in ${DTS_LIST}; do
     38   echo "Building $dts..."
     39   src_dts="${SRCDIR}/${dts}"
     40   out_dtb="${OUTDIR}/${dts}.dtb"
     41   dtc -O dtb -@ -qq -a "$ALIGN" -o "$out_dtb" "$src_dts"
     42 done
     43 
     44 IMG="${OUTDIR}/cfg_create.img"
     45 mkdtimg cfg_create "$IMG" "${CONFIG}" --dtb-dir="$OUTDIR"
     46 mkdtimg dump "$IMG" -b "$OUTDTB_CFG" | tee "${OUTDIR}/cfg_create.dump"
     47 for index in ${!DTB_LIST[@]}; do
     48   diff ${OUTDIR}/${DTB_LIST[$index]} ${OUTDTB_CFG}.$index
     49 done
     50 
     51 IMG="${OUTDIR}/create.img"
     52 mkdtimg create "$IMG" \
     53   --page_size=4096 --id=/:board_id --rev=/:board_rev --custom0=0xabc \
     54   "${OUTDIR}/board1v1.dts.dtb" \
     55   "${OUTDIR}/board1v1_1.dts.dtb" --id=/:another_board_id \
     56   "${OUTDIR}/board2v1.dts.dtb" --rev=0x201 \
     57   "${OUTDIR}/board1v1.dts.dtb" --custom0=0xdef
     58 mkdtimg dump "$IMG" -b "$OUTDTB" | tee "${OUTDIR}/create.dump"
     59 for index in ${!DTB_LIST[@]}; do
     60   diff ${OUTDIR}/${DTB_LIST[$index]} ${OUTDTB}.$index
     61 done
     62 
     63 diff "${OUTDIR}/cfg_create.dump" "${OUTDIR}/create.dump"
     64