ophub/amlogic-s9xxx-armbian

FunTV/X96W(s905w) Wired/Wireless/Bluetooth are normal

daniyo27 opened this issue · 44 comments

Device Information | 设备信息

  • SOC: [S905W]
  • Model [FunTV (X96W)]

Armbian Version | 系统版本
jammy_5.15.91_server_2023.02.05

Describe the bug | 问题描述

Hi all, I have a FunTV box which seems to be a X96W S905W variant. https://4pda.to/forum/index.php?showtopic=886489

Mine has AP6255 wifi + H1621SR ethernet NIC

  • The Wi-Fi doesn't seem to be detected. I think I need a dtb suitable for my device. Any help is appreciated!

Thank you!

IMG_5315
IMG_5314
IMG_5313
IMG_5312
IMG_5311
full board photo https://4pda.to/forum/index.php?showtopic=886489&st=0#entry70149472

ophub commented

WiFi & BT combo module AMPAK AP6255: try bcm4329-fmac

Which dtb are you using now, can it start normally, is the wired network normal?

I am using meson-gxl-s905w-x96-mini.dtb

wired network is normal (10/100mbps) and the box does start normally.

I don't know how to add bcm4329-fmac to a dtb. Can you please help?

Thanks!

ophub commented
cd /boot
cp u-boot-s905x-s912.bin u-boot.ext
cp u-boot-s905x-s912.bin u-boot.emmc
chmod +x u-boot.emmc u-boot.ext
sync && reboot

Test whether this u-boot can be used.

cd /boot
cp u-boot-s905x-s912.bin u-boot.ext
cp u-boot-s905x-s912.bin u-boot.emmc
chmod +x u-boot.emmc u-boot.ext
sync && reboot

Test whether this u-boot can be used.

I am stuck here now after running this ^^

IMG_5316

ophub commented

Insert the U disk into the computer, you can open the /boot partition, and delete the two files added by copying.

u-boot does not support, you can only use the 5.15/5.4 kernel in the future, do not update 6.1

@ophub I decompiled X96-Mini.dtb and added

wifi@1 { reg = <0x01>; compatible = "brcm,bcm4329-fmac"; };

at the end of mmc@70000 and was able to get Wi-Fi working. Can this be added as a dtb file to be built for future images? The box should be called FunTV3 or X96W

Additionally, I was able to run armbian-install and can boot from eMMC.

ophub commented

meson-gxl-s905w-x96w.dtb.zip

Download, decompress into a dtb file, upload it to the /boot/dtb/amlogic directory, and modify the name of dtb in /boot/uEnv.txt to: meson-gxl-s905w-x96w.dtb

Save, restart, and test whether the wired, wireless, and Bluetooth are working properly. Bluetooth Go to armbian-config and add the Bluetooth support module.

Thank you! I tested wired and wireless and both are working.

Bluetooth is NOT working. I ran bluetoothctl with list command and it is not showing any available controllers. I did add the Bluetooth support module.

Almost there for getting everything working!

ophub commented

dmesg | grep Bluetooth

This is what I see!

image

ophub commented

meson-gxl-s905w-x96w.dtb.zip

I modified the bluetooth code, you overwrite the source file, restart and try this

Similar problem!
image

No more errors, but still nothing in bluetoothctl and no hci0 messages

image

Still not working

image

ophub commented
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2018 Martin Blumenstingl <martin.blumenstingl@googlemail.com>.
 * Based on meson-gxl-s905d-p231.dts:
 * - Copyright (c) 2016 Endless Computers, Inc.
 * - Copyright (c) unifreq
 */

/dts-v1/;

#include "meson-gxl-s905w-p281.dts"

/ {
	compatible = "amlogic,p281", "amlogic,s905w", "amlogic,meson-gxl";
	model = "X96W";

	aliases {
		serial0 = &uart_AO;   /* Console */
		serial1 = &uart_A;    /* Bluetooth */
		ethernet0 = &ethmac;
	};
};

/* SDIO wifi: AP6255 */
&sd_emmc_a {
	status = "okay";

	brcmf: wifi@1 {
		reg = <1>;
		compatible = "brcm,bcm4329-fmac";
	};
};

/* SD card */
&sd_emmc_b {
	status = "okay";
	bus-width = <4>;
	cap-sd-highspeed;
	max-frequency = <50000000>;
};

/* eMMC */
&sd_emmc_c {
	status = "okay";
	max-frequency = <50000000>;
};

/* Console UART */
&uart_AO {
	status = "okay";
	pinctrl-0 = <&uart_ao_a_pins>;
	pinctrl-names = "default";
};

