Sathees Balya | 6f07a60 | 2018-11-02 14:56:06 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | output="bl1_romlib.bin" |
| 9 | |
| 10 | # Set trap for removing temporary file |
| 11 | trap 'r=$?;rm -f $bin_path/$$.tmp;exit $r' EXIT HUP QUIT INT TERM |
| 12 | |
| 13 | # Read input parameters |
| 14 | for i |
| 15 | do |
| 16 | case $i in |
| 17 | -o) |
| 18 | output=$2 |
| 19 | shift 2 |
| 20 | ;; |
| 21 | --) |
| 22 | shift |
| 23 | break |
| 24 | ;; |
| 25 | -*) |
| 26 | echo usage: gen_combined_bl1_romlib.sh [-o output] path_to_build_directory >&2 |
| 27 | ;; |
| 28 | esac |
| 29 | done |
| 30 | |
| 31 | |
| 32 | bin_path=$1 |
| 33 | romlib_path=$1/romlib |
| 34 | bl1_file="$1/bl1/bl1.elf" |
| 35 | romlib_file="$1/romlib/romlib.elf" |
| 36 | bl1_end="" |
| 37 | romlib_begin="" |
| 38 | |
| 39 | # Get address of __BL1_ROM_END__ |
| 40 | bl1_end=`nm -a "$bl1_file" | |
| 41 | awk '$3 == "__BL1_ROM_END__" {print "0x"$1}'` |
| 42 | |
| 43 | # Get start address of romlib "text" section |
| 44 | romlib_begin=`nm -a "$romlib_file" | |
| 45 | awk '$3 == ".text" {print "0x"$1}'` |
| 46 | |
| 47 | # Character "U" will be read as "55" in hex when it is |
| 48 | # concatenated with bl1.bin. Generate combined BL1 and ROMLIB |
| 49 | # binary with filler bytes for juno |
| 50 | (cat $bin_path/bl1.bin |
| 51 | yes U | sed $(($romlib_begin - $bl1_end))q | tr -d '\n' |
| 52 | cat $bin_path/romlib/romlib.bin) > $bin_path/$$.tmp && |
| 53 | mv $bin_path/$$.tmp $bin_path/$output |