util/hatch: remove GBB_HWID, clean up user-visible output
* GBB_HWID is no longer used in Hatch Kconfig, so remove the code that creates the GBB_HWID and adds it to the Kconfig section * Add more information in the usage message when the cmdline params are incorrect. * Remove messages that tell the user what to do, because the top-level program that invokes this script will handle those commands, and so this script telling the user what to do is noise (and possibly harmful) * Add more information to the commit message that the script prepares for the user. * Bump script version number. BRANCH=None BUG=b:140261109 TEST=Create the "sushi" variant of the "hatch" baseboard: `util/mainboard/google/hatch/create_coreboot_variant.sh sushi` Inspect the files in src/mainboard/google/hatch/variants/sushi Change-Id: I04e949aedce61ed7fc7df681b72c3cfef31b5513 Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/37647 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Justin TerAvest <teravest@chromium.org>
This commit is contained in:
parent
32bae49435
commit
149d523c9a
|
@ -13,7 +13,7 @@
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
VERSION="1.0.0"
|
VERSION="1.0.1"
|
||||||
SCRIPT=$(basename -- "${0}")
|
SCRIPT=$(basename -- "${0}")
|
||||||
|
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
|
@ -21,9 +21,8 @@ export LC_ALL=C
|
||||||
if [[ "$#" -lt 1 ]]; then
|
if [[ "$#" -lt 1 ]]; then
|
||||||
echo "Usage: ${SCRIPT} variant_name [b:bug_number]"
|
echo "Usage: ${SCRIPT} variant_name [b:bug_number]"
|
||||||
echo "e.g. ${SCRIPT} kohaku b:140261109"
|
echo "e.g. ${SCRIPT} kohaku b:140261109"
|
||||||
echo "Adds a new variant of Hatch to Kconfig and Kconfig.name, creates the"
|
echo "* Adds a new variant of the baseboard to Kconfig and Kconfig.name"
|
||||||
echo "skeleton files for acpi, ec, and gpio, copies the makefile for"
|
echo "* Copies the template files for the baseboard to the new variant"
|
||||||
echo "SPD sources, and sets up a basic overridetree"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -78,11 +77,12 @@ git add Kconfig Kconfig.name
|
||||||
# Now commit the files.
|
# Now commit the files.
|
||||||
git commit -sm "${BASE}: Create ${VARIANT} variant
|
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}).
|
(Auto-Generated by ${SCRIPT} version ${VERSION}).
|
||||||
|
|
||||||
BUG=${BUG}
|
BUG=${BUG}
|
||||||
TEST=util/abuild/abuild -p none -t google/${BASE} -x -a
|
TEST=util/abuild/abuild -p none -t google/${BASE} -x -a
|
||||||
make sure the build includes GOOGLE_${VARIANT_UPPER}"
|
make sure the build includes GOOGLE_${VARIANT_UPPER}"
|
||||||
|
|
||||||
echo "Please check all the files (git show), make any changes you want,"
|
|
||||||
echo "and then push to coreboot HEAD:refs/for/master"
|
|
||||||
|
|
|
@ -3,22 +3,11 @@
|
||||||
|
|
||||||
To start a new variant of an existing baseboard, we need to add
|
To start a new variant of an existing baseboard, we need to add
|
||||||
the variant into the Kconfig and Kconfig.name files for the
|
the variant into the Kconfig and Kconfig.name files for the
|
||||||
baseboard. In Kconfig, we have three sections that need additional
|
baseboard. In Kconfig, we have two sections that need additional
|
||||||
entries, GBB_HWID, MAINBOARD_PART_NUMBER, and VARIANT_DIR.
|
entries, MAINBOARD_PART_NUMBER and VARIANT_DIR.
|
||||||
|
|
||||||
In GBB_HWID, we need to add a HWID that includes a numeric suffix.
|
The MAINBOARD_PART_NUMBER and VARIANT_DIR just use various
|
||||||
The numeric suffix is the CRC-32 of the all-caps ASCII name,
|
capitalizations of the variant name to create the strings.
|
||||||
modulo 10000.
|
|
||||||
For example, if the board name is "Fizz", we calculate the CRC of
|
|
||||||
"FIZZ TEST", which is 0x598C492D. In decimal, the value is 1502365997,
|
|
||||||
modulo 10000 is 5997. So the HWID string is "FIZZ TEST 5997"
|
|
||||||
In the past, we have used an online CRC-32 calculator such as
|
|
||||||
https://www.lammertbies.nl/comm/info/crc-calculation.html, and then
|
|
||||||
used the calculator app to convert to decimal and take the last
|
|
||||||
4 digits.
|
|
||||||
|
|
||||||
The MAINBOARD_PART_NUMBER and VARIANT_DIR are simpler, just using
|
|
||||||
various capitalizations of the variant name to create the strings.
|
|
||||||
|
|
||||||
Kconfig.name adds an entire section for the new variant, and all
|
Kconfig.name adds an entire section for the new variant, and all
|
||||||
of these use various capitalizations of the variant name. The strings
|
of these use various capitalizations of the variant name. The strings
|
||||||
|
@ -38,7 +27,6 @@ GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import zlib
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -52,26 +40,6 @@ def main():
|
||||||
add_to_Kconfig_name(args.name)
|
add_to_Kconfig_name(args.name)
|
||||||
|
|
||||||
|
|
||||||
def get_gbb_hwid(variant_name):
|
|
||||||
"""Create the GBB_HWID for a variant
|
|
||||||
|
|
||||||
variant_name The name of the board variant, e.g. 'kohaku'
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
GBB_HWID string for the board variant, e.g. 'KOHAKU TEST 1953'
|
|
||||||
|
|
||||||
Note that the case of the variant name does not matter; it gets
|
|
||||||
converted to all uppercase as part of this function."""
|
|
||||||
hwid = variant_name + ' test'
|
|
||||||
upperhwid = hwid.upper()
|
|
||||||
# Force conversion to unsigned by bitwise AND with (2^32)-1.
|
|
||||||
# See the docs for crc32 at https://docs.python.org/3/library/zlib.html
|
|
||||||
# for why '& 0xffffffff' is necessary.
|
|
||||||
crc = zlib.crc32(upperhwid.encode('UTF-8')) & 0xffffffff
|
|
||||||
gbb_hwid = upperhwid + ' ' + str(crc % 10000).zfill(4)
|
|
||||||
return gbb_hwid
|
|
||||||
|
|
||||||
|
|
||||||
def add_to_Kconfig(variant_name):
|
def add_to_Kconfig(variant_name):
|
||||||
"""Add options for the variant to the Kconfig
|
"""Add options for the variant to the Kconfig
|
||||||
|
|
||||||
|
@ -84,12 +52,10 @@ def add_to_Kconfig(variant_name):
|
||||||
variant_name The name of the board variant, e.g. 'kohaku'"""
|
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
|
# These are the part of the strings that we'll add to the sections
|
||||||
BOARD = 'BOARD_GOOGLE_' + variant_name.upper()
|
BOARD = 'BOARD_GOOGLE_' + variant_name.upper()
|
||||||
gbb_hwid = get_gbb_hwid(variant_name)
|
|
||||||
lowercase = variant_name.lower()
|
lowercase = variant_name.lower()
|
||||||
capitalized = lowercase.capitalize()
|
capitalized = lowercase.capitalize()
|
||||||
|
|
||||||
# These flags track whether we're in a section where we need to add an option
|
# These flags track whether we're in a section where we need to add an option
|
||||||
in_gbb_hwid = False
|
|
||||||
in_mainboard_part_number = False
|
in_mainboard_part_number = False
|
||||||
in_variant_dir = False
|
in_variant_dir = False
|
||||||
|
|
||||||
|
@ -101,8 +67,6 @@ def add_to_Kconfig(variant_name):
|
||||||
line = rawline.rstrip('\r\n')
|
line = rawline.rstrip('\r\n')
|
||||||
|
|
||||||
# Are we in one of the sections of interest?
|
# Are we in one of the sections of interest?
|
||||||
if line == 'config GBB_HWID':
|
|
||||||
in_gbb_hwid = True
|
|
||||||
if line == 'config MAINBOARD_PART_NUMBER':
|
if line == 'config MAINBOARD_PART_NUMBER':
|
||||||
in_mainboard_part_number = True
|
in_mainboard_part_number = True
|
||||||
if line == 'config VARIANT_DIR':
|
if line == 'config VARIANT_DIR':
|
||||||
|
@ -111,9 +75,6 @@ def add_to_Kconfig(variant_name):
|
||||||
# Are we at the end of a section, and if so, is it one of the
|
# Are we at the end of a section, and if so, is it one of the
|
||||||
# sections of interest?
|
# sections of interest?
|
||||||
if line == '':
|
if line == '':
|
||||||
if in_gbb_hwid:
|
|
||||||
print('\tdefault "' + gbb_hwid + '" if ' + BOARD, file=outfile)
|
|
||||||
in_gbb_hwid = False
|
|
||||||
if in_mainboard_part_number:
|
if in_mainboard_part_number:
|
||||||
print('\tdefault "' + capitalized + '" if ' + BOARD, file=outfile)
|
print('\tdefault "' + capitalized + '" if ' + BOARD, file=outfile)
|
||||||
in_mainboard_part_number = False
|
in_mainboard_part_number = False
|
||||||
|
@ -130,12 +91,9 @@ def add_to_Kconfig_name(variant_name):
|
||||||
Kconfig.name is easier to modify than Kconfig; it only has a block at
|
Kconfig.name is easier to modify than Kconfig; it only has a block at
|
||||||
the end with the new variant's details.
|
the end with the new variant's details.
|
||||||
|
|
||||||
config BOARD_GOOGLE_${VARIANT}
|
|
||||||
|
|
||||||
variant_name The name of the board variant, e.g. 'kohaku'"""
|
variant_name The name of the board variant, e.g. 'kohaku'"""
|
||||||
# Board name for the config section
|
# Board name for the config section
|
||||||
uppercase = variant_name.upper()
|
uppercase = variant_name.upper()
|
||||||
BOARD = 'BOARD_GOOGLE_' + uppercase
|
|
||||||
capitalized = variant_name.lower().capitalize()
|
capitalized = variant_name.lower().capitalize()
|
||||||
|
|
||||||
inputname = 'Kconfig.name'
|
inputname = 'Kconfig.name'
|
||||||
|
@ -148,7 +106,7 @@ def add_to_Kconfig_name(variant_name):
|
||||||
print(line, file=outfile)
|
print(line, file=outfile)
|
||||||
|
|
||||||
# Now add the new section
|
# Now add the new section
|
||||||
print('\nconfig ' + BOARD, file=outfile)
|
print('\nconfig ' + 'BOARD_GOOGLE_' + uppercase, file=outfile)
|
||||||
print('\tbool "-> ' + capitalized + '"', file=outfile)
|
print('\tbool "-> ' + capitalized + '"', file=outfile)
|
||||||
print('\tselect BOARD_GOOGLE_BASEBOARD_HATCH', file=outfile)
|
print('\tselect BOARD_GOOGLE_BASEBOARD_HATCH', file=outfile)
|
||||||
print('\tselect BOARD_ROMSIZE_KB_16384', file=outfile)
|
print('\tselect BOARD_ROMSIZE_KB_16384', file=outfile)
|
||||||
|
|
Loading…
Reference in New Issue