Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgv3000(s905l3) 带蓝牙rtl8761btv 可正常驱动使用 #639

Closed
imzlh opened this issue Oct 22, 2022 · 69 comments
Closed

mgv3000(s905l3) 带蓝牙rtl8761btv 可正常驱动使用 #639

imzlh opened this issue Oct 22, 2022 · 69 comments
Labels
documentation Improvements or additions to documentation support This need is supported

Comments

@imzlh
Copy link

imzlh commented Oct 22, 2022

最近刷了一台mgv3000机器,s905l3的cpu,带蓝牙rtl8761btv,这款芯片很容易驱动,就想着能否修改dtb增加蓝牙串口驱动蓝牙播放音乐什么的。
最开始clone了unifreq的kernel,照着dtsi一顿修改,然后用dtc编译,结果搞了半天还是没搞定问题,是include写法太无语了。。。自己还特地写了两个脚本把它都替换掉,但是还是没有成功
最后我还是选择了反编译,照着cm311-1a的dtb修改了一些,可是最后还是没有显示出/dev/ttyAML1。后来在网上冲浪也没有找到相关的资料,只能来这里碰碰运气了
您是怎么修改的呢?能否教教我?感激不尽!
最后附上我改的和原先的安卓dtb:https://imzlh.top/www.zip

@ophub
Copy link
Owner

ophub commented Oct 22, 2022

你用的哪个dtb可以正常启动,有线网卡工作正常,只是缺蓝牙

https:/unifreq/linux-5.15.y/blob/67ebe60c9eb5ce819a37f231b47707b6beb4d085/drivers/bluetooth/btrtl.c#L127-L146

/usr/lib/firmware/rtl_bt/rtl8761bu_fw.bin

@xcray
Copy link

xcray commented Oct 22, 2022

看你改的dts文件逻辑上就没搞对。你用“meson-gxl-s905l2-x7-5g”可以正常启动是吗?

@imzlh
Copy link
Author

imzlh commented Oct 23, 2022

是meson-gxl-s905l2-x7-5g.dtb,本来只是抱试一试的态度,结果还真的网卡正常,也不会重启需要插拔网线什么的,美中不足就是CPU频率不正确(没关系的)和指示灯得手动点亮(也还可以,gpio73),但是蓝牙我就想照抄大佬的作业试试看,但是反编译完我人傻了,大概g12a与gxl差别太大,我复制完一点用也没有。

@xcray
Copy link

xcray commented Oct 23, 2022

我刚刚为你编译了一版,你试试吧:
https:/xcray/amlogic-s905l3a-armbian/releases/download/kernel_5.15.74/5.15.74.tar.gz

@imzlh
Copy link
Author

imzlh commented Oct 23, 2022

我刚刚为你编译了一版,你试试吧:
https:/xcray/amlogic-s905l3a-armbian/releases/download/kernel_5.15.74/5.15.74.tar.gz

大佬,是帮我加好串口支持了吗?

@imzlh
Copy link
Author

imzlh commented Oct 23, 2022

Uploading 8545785D-1B45-4450-9C38-1BE51C62F387.jpeg…
谢谢,可以了。请教您是怎么改的

@imzlh
Copy link
Author

imzlh commented Oct 23, 2022

