diff --git a/PCBA/board/funkey/rootfs-overlay/bin/test-battery b/PCBA/board/funkey/rootfs-overlay/bin/test-battery new file mode 100755 index 0000000..6be5629 --- /dev/null +++ b/PCBA/board/funkey/rootfs-overlay/bin/test-battery @@ -0,0 +1,35 @@ +#!/bin/sh + +# Load I2C modules +modprobe i2c-dev +modprobe i2c-mv64xxx + +# Look for U1 (PCAL6416 GPIO expander) +U1=$(i2cdetect -y 0 20 20 | grep 20: | cut -d ':' -f 2) +let U1=U1+0 +if [ ${U1} -ne 20 ]; then + echo "ERROR BATTERY CHIP" +else + + # Wait for the battery detected and charging for 10s + timeout=10 + while [ ${timeout} -ne 0 ]; do + value=$(i2cget -y 0 34 1) + if [ $? -ne 0 ]; then + echo "ERROR BATTERY I2C" + break + fi + if [ "${value}" = "0x74" ]; then + echo "OK" + break + fi + sleep 1 + let timeout=timeout-1 + done + if [ ${timeout} -eq 0 ]; then + echo "ERROR BATTERY TIMEOUT" + fi +fi + +# Unload I2C modules +modprobe -r i2c_mv64xxx i2c_dev >/dev/null 2>&1 diff --git a/PCBA/board/funkey/rootfs-overlay/bin/test-gpio b/PCBA/board/funkey/rootfs-overlay/bin/test-gpio index e5d1cac..2f392d3 100755 --- a/PCBA/board/funkey/rootfs-overlay/bin/test-gpio +++ b/PCBA/board/funkey/rootfs-overlay/bin/test-gpio @@ -1,18 +1,22 @@ #!/bin/sh if [ $# -ne 2 ]; then - echo "ERROR Wrong number of arguments $#" + echo "ERROR GPIO ARGS" exit 1 fi pin=$(gpiofind "${1}") if [ $? -ne 0 ]; then - echo "ERROR Unknown GPIO ${1}" + echo "ERROR GPIO PIN" exit 1 fi case ${2} in 0) value=${2};; 1) value=${2};; - *) echo "ERROR Bad value ${2}"; exit 1;; + *) echo "ERROR GPIO VALUE"; exit 1;; esac gpioset ${pin}=${value} -echo "OK" +if [ $? -ne 0 ]; then + echo "ERROR GPIO I2C" +else + echo "OK" +fi diff --git a/PCBA/board/funkey/rootfs-overlay/bin/test-i2c b/PCBA/board/funkey/rootfs-overlay/bin/test-i2c index 2800e6d..17e681d 100755 --- a/PCBA/board/funkey/rootfs-overlay/bin/test-i2c +++ b/PCBA/board/funkey/rootfs-overlay/bin/test-i2c @@ -4,19 +4,19 @@ modprobe i2c-dev modprobe i2c-mv64xxx -# Look for PCF6416 GPIO expander -PCF6416=$(i2cdetect -y 0 20 20 | grep 20: | cut -d ':' -f 2) -let PCF6416=PCF6416+0 -if [ ${PCF6416} -ne 20 ]; then - echo "ERROR PCF6416" +# Look for U1 (PCAL6416 GPIO expander) +U1=$(i2cdetect -y 0 20 20 | grep 20: | cut -d ':' -f 2) +let U1=U1+0 +if [ ${U1} -ne 20 ]; then + echo "ERROR I2C U1" exit 1 fi -# Look for AXP209 PMIC -AXP209=$(i2cdetect -y 0 34 34 | grep 30: | cut -d ':' -f 2) -let AXP2090=AXP209+0 -if [ ${AXP209} -ne 34 ]; then - echo "ERROR AXP209" +# Look for U5 (AXP209 PMIC) +U5=$(i2cdetect -y 0 34 34 | grep 30: | cut -d ':' -f 2) +let U5=U5+0 +if [ ${U5} -ne 34 ]; then + echo "ERROR I2C U5" exit 1 fi diff --git a/PCBA/board/funkey/rootfs-overlay/bin/test-led b/PCBA/board/funkey/rootfs-overlay/bin/test-led index c9b20e2..7e82ea2 100755 --- a/PCBA/board/funkey/rootfs-overlay/bin/test-led +++ b/PCBA/board/funkey/rootfs-overlay/bin/test-led @@ -1,13 +1,13 @@ #!/bin/sh if [ $# -ne 1 ];then - echo "ERROR Wrong number of arguments $#" + echo "ERROR LED ARGS" exit; fi case ${1} in 0) value=0x0a;; 1) value=0x3a;; - *) echo "ERROR Bad argument ${1}"; exit 1;; + *) echo "ERROR LED VALUE"; exit 1;; esac # Load I2C modules @@ -16,7 +16,11 @@ modprobe i2c-mv64xxx # Turn on/off the LED i2cset -y 0 0x34 0x32 ${value} +if [ $? -ne 0 ]; then + echo "ERROR LED I2C" +else + echo "OK" +fi # Unload I2C modules modprobe -r i2c_mv64xxx i2c_dev >/dev/null 2>&1 -echo "OK" diff --git a/PCBA/board/funkey/rootfs-overlay/bin/test-speaker b/PCBA/board/funkey/rootfs-overlay/bin/test-speaker index f223d2b..306b300 100755 --- a/PCBA/board/funkey/rootfs-overlay/bin/test-speaker +++ b/PCBA/board/funkey/rootfs-overlay/bin/test-speaker @@ -2,11 +2,23 @@ # Turn on Power Amplifier gpioset $(gpiofind "PA")=1 +if [ $? -ne 0 ]; then + echo "ERROR SPEAKER ON" +else -# Play 1kHz sine wave -speaker-test -t sine -s 1 -f 1000 >/dev/null 2>&1 + # Play 1kHz sine wave + speaker-test -t sine -s 1 -f 1000 >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR SPEAKER SINE" + gpioset $(gpiofind "PA")=0 + else -# Turn off Power Amplifier -gpioset $(gpiofind "PA")=0 - -echo "OK" + # Turn off Power Amplifier + gpioset $(gpiofind "PA")=0 + if [ $? -ne 0 ]; then + echo "ERROR SPEAKER OFF" + else + echo "OK" + fi + fi +fi