/* S905W only has access to its internal PHY */
&ethmac {
	status = "okay";
	phy-mode = "rmii";
	phy-handle = <&internal_phy>;
};

&internal_phy {
	status = "okay";
	pinctrl-0 = <&eth_link_led_pins>, <&eth_act_led_pins>;
	pinctrl-names = "default";
	max-speed = <100>;
};

/* This is connected to the Bluetooth module: AP6255 */
&uart_A {
	status = "okay";
	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
	pinctrl-names = "default";
	uart-has-rtscts;

	bluetooth {
		compatible = "brcm,bcm4345c5";
		enable-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
		host-wake-gpios = <&gpio GPIOX_18 GPIO_ACTIVE_HIGH>;
	};
};

meson-gxl-s905w-x96w.dts.zip
meson-gxl-s905w-x96w.dtb.zip

This is the current test dts, you can continue to try

bluetooth: 
compatible = "brcm,bcm4345c5";
compatible = "bcm4329-fmac";

These two Bluetooth codes have cases in the current dts, but you can't use them for testing. Perhaps the bluetooth firmware is not working for you?

https://github.com/unifreq/linux-5.15.y/blob/main/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml

https://github.com/ophub/firmware/tree/main/firmware/brcm

https://github.com/unifreq/linux-5.15.y/blob/02659e48f0ec17cb78a01846719812bf0f30536e/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-lite2.dts#L77

I don't think we are doing this correctly. AP6255 should be using brcm,bcm4345c5 as bt binding.

I cannot compile dtb from source and so I cannot compile stuff with &gpio

I believe I am missing the interrupt pins and using the right variables such as shutdown-gpios instead of enable-gpios.

Also, host-wakeup-gpios is deprecated and the message inside says This is deprecated and replaced by interrupts and "host-wakeup" interrupt-names

Can you try and help me compile this with the gpio/interrupt settings?

broadcom-bluetooth.yaml

Attached is current dmesg of brcm with

bluetooth {
	compatible = "brcm,bcm4345c5";
	brcm,bt-pcm-int-params = [01 02 00 01 01];
	shutdown-gpios = <0x15 0x60 0x00>;
	max-speed = <921600>;
	device-wakeup-gpios = <0x16 0x61 0x00>;
};

image

Bingo! It works!

image

ophub commented
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2018 Martin Blumenstingl <martin.blumenstingl@googlemail.com>.
 * Based on meson-gxl-s905d-p231.dts:
 * - Copyright (c) 2016 Endless Computers, Inc.
 * - Copyright (c) unifreq
 */

/dts-v1/;

#include "meson-gxl-s905w-p281.dts"

/ {
	compatible = "amlogic,p281", "amlogic,s905w", "amlogic,meson-gxl";
	model = "X96W";

	aliases {
		serial0 = &uart_AO;   /* Console */
		serial1 = &uart_A;    /* Bluetooth */
		ethernet0 = &ethmac;
	};
};

/* SDIO wifi: AP6255 */
&sd_emmc_a {
	status = "okay";

	brcmf: wifi@1 {
		reg = <1>;
		compatible = "brcm,bcm4329-fmac";
	};
};

/* SD card */
&sd_emmc_b {
	status = "okay";
	bus-width = <4>;
	cap-sd-highspeed;
	max-frequency = <50000000>;
};

/* eMMC */
&sd_emmc_c {
	status = "okay";
	max-frequency = <50000000>;
};

/* Console UART */
&uart_AO {
	status = "okay";
	pinctrl-0 = <&uart_ao_a_pins>;
	pinctrl-names = "default";
};

/* S905W only has access to its internal PHY */
&ethmac {
	status = "okay";
	phy-mode = "rmii";
	phy-handle = <&internal_phy>;
};

&internal_phy {
	status = "okay";
	pinctrl-0 = <&eth_link_led_pins>, <&eth_act_led_pins>;
	pinctrl-names = "default";
	max-speed = <100>;
};

/* This is connected to the Bluetooth module: AP6255 */
&uart_A {
	status = "okay";
	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
	pinctrl-names = "default";
	uart-has-rtscts;

	bluetooth {
		compatible = "brcm,bcm4345c5";
		shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
		max-speed = <2000000>;
		clocks = <&wifi32k>;
		clock-names = "lpo";
	};
};

meson-gxl-s905w-x96w.dts.zip

meson-gxl-s905w-x96w.dtb.zip

ophub commented

The s905w series of TV Boxes only support the use of the 5.4.y/5.15.y kernel.

I submit to the kernel source repository of unifreq.

Thank you for your time and persistence to get this device to work! Hopefully this is of use to other X96W / FunTV owners!

ophub commented

