usb: add support for board control over usb requests Add support for controlling the board function through USB vendor request, add an initial system for instantiating callbacks, implement the basic power reset and boot control codes and a sample script to flash npcx chips. BUG=none TEST=./flash_npcx.py Change-Id: I4bfe0b4546afc4d777db379f09e3ec3ff061891b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec-aic-tester/+/6182268 Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: Fabio Baltieri <fabiobaltieri@google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
The firmware can be built and flashed both with or without the chroot, though it's recommended reusing the checkout that is part of a ChromiumOS SDK as that includes the necessary configuration to upload changes to Gerrit.
TODO
This setup reuses the repository that is part of the normal chroot setup, just adds a west workspace on top of it, which can coexist with the normal one managed with repo.
Venv setup (only needed once)
sudo apt install python3-venv python3 -m venv ~/chromiumos/src/platform/ec-aic-tester/.venv
Enter the venv (once before either setting up or building):
source ~/chromiumos/src/platform/ec-aic-tester/.venv/bin/activate
Initialize the project modules and install dependencies (only needed once):
cd ~/chromiumos/src/platform/ec-aic-tester pip install west unset ZEPHYR_BASE # only needed if there's other Zephyr checkouts in the system west init -l firmware west update -o=--depth=1 -n pip install -U -r zephyr/scripts/requirements.txt west sdk install -t arm-zephyr-eabi sudo apt install cmake ninja-build ccache dfu-util
Build and flash:
cd ~/chromiumos/src/platform/ec-aic-tester west update # only needed if there was a breaking change in the modules west build firmware west flash
It's possible to build, flash and debug the firmware without the whole chromiumos checkout, in that case just pick an arbitrary directory as a workspace instead of ~/chromiumos/src/platform/ec-aic-tester and initialize it with west init --mf firmware/west.yml -m https://chromium.googlesource.com/chromiumos/platform/ec-aic-tester, the rest of the process it the same.
This setup takes less disk space, but results in a checkout with no tools to upload changelists.
The project is setup to use the chromium mirror of Zephyr and modules, but can also be built against the upstream repositories directly. To do that use the west-upstream.yml manifest when initializing the west workspace, for example
west init -l firmware --mf west-upstream.yml
The firmware can be built against an existing Zephyr project checkout, in that case follow the project Getting Started Guide, make sure that the ZEPHYR_BASE variable is set and run west build from the project firwmare directory.
There‘s multiple options for flashing and debugging the board firmware, depending on what’s hardware is available.
Just for flashing, uses the embedded USB DFU bootloader, requires no additional hardware. Put the board in DFU mode (press NRST while holding the BOOT0 button) and then run:
west flash -r dfu-util
JLink can be used for both flahing and debugging, requires the J-Link Software installed.
Flash with:
west flash -r jlink
or start a debugging session with
west debug -r jlink
ST-LINK requires the STM32CubeProgrammer host tools.
Flash with:
west flash -r stm32cubeprogrammer
or start a debugging session with
west debug -r stm32cubeprogrammer
TODO: verify that the ones above actually work and check if openocd works for debugging