diff --git a/test/hooks/bin/flash.sdwire_ykush_mount b/test/hooks/bin/flash.sdwire_ykush_mount new file mode 100644 index 00000000000..bd60dc38d7f --- /dev/null +++ b/test/hooks/bin/flash.sdwire_ykush_mount @@ -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 diff --git a/test/hooks/bin/poweroff.ykush b/test/hooks/bin/poweroff.ykush new file mode 100644 index 00000000000..fe03df70e2b --- /dev/null +++ b/test/hooks/bin/poweroff.ykush @@ -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} diff --git a/test/hooks/bin/poweron.ykush b/test/hooks/bin/poweron.ykush new file mode 100644 index 00000000000..5a541eccffd --- /dev/null +++ b/test/hooks/bin/poweron.ykush @@ -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} diff --git a/test/hooks/bin/reset.ykush b/test/hooks/bin/reset.ykush new file mode 100644 index 00000000000..f328eec5db8 --- /dev/null +++ b/test/hooks/bin/reset.ykush @@ -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} diff --git a/test/hooks/bin/writer.rpi3_mount b/test/hooks/bin/writer.rpi3_mount new file mode 100755 index 00000000000..7b078a168f2 --- /dev/null +++ b/test/hooks/bin/writer.rpi3_mount @@ -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