firmweaver: shared OAuth PKCE flow

- New shared/auth package with OAuth2 PKCE authorization
- Token caching in ~/.config/firmweaver/token.json
- Add "firmweaver auth [login|status|logout|token]" subcommands
- Add unit tests for PKCE
Auth stuff is needed for both supporting google sheets and metrics in
subsequent CLs.

BUG=b:475292981
TEST=go test -v -race ./...

Change-Id: Ib485823adeb30e15d4badec4ac9f1b2ea2b0f681
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/firmweaver/+/8318029
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Tested-by: Kshitij Shah <tij@google.com>
Commit-Queue: Kshitij Shah <tij@google.com>
7 files changed
tree: 2b359e04867aa64e1eb8f31ae8289de0e2106d2f
  1. coreboot_gpio/
  2. shared/
  3. zephyr_dtsi/
  4. .gitignore
  5. DIR_METADATA
  6. go.mod
  7. LICENSE
  8. main.go
  9. main_test.go
  10. OWNERS
  11. PRESUBMIT.cfg
  12. README.md
README.md

Firmweaver

Firmweaver is a collection of tools for Chromium OS to assist with initial firmware setup during board bringup.

Introduction

The Chromium OS project includes tools to assist with initial firmware setup during board bringup. These tools generate certain objects in Application Processor (AP) and Embedded Controller (EC) firmware (e.g., EC devicetree, AP GPIO configuration, etc.).

The tools take a curated sheet as prepared by the hardware team as an input and generate these objects as output. Developers can validate the generated output and contribute them to the concerned project.

Features

  • Automatic Generation: Generates firmware objects from hardware sheets.
  • Supported Outputs:
    • AP GPIO Configuration (coreboot_gpio, alias: gpio)
    • EC Devicetree (zephyr_dtsi, alias: dtsi)

Getting Started

Building Firmweaver

Build the firmweaver binary from the repository root:

go build -o firmweaver .

Usage

Running the Coreboot GPIO Tool

The coreboot_gpio (alias: gpio) parses a GPIO map CSV file and generates C configuration code.

./firmweaver coreboot_gpio --soc <soc_type> --csv <path_to_csv> [--output <path_to_output_c_file>]

Arguments:

  • --soc: SoC type. Supported values: intel, qcom, mtk. (Required)
  • --csv: Path to the local CSV file containing the GPIO map. (Required)
  • --output: Path to the output file. If omitted, output is written to stdout.

Example:

To generate Intel GPIO configuration from the provided example CSV:

./firmweaver coreboot_gpio --soc intel --csv coreboot_gpio/test/ExampleGpio.csv --output coreboot_gpio/test/gpio_config.c

(You can also use the shorthand ./firmweaver gpio ...)

Running the EC Zephyr Devicetree Generator

The zephyr_dtsi (alias: dtsi) parses an EC pinout CSV spreadsheet and generates Zephyr devicetree overlays.

./firmweaver zephyr_dtsi --chip <chip_name> --csv <path_to_csv> [--pin-col <variant>] [--output <path_to_output_dtsi>]

Example:

To generate Nuvoton NPCX9 Devicetree overlay from the provided example CSV:

./firmweaver zephyr_dtsi --chip npcx99 --csv zephyr_dtsi/test/ExampleEcPinout.csv --pin-col "NPCX99 (NPCX)" --output zephyr_dtsi/test/generated.dtsi

(You can also use the shorthand ./firmweaver dtsi ...)

Testing

Run unit tests across all tools in the workspace:

go test -v ./...

Contributing

This project follows the standard Chromium OS contribution process.