可是好像报错了,没法成功驱动:(
4A50B9BC-AC6E-4FB4-AE71-5D594146FEB0

@xcray
Copy link

xcray commented Oct 23, 2022

你成功地把我踩过的坑又重复踩了一遍。。。不过你运气比我好,当初根本就没有个明白人能帮我。。。

修改方法很简单原来说过:https:/xcray/linux-5.15.y/blob/main/arch/arm64/boot/dts/amlogic/meson-gxl-s905l2-x7-5g.dts

报错的原因之前也说过,需要用gpioset重置一下蓝牙电路,或者关机断电再重开,一定要断电,reboot不行;另外一个可能是config文件有问题(里面指定的波特率是错的)。

@ophub
Copy link
Owner

ophub commented Oct 23, 2022

meson-gxl-s905l3-mgv3000.dtb.zip

下载解压,上传到/boot/dtb/amlogic目录
修改/boot/uEnv.txt里的dtb名字

https:/unifreq/linux-5.15.y/blob/main/drivers/bluetooth/btrtl.c#L134-L139

根据上面的描述,看看固件里有没这2个文件。
ls /usr/lib/firmware/rtl_bt/rtl8761b_*

@imzlh
Copy link
Author

imzlh commented Oct 23, 2022

meson-gxl-s905l3-mgv3000.dtb.zip

下载解压,上传到/boot/dtb/amlogic目录 修改/boot/uEnv.txt里的dtb名字

https:/unifreq/linux-5.15.y/blob/main/drivers/bluetooth/btrtl.c#L134-L139

根据上面的描述,看看固件里有没这2个文件。 ls /usr/lib/firmware/rtl_bt/rtl8761b_*

谢谢两位大佬,不过我都失败了
x大改的dtb的确名不虚传,出现了串口,但是当我尝试rtk_hciattach工具驱动时直接卡死掉线无响应,只能重新插拔电源
最后我试了试您的这个dtb,串口消失了。我反编译比较了下,看见dtb中好像加了bluetooth 的设置,不知为什么反而不行了
我再试试吧,谢谢大佬的努力

@ophub
Copy link
Owner

ophub commented Oct 23, 2022

https:/unifreq/linux-5.15.y/blob/main/Documentation/devicetree/bindings/net/rtl8723bs-bluetooth.txt

这有文档,你看看,r_pio每个机型不同,这是中断控制器的名字。你对一个安卓里的名字

@imzlh
Copy link
Author

imzlh commented Oct 23, 2022

https:/unifreq/linux-5.15.y/blob/main/Documentation/devicetree/bindings/net/rtl8723bs-bluetooth.txt

这有文档,你看看,r_pio每个机型不同,这是中断控制器的名字。你对一个安卓里的名字

我想不明白,为什么在uart_A里直接&gpio_a_pins就行了,是因为两个cpu接近的原因吗?不科学啊,理论上不通用吧,那请问应该如何修改?

@imzlh
Copy link
Author

imzlh commented Oct 23, 2022

听说安卓dtb和armbian的很不一样,那类似这种gpio能直接照抄吗
我去看了看,好像你改的和安卓dtb有不一样的地方
CD024BB4-77B5-4F37-9AEA-C76E8843C084
76028EA3-2187-4C2E-9D40-A6189EAB5D70
还有一个问题,为什么要限制波特率为20000?

@xcray
Copy link

xcray commented Oct 23, 2022

dtb里的蓝牙怎么起作用、起什么作用?这个问题我也没搞明白。不过就我的经验来说,只要串口对了,蓝牙就可以用起来。当然,蓝牙的固件(fw和config)也必须正确才行。

话说你试过别的config文件了吗?

@imzlh
Copy link
Author

imzlh commented Oct 23, 2022

找到问题所在了,好像是clock不对,不是r_pio
72ECE3C3-D1F2-42F7-939C-867FE366363D

@ophub
Copy link
Owner

ophub commented Oct 23, 2022

根据安卓dtb里的值修改,安卓的换到linux好象要减1,你试试原值不对就-1测试

@lovelylain
Copy link

dtb里的蓝牙怎么起作用、起什么作用?这个问题我也没搞明白。不过就我的经验来说,只要串口对了,蓝牙就可以用起来。当然,蓝牙的固件(fw和config)也必须正确才行。

话说你试过别的config文件了吗?

dtb里的bluetooth起自动加载蓝牙驱动的作用,如果dtb里的蓝牙正确驱动了,就不需要再在用户态运行rtk_hciattach了。dtb里如果配置了启用的bluetooth,就不会出现ttyAML,没配置就会出现且可以通过alias指定名称,这个时候是把底层的uart功能暴露给用户态,所以运行rtk_hciattach也能驱动。bluetooth的compatible并不是根据芯片确定的,虽然芯片是realtek 8761btv,并不是compatible配置为realtek,rtl8761b-bt就能自动识别并加载驱动,需要内核里有匹配的compatible名称才行。
https:/unifreq/linux-5.15.y/blob/main/drivers/bluetooth/hci_h5.c#L1101
从这里可以看到,内核里只支持realtek,rtl8822cs-bt, realtek,rtl8723bs-bt, realtek,rtl8723ds-bt这3个名称,所以与其配置compatible为realtek,rtl8761b-bt,不如设置为realtek,rtl8723bs-bt试试,也许这样就能触发内核里的芯片检测功能,然后自动加载相应的驱动。

@xcray
Copy link

xcray commented Oct 25, 2022

dtb里的bluetooth起自动加载蓝牙驱动的作用,如果dtb里的蓝牙正确驱动了,就不需要再在用户态运行rtk_hciattach了。dtb里如果配置了启用的bluetooth,就不会出现ttyAML,没配置就会出现且可以通过alias指定名称,这个时候是把底层的uart功能暴露给用户态,所以运行rtk_hciattach也能驱动。bluetooth的compatible并不是根据芯片确定的,虽然芯片是realtek 8761btv,并不是compatible配置为realtek,rtl8761b-bt就能自动识别并加载驱动,需要内核里有匹配的compatible名称才行。 https:/unifreq/linux-5.15.y/blob/main/drivers/bluetooth/hci_h5.c#L1101 从这里可以看到,内核里只支持realtek,rtl8822cs-bt, realtek,rtl8723bs-bt, realtek,rtl8723ds-bt这3个名称,所以与其配置compatible为realtek,rtl8761b-bt,不如设置为realtek,rtl8723bs-bt试试,也许这样就能触发内核里的芯片检测功能,然后自动加载相应的驱动。

学习了!
根据realtek说明,初始化必须使用其提供的rtk_hciattach命令,系统/bluez自带的hciattach不好使。那么这个命令也可以被自动调用么?

@ophub
Copy link
Owner

ophub commented Oct 25, 2022

meson-gxl-s905l3-mgv3000-1-2.zip

这个改为了realtek,rtl8723bs-bt,你试试
2个不同的都分别试下,修改/boot/uEnv.txt重启,看日志 dmesg | grep Bluetooth

@ophub
Copy link
Owner

ophub commented Oct 25, 2022

#645 (comment)

用户反馈rtl8723cs的芯片使用realtek,rtl8723bs-bt可以驱动蓝牙

meson-gxl-s905l3-mgv3000.dtb.zip

你再试试这个。添加了无线和蓝牙。

@imzlh
Copy link
Author

imzlh commented Oct 28, 2022

呃,依旧没有效果:(
293AC552-95F0-4C36-9A34-89466D36A128
不过我这台机器没有wifi,这就尴尬了

@ophub
Copy link
Owner

ophub commented Oct 28, 2022

dmesg | grep Bluetooth

大写B

@imzlh
Copy link
Author

imzlh commented Oct 28, 2022

试了试,这是使用结果
91988BC1-3D4F-4B0F-BAC0-F00E8CA0E8F1
我开始怀疑问题出在串口的gpio不对,我打算再买一台在安卓里调试,也许能解决问题

@ophub
Copy link
Owner

ophub commented Oct 28, 2022

这是ok了,这是驱动起来了。

dts代码如下:

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2016 Endless Computers, Inc.
 * Author: Carlo Caione <[email protected]>
 */

/dts-v1/;

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

/ {
		compatible = "amlogic,mgv3000", "amlogic,s905l3", "amlogic,meson-gxl";
		model = "MGV3000 (s905l3)";

		aliases {
				serial1 = &uart_A;
		};
};

// the gpu in the S905L2 has one pp core less
// (i.e. only two in total) than the one in the other S905X/W
&mali {
		interrupts = <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
					<GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
					<GIC_SPI 162 IRQ_TYPE_LEVEL_HIGH>,
					<GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>,
					<GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>,
					<GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>,
					<GIC_SPI 166 IRQ_TYPE_LEVEL_HIGH>,
					<GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>;
		interrupt-names = "gp", "gpmmu", "pp", "pmu",
					"pp0", "ppmmu0", "pp1", "ppmmu1";
};

/* Realtek Wireless SDIO Module */
&sd_emmc_a {
	/delete-node/ brcmf;

	rtl8723bs: wifi@1 {
		reg = <1>;
		compatible = "realtek,rtl8723bs";
	};
};

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

	bluetooth {
		compatible = "realtek,rtl8723bs-bt";
		enable-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
		max-speed = <2000000>;
		clocks = <&wifi32k>;
		clock-names = "lpo";
	};
};


源码: meson-gxl-s905l3-mgv3000.dts.zip

文件: meson-gxl-s905l3-mgv3000.dtb.zip

@ophub
Copy link
Owner

ophub commented Oct 28, 2022

把你的mgv3000的产品外观,盒子底部的型号描述信息,盒子主板正面、反面,都拍个照片发上来。
有这个设备的安卓系统镜像没?发个链接我备份到下载专区里。
你这设备有线和蓝牙都工作正常了,我给添加个安装序号。

@ophub ophub added documentation Improvements or additions to documentation support This need is supported labels Oct 28, 2022
@ophub ophub changed the title 能否教小白改蓝牙串口 mgv3000(s905l3) 带蓝牙rtl8761btv 可正常驱动使用 Oct 28, 2022
@imzlh
Copy link
Author

imzlh commented Oct 28, 2022

可是蓝牙还是不行啊,输了hciconfig啥都没有

@xcray
Copy link

xcray commented Oct 29, 2022

在m401a盒子5.15.75内核测试了各种组合,结果如下:
bluetooth部分只需要一行:compatible = "realtek,rtl8723bs-bt";
其它内容都没有任何作用,reboot问题只能靠gpioset来解决。

@imzlh
Copy link
Author

imzlh commented Oct 30, 2022

我有一个成果,最大化利用EMMC空间:
good
这个怎么样?(别问我为什么用Debian9,占用少)
这是我提前的分区表:
android_partition_table_template.xlsx

@ophub
Copy link
Owner

ophub commented Oct 30, 2022

p3p4是连续吧,中间有要跳过的空间?

@imzlh
Copy link
Author

imzlh commented Oct 30, 2022

不需要,只是我把他分开来了

@imzlh
Copy link
Author

imzlh commented Oct 30, 2022

个人觉得cache那块大蛋糕放着不用太浪费了,1G也好啊

@ophub
Copy link
Owner

ophub commented Oct 30, 2022

很多盒子都被迫浪费了一块(在armbian-install安装脚本的分区备注里写了空间大小),可以计算好手动fdisk一个出来

@ophub ophub closed this as completed Oct 30, 2022
@ophub
Copy link
Owner

ophub commented Nov 2, 2022

在m401a盒子5.15.75内核测试了各种组合,结果如下: bluetooth部分只需要一行:compatible = "realtek,rtl8723bs-bt"; 其它内容都没有任何作用,reboot问题只能靠gpioset来解决。

max-speed = <2000000>;
把速率调低点试试,重启是否可以使用。

enable-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
这个值是盲猜的,不一定是对的,看看安卓里的值是多少。gpio是需要原理图确认的,或者是把cpu拆下来一台用万用表量。弄对了重启也可以。

@lovelylain
Copy link

在m401a盒子5.15.75内核测试了各种组合,结果如下: bluetooth部分只需要一行:compatible = "realtek,rtl8723bs-bt"; 其它内容都没有任何作用,reboot问题只能靠gpioset来解决。

max-speed = <2000000>; 把速率调低点试试,重启是否可以使用。

enable-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; 这个值是盲猜的,不一定是对的,看看安卓里的值是多少。gpio是需要原理图确认的,或者是把cpu拆下来一台用万用表量。弄对了重启也可以。

你可以编译内核吧,能打上unifreq/linux-5.15.y#24 这个补丁编译一下吗?

@ophub
Copy link
Owner

ophub commented Nov 3, 2022

你可以fork内核仓库,编译内核指向自己的仓库,测试一下

@xcray
Copy link

xcray commented Nov 4, 2022

在m401a盒子5.15.75内核测试了各种组合,结果如下: bluetooth部分只需要一行:compatible = "realtek,rtl8723bs-bt"; 其它内容都没有任何作用,reboot问题只能靠gpioset来解决。

max-speed = <2000000>; 把速率调低点试试,重启是否可以使用。

enable-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; 这个值是盲猜的,不一定是对的,看看安卓里的值是多少。gpio是需要原理图确认的,或者是把cpu拆下来一台用万用表量。弄对了重启也可以。

盲猜的???那也太神奇了吧!经过对编译后的dtb反编译和实际验证,这个值确实是对的。
至于速率,感觉和这个问题关系不大,再说2m已经是一个比较保守的数值了——针对音乐播放需求来说。系统原有的不能用的config文件中的速率是1.5m

@imzlh
Copy link
Author

imzlh commented Nov 5, 2022

观察了一周,运行挺稳定的,稳定跑docker和网站。dtb除了没有蓝牙没有显示都正常的,故希望能将其添加到安装菜单中,方便安装使用,感谢你:)
附上安卓的bootloader和我改制的安装文件:
data.zip

