From f14d79f5a6f6f58d28c00ebf41ae2f883fc6ae36 Mon Sep 17 00:00:00 2001 From: Hector Bujanda Date: Wed, 4 Mar 2020 09:57:30 +0100 Subject: [PATCH] xbee-init: script updated to use libgpiod tools Additionally: - The handling of gpios has been swapped so 'Set low XBEE_SLEEP_RQ' is done before 'Power cycle XBEE_RESET_N' to assure the device doesn't enter sleep mode. - Removed ExecStop entry from systemd service since it's doing nothing. https://jira.digi.com/browse/DEL-6424 https://jira.digi.com/browse/DEL-6423 Signed-off-by: Hector Bujanda --- meta-digi-arm/conf/machine/ccimx8mn-dvk.conf | 4 +- .../conf/machine/ccimx8x-sbc-express.conf | 4 +- .../conf/machine/ccimx8x-sbc-pro.conf | 4 +- .../recipes-connectivity/xbee/xbee/xbee-init | 49 ++----------------- .../xbee/xbee/xbee-init.service | 1 - 5 files changed, 11 insertions(+), 51 deletions(-) diff --git a/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf b/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf index 36b6b1197..838aeabeb 100644 --- a/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf +++ b/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf @@ -25,8 +25,8 @@ SERIAL_CONSOLES ?= "115200;ttymxc0" BT_TTY ?= "ttymxc1" # XBees -XBEE_RESET_N_GPIO ?= "508,8" -XBEE_SLEEP_RQ_GPIO ?= "504,7" +XBEE_RESET_N_GPIO ?= "mca-gpio@15,gpio1@8" +XBEE_SLEEP_RQ_GPIO ?= "mca-gpio@11,gpio1@7" XBEE_TTY ?= "ttymxc3" # U-Boot script to be copied to the boot image diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf index 674bf02c7..345996921 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf @@ -23,8 +23,8 @@ SERIAL_CONSOLES ?= "115200;ttyLP2" BT_TTY ?= "ttyLP1" # XBee -XBEE_RESET_N_GPIO ?= "397" -XBEE_SLEEP_RQ_GPIO ?= "400" +XBEE_RESET_N_GPIO ?= "gpio3@13" +XBEE_SLEEP_RQ_GPIO ?= "gpio3@16" XBEE_TTY ?= "ttyLP0" # U-Boot script to be copied to the boot image diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf index 76b687507..e1dc672dd 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf @@ -26,8 +26,8 @@ SERIAL_CONSOLES ?= "115200;ttyLP2" BT_TTY ?= "ttyLP1" # XBee -XBEE_RESET_N_GPIO ?= "220" -XBEE_SLEEP_RQ_GPIO ?= "216" +XBEE_RESET_N_GPIO ?= "mca-gpio@15" +XBEE_SLEEP_RQ_GPIO ?= "mca-gpio@11" XBEE_TTY ?= "ttyMCA0" # U-Boot script to be copied to the boot image diff --git a/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init b/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init index 19909cf5a..3ff7a91b7 100644 --- a/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init +++ b/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init @@ -4,47 +4,13 @@ XBEE_RESET_N_GPIO="##XBEE_RESET_N_GPIO##" XBEE_SLEEP_RQ_GPIO="##XBEE_SLEEP_RQ_GPIO##" -# request_gpio -request_gpio_out() { - local SG_GPIONR="${1}" - local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}" - - [ -d "${SG_GPIOPATH}" ] || printf "%s" "${SG_GPIONR}" > /sys/class/gpio/export - printf out > "${SG_GPIOPATH}/direction" && sleep .2 -} - -# free_gpio -free_gpio() { - local SG_GPIONR="${1}" - local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}" - - [ -d "${SG_GPIOPATH}" ] && printf "%s" "${SG_GPIONR}" > /sys/class/gpio/unexport -} - -# set_gpio_value -set_gpio_value() { - local SG_GPIONR="${1}" - local SG_GPIOVAL="${2}" - local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}" - - printf out > "${SG_GPIOPATH}/direction" && sleep .2 - printf "${SG_GPIOVAL}" > "${SG_GPIOPATH}/value" && sleep .2 -} - xbee_init() { - # Power cycle XBEE_RESET_N - request_gpio_out ${1} - set_gpio_value ${1} 0 - set_gpio_value ${1} 1 - # Set low XBEE_SLEEP_RQ - request_gpio_out ${2} - set_gpio_value ${2} 0 -} + gpioset ${3} ${4}=0 -xbee_stop() { - free_gpio ${1} - free_gpio ${2} + # Power cycle XBEE_RESET_N + gpioset ${1} ${2}=0 + gpioset ${1} ${2}=1 } xbee_iterate_list() { @@ -54,9 +20,7 @@ xbee_iterate_list() { for SLEEP in $(echo ${XBEE_SLEEP_RQ_GPIO} | sed "s/,/ /g"); do if [ "${i}" = "${j}" ]; then if [ "${1}" = "start" ]; then - xbee_init ${RESET} ${SLEEP} - elif [ "${1}" = "stop" ]; then - xbee_stop ${RESET} ${SLEEP} + xbee_init $(echo ${RESET} | sed "s/@/ /g") $(echo ${SLEEP} | sed "s/@/ /g") fi fi j="$((j + 1))" @@ -72,9 +36,6 @@ case "$1" in echo "done." ;; stop) - echo -n "Stopping XBee hardware: " - xbee_iterate_list stop - echo "done." ;; restart) $0 stop diff --git a/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init.service b/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init.service index f56cc5580..c255c051c 100644 --- a/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init.service +++ b/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init.service @@ -6,7 +6,6 @@ Before=ModemManager.service Type=oneshot RemainAfterExit=yes ExecStart=/etc/xbee-init start -ExecStop=/etc/xbee-init stop [Install] WantedBy=multi-user.target