hooks: Add support for sdwire/ykush combination
With these two items it is possible to control the power of the device and access its SD card when off. This adds support for using a single rpi_3 with - SDwire used to allow updating the uSD card over USB - Ykush (YepKit) to control power to the rpi_3 There are a few udev changes as well, not included here. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Stephen Warren <swarren@nvidia.com>
This commit is contained in:
68
test/hooks/bin/flash.sdwire_ykush_mount
Normal file
68
test/hooks/bin/flash.sdwire_ykush_mount
Normal file
@@ -0,0 +1,68 @@
|
||||
# Copyright 2019 Google LLC. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Designed for using SDwire uSD myx and ykush USB power control:
|
||||
# https://wiki.tizen.org/SDWire
|
||||
# https://www.yepkit.com/products/ykush
|
||||
|
||||
# It requires these tools:
|
||||
# sd-mux-ctrl at https://git.tizen.org/cgit/tools/testlab/sd-mux/
|
||||
# ykushcmd at https://github.com/Yepkit/ykush
|
||||
|
||||
mount_dir=/media/${mount_point}
|
||||
|
||||
# Power off
|
||||
ykushcmd -s ${ykush_serial} -d ${ykush_port}
|
||||
|
||||
# Switch over to get USB card access
|
||||
sd-mux-ctrl --device-serial ${sdwire_serial} --ts
|
||||
|
||||
done=false
|
||||
for i in {0..9}; do
|
||||
if out="$(mount UUID=${mount_uuid} 2>&1)"; then
|
||||
done=true
|
||||
break
|
||||
fi
|
||||
echo $out
|
||||
|
||||
# If it is already mounted, try to unmount it first. It may have been
|
||||
# mounted by another user so we won't have the access we need. If this gives
|
||||
# an error then we know we cannot continue
|
||||
if [[ $out == *"already mounted"* ]]; then
|
||||
umount UUID=${mount_uuid}
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
if [[ $done = false ]]; then
|
||||
echo "Failed to mount UUID ${mount_uuid} after 10 tries"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Sanity check
|
||||
if ! mountpoint -q ${mount_dir}; then
|
||||
echo "Mount ${mount_dir} not available after 'mount'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
writer.${flash_writer} ${mount_dir} ${U_BOOT_BUILD_DIR}
|
||||
umount ${mount_dir}
|
||||
|
||||
# Back to card access for the DUT
|
||||
sd-mux-ctrl --device-serial ${sdwire_serial} --dut
|
||||
23
test/hooks/bin/poweroff.ykush
Normal file
23
test/hooks/bin/poweroff.ykush
Normal file
@@ -0,0 +1,23 @@
|
||||
# Copyright 2019 Google LLC. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Usees YKUSB to power the device off
|
||||
|
||||
ykushcmd -s ${ykush_serial} -d ${ykush_port}
|
||||
23
test/hooks/bin/poweron.ykush
Normal file
23
test/hooks/bin/poweron.ykush
Normal file
@@ -0,0 +1,23 @@
|
||||
# Copyright 2019 Google LLC. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Usees YKUSB to power the device on
|
||||
|
||||
ykushcmd -s ${ykush_serial} -u ${ykush_port}
|
||||
25
test/hooks/bin/reset.ykush
Normal file
25
test/hooks/bin/reset.ykush
Normal file
@@ -0,0 +1,25 @@
|
||||
# Copyright 2019 Google LLC. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Usees YKUSB to power the device off and then on
|
||||
|
||||
ykushcmd -s ${ykush_serial} -d ${ykush_port}
|
||||
sleep 1
|
||||
ykushcmd -s ${ykush_serial} -u ${ykush_port}
|
||||
49
test/hooks/bin/writer.rpi3_mount
Executable file
49
test/hooks/bin/writer.rpi3_mount
Executable file
@@ -0,0 +1,49 @@
|
||||
# Copyright 2019 Google LLC. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Writes rpi3_b to the board
|
||||
|
||||
# Args:
|
||||
# $1: Mount point of the sdcard when board is off
|
||||
# $2: U-Boot build directory
|
||||
|
||||
set -ex
|
||||
|
||||
mount=$1
|
||||
build=$2
|
||||
|
||||
echo "Writing to ${mount} from build at ${build}"
|
||||
|
||||
# First make a copy of the original files if we haven't already
|
||||
if [[ ! -e ${mount}/config.orig ]]; then
|
||||
cp ${mount}/config.txt ${mount}/config.orig
|
||||
fi
|
||||
if [[ ! -e ${mount}/rpi3-u-boot.bin.orig ]]; then
|
||||
cp ${mount}/rpi3-u-boot.bin ${mount}/rpi3-u-boot.bin.orig
|
||||
fi
|
||||
|
||||
# Enable the UART and fix the GPU frequency so it works correctly
|
||||
sed -i '/enable_uart/c\enable_uart = 1' /media/rpi3_b_boot/config.txt
|
||||
if ! grep -q gpu_freq=250 /media/rpi3_b_boot/config.txt; then
|
||||
echo 'gpu_freq=250' >>/media/rpi3_b_boot/config.txt
|
||||
fi
|
||||
|
||||
# Copy U-Boot over from the build directory
|
||||
cp ${build}/u-boot.bin ${mount}/rpi3-u-boot.bin
|
||||
Reference in New Issue
Block a user