@ophub
Copy link
Owner

ophub commented Nov 5, 2022

你的压缩包里是2个安装sh文件和一个安卓的img文件?你的安装文件似乎没有使用这个bootloader文件,也没划分分区跳过的不安全区域大小?

307:MGV2000:s905l2:meson-gxl-s905l2-x7-5g.dtb:u-boot-s905x-s912.bin:NA:NA

和这行配置有什么区别?

你是使用的哪个dtb?哪个u-boot?哪个分区表?你的安装配置信息那行是怎么写的?
贴你的盒子的外观照片,主板正反两面的照片,短接点救砖标识位置,安卓系统原厂固件有没?

@livelier
Copy link
Contributor

livelier commented Nov 5, 2022

压缩包里的脚本,与此链接相似。@imzlh 建议写完整。
https:/yangxuan8282/phicomm-n1/blob/master/scripts/install-arch.sh

@imzlh
Copy link
Author

imzlh commented Nov 6, 2022

你的压缩包里是2个安装sh文件和一个安卓的img文件?你的安装文件似乎没有使用这个bootloader文件,也没划分分区跳过的不安全区域大小?

307:MGV2000:s905l2:meson-gxl-s905l2-x7-5g.dtb:u-boot-s905x-s912.bin:NA:NA

和这行配置有什么区别?
你是使用的哪个dtb?哪个u-boot?哪个分区表?你的安装配置信息那行是怎么写的? 贴你的盒子的外观照片,主板正反两面的照片,短接点救砖标识位置,安卓系统原厂固件有没?

