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