diff options
author | Andrew McRae <amcrae@google.com> | 2022-02-14 14:05:55 +1100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-02-14 05:11:20 +0000 |
commit | f1cd4591a85d68461b9f3198947ffc682b3c7d30 (patch) | |
tree | 02053ccb0390e425c9c92bcec183ecedb3f5a341 | |
parent | 8e34b55cbfdaab5f84490688fc207527b7bd1c78 (diff) | |
download | chrome-ec-f1cd4591a85d68461b9f3198947ffc682b3c7d30.tar.gz |
dt-gpionames: Update README.md and add shell script
SDK now has go 1.17, so update README.md
Add a shell script to make it easy to run utility.
BUG=b:219379591
TEST=run and check output
BRANCH=none
Signed-off-by: Andrew McRae <amcrae@google.com>
Change-Id: Id16369b63a14c2c34381c4841a38ea8ca59a383d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3460765
Reviewed-by: Yuval Peress <peress@google.com>
-rw-r--r-- | util/dt-gpionames/README.md | 56 | ||||
-rwxr-xr-x | util/dt-gpionames/gpionames.sh | 34 |
2 files changed, 67 insertions, 23 deletions
diff --git a/util/dt-gpionames/README.md b/util/dt-gpionames/README.md index 06b9a1c4b6..405b963220 100644 --- a/util/dt-gpionames/README.md +++ b/util/dt-gpionames/README.md @@ -10,30 +10,29 @@ The `named-gpios` compatible node is used as the source of the names. Each child of the `named-gpios` node is named from a EC pin name, has a `gpios` property referencing the GPIO pin. -The program matches the GPIO controller and pin for each of the `named-gpios` entries, -and creates overlay DTS fragments for each of the GPIO controllers setting the `gpio-line-names`. +The program matches the GPIO controller and pin for each of the +`named-gpios` entries, and creates overlay DTS fragments for each of +the GPIO controllers setting the `gpio-line-names`. -The purpose of this program is to help upstream the EC GPIO support, specifically -to enable a Zephyr based console command equivalent to `gpioget` and `gpioset`. +The purpose of this program is to help upstream the EC GPIO support, +specifically to enable a Zephyr based console command equivalent +to `gpioget` and `gpioset`. -Currently these commands rely on the existence of the `named-gpios` child nodes to -specify the engineer-friendly name of the GPIO pins. However, core Zephyr does not -use `named-gpios`, and any command upstreamed to Zephyr should only rely on -the core Zephyr API and interfaces (and the `gpio-line-names` property is a standard attribute of -the Zephyr GPIO definition). +Currently these commands rely on the existence of the +`named-gpios` child nodes to specify the engineer-friendly name of +the GPIO pins. However, core Zephyr does not use `named-gpios`, +and any command upstreamed to Zephyr should only rely on +the core Zephyr API and interfaces (and the `gpio-line-names` +property is a standard attribute of the Zephyr GPIO definition). -Using this program, a DTS fragment can be generated from an existing DTS with a `named-gpios` node -that will allow an upstreamed `gpioget`/`gpioset` command to operate. +Using this program, a DTS fragment can be generated from an existing +DTS with a `named-gpios` node that will allow an upstreamed +`gpioget`/`gpioset` command to operate. ## Building -This program uses an external library to read the DTB; this external library requires -go 1.17 at the minimum, and currently the ChromeOS SDK installs go 1.15, so this -program will require building outside of the SDK: - ``` -[from home directory outside the SDK] -cd ~/chromiumos/src/platform/ec/util/dt-gpionames +cd platform/ec/util/dt-gpionames go build ``` @@ -42,12 +41,11 @@ This builds the `dt-gpionames` binary in this directory. ## Executing -The program input expects a compiled, flattened device tree binary (DTB) file. -This can built from an existing device tree source file using the device tree compiler (dtc), -which is installed in the SDK by default. +The program input expects a compiled, flattened device tree binary (DTB) +file. -The source file for the compiler can be obtained from a device tree source file generated as part -of a project build. +The source file for the compiler can be obtained from a device tree +source file generated as part of a project build. So the complete process is (using the nivviks project target as an example): @@ -60,7 +58,19 @@ dtc --out /tmp/dt.dtb ../../build/zephyr/nivviks/build-ro/zephyr/zephyr.dts ./dt-gpionames --output gpionames.dts --input /tmp/dt.dtb ``` -This `gpionames.dts` can then be copied and added to the project's device tree source files. +This `gpionames.dts` can then be copied and added to the project's +device tree source files. + +A shell script is available that runs these commands as a +single step: + + +``` +gpionames.sh <project> +``` + +Where `project` is the project target e.g `nivviks`, `lazor` etc. +The script will place the output file in `/tmp/gpionames-`<project>`.dts`. ## Examples diff --git a/util/dt-gpionames/gpionames.sh b/util/dt-gpionames/gpionames.sh new file mode 100755 index 0000000000..92b2bd4580 --- /dev/null +++ b/util/dt-gpionames/gpionames.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Copyright 2022 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +set -e + +if [ $# != 1 ]; then + echo "Usage $0 <project>" + exit +fi + +basedir=$(pwd) +dtprog="${basedir}/dt-gpionames" +proj=$1 +dtb="/tmp/dt-${proj}.dtb" +names="/tmp/gpionames-${proj}.dts" +dts="../../build/zephyr/${proj}/build-ro/zephyr/zephyr.dts" + +# Remove dt-gpionames binary +trap 'rm -f ${dtprog}' EXIT + +proj=$1 +echo "Using ${proj} project" +echo "Building ${dtprog}" +go build +echo "Building project ${proj}" +(cd ../../zephyr; zmake configure -b "${proj}") +echo "Compiling device tree ${dts} to ${dtb}" +dtc --out "${dtb}" "${dts}" +echo "Generating ${names} from ${dtb}" +${dtprog} --output "${names}" --input "${dtb}" +echo "Successfully generated ${names}" |