那就算了,我不知道选项已经加好了,一直用的都是5.15.68的版本。
我的这个bootloader开机自动转绿灯(原厂的bootloader不行),不需要设置gpio73,而且我的安装文件的确跳过了不安全分区以及用了这个bootloader。那就这样吧
3949C616-F401-45F7-B988-5BE4FC620462
刷机包我收集到了两个,都可以使用:dl.imzlh.top:7297/镜像/S905/L3
(请使用ipv6访问)
主板:
F2C85780-896B-491A-AAB2-420F8D2BA974
短接点刷机包里有
%B6%CC%BD%D3%CD%BC%CA%BE

@imzlh
Copy link
Author

imzlh commented Nov 6, 2022

压缩包里的脚本,与此链接相似。@imzlh 建议写完整。
https:/yangxuan8282/phicomm-n1/blob/master/scripts/install-arch.sh

正常,是抄150大神在s9xx镜像包里的安装文件

@121592512
Copy link

把你的mgv3000的产品外观,盒子底部的型号描述信息,盒子主板正面、反面,都拍个照片发上来。 有这个设备的安卓系统镜像没?发个链接我备份到下载专区里。 你这设备有线和蓝牙都工作正常了,我给添加个安装序号。

请问大佬, 有安卓镜像了吗,下载专区没找到么

