blob: 39414674d753059d722da87a2d17d3d7ded3dc8c [file] [log] [blame]
Sathees Balya6f07a602018-11-02 14:56:06 +00001#!/bin/sh
Govindraj Rajaeee28e72023-08-01 15:52:40 -05002# Copyright (c) 2018, Arm Limited and Contributors. All rights reserved.
Sathees Balya6f07a602018-11-02 14:56:06 +00003#
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