GoogleGit

blob: bf738257c8f9d7ab12449366693ac981484bfb4f [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{,.RW}.bin
  51. grep -q "^CONFIG_FW_INCLUDE_RO=y" .config && newins ec.RO.flat ec.RO.bin
  52. # EC test binaries
  53. nonfatal doins test-*.bin || ewarn "No test binaries found"
  54. # Intermediate files for debugging
  55. doins ec.*.elf
  56. popd > /dev/null
  57. newins build/$1_shifted/ec.bin ec_autest_image.bin
  58. }
  59. src_install() {
  60. set_build_env
  61. # The first board should be the main EC
  62. local ec="${EC_BOARDS[0]}"
  63. # EC firmware binaries
  64. board_install ${ec} /firmware
  65. # Install additional firmwares
  66. local board
  67. for board in "${EC_BOARDS[@]}"; do
  68. board_install ${board} /firmware/${board}
  69. done
  70. }
  71. src_test() {
  72. emake runtests
  73. }