@alanfans
Copy link

把你的mgv3000的产品外观,盒子底部的型号描述信息,盒子主板正面、反面,都拍个照片发上来。 有这个设备的安卓系统镜像没?发个链接我备份到下载专区里。 你这设备有线和蓝牙都工作正常了,我给添加个安装序号。

请问大佬, 有安卓镜像了吗,下载专区没找到么

盒子刷机固件合集大全:
链接: https://pan.baidu.com/s/1qSmtBgSEbKs6ZFm-yCr-XQ
提取码: nnw3

@121592512
Copy link

把你的mgv3000的产品外观,盒子底部的型号描述信息,盒子主板正面、反面,都拍个照片发上来。 有这个设备的安卓系统镜像没?发个链接我备份到下载专区里。 你这设备有线和蓝牙都工作正常了,我给添加个安装序号。

请问大佬, 有安卓镜像了吗,下载专区没找到么

盒子刷机固件合集大全: 链接: https://pan.baidu.com/s/1qSmtBgSEbKs6ZFm-yCr-XQ 提取码: nnw3

这个里面的mgv3000固件,打开ADB了吗

@alanfans
Copy link

alanfans commented Feb 10, 2023

把你的mgv3000的产品外观,盒子底部的型号描述信息,盒子主板正面、反面,都拍个照片发上来。 有这个设备的安卓系统镜像没?发个链接我备份到下载专区里。 你这设备有线和蓝牙都工作正常了,我给添加个安装序号。

请问大佬, 有安卓镜像了吗,下载专区没找到么

盒子刷机固件合集大全: 链接: https://pan.baidu.com/s/1qSmtBgSEbKs6ZFm-yCr-XQ 提取码: nnw3

这个里面的mgv3000固件,打开ADB了吗

我没有这个型号的盒子,我没有刷过,不太清楚
我只知道adb是连按安卓版本号就能打开开发者,里面打开debug就有adb了

@xiayang0521
Copy link

https:/unifreq/linux-5.15.y/blob/3f1f0123b98c9defe0f540b40065a8e88ccbed81/Documentation/devicetree/bindings/net/rtl8723bs-bluetooth.txt#L15-L19
用reset-gpios试试,看他下面的30-33行的代码示例。

增加reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; 不行; 改成reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_LOW>; 还是不行; 删掉enable-gpios只保留reset-gpios(ACTIVE_LOW不变);仍然不行; 改成reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; 继续不行;

