Fix futility bintool to run on newer distros

Apply a lost patch
 -----BEGIN PGP SIGNATURE-----
 
 iQFFBAABCgAvFiEEslwAIq+Gp8wWVbYnfxc6PpAIreYFAmMq3TARHHNqZ0BjaHJv
 bWl1bS5vcmcACgkQfxc6PpAIreY8oggAnQe34Gf/Smr2zQLY73ChSJduRbsMkaBW
 d9sN8RPmCUPo80n6oHT6M4rTS7pOH7aweX5ff9gEVneMxokHtGHIFA33f7dFhUH0
 bMyuc5P06TB1InIyezBttal+BDZjAM7IAsULvom6cDRt1UNmwP3+ond3QeZ2/k/T
 as8jCIOX79tKN3EHEc6IqU+WPRUJ/qIgCG4l4qcc8qaMCjVBiYj0UyEIpgR2cLnJ
 qMElUENRQLy5tXsEUEKBPDReVjwMnq213HpLZRl+vGaVE6t/dUalA51RVOfo67Hu
 ip7VUiRmUdUNoD2R2AvEVxDE7hNCIQo5Am0hkKUIMf6wHJDGXZmjQQ==
 =caHw
 -----END PGP SIGNATURE-----

Merge tag 'dm-pull-21sep22' of https://source.denx.de/u-boot/custodians/u-boot-dm

Fix futility bintool to run on newer distros
Apply a lost patch
This commit is contained in:
Tom Rini 2022-09-21 08:22:11 -04:00
commit 179a9320c0
3 changed files with 48 additions and 13 deletions

View File

@ -48,11 +48,27 @@ void set_working_fdt_addr(ulong addr)
/*
* Get a value from the fdt and format it to be set in the environment
*/
static int fdt_value_env_set(const void *nodep, int len, const char *var)
static int fdt_value_env_set(const void *nodep, int len,
const char *var, int index)
{
if (is_printable_string(nodep, len))
env_set(var, (void *)nodep);
else if (len == 4) {
if (is_printable_string(nodep, len)) {
const char *nodec = (const char *)nodep;
int i;
/*
* Iterate over all members in stringlist and find the one at
* offset $index. If no such index exists, indicate failure.
*/
for (i = 0; i < len; i += strlen(nodec) + 1) {
if (index-- > 0)
continue;
env_set(var, nodec + i);
return 0;
}
return 1;
} else if (len == 4) {
char buf[11];
sprintf(buf, "0x%08X", fdt32_to_cpu(*(fdt32_t *)nodep));
@ -426,10 +442,14 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
return 0;
} else if (nodep && len > 0) {
if (subcmd[0] == 'v') {
int index = 0;
int ret;
if (argc == 7)
index = simple_strtoul(argv[6], NULL, 10);
ret = fdt_value_env_set(nodep, len,
var);
var, index);
if (ret != 0)
return ret;
} else if (subcmd[0] == 'a') {
@ -1085,7 +1105,9 @@ static char fdt_help_text[] =
"fdt resize [<extrasize>] - Resize fdt to size + padding to 4k addr + some optional <extrasize> if needed\n"
"fdt print <path> [<prop>] - Recursive print starting at <path>\n"
"fdt list <path> [<prop>] - Print one level starting at <path>\n"
"fdt get value <var> <path> <prop> - Get <property> and store in <var>\n"
"fdt get value <var> <path> <prop> [<index>] - Get <property> and store in <var>\n"
" In case of stringlist property, use optional <index>\n"
" to select string within the stringlist. Default is 0.\n"
"fdt get name <var> <path> <index> - Get name of node <index> and store in <var>\n"
"fdt get addr <var> <path> <prop> - Get start address of <property> and store in <var>\n"
"fdt get size <var> <path> [<prop>] - Get size of [<property>] or num nodes and store in <var>\n"

View File

@ -319,7 +319,7 @@ class Bintool:
return result.stdout
@classmethod
def build_from_git(cls, git_repo, make_target, bintool_path):
def build_from_git(cls, git_repo, make_target, bintool_path, flags=None):
"""Build a bintool from a git repo
This clones the repo in a temporary directory, builds it with 'make',
@ -330,6 +330,7 @@ class Bintool:
make_target (str): Target to pass to 'make' to build the tool
bintool_path (str): Relative path of the tool in the repo, after
build is complete
flags (list of str): Flags or variables to pass to make, or None
Returns:
tuple:
@ -341,8 +342,11 @@ class Bintool:
print(f"- clone git repo '{git_repo}' to '{tmpdir}'")
tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir)
print(f"- build target '{make_target}'")
tools.run('make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}',
make_target)
cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}',
make_target]
if flags:
cmd += flags
tools.run(*cmd)
fname = os.path.join(tmpdir, bintool_path)
if not os.path.exists(fname):
print(f"- File '{fname}' was not produced")

View File

@ -160,8 +160,17 @@ class Bintoolfutility(bintool.Bintool):
Raises:
Valuerror: Fetching could not be completed
"""
if method != bintool.FETCH_BIN:
if method != bintool.FETCH_BUILD:
return None
fname, tmpdir = self.fetch_from_drive(
'1hdsInzsE4aJbmBeJ663kYgjOQyW1I-E0')
return fname, tmpdir
# The Chromium OS repo is here:
# https://chromium.googlesource.com/chromiumos/platform/vboot_reference/
#
# Unfortunately this requires logging in and obtaining a line for the
# .gitcookies file. So use a mirror instead.
result = self.build_from_git(
'https://github.com/sjg20/vboot_reference.git',
'all',
'build/futility/futility',
flags=['USE_FLASHROM=0'])
return result