GoogleGit

blob: 4d7b14249ca82676e0f3c33fe2434b800e99630b [file] [log] [blame]
  1. # Copyright (C) 2012 The Chromium OS Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE.makefile file.
  4. EAPI="4"
  5. CROS_WORKON_PROJECT="chromiumos/platform/ec"
  6. CROS_WORKON_LOCALNAME="ec"
  7. inherit toolchain-funcs cros-ec-board cros-workon
  8. DESCRIPTION="Embedded Controller firmware code"
  9. HOMEPAGE="http://www.chromium.org/"
  10. SRC_URI=""
  11. LICENSE="BSD-Google"
  12. SLOT="0"
  13. KEYWORDS="~*"
  14. RDEPEND="dev-embedded/libftdi"
  15. DEPEND="${RDEPEND}"
  16. # We don't want binchecks since we're cross-compiling firmware images using
  17. # non-standard layout.
  18. RESTRICT="binchecks"
  19. src_configure() {
  20. cros-workon_src_configure
  21. }
  22. set_build_env() {
  23. # The firmware is running on ARMv7-m (Cortex-M4)
  24. export CROSS_COMPILE=arm-none-eabi-
  25. tc-export CC BUILD_CC
  26. export HOSTCC=${CC}
  27. export BUILDCC=${BUILD_CC}
  28. get_ec_boards
  29. }
  30. src_compile() {
  31. set_build_env
  32. local board
  33. for board in "${EC_BOARDS[@]}"; do
  34. BOARD=${board} emake clean
  35. BOARD=${board} emake all
  36. BOARD=${board} emake tests
  37. BOARD=${board} emake all out=build/${board}_shifted \
  38. EXTRA_CFLAGS="-DSHIFT_CODE_FOR_TEST"
  39. done
  40. }
  41. #
  42. # Install firmware binaries for a specific board.
  43. #
  44. # param $1 - the board name.
  45. # param $2 - the output directory to install artifacts.
  46. #
  47. board_install() {
  48. insinto $2
  49. pushd build/$1 >/dev/null || die
  50. doins ec.bin
  51. newins RW/ec.RW.flat ec.RW.bin
  52. # Intermediate file for debugging.
  53. doins RW/ec.RW.elf
  54. if [ `grep "^CONFIG_FW_INCLUDE_RO=y" .config` ];
  55. then
  56. newins RO/ec.RO.flat ec.RO.bin
  57. # Intermediate file for debugging.
  58. doins RO/ec.RO.elf
  59. fi
  60. # The shared objects library is not built by default.
  61. if [ `grep "^CONFIG_SHAREDLIB=y" .config` ];
  62. then
  63. doins libsharedobjs/libsharedobjs.elf
  64. fi
  65. # EC test binaries
  66. nonfatal doins test-*.bin || ewarn "No test binaries found"
  67. popd > /dev/null
  68. newins build/$1_shifted/ec.bin ec_autest_image.bin
  69. }
  70. src_install() {
  71. set_build_env
  72. # The first board should be the main EC
  73. local ec="${EC_BOARDS[0]}"
  74. # EC firmware binaries
  75. board_install ${ec} /firmware
  76. # Install additional firmwares
  77. local board
  78. for board in "${EC_BOARDS[@]}"; do
  79. board_install ${board} /firmware/${board}
  80. done
  81. }
  82. src_test() {
  83. emake runtests
  84. }