感觉rfkill就没有尝试做任何动作。 删掉enable只保留reset,倒是可以在命令行用gpioset操作了,重启后执行,先低后高,蓝牙自动恢复

修改/lib/systemd/system/bluetooth.server、在[Service]部分加一句? ExecStopPost=/usr/bin/env gpioset 0 82=0 反正这么弄很好用,重启了几次都没问题,我先这么用着了

简单学习了一下,这种方式比在用户空间运行rtk_hciattach要好——那种是陈旧的方法、这种是被称作serdev的“现代化”方式,虽然还没找到完美的方法,但值得采用。

请求帮忙编译一个meson-g12a-s905l3a-cm311.dtb 同样加入rtl8761b的驱动,目前只在从dtb反编译的dts里加了,
bluetooth {
compatible = "realtek,rtl8723bs-bt";
};
加入相关配置文件 https://gitee.com/xiayang0521/set_bluetooth
蓝牙可用 ,但是reboot之后不行, 所以请你帮忙参照你的处理办法在源码的dts里加reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>,编一个meson-g12a-s905l3a-cm311.dtb (我不知道咋操作。。。)

@alanfans
Copy link

https:/unifreq/linux-5.15.y/blob/3f1f0123b98c9defe0f540b40065a8e88ccbed81/Documentation/devicetree/bindings/net/rtl8723bs-bluetooth.txt#L15-L19
用reset-gpios试试,看他下面的30-33行的代码示例。

增加reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; 不行; 改成reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_LOW>; 还是不行; 删掉enable-gpios只保留reset-gpios(ACTIVE_LOW不变);仍然不行; 改成reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; 继续不行;
感觉rfkill就没有尝试做任何动作。 删掉enable只保留reset,倒是可以在命令行用gpioset操作了,重启后执行,先低后高,蓝牙自动恢复
修改/lib/systemd/system/bluetooth.server、在[Service]部分加一句? ExecStopPost=/usr/bin/env gpioset 0 82=0 反正这么弄很好用,重启了几次都没问题,我先这么用着了
简单学习了一下,这种方式比在用户空间运行rtk_hciattach要好——那种是陈旧的方法、这种是被称作serdev的“现代化”方式,虽然还没找到完美的方法,但值得采用。

请求帮忙编译一个meson-g12a-s905l3a-cm311.dtb 同样加入rtl8761b的驱动,目前只在从dtb反编译的dts里加了, bluetooth { compatible = "realtek,rtl8723bs-bt"; }; 加入相关配置文件 https://gitee.com/xiayang0521/set_bluetooth 蓝牙可用 ,但是reboot之后不行, 所以请你帮忙参照你的处理办法在源码的dts里加reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>,编一个meson-g12a-s905l3a-cm311.dtb (我不知道咋操作。。。)

https:/ophub/amlogic-s9xxx-armbian/blob/main/build-armbian/documents/README.cn.md#1213-%E5%A6%82%E4%BD%95%E5%8F%8D%E7%BC%96%E8%AF%91-dtb-%E6%96%87%E4%BB%B6
这里都有写如何编译与反编译dtb

@xiayang0521
Copy link

xiayang0521 commented Feb 26, 2023

https:/unifreq/linux-5.15.y/blob/3f1f0123b98c9defe0f540b40065a8e88ccbed81/Documentation/devicetree/bindings/net/rtl8723bs-bluetooth.txt#L15-L19
用reset-gpios试试,看他下面的30-33行的代码示例。

增加reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; 不行; 改成reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_LOW>; 还是不行; 删掉enable-gpios只保留reset-gpios(ACTIVE_LOW不变);仍然不行; 改成reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; 继续不行;
感觉rfkill就没有尝试做任何动作。 删掉enable只保留reset,倒是可以在命令行用gpioset操作了,重启后执行,先低后高,蓝牙自动恢复
修改/lib/systemd/system/bluetooth.server、在[Service]部分加一句? ExecStopPost=/usr/bin/env gpioset 0 82=0 反正这么弄很好用,重启了几次都没问题,我先这么用着了
简单学习了一下,这种方式比在用户空间运行rtk_hciattach要好——那种是陈旧的方法、这种是被称作serdev的“现代化”方式,虽然还没找到完美的方法,但值得采用。

请求帮忙编译一个meson-g12a-s905l3a-cm311.dtb 同样加入rtl8761b的驱动,目前只在从dtb反编译的dts里加了, bluetooth { compatible = "realtek,rtl8723bs-bt"; }; 加入相关配置文件 https://gitee.com/xiayang0521/set_bluetooth 蓝牙可用 ,但是reboot之后不行, 所以请你帮忙参照你的处理办法在源码的dts里加reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>,编一个meson-g12a-s905l3a-cm311.dtb (我不知道咋操作。。。)

