From b2c3af18879ee8c4e4d2eca9ae27ddf64a66153f Mon Sep 17 00:00:00 2001 From: Ruledo Date: Thu, 16 Jan 2025 01:36:40 -0800 Subject: [PATCH 1/3] Fixed getting interface state ip link was reporting interface as down when wifi was not connected. --- .../rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100755 => 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh old mode 100755 new mode 100644 index 4757a4f..0ff79a6 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh @@ -53,7 +53,7 @@ sync_states() { log "Synced mobile Wi-Fi state to $text_state." fi - current_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + current_wlan_state=$(cat /sys/class/net/wlan0/operstate) if [[ "$text_state" != "$current_wlan_state" ]]; then set_wlan_state "$text_state" log "Synced wlan0 state to $text_state." @@ -63,7 +63,7 @@ sync_states() { monitor_changes() { local previous_mobile_state previous_wlan_state previous_mobile_state=$(get_mobile_wifi_state) - previous_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + previous_wlan_state=$(cat /sys/class/net/wlan0/operstate) while true; do PID=$(ps -C meshtasticd -o pid= | tr -d ' ') @@ -71,7 +71,7 @@ monitor_changes() { #if sudo lsof /dev/spidev0.0 | grep -q "meshtasticd"; then local current_mobile_state current_wlan_state current_mobile_state=$(get_mobile_wifi_state) - current_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + current_wlan_state=$(cat /sys/class/net/wlan0/operstate) if [[ "$current_mobile_state" != "$previous_mobile_state" ]]; then log "Detected mobile Wi-Fi state change: $previous_mobile_state -> $current_mobile_state" From 8dcc88e961c4adf050f2d25fedd2b54a056eda66 Mon Sep 17 00:00:00 2001 From: Ruledo Date: Thu, 16 Jan 2025 01:43:55 -0800 Subject: [PATCH 2/3] Change the way wifi mesh control gets the state of the interface ip link was reporting the interface as down when wifi was disconnected so switched to operstate to get authoritative interface state. --- .../rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100755 => 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh old mode 100755 new mode 100644 index 4757a4f..0ff79a6 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh @@ -53,7 +53,7 @@ sync_states() { log "Synced mobile Wi-Fi state to $text_state." fi - current_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + current_wlan_state=$(cat /sys/class/net/wlan0/operstate) if [[ "$text_state" != "$current_wlan_state" ]]; then set_wlan_state "$text_state" log "Synced wlan0 state to $text_state." @@ -63,7 +63,7 @@ sync_states() { monitor_changes() { local previous_mobile_state previous_wlan_state previous_mobile_state=$(get_mobile_wifi_state) - previous_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + previous_wlan_state=$(cat /sys/class/net/wlan0/operstate) while true; do PID=$(ps -C meshtasticd -o pid= | tr -d ' ') @@ -71,7 +71,7 @@ monitor_changes() { #if sudo lsof /dev/spidev0.0 | grep -q "meshtasticd"; then local current_mobile_state current_wlan_state current_mobile_state=$(get_mobile_wifi_state) - current_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + current_wlan_state=$(cat /sys/class/net/wlan0/operstate) if [[ "$current_mobile_state" != "$previous_mobile_state" ]]; then log "Detected mobile Wi-Fi state change: $previous_mobile_state -> $current_mobile_state" From 9ddd4625858fa95d8bcca0e303e9ea3315238cee Mon Sep 17 00:00:00 2001 From: Ruledo Date: Thu, 16 Jan 2025 20:47:07 -0800 Subject: [PATCH 3/3] Added DTS files for Luckfox Pico U I have not tested this. A full sdk install would be needed and the correct board selected. --- .../boot/dts/rv1106g-luckfox-pico-ultra-w.dts | 147 ++++++++++++++++++ .../boot/dts/rv1106g-luckfox-pico-ultra.dts | 81 ++++++++++ 2 files changed, 228 insertions(+) create mode 100644 foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra-w.dts create mode 100644 foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra.dts diff --git a/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra-w.dts b/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra-w.dts new file mode 100644 index 0000000..2465807 --- /dev/null +++ b/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra-w.dts @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2022 Rockchip Electronics Co., Ltd. + */ + +/dts-v1/; +#include "rv1106.dtsi" +#include "rv1106-luckfox-pico-ultra-ipc.dtsi" +#include +#include + +/ { + model = "Luckfox Pico Ultra W"; + compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1106g3"; + + restart-poweroff { + compatible = "restart-poweroff"; + }; + + sdio_pwrseq: sdio-pwrseq { + compatible = "mmc-pwrseq-simple"; + pinctrl-names = "default"; + reset-gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; + }; + + wireless_bluetooth: wireless-bluetooth { + compatible = "bluetooth-platdata"; + uart_rts_gpios = <&gpio0 RK_PA5 GPIO_ACTIVE_LOW>; + pinctrl-names = "default", "rts_gpio"; + pinctrl-0 = <&uart1m0_rtsn>; + pinctrl-1 = <&uart1_gpios>; + BT,wake_gpio = <&gpio0 RK_PA2 GPIO_ACTIVE_HIGH>; + BT,wake_host_irq = <&gpio1 RK_PA2 GPIO_ACTIVE_HIGH>; + status = "okay"; + }; +}; + +/**********CRU**********/ +//&cru { +// assigned-clocks = +// <&cru PLL_GPLL>, <&cru PLL_CPLL>, +// <&cru ARMCLK>, +// <&cru ACLK_PERI_ROOT>, <&cru HCLK_PERI_ROOT>, +// <&cru PCLK_PERI_ROOT>, <&cru ACLK_BUS_ROOT>, +// <&cru PCLK_TOP_ROOT>, <&cru PCLK_PMU_ROOT>, +// <&cru HCLK_PMU_ROOT>, <&cru CLK_500M_SRC>; +// assigned-clock-rates = +// <1188000000>, <700000000>, +// <1104000000>, +// <400000000>, <200000000>, +// <100000000>, <300000000>, +// <100000000>, <100000000>, +// <200000000>, <700000000>; +//}; + +/**********NPU**********/ +//&npu { +// assigned-clock-rates = <700000000>; +//}; + +/**********EMMC**********/ +&emmc { + bus-width = <8>; + cap-mmc-highspeed; + non-removable; + // mmc-hs200-1_8v; + rockchip,default-sample-phase = <90>; + no-sdio; + no-sd; + memory-region-ecsd = <&mmc_ecsd>; + post-power-on-delay-ms = <0>; + status = "okay"; +}; + +&fiq_debugger { + rockchip,irq-mode-enable = <1>; + status = "okay"; +}; + +/**********SDIO-WIFI**********/ +&sdmmc { + max-frequency = <50000000>; + bus-width = <4>; + cap-sd-highspeed; + cap-sdio-irq; + keep-power-in-suspend; + non-removable; + rockchip,default-sample-phase = <90>; + // no-sd; + // no-mmc; + supports-sdio; + mmc-pwrseq = <&sdio_pwrseq>; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc0_clk &sdmmc0_cmd &sdmmc0_bus4 &sdmmc0_det>; + status = "okay"; +}; + +&pinctrl{ + sdmmc0{ + sdmmc0_det: sdmmc0-det { + rockchip,pins = + /* sdmmc0_det */ + <3 RK_PA1 1 &pcfg_pull_down>; + }; + }; +}; + + +/**********ETH**********/ +&gmac { + status = "okay"; +}; + +/**********USB**********/ +&usbdrd_dwc3 { + status = "okay"; + dr_mode = "host"; + #dr_mode = "host"; +}; + +/**********RTC**********/ +&rtc { + status = "okay"; +}; + +/**********BT**********/ +&uart1 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&uart1m0_xfer &uart1m0_ctsn>; +}; + +&pinctrl { + wireless-bluetooth { + uart1_gpios: uart1-gpios { + rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +}; + +/**********SPI**********/ +&spi0 { + status = "okay"; + spidev@0 { + spi-max-frequency = <50000000>; + }; +}; diff --git a/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra.dts b/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra.dts new file mode 100644 index 0000000..c988795 --- /dev/null +++ b/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra.dts @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2022 Rockchip Electronics Co., Ltd. + */ + +/dts-v1/; +#include "rv1106.dtsi" +#include "rv1106-luckfox-pico-ultra-ipc.dtsi" +#include +#include + +/ { + model = "Luckfox Pico Ultra"; + compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1106g3"; +}; + +/**********CRU**********/ +//&cru { +// assigned-clocks = +// <&cru PLL_GPLL>, <&cru PLL_CPLL>, +// <&cru ARMCLK>, +// <&cru ACLK_PERI_ROOT>, <&cru HCLK_PERI_ROOT>, +// <&cru PCLK_PERI_ROOT>, <&cru ACLK_BUS_ROOT>, +// <&cru PCLK_TOP_ROOT>, <&cru PCLK_PMU_ROOT>, +// <&cru HCLK_PMU_ROOT>, <&cru CLK_500M_SRC>; +// assigned-clock-rates = +// <1188000000>, <700000000>, +// <1104000000>, +// <400000000>, <200000000>, +// <100000000>, <300000000>, +// <100000000>, <100000000>, +// <200000000>, <700000000>; +//}; + +/**********NPU**********/ +//&npu { +// assigned-clock-rates = <700000000>; +//}; + +/**********EMMC**********/ +&emmc { + bus-width = <8>; + cap-mmc-highspeed; + non-removable; + // mmc-hs200-1_8v; + rockchip,default-sample-phase = <90>; + no-sdio; + no-sd; + memory-region-ecsd = <&mmc_ecsd>; + post-power-on-delay-ms = <0>; + status = "okay"; +}; + +&fiq_debugger { + rockchip,irq-mode-enable = <1>; + status = "okay"; +}; + +/**********ETH**********/ +&gmac { + status = "okay"; +}; + +/**********USB**********/ +&usbdrd_dwc3 { + status = "okay"; + dr_mode = "host"; +}; + +/**********RTC**********/ +&rtc { + status = "okay"; +}; + +/**********SPI**********/ +&spi0 { + status = "okay"; + spidev@0 { + spi-max-frequency = <50000000>; + }; +};