gen_combined_bl1_romlib.sh 1.1 KB

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