https:/ophub/amlogic-s9xxx-armbian/blob/main/build-armbian/documents/README.cn.md#1213-%E5%A6%82%E4%BD%95%E5%8F%8D%E7%BC%96%E8%AF%91-dtb-%E6%96%87%E4%BB%B6 这里都有写如何编译与反编译dtb

谢谢,dtb先反编译改后编译这方法我会,只是里面这里修改不能直接加入reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>。

不过根据他的思路,我就通过启动后查看cat /sys/kernel/debug/gpio信息,
root@armbian:~# cat /sys/kernel/debug/gpio
gpiochip1: GPIOs 412-426, parent: platform/ff800000.sys-ctrl:pinctrl@14, aobus-banks:
gpio-421 ( |net_led ) out hi ACTIVE LOW
gpio-422 ( |remote_led ) out hi ACTIVE LOW
gpio-423 ( |power_led ) out lo ACTIVE LOW

gpiochip0: GPIOs 427-511, parent: platform/ff634400.bus:pinctrl@40, periphs-banks:
gpio-449 ( |regulator-usb_pwr_en) out hi
gpio-451 ( |regulator-vcc_5v ) out hi
gpio-464 ( |reset ) out hi ACTIVE LOW
gpio-474 ( |cd ) in hi ACTIVE LOW
猜测蓝牙由ff634400.bus:pinctrl@40控制,查看dts中,gpio的phandle 应该是0x39,pinctrl@40对应的phandle = <0x17>,感觉GPIOX_17的值就对应0x17,我在反编译的dts中加入了
reset-gpios = <0x39 0x17 0x01>;
编译回去之后,实测可用,reboot之后也不会出问题了。
当然这里面的值应该不通用,从源码去改才通用吧。

。。。。
好吧 怪我不懂GPIO 哈哈 才反应过来GPIOX_17里面就是17嘛 不是巧合吧

@alanfans
Copy link

https:/unifreq/linux-5.15.y/blob/3f1f0123b98c9defe0f540b40065a8e88ccbed81/Documentation/devicetree/bindings/net/rtl8723bs-bluetooth.txt#L15-L19
用reset-gpios试试,看他下面的30-33行的代码示例。

增加reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; 不行; 改成reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_LOW>; 还是不行; 删掉enable-gpios只保留reset-gpios(ACTIVE_LOW不变);仍然不行; 改成reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; 继续不行;
感觉rfkill就没有尝试做任何动作。 删掉enable只保留reset,倒是可以在命令行用gpioset操作了,重启后执行,先低后高,蓝牙自动恢复
修改/lib/systemd/system/bluetooth.server、在[Service]部分加一句? ExecStopPost=/usr/bin/env gpioset 0 82=0 反正这么弄很好用,重启了几次都没问题,我先这么用着了
简单学习了一下,这种方式比在用户空间运行rtk_hciattach要好——那种是陈旧的方法、这种是被称作serdev的“现代化”方式,虽然还没找到完美的方法,但值得采用。

请求帮忙编译一个meson-g12a-s905l3a-cm311.dtb 同样加入rtl8761b的驱动,目前只在从dtb反编译的dts里加了, bluetooth { compatible = "realtek,rtl8723bs-bt"; }; 加入相关配置文件 https://gitee.com/xiayang0521/set_bluetooth 蓝牙可用 ,但是reboot之后不行, 所以请你帮忙参照你的处理办法在源码的dts里加reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>,编一个meson-g12a-s905l3a-cm311.dtb (我不知道咋操作。。。)

https:/ophub/amlogic-s9xxx-armbian/blob/main/build-armbian/documents/README.cn.md#1213-%E5%A6%82%E4%BD%95%E5%8F%8D%E7%BC%96%E8%AF%91-dtb-%E6%96%87%E4%BB%B6 这里都有写如何编译与反编译dtb

谢谢,dtb先反编译改后编译这方法我会,只是里面这里修改不能直接加入reset-gpios= <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>。

不过根据他的思路,我就通过启动后查看cat /sys/kernel/debug/gpio信息, root@armbian:~# cat /sys/kernel/debug/gpio gpiochip1: GPIOs 412-426, parent: platform/ff800000.sys-ctrl:pinctrl@14, aobus-banks: gpio-421 ( |net_led ) out hi ACTIVE LOW gpio-422 ( |remote_led ) out hi ACTIVE LOW gpio-423 ( |power_led ) out lo ACTIVE LOW

