util/mainboard/google: add support for Volteer
create_coreboot_variant.sh now supports the Volteer baseboard in addition to Hatch. The shell script and supporting python code are moved up one level, while retaining the ${BASE}/template/* file structure for each supported baseboard. kconfig.py has to add slightly different text to Kconfig.name depending on which baseboard is selected. BRANCH=None BUG=b:146646594 TEST=Create variants of Hatch and Volteer, check that the staged commits are correct. $ ./create_coreboot_variant.sh hatch sushi b:12345 src/mainboard/google/hatch/Kconfig and Kconfig.name will have new sections for SUSHI. src/mainboard/google/hatch/variants/sushi will have a copy of util/mainboard/google/hatch/template $ ./create_coreboot_variant.sh volteer ripto b:12345 src/mainboard/google/volteer/Kconfig and Kconfig.name will have new sections for RIPTO. src/mainboard/google/volteer/variants/ripto will have a copy of util/mainboard/google/volteer/template Also run the script with an existing board name to verify that you can't create a variant that already exists. Change-Id: I084b6c50bb76af0d11dc86a96b3c3c434569a0dd Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/37878 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Justin TerAvest <teravest@chromium.org> Reviewed-by: Marco Chen <marcochen@google.com>
This commit is contained in:
committed by
Patrick Georgi
parent
f71991edc3
commit
1fe7dcb047
@ -1,88 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This file is part of the coreboot project.
|
||||
#
|
||||
# Copyright 2019 Google LLC.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
VERSION="1.0.1"
|
||||
SCRIPT=$(basename -- "${0}")
|
||||
|
||||
export LC_ALL=C
|
||||
|
||||
if [[ "$#" -lt 1 ]]; then
|
||||
echo "Usage: ${SCRIPT} variant_name [b:bug_number]"
|
||||
echo "e.g. ${SCRIPT} kohaku b:140261109"
|
||||
echo "* Adds a new variant of the baseboard to Kconfig and Kconfig.name"
|
||||
echo "* Copies the template files for the baseboard to the new variant"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Note that this script is specific to Hatch, and so it does not allow
|
||||
# you to specify the baseboard as one of the cmdline arguments.
|
||||
#
|
||||
# This is the name of the base board that we're cloning to make the variant.
|
||||
BASE="hatch"
|
||||
# This is the name of the variant that is being cloned.
|
||||
# ${var,,} converts to all lowercase; ${var^^} is all uppercase.
|
||||
VARIANT="${1,,}"
|
||||
VARIANT_UPPER="${VARIANT^^}"
|
||||
|
||||
# Assign text for the "BUG=" part of the commit, or use "None" if that
|
||||
# parameter wasn't specified.
|
||||
BUG=${2:-None}
|
||||
|
||||
# This script and the templates live in util/mainboard/google/hatch
|
||||
# We need to create files in src/mainboard/google/hatch
|
||||
pushd "${BASH_SOURCE%/*}" || exit 1
|
||||
SRC=$(pwd)
|
||||
popd || exit 1
|
||||
pushd "${SRC}/../../../../src/mainboard/google/${BASE}" || {
|
||||
echo "The baseboard directory for ${BASE} does not exist.";
|
||||
exit 1; }
|
||||
|
||||
# Make sure the variant doesn't already exist.
|
||||
if [[ -e variants/${VARIANT} ]]; then
|
||||
echo "variants/${VARIANT} already exists."
|
||||
echo "Have you already created this variant?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start a branch. Use YMD timestamp to avoid collisions.
|
||||
DATE=$(date +%Y%m%d)
|
||||
git checkout -b "coreboot_${VARIANT}_${DATE}" || exit 1
|
||||
|
||||
# Copy the template tree to the target.
|
||||
mkdir -p "variants/${VARIANT}/"
|
||||
cp -pr "${SRC}/template/." "variants/${VARIANT}/"
|
||||
git add "variants/${VARIANT}/"
|
||||
|
||||
# Now add the new variant to Kconfig and Kconfig.name
|
||||
# These files are in the current directory, e.g. src/mainboard/google/hatch
|
||||
"${SRC}/kconfig.py" --name "${VARIANT}"
|
||||
|
||||
mv Kconfig.new Kconfig
|
||||
mv Kconfig.name.new Kconfig.name
|
||||
|
||||
git add Kconfig Kconfig.name
|
||||
|
||||
# Now commit the files.
|
||||
git commit -sm "${BASE}: Create ${VARIANT} variant
|
||||
|
||||
Create the ${VARIANT} variant of the ${BASE} baseboard by
|
||||
copying the baseboard template files to a new directory
|
||||
named for the variant.
|
||||
|
||||
(Auto-Generated by ${SCRIPT} version ${VERSION}).
|
||||
|
||||
BUG=${BUG}
|
||||
TEST=util/abuild/abuild -p none -t google/${BASE} -x -a
|
||||
make sure the build includes GOOGLE_${VARIANT_UPPER}"
|
@ -1,116 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
"""Add a new variant to the Kconfig and Kconfig.name for the baseboard
|
||||
|
||||
To start a new variant of an existing baseboard, we need to add
|
||||
the variant into the Kconfig and Kconfig.name files for the
|
||||
baseboard. In Kconfig, we have two sections that need additional
|
||||
entries, MAINBOARD_PART_NUMBER and VARIANT_DIR.
|
||||
|
||||
The MAINBOARD_PART_NUMBER and VARIANT_DIR just use various
|
||||
capitalizations of the variant name to create the strings.
|
||||
|
||||
Kconfig.name adds an entire section for the new variant, and all
|
||||
of these use various capitalizations of the variant name. The strings
|
||||
in this section are SOC-specific, so we'll need versions for each
|
||||
SOC that we support.
|
||||
|
||||
Copyright 2019 Google LLC.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Add strings to coreboot Kconfig for a new board variant")
|
||||
parser.add_argument('--name', type=str, required=True,
|
||||
help='Name of the board variant')
|
||||
args = parser.parse_args()
|
||||
|
||||
add_to_Kconfig(args.name)
|
||||
add_to_Kconfig_name(args.name)
|
||||
|
||||
|
||||
def add_to_Kconfig(variant_name):
|
||||
"""Add options for the variant to the Kconfig
|
||||
|
||||
Open the Kconfig file and read it line-by-line. When we detect that we're
|
||||
in one of the sections of interest, wait until we get a blank line
|
||||
(signalling the end of that section), and then add our new line before
|
||||
the blank line. The updated lines are written out to Kconfig.new in the
|
||||
same directory as Kconfig.
|
||||
|
||||
variant_name The name of the board variant, e.g. 'kohaku'"""
|
||||
# These are the part of the strings that we'll add to the sections
|
||||
BOARD = 'BOARD_GOOGLE_' + variant_name.upper()
|
||||
lowercase = variant_name.lower()
|
||||
capitalized = lowercase.capitalize()
|
||||
|
||||
# These flags track whether we're in a section where we need to add an option
|
||||
in_mainboard_part_number = False
|
||||
in_variant_dir = False
|
||||
|
||||
inputname = 'Kconfig'
|
||||
outputname = 'Kconfig.new'
|
||||
with open(outputname, 'w') as outfile:
|
||||
with open(inputname, 'r') as infile:
|
||||
for rawline in infile:
|
||||
line = rawline.rstrip('\r\n')
|
||||
|
||||
# Are we in one of the sections of interest?
|
||||
if line == 'config MAINBOARD_PART_NUMBER':
|
||||
in_mainboard_part_number = True
|
||||
if line == 'config VARIANT_DIR':
|
||||
in_variant_dir = True
|
||||
|
||||
# Are we at the end of a section, and if so, is it one of the
|
||||
# sections of interest?
|
||||
if line == '':
|
||||
if in_mainboard_part_number:
|
||||
print('\tdefault "' + capitalized + '" if ' + BOARD, file=outfile)
|
||||
in_mainboard_part_number = False
|
||||
if in_variant_dir:
|
||||
print('\tdefault "' + lowercase + '" if ' + BOARD, file=outfile)
|
||||
in_variant_dir = False
|
||||
|
||||
print(line, file=outfile)
|
||||
|
||||
|
||||
def add_to_Kconfig_name(variant_name):
|
||||
"""Add a config section for the variant to the Kconfig.name
|
||||
|
||||
Kconfig.name is easier to modify than Kconfig; it only has a block at
|
||||
the end with the new variant's details.
|
||||
|
||||
variant_name The name of the board variant, e.g. 'kohaku'"""
|
||||
# Board name for the config section
|
||||
uppercase = variant_name.upper()
|
||||
capitalized = variant_name.lower().capitalize()
|
||||
|
||||
inputname = 'Kconfig.name'
|
||||
outputname = 'Kconfig.name.new'
|
||||
with open(outputname, 'w') as outfile:
|
||||
with open(inputname, 'r') as infile:
|
||||
# Copy all input lines to output
|
||||
for rawline in infile:
|
||||
line = rawline.rstrip('\r\n')
|
||||
print(line, file=outfile)
|
||||
|
||||
# Now add the new section
|
||||
print('\nconfig ' + 'BOARD_GOOGLE_' + uppercase, file=outfile)
|
||||
print('\tbool "-> ' + capitalized + '"', file=outfile)
|
||||
print('\tselect BOARD_GOOGLE_BASEBOARD_HATCH', file=outfile)
|
||||
print('\tselect BOARD_ROMSIZE_KB_16384', file=outfile)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Reference in New Issue
Block a user