rpit/write_to: quit when no proposed disk is available

This commit is contained in:
2025-04-07 15:32:15 +02:00
parent 832d8720d1
commit 52a1e2932b
2 changed files with 27 additions and 22 deletions

View File

@ -1,6 +1,6 @@
# Installation tools for APUs and Raspberry Pi boxes # Installation tools for APUs and Raspberry Pi boxes
Supports teh following boxes used at LIN sample environment: Supports the following boxes used at LIN sample environment:
- bare-apu: Linux box - bare-apu: Linux box
- controlbox: from FRM2 - controlbox: from FRM2

View File

@ -92,6 +92,7 @@ Example on Markus Mac:
Please unpower the box with compute module, Please unpower the box with compute module,
start this script again and put power immediately.""" start this script again and put power immediately."""
def write_image(kind): def write_image(kind):
if kind == 'eemc': if kind == 'eemc':
print("\nmake sure microUSB 'SLAVE' is connected to this computer") print("\nmake sure microUSB 'SLAVE' is connected to this computer")
@ -100,7 +101,8 @@ def write_image(kind):
else: else:
pass pass
proposed = find_raspi(kind) proposed = find_raspi(kind)
if not proposed and kind == 'emmc': if not proposed:
if kind == 'emmc':
# we may install rpiboot here if not available # we may install rpiboot here if not available
# git clone --depth=1 https://github.com/raspberrypi/usbboot # git clone --depth=1 https://github.com/raspberrypi/usbboot
# cd usbboot # cd usbboot
@ -121,13 +123,16 @@ def write_image(kind):
print('can not find CM') print('can not find CM')
return return
list_external() list_external()
if len(proposed) > 1: if len(proposed) == 1:
dev = proposed[0]
elif len(proposed) > 1:
if kind == 'emmc': if kind == 'emmc':
print('several potential devices for CM:', proposed) print('several potential devices for CM:', proposed)
return return
dev = input('select device to write to {" ".join(proposed)}: ') dev = input('select device to write to {" ".join(proposed)}: ')
else: else:
dev = proposed[0] print('none of above disks seems to be the sd card')
return
images = check_output(['sudo', '-u', 'zolliker', 'ssh', IMAGES_HOST, f'cd {IMAGES_DIR} ; ls {IMAGES_PAT}']).decode('latin-1').split('\n') images = check_output(['sudo', '-u', 'zolliker', 'ssh', IMAGES_HOST, f'cd {IMAGES_DIR} ; ls {IMAGES_PAT}']).decode('latin-1').split('\n')
for file in sorted(images): for file in sorted(images):
print(file) print(file)