gpiochip0: GPIOs 427-511, parent: platform/ff634400.bus:pinctrl@40, periphs-banks: gpio-449 ( |regulator-usb_pwr_en) out hi gpio-451 ( |regulator-vcc_5v ) out hi gpio-464 ( |reset ) out hi ACTIVE LOW gpio-474 ( |cd ) in hi ACTIVE LOW 猜测蓝牙由ff634400.bus:pinctrl@40控制,查看dts中,gpio的phandle 应该是0x39,pinctrl@40对应的phandle = <0x17>,感觉GPIOX_17的值就对应0x17,我在反编译的dts中加入了 reset-gpios = <0x39 0x17 0x01>; 编译回去之后,实测可用,reboot之后也不会出问题了。 当然这里面的值应该不通用,从源码去改才通用吧。

。。。。 好吧 怪我不懂GPIO 哈哈 才反应过来GPIOX_17里面就是17嘛 不是巧合吧

兄弟,esp32 点灯玩起来

@xiayang0521
Copy link

xiayang0521 commented Feb 26, 2023 via email

@uncle-wong
Copy link

我的蓝牙报这个错误,mgv3000盒子。dmesg | grep Bluetooth
[ 11.119142] Bluetooth: Core ver 2.22
[ 11.119200] Bluetooth: Starting self testing
[ 11.154349] Bluetooth: ECDH test passed in 30654 usecs
[ 11.172871] Bluetooth: SMP test passed in 17946 usecs
[ 11.172971] Bluetooth: Finished self testing
[ 11.220916] Bluetooth: HCI device and connection manager initialized
[ 11.235495] Bluetooth: HCI socket layer initialized
[ 11.235560] Bluetooth: L2CAP socket layer initialized
[ 11.241280] Bluetooth: SCO socket layer initialized
[ 11.377480] Bluetooth: HCI UART driver ver 2.3
[ 11.377548] Bluetooth: HCI UART protocol H4 registered
[ 11.385643] Bluetooth: HCI UART protocol BCSP registered
[ 11.386783] Bluetooth: HCI UART protocol LL registered
[ 11.398884] Bluetooth: HCI UART protocol ATH3K registered
[ 11.399085] Bluetooth: HCI UART protocol Three-wire (H5) registered
[ 11.577610] Bluetooth: HCI UART protocol Intel registered
[ 11.617825] Bluetooth: HCI UART protocol Broadcom registered
[ 11.644064] Bluetooth: HCI UART protocol QCA registered
[ 11.648060] Bluetooth: HCI UART protocol AG6XX registered
[ 11.653423] Bluetooth: HCI UART protocol Marvell registered
[ 12.035585] Bluetooth: hci0: RTL: examining hci_ver=0a hci_rev=000b lmp_ver=0a lmp_subver=8761
[ 12.045343] Bluetooth: hci0: RTL: rom_version status=0 version=1
[ 12.053243] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761b_fw.bin
[ 12.064089] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761b_config.bin
[ 12.091611] Bluetooth: hci0: RTL: cfg_sz 81, total sz 30005
[ 14.134866] Bluetooth: hci0: command 0xfc20 tx timeout
[ 18.962651] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 18.962717] Bluetooth: BNEP filters: protocol multicast
[ 18.967634] Bluetooth: BNEP socket layer initialized
[ 22.241562] Bluetooth: hci0: RTL: download fw command failed (-110)
[49245.635919] Bluetooth: hci0: command 0x1001 tx timeout
[49253.742659] Bluetooth: hci0: RTL: HCI_OP_READ_LOCAL_VERSION failed (-110)

@uncle-wong
Copy link

dmesg |grep -i fail
[ 4.928948] genirq: Setting trigger mode 3 for irq 47 failed (meson_gpio_irq_set_type+0x0/0x140)
[ 5.113909] meson-drm d0100000.vpu: failed to bind c883a000.hdmi-tx (ops 0xffffffc00a336460): -19
[ 5.128614] meson-drm d0100000.vpu: master bind failed: -19
[ 5.880761] hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
[ 8.827199] systemd[423]: /usr/lib/systemd/system-generators/netplan failed with exit status 1.
[ 9.480818] systemd[1]: Failed to listen on Network Service Netlink Socket.
[ 21.814695] Bluetooth: hci0: RTL: download fw command failed (-110)
应该是驱动不对,下载不成功,另外io口也不是gpio 0 82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation support This need is supported
Projects
None yet
Development

No branches or pull requests

10 participants