mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 09:54:35 +00:00
expo: Tidy up the expo.py tool and usage
Tidy up this tool a little: - define which arguments are needed - split the enum values out into a header file - warn if no enum values are found - display the dtc error if something goes wrong - avoid a Python traceback on error Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
8d0f890a0b
commit
d5737b3f6a
5 changed files with 62 additions and 43 deletions
|
@ -367,22 +367,27 @@ strings are provided inline in the nodes where they are used.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
#define ID_PROMPT 1
|
/* this comment is parsed by the expo.py tool to insert the values below
|
||||||
#define ID_SCENE1 2
|
|
||||||
#define ID_SCENE1_TITLE 3
|
|
||||||
|
|
||||||
#define ID_CPU_SPEED 4
|
enum {
|
||||||
#define ID_CPU_SPEED_TITLE 5
|
ZERO,
|
||||||
#define ID_CPU_SPEED_1 6
|
ID_PROMPT,
|
||||||
#define ID_CPU_SPEED_2 7
|
ID_SCENE1,
|
||||||
#define ID_CPU_SPEED_3 8
|
ID_SCENE1_TITLE,
|
||||||
|
|
||||||
#define ID_POWER_LOSS 9
|
ID_CPU_SPEED,
|
||||||
#define ID_AC_OFF 10
|
ID_CPU_SPEED_TITLE,
|
||||||
#define ID_AC_ON 11
|
ID_CPU_SPEED_1,
|
||||||
#define ID_AC_MEMORY 12
|
ID_CPU_SPEED_2,
|
||||||
|
ID_CPU_SPEED_3,
|
||||||
|
|
||||||
#define ID_DYNAMIC_START 13
|
ID_POWER_LOSS,
|
||||||
|
ID_AC_OFF,
|
||||||
|
ID_AC_ON,
|
||||||
|
ID_AC_MEMORY,
|
||||||
|
|
||||||
|
ID_DYNAMIC_START,
|
||||||
|
*/
|
||||||
|
|
||||||
&cedit {
|
&cedit {
|
||||||
dynamic-start = <ID_DYNAMIC_START>;
|
dynamic-start = <ID_DYNAMIC_START>;
|
||||||
|
|
25
test/boot/files/expo_ids.h
Normal file
25
test/boot/files/expo_ids.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||||
|
/*
|
||||||
|
* Sample expo screen layout (ID numbers)
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ZERO,
|
||||||
|
ID_PROMPT,
|
||||||
|
|
||||||
|
ID_SCENE1,
|
||||||
|
ID_SCENE1_TITLE,
|
||||||
|
|
||||||
|
ID_CPU_SPEED,
|
||||||
|
ID_CPU_SPEED_TITLE,
|
||||||
|
ID_CPU_SPEED_1,
|
||||||
|
ID_CPU_SPEED_2,
|
||||||
|
ID_CPU_SPEED_3,
|
||||||
|
|
||||||
|
ID_POWER_LOSS,
|
||||||
|
ID_AC_OFF,
|
||||||
|
ID_AC_ON,
|
||||||
|
ID_AC_MEMORY,
|
||||||
|
|
||||||
|
ID_DYNAMIC_START,
|
||||||
|
};
|
|
@ -5,28 +5,7 @@
|
||||||
|
|
||||||
/dts-v1/;
|
/dts-v1/;
|
||||||
|
|
||||||
/*
|
/* see expo_ids.h for the IDs */
|
||||||
enum {
|
|
||||||
ZERO,
|
|
||||||
ID_PROMPT,
|
|
||||||
|
|
||||||
ID_SCENE1,
|
|
||||||
ID_SCENE1_TITLE,
|
|
||||||
|
|
||||||
ID_CPU_SPEED,
|
|
||||||
ID_CPU_SPEED_TITLE,
|
|
||||||
ID_CPU_SPEED_1,
|
|
||||||
ID_CPU_SPEED_2,
|
|
||||||
ID_CPU_SPEED_3,
|
|
||||||
|
|
||||||
ID_POWER_LOSS,
|
|
||||||
ID_AC_OFF,
|
|
||||||
ID_AC_ON,
|
|
||||||
ID_AC_MEMORY,
|
|
||||||
|
|
||||||
ID_DYNAMIC_START,
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
dynamic-start = <ID_DYNAMIC_START>;
|
dynamic-start = <ID_DYNAMIC_START>;
|
||||||
|
|
|
@ -285,10 +285,12 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
|
||||||
def setup_cedit_file(cons):
|
def setup_cedit_file(cons):
|
||||||
infname = os.path.join(cons.config.source_dir,
|
infname = os.path.join(cons.config.source_dir,
|
||||||
'test/boot/files/expo_layout.dts')
|
'test/boot/files/expo_layout.dts')
|
||||||
|
inhname = os.path.join(cons.config.source_dir,
|
||||||
|
'test/boot/files/expo_ids.h')
|
||||||
expo_tool = os.path.join(cons.config.source_dir, 'tools/expo.py')
|
expo_tool = os.path.join(cons.config.source_dir, 'tools/expo.py')
|
||||||
outfname = 'cedit.dtb'
|
outfname = 'cedit.dtb'
|
||||||
u_boot_utils.run_and_log(
|
u_boot_utils.run_and_log(
|
||||||
cons, f'{expo_tool} -e {infname} -l {infname} -o {outfname}')
|
cons, f'{expo_tool} -e {inhname} -l {infname} -o {outfname}')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.buildconfigspec('ut_dm')
|
@pytest.mark.buildconfigspec('ut_dm')
|
||||||
|
|
|
@ -69,7 +69,10 @@ def calc_ids(fname):
|
||||||
|
|
||||||
def run_expo(args):
|
def run_expo(args):
|
||||||
"""Run the expo program"""
|
"""Run the expo program"""
|
||||||
ids = calc_ids(args.enum_fname)
|
fname = args.enum_fname or args.layout
|
||||||
|
ids = calc_ids(fname)
|
||||||
|
if not ids:
|
||||||
|
print(f"Warning: No enum ID values found in file '{fname}'")
|
||||||
|
|
||||||
indata = tools.read_file(args.layout)
|
indata = tools.read_file(args.layout)
|
||||||
|
|
||||||
|
@ -88,10 +91,10 @@ def run_expo(args):
|
||||||
|
|
||||||
with open('/tmp/asc', 'wb') as outf:
|
with open('/tmp/asc', 'wb') as outf:
|
||||||
outf.write(data)
|
outf.write(data)
|
||||||
proc = subprocess.run('dtc', input=data, capture_output=True, check=True)
|
proc = subprocess.run('dtc', input=data, capture_output=True)
|
||||||
edtb = proc.stdout
|
edtb = proc.stdout
|
||||||
if proc.stderr:
|
if proc.stderr:
|
||||||
print(proc.stderr)
|
print(f"Devicetree compiler error:\n{proc.stderr.decode('utf-8')}")
|
||||||
return 1
|
return 1
|
||||||
tools.write_file(args.outfile, edtb)
|
tools.write_file(args.outfile, edtb)
|
||||||
return 0
|
return 0
|
||||||
|
@ -109,11 +112,13 @@ def parse_args(argv):
|
||||||
args is a list of string arguments
|
args is a list of string arguments
|
||||||
"""
|
"""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('-D', '--debug', action='store_true',
|
||||||
|
help='Enable full debug traceback')
|
||||||
parser.add_argument('-e', '--enum-fname', type=str,
|
parser.add_argument('-e', '--enum-fname', type=str,
|
||||||
help='C file containing enum declaration for expo items')
|
help='.dts or C file containing enum declaration for expo items')
|
||||||
parser.add_argument('-l', '--layout', type=str,
|
parser.add_argument('-l', '--layout', type=str, required=True,
|
||||||
help='Devicetree file source .dts for expo layout')
|
help='Devicetree file source .dts for expo layout (and perhaps enums)')
|
||||||
parser.add_argument('-o', '--outfile', type=str,
|
parser.add_argument('-o', '--outfile', type=str, required=True,
|
||||||
help='Filename to write expo layout dtb')
|
help='Filename to write expo layout dtb')
|
||||||
|
|
||||||
return parser.parse_args(argv)
|
return parser.parse_args(argv)
|
||||||
|
@ -122,6 +127,9 @@ def start_expo():
|
||||||
"""Start the expo program"""
|
"""Start the expo program"""
|
||||||
args = parse_args(sys.argv[1:])
|
args = parse_args(sys.argv[1:])
|
||||||
|
|
||||||
|
if not args.debug:
|
||||||
|
sys.tracebacklimit = 0
|
||||||
|
|
||||||
ret_code = run_expo(args)
|
ret_code = run_expo(args)
|
||||||
sys.exit(ret_code)
|
sys.exit(ret_code)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue