blob: 1e3f73a0f4349643039c973c51efc3bdaf413436 [file] [log] [blame]
Sathees Balya6f07a602018-11-02 14:56:06 +00001#!/bin/sh
2# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5
6set -e
7
8output="bl1_romlib.bin"
9
10# Set trap for removing temporary file
11trap 'r=$?;rm -f $bin_path/$$.tmp;exit $r' EXIT HUP QUIT INT TERM
12
13# Read input parameters
14for i
15do
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
29done
30
31
32bin_path=$1
33romlib_path=$1/romlib
34bl1_file="$1/bl1/bl1.elf"
35romlib_file="$1/romlib/romlib.elf"
36bl1_end=""
37romlib_begin=""
38
39# Get address of __BL1_ROM_END__
40bl1_end=`nm -a "$bl1_file" |
41awk '$3 == "__BL1_ROM_END__" {print "0x"$1}'`
42
43# Get start address of romlib "text" section
44romlib_begin=`nm -a "$romlib_file" |
45awk '$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 &&
53mv $bin_path/$$.tmp $bin_path/$output