tree: 11525544a3a92737ced3256482586e999a49decd [path history] [tgz]
  1. app/
  2. boards/
  3. cmake/
  4. drivers/
  5. dts/
  6. emul/
  7. fake/
  8. include/
  9. libc/
  10. linker/
  11. mock/
  12. program/
  13. scripts/
  14. shim/
  15. subsys/
  16. test/
  17. zmake/
  18. .pylintrc
  19. CMakeLists.txt
  20. DIR_METADATA
  21. firmware_builder.py
  22. fpu.cmake
  23. gcov.tmpl.sh
  24. hayato_get_cfg.sh
  25. Kconfig
  26. Kconfig.accelgyro_bmi
  27. Kconfig.accelgyro_icm
  28. Kconfig.adc
  29. Kconfig.ap_hang_detect
  30. Kconfig.ap_power
  31. Kconfig.battery
  32. Kconfig.board_version
  33. Kconfig.body_detection
  34. Kconfig.cbi
  35. Kconfig.cec
  36. Kconfig.charger
  37. Kconfig.chargesplash
  38. Kconfig.console
  39. Kconfig.console_cmd_mem
  40. Kconfig.debug_assert
  41. Kconfig.defaults
  42. Kconfig.defaults-arm
  43. Kconfig.detachable_base
  44. Kconfig.espi
  45. Kconfig.fingerprint
  46. Kconfig.flash
  47. Kconfig.header
  48. Kconfig.host_interface
  49. Kconfig.i2c
  50. Kconfig.init_priority
  51. Kconfig.ioex
  52. Kconfig.keyboard
  53. Kconfig.led
  54. Kconfig.led_dt
  55. Kconfig.mkbp_event
  56. Kconfig.motionsense
  57. Kconfig.panic
  58. Kconfig.pd
  59. Kconfig.pd_console_cmd
  60. Kconfig.pd_discharge
  61. Kconfig.pd_frs
  62. Kconfig.pd_host_cmd
  63. Kconfig.pd_int_shared
  64. Kconfig.pd_meas_vbus
  65. Kconfig.pd_usbc_device_type
  66. Kconfig.pd_vbus_detection
  67. Kconfig.pmic
  68. Kconfig.port80
  69. Kconfig.powerseq
  70. Kconfig.ppc
  71. Kconfig.random
  72. Kconfig.retimer
  73. Kconfig.rollback
  74. Kconfig.rsa
  75. Kconfig.rtc
  76. Kconfig.sensor_devices
  77. Kconfig.stacks
  78. Kconfig.svdm_rsp
  79. Kconfig.system
  80. Kconfig.tabletmode
  81. Kconfig.tasks
  82. Kconfig.tcpm
  83. Kconfig.temperature
  84. Kconfig.test
  85. Kconfig.throttle_ap
  86. Kconfig.timer
  87. Kconfig.touchpad
  88. Kconfig.usb_charger
  89. Kconfig.usb_i2c
  90. Kconfig.usb_mux
  91. Kconfig.usb_update
  92. Kconfig.usba
  93. Kconfig.usbc
  94. Kconfig.usbc_common_altmode
  95. Kconfig.usbc_ss_mux
  96. Kconfig.watchdog
  97. Kconfig.wireless_charger
  98. Makefile.cq
  99. module.yml
  100. pigweed-vpython3
  101. README.md
  102. tcpmv2.cmake
zephyr/README.md

Zephyr EC

Introduction

Zephyr EC is an effort to create an industry-standard Embedded Controller implementation for use primarily on laptops. It is born out of the Chromium OS EC.

native-posix development

Zephyr can be built to run on your host machine, making it easier to develop and test features. This is called the minimal-posix build.

To build it::

  cd ~/chromium/src/platform/ec
  zmake build minimal-posix

and run it:

  build/zephyr/minimal-posix/build-singleimage/zephyr/zephyr.exe

Check the display for the pseudotty and connect an xterm to it, e.g.:

   xterm -e screen /dev/pts/28

You will then see the EC prompt and you can type commands, e.g. type ‘help’:

  Please press the <Tab> button to see all available commands.
  You can also use the <Tab> button to prompt or auto-complete all commands or its subcommands.
  You can try to call commands with <-h> or <--help> parameter for more information.

  Available commands:
    cbi        :Print or change Cros Board Info from flash
    chan       :Save, restore, get or set console channel mask
    crash      :Crash the system (for testing)
    feat       :Print feature flags
    gettime    :Print current time
    gpioget    :Read GPIO value(s)
    gpioset    :Set a GPIO
    help       :Prints the help message.
    hibernate  :Hibernate the EC
    kernel     :Kernel commands
    log        :Commands for controlling logger
    md         :dump memory values, optionally specifying the format
    panicinfo  :Print info from a previous panic
    reboot     :Reboot the EC
    rw         :Read or write a word in memory optionally specifying the size
    shmem      :Print shared memory stats
    sysinfo    :Print system info
    syslock    :Lock the system, even if WP is disabled
    timerinfo  :Print timer info
    version    :Print versions
    waitms     :Busy-wait for msec (large delays will reset)

Use Ctrl-C to quit (from the main terminal) as normal.

You can run zephyr under gdb just like any other program.

If you want to share the same terminal, add this line to zephyr/program/minimal/prj.conf and rebuild:

  CONFIG_NATIVE_UART_0_ON_STDINOUT=y

Running that will show an EC prompt on your terminal. Use Ctrl-\ to quit.

CQ builder

To test the cq builder script run these commands:

firmware-zephyr-cq

rm -rf /tmp/artifact_bundles /tmp/artifact_bundle_metadata \
 ~/chromiumos/src/platform/ec/build
( cd ~/chromiumos/src/platform/ec/zephyr ; \
./firmware_builder.py --metrics /tmp/metrics-build build && \
./firmware_builder.py --metrics /tmp/metrics-test test && \
./firmware_builder.py --metrics /tmp/metrics-bundle --metadata /tmp/artifact_bundle_metadata bundle && \
echo PASSED )
cat /tmp/artifact_bundle_metadata
cat /tmp/metrics-build
ls -l /tmp/artifact_bundles/

firmware-zephyr-cov-cq

rm -rf /tmp/artifact_bundles-cov /tmp/artifact_bundle_metadata-cov \
  ~/chromiumos/src/platform/ec/build && \
cd ~/chromiumos/src/platform/ec/zephyr && \
./firmware_builder.py --metrics /tmp/metrics --code-coverage build && \
./firmware_builder.py --metrics /tmp/metrics --code-coverage test && \
./firmware_builder.py --metrics /tmp/metrics --code-coverage \
  --output-dir=/tmp/artifact_bundles-cov \
  --metadata=/tmp/artifact_bundle_metadata-cov bundle && \
echo PASSED
cat /tmp/artifact_bundle_metadata-cov
ls -l /tmp/artifact_bundles-cov

Zmake unit tests

Run the tests with zephyr/zmake/run_tests.sh. You can generate a coverage report, but not in the chroot, as some pip modules are missing there.

You can run the coverage report outside of the chroot easily:

# Install test dependencies
cd ~/chromiumos/src/platform/ec
python3 -m pip install 'zephyr/zmake[tests]' --user
# Run tests with coverage
cd ~/chromiumos/src/platform/ec/zephyr/zmake
coverage run --source=zmake -m pytest .
coverage report
coverage html
xdg-open htmlcov/index.html
OSZAR »