119 :X96W/FunTV :s905w :meson-gxl-s905w-x96w.dtb :NA :NA :NA :5.15.y :amlogic :meson-gxl :uEnv.txt :s905w :no

Already added, the installation number is 119

ophub commented

At present, several other devices of s905w, such as X96-Mini, TX3-Mini and W95, can use u-boot-s905x-s912.bin to start the 6.1.y kernel.

You test again, use USB to start the firmware of 5.15.y of s905w, and modify the dtb in /boot/uEnv.txt to: meson-gxl-s905w-x96w.dtb

Copy u-boot-s905x-s912.bin to u-boot.ext

Then start USB to see if it can start to the welcome interface normally.

I am trying to boot from USB but it seems to keep booting off of eMMC. I have a reset button on the back, but it is not doing anything. Any ideas?

ophub commented
cd /boot
mv boot.cmd boot.cmd.bak
mv boot.src boot.src.bak

After you start from USB, you can mount emmc into USB, modify it back, and then you can restart from EMMC after unplugging USB.

cd /mnt
mkdir emmc_boot
mount /dev/mmcblk2p1 emmc_boot
cd emmc_boot
mv boot.cmd.bak boot.cmd
mv boot.src.bak boot.src

Very interesting... it is booting indeed with the uboot!
image

cd /boot
cp u-boot-s905x-s912.bin u-boot.ext
cp u-boot-s905x-s912.bin u-boot.emmc
chmod +x u-boot.emmc u-boot.ext
sync && reboot

Test whether this u-boot can be used.

I believe this earlier test did not work because I was booting off a SD card.

On another note, is there any reason why the kernel config build has CONFIG_WIREGUARD=m? Can we have this enabled by default so users can use Wireguard properly?

I am happy to test a 6.1 kernel release if you want with the wireguard and the uboot if it can be compiled!

ophub commented

Just operate in USB

vi /etc/ophub-releases

Modify the following 3 content

FDTFILE='meson-gxl-s905w-x96w.dtb'
UBOOT_OVERLOAD='u-boot-s905x-s912.bin'
KERNEL_VERSION='stable'

Update the script first, then update the kernel

armbian-sync
armbian-update -k 6.1.12

I did the update but after rebooting and running uname -r it is still 5.15.91
I also had to change KERNEL_BRANCH to stable for it to do install

I will retry install again!
image

I tried again, this is the result now.

IMG_5366

ophub commented

FDTFILE error

You don't have the update script and the 6.1.12 kernel

Are you on a USB? What did you do after you added U-BOOT to boot successfully? The command to execute?

Yes I am on USB. I did the modification on ophub-release and also changed current branch to stable.

then I ran
‘armbian-sync’
‘armbian-update -k 6.1.12’

And it auto rebooted to what you see above

Maybe it’s best to have a compiled img of kernel 6.1 for our board for me to test?

ophub commented

https://github.com/ophub/amlogic-s9xxx-armbian/actions

It is being repackaged and should be completed within half an hour. You can download the firmware in 6.1.12 of s905w from Releases.

Modify the dtb of /boot/uEnv.txt to meson-gxl-s905w-x96w.dtb

u-boot has been added by default.

After you write the firmware in 6.1.12 to usb, in addition to modifying the uEnv.txt file, put the meson-gxl-s905w-x96w.dtb in 5.15 into the same directory in 6.1.12: /boot/dtb/amlogic

Then start from USB to test whether it can start to the welcome interface normally.

ophub commented

Your meson-gxl-s905w-x96w.dtb is not added to the 6.1.y source code. I only add your dtb to the upstream 5.4 and 5.15 kernel source code repository, because you have previously reported that u-boot cannot be used.

I managed to boot kernel 6.1.12 with the new images.
I had to rename the FDTFILE to my dtb and all is good except that the SSH server is failing?

I never had any SSH issues until trying the 6.1.12 kernel!

IMG_5368

ophub commented

Thank you for your feedback. It seems that the s905w can also use the 6.x.y series kernel. I will cancel the restrictions on it.

ophub commented

# Restart ssh service
[[ -d "/var/run/sshd" ]] || mkdir -p -m0755 /var/run/sshd 2>/dev/null
[[ -f "/etc/init.d/ssh" ]] && sleep 5 && /etc/init.d/ssh restart 2>/dev/null

By default, the ssh service is restarted with a delay of 5 seconds at startup. You can restart and wait for 5 seconds. You can also add # comments at the beginning of the line

ophub commented

unifreq/linux-6.1.y@f91670f

6.1/5.10 also added this dtb.

@ophub sorry for the delay, I can confirm the latest image with kernel 6.1 does work on the s905w along with eMMC install

image

ophub commented

ok