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

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.

Gitlab integration

As an experiment we have a basic gitlab integration. It watches the EC repo and kicks of a build when new commits appear. So far it just builds for volteer and does not run any tests. For firmware branches, it also builds, but fails.

The gitlab builder works without a chroot and uses the Zephyr toolchain. This is intended to ensure that we have a path to upstreaming our code eventually and do not rely on Chrome OS-specific tools. It does make use of ‘zmake’, however.

See the piplines here.

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 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.

The latest coverage report is on gitlab.

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