Skip to content

Commit

Permalink
WIP: Updates to incorporate
Browse files Browse the repository at this point in the history
This needs to be turned into patches

Signed-off-by: Simon Glass <sjg@chromium.org>
  • Loading branch information
sjg20 committed Dec 14, 2024
1 parent 8fbcc19 commit dc97a27
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 11 deletions.
6 changes: 3 additions & 3 deletions contrib/u-boot/lg-env
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
export LG_COORDINATOR=kea:20408

# Environment file for the lab
export LG_ENV=/vid/software/devel/ubtest/lab/cfg/env.cfg
export LG_ENV=/vid/software/devel/ubtest/lab/cfg/kea_env.cfg

# Location of the U-Boot test hooks
export UB_TEST_HOOKS=/vid/software/devel/ubtest/u-boot-test-hooks
Expand All @@ -20,5 +20,5 @@ export BUILDMAN_PROCESS_LIMIT=1
# Use the internal console since microcom can miss serial input at boot
export LG_CONSOLE=internal

# Tell u-boot-test-hooks to use the Labgrid integration
export USE_LABGRID=1
# Tell u-boot-test-hooks to use the Labgrid-sjg integration
export USE_LABGRID_SJG=1
13 changes: 10 additions & 3 deletions labgrid/driver/ubootproviderdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class UBootProviderDriver(Driver):
board (str): U-Boot board name, e.g. "gurnard"
bl31 (str): pathname of ARM Trusted Firmware BL31 binary blob
tee (str): pathname of OP-TEE Trusted Execution Environment blob
opensbi (str): pathname of Open Source Supervisor Binary Interface
binman_indir (str): pathname to a directory containing blobs for Binman
board_extra (str): U-Boot board name for a second build which uses the
same source code, e.g. "am62x_beagleplay_r5"
Expand Down Expand Up @@ -59,6 +60,7 @@ class UBootProviderDriver(Driver):
board = attr.ib(validator=attr.validators.instance_of(str))
bl31 = attr.ib(default='', validator=attr.validators.instance_of(str))
tee = attr.ib(default='', validator=attr.validators.instance_of(str))
opensbi = attr.ib(default='', validator=attr.validators.instance_of(str))
binman_indir = attr.ib(default='', validator=attr.validators.instance_of(str))
board_extra = attr.ib(default='', validator=attr.validators.instance_of(str))

Expand Down Expand Up @@ -187,9 +189,11 @@ def build(self, do_print=True, config_only=False):
patch = get_var('patch')
process_limit = get_var('process-limit')

env = os.environ
env = {}
if self.bl31:
env['BL31'] = self.bl31
if self.opensbi:
env['OPENSBI'] = self.opensbi
if self.binman_indir:
env['BINMAN_INDIRS'] = self.binman_indir
if self.tee:
Expand All @@ -200,7 +204,7 @@ def build(self, do_print=True, config_only=False):
self.tool,
'-w',
'-W',
'-ve',
'-veu',
]
if config_only:
cmd.append('--config-only')
Expand All @@ -223,8 +227,11 @@ def build(self, do_print=True, config_only=False):
if get_var('do-clean', '0') == '1':
cmd.append('-m')

full_env = os.environ
full_env.update(env)
for board, build_path in zip(boards, build_paths):
self.run_build(board, build_path, do_print, detail, cwd, env, cmd)
self.run_build(board, build_path, do_print, detail, cwd, full_env,
cmd)

return build_paths

Expand Down
6 changes: 6 additions & 0 deletions labgrid/driver/ubootwriterdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ def write(self, image_dirs):
dest = pathlib.PurePath('/u-boot.img')
image = os.path.join(image_dir, 'u-boot.img_unsigned')
self.storage.write_files([image], dest, 1, False)
elif self.method == 'riscv':
spl = os.path.join(image_dir, 'spl/u-boot-spl.bin.normal.out')
self.storage.write_image(spl, partition=13, block_size=512)

u_boot = os.path.join(image_dir, 'u-boot.itb')
self.storage.write_image(u_boot, partition=2, block_size=512)
else:
raise ValueError(f'Unknown writing method {self.method}')
if self.storage:
Expand Down
22 changes: 20 additions & 2 deletions labgrid/driver/usbstoragedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def write_image(self, filename=None, mode=Mode.DD, partition=None, skip=0, seek=

start = time.time()
if mode == Mode.DD:
self.logger.info('Writing %s to %s using dd.', remote_path, target)
self.logger.info('Writing %s to %s using dd', remote_path, target)
if block_size == "auto":
block_size = "512" if skip or seek else "4M"
args = [
Expand Down Expand Up @@ -214,11 +214,29 @@ def _get_devpath(self, partition):
# simple concatenation is sufficient for USB mass storage
return f"{self.storage.path}{partition}"

def can_write(self, partition):
"""Check if writing to a device is possible
Args:
partition (int or None): optional specified partition, or None
for root device (defaults to None)
Returns:
True if write access is available, False if not
"""
args = ['test', '-w', self._get_devpath(partition)]
try:
size = subprocess.check_output(self.storage.command_prefix + args)
except subprocess.CalledProcessError:
# perhaps udev has not run yet
return False
return True

@Driver.check_active
def _wait_for_medium(self, partition):
timeout = Timeout(self.WAIT_FOR_MEDIUM_TIMEOUT)
while not timeout.expired:
if self.get_size(partition) > 0:
if self.get_size(partition) > 0 and self.can_write(partition):
break
time.sleep(self.WAIT_FOR_MEDIUM_SLEEP)
else:
Expand Down
18 changes: 17 additions & 1 deletion labgrid/remote/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,12 +1535,18 @@ async def query(self, place, target):
raise UserError(f"{item}: Expected Driver:name[,name...]")
cls_name, names = item.split(':')
drv = target.get_driver(cls_name)

# Collect all values before we print anything
values = OrderedDict()
for name in names.split(','):
val = drv.query_info(name)
values[name] = drv.query_info(name)

for name, val in values.items():
if self.args.show_name:
print(f'{cls_name}:{name} {val}')
else:
print(f'{val}')

query.needs_target = True

def print_version(self, target):
Expand Down Expand Up @@ -2202,7 +2208,17 @@ def main():
coro = session.release()
session.loop.run_until_complete(coro)
else:
if args.acquire:
place = session.get_place(args.place)
if not place.acquired:
args.allow_unmatched = True
coro = session.acquire()
session.loop.run_until_complete(coro)
auto_release = True
args.func(session)
if auto_release:
coro = session.release()
session.loop.run_until_complete(coro)
finally:
logging.debug("Stopping session")
session.loop.run_until_complete(session.stop())
Expand Down
2 changes: 1 addition & 1 deletion labgrid/resource/servo.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def start(self):
for _ in range(30):
if self._proc.poll():
out = self._proc.communicate(timeout=100)
raise ValueError(f"servod died: '{out[1]}'")
raise ValueError(f"oh servod died: cmd {' '.join(cmd)} output '{out[1]}'")
if os.path.exists(self._info_file):
done = True
break
Expand Down
6 changes: 5 additions & 1 deletion labgrid/strategy/ubootstrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def bootstrap(self):
image_dirs = builder.build()
else:
image_dirs = builder.get_build_paths()
print(f"Bootstrapping U-Boot from dir {' '.join(image_dirs)}")
if len(image_dirs) == 1 or image_dirs[1] == 'None':
msg = f'dir {image_dirs[0]}'
else:
msg = f'dirs {image_dirs[0]} and {image_dirs[1]}'
print(f"Bootstrapping U-Boot from {msg}")

writer = self.target.get_driver("UBootWriterDriver")
if self.use_send():
Expand Down

0 comments on commit dc97a27

Please sign in to comment.