How to use UART3 for bluetooth HCI?

96boards

#21

Hi Loic,

I did exactly what is mentioned in build instruction. I could see the kernel build time and date properly using ‘uname -a’. Still hci0 is getting created for TI controller.

What to check in /proc/device-tree ? following are the contents of this folder -

#address-cells
#size-cells
aliases
apb_pclk
btwilink
chosen
compatible
cpus
ddr_devfreq
dpe@E8600000
dsi@E8601000
fiq-debugger
firmware
hifidsp
hisi,ion
interrupt-controller@e82b0000
interrupt-parent
ipc@e896b000
keys
kim
leds
mali@E82C0000
memory@0
model
name
opp_table0
opp_table1
overlay_mgr
pmic@fff34000
pmu
psci
ramoops
reboot-mode-syscon@32100000
reserved-memory
smmu
smmu_lpae
soc
timer
uart_overlay@0
wlan-en-1-8v

Thanking you,

Regards,
Arnab Dey


#22

You are absolutely right. I just checked the tree nodes under /proc/device-tree/soc/serial@fdf01000 - which is for uart4 and found that bluetooth child-node was not not deleted. That means whatever I changed in ‘hi3660-hikey960.dts’ did not take effect though uname-a shows proper date and time of kernel build. What can be the reason and how can I ensure my changes in the kernel?

Thanking you,

Regards,
Arnab Dey


#23

From kernel dir, you can try make ARCH=arm64 dtbs to regenerate your dtb.


#24

Hi Loic,

Actually the problem was with device tree image(dt.img). As I changed device tree in kernel code, I should rebuild and flash dt.img along with boot.img. In the kernel code(arch/arm64/boot/dts/hisiliconhi3660-hikey960.dts), I just removed bluetooth child node under uart4 and made status=“disabled”. Then rebuilt and flashed both dt.img and boot.img. Now I can see my BT controller as hci0 and it responds to bluetooth service start/stop!!!

However, If I change the kernel code, I do not get any video output from HDMI port. Can you please guide?

Thanking you,

Regards,
Arnab Dey


#25

Yes I missed this point, dt has its own image.

Any related dmesg/logcat output ? (hwcomposer, surfaceflinger, Mali…)


#26

Hi Loic,

Following is an error log related to mali gpu from dmesg -

[32m[ 3.025712] e[0m[drm] Initialized
e[32m[ 3.026446] e[0m[drm] wait for external HDMI bridge driver.
e[32m[ 3.026708] e[33mmali e82c0000.malie[0m: Continuing without Mali regulator control
e[32m[ 3.032634] e[33mmali e82c0000.malie[0m: GPU identified as 0x0 arch 6.0.10 r0p0 status 2
e[32m[ 3.033659] e[33mOFe[31m: ERROR: Bad of_node_put() on /mali@E82C0000
e[32m[ 3.033670] e[33mCPUe[0m: 0 PID: 1 Comm: swapper/0 Tainted: G S 4.9.60-02839-g9ea4cdd-dirty #1
e[32m[ 3.033675] e[33mHardware namee[0m: HiKey960 (DT)
e[32m[ 3.033680] e[0mCall trace:
e[32m[ 3.033696] e[0m[] dump_backtrace+0x0/0x1dc
e[32m[ 3.033703] e[0m[] show_stack+0x20/0x28
e[32m[ 3.033711] e[0m[] dump_stack+0xa8/0xe0
e[32m[ 3.033720] e[0m[] of_node_release+0xa4/0xa8
e[32m[ 3.033726] e[0m[] kobject_put+0x80/0xdc
e[32m[ 3.033731] e[0m[] of_node_put+0x24/0x30
e[32m[ 3.033736] e[0m[] of_find_compatible_node+0xbc/0xe8
e[32m[ 3.033747] e[0m[] kbase_ipa_model_add_param_string+0x68/0x144
e[32m[ 3.033752] e[0m[] kbase_simple_power_model_init+0x130/0x178
e[32m[ 3.033757] e[0m[] kbase_ipa_init_model+0x68/0xf0
e[32m[ 3.033762] e[0m[] kbase_ipa_init+0xa8/0x248
e[32m[ 3.033771] e[0m[] kbase_devfreq_init+0x19c/0x50c
e[32m[ 3.033777] e[0m[] kbase_platform_device_probe+0x604/0xc5c
e[32m[ 3.033785] e[0m[] platform_drv_probe+0x58/0xd0
e[32m[ 3.033791] e[0m[] driver_probe_device+0x224/0x2c4
e[32m[ 3.033796] e[0m[] __driver_attach+0xbc/0xc0
e[32m[ 3.033802] e[0m[] bus_for_each_dev+0x6c/0xac
e[32m[ 3.033807] e[0m[] driver_attach+0x2c/0x34
e[32m[ 3.033812] e[0m[] bus_add_driver+0x1c0/0x224
e[32m[ 3.033817] e[0m[] driver_register+0x7c/0x114
e[32m[ 3.033825] e[0m[] __platform_driver_register+0x60/0x6c
e[32m[ 3.033834] e[0m[] kbase_platform_driver_init+0x18/0x20
e[32m[ 3.033842] e[0m[] do_one_initcall+0x88/0x11c
e[32m[ 3.033847] e[0m[] kernel_init_freeable+0x1c8/0x268
e[32m[ 3.033857] e[0m[] kernel_init+0x20/0x140
e[32m[ 3.033863] e[0m[] ret_from_fork+0x10/0x50
e[32m[ 3.034106] e[33mmali e82c0000.malie[0m: Couldn’t find power_model DT node matching 'arm,mali-g71-power-model’
e[32m[ 3.034490] e[33mError reading temperature for gpu thermal zonee[0m: -22
e[32m[ 3.039313] e[33mmali e82c0000.malie[0m: Using configured power model mali-g71-power-model, and fallback mali-simple-power-model
e[32m[ 3.044164] e[33mmali e82c0000.malie[0m: Probed as mali0
e[32m[ 3.120216] e[33mbrde[0m: module loaded

Is there any way to attach text file here? I can attach the full dmesg log then.

Thanking you,

Regards,
Arnab Dey


#27

Simplest way is to use a pastebin or github gist and share the link!


#28

Hi Danielt,

Great!!!

Hi Loic,

The full dmesg log file is here

Thanking you,

Regards,
Arnab Dey


#29

Yeah, something clearly goes wrong here.
mali e82c0000.mali0: GPU identified as 0x0 arch 6.0.10 r0p0 status 2
ERROR: Bad of_node_put() on /mali@E82C0000
mali e82c0000.malie[0m: Couldn’t find power_model DT node matching ‘arm,mali-g71-power-model’

If I understand, problem occurs since you updated the DT.
Not sure but I can see two pretty recent changes on hi3360-gpu.dtsi could you please try to revert them, rebuilt your DT and retry.
git revert 9c7f79e01e7572c56ec6b55c4324dc58899bdb4e
git revert 6ebc1c7ab8f0630534c935eed2f7aa6963b4d7fb

Let me know…


#30

Hi Loic,

After reverting 9c7f79e01e7572c56ec6b55c4324dc58899bdb4e that

ERROR: Bad of_node_put() on /mali@E82C0000

is not coming but there is no output from HDMI.
Then I reverted 6ebc1c7ab8f0630534c935eed2f7aa6963b4d7fb also, still no luck. Last working dtb binary I had - Sep 08 '17 - it came along with AOSP master branch.

Please help.

Thanking you,

Regards,
Arnab Dey


#31

Hi Loic,

To get HDMI output, I had to revert the above change and remove the following from /device/linaro/hikey/hikey960/BoardConfig.mk -

BOARD_KERNEL_CMDLINE += video=HDMI-A-1:1280x800@30

It seems with this kernel command, HDMI output is broken. I included this kernel command and it used to work with the master branch I downloaded on sep’08 2017.

Can you please check if there is any problem in using this kernel command?

Thanking you,

Regards,
Arnab Dey


#32

This parameter seems used for hikey (hikey/README). There is no such indication for hikey-960 (not sure if this is considered/supported), your display resolution should be automatically detected.


#33

Hi Loic,

What about 9c7f79e01e7572c56ec6b55c4324dc58899bdb4e commit? Can you please check if this is causing some problem? When I tried to remove only that video option from command line keeping this commit, then also I did not get any HDMI output.

Thanking you,

Regards,
Arnab Dey


#34

I’ve just tested and actually reproduce the kernel ‘Error’ with last kernel/dtb, however the HDMI/display works.

mali e82c0000.mali: Continuing without Mali regulator control
mali e82c0000.mali: GPU identified as 0x0 arch 6.0.10 r0p0 status 2
OF: ERROR: Bad of_node_put() on /mali@E82C0000
CPU: 2 PID: 1 Comm: swapper/0 Tainted: G S              4.9.62-03021-g8116a00ad491 #10
Hardware name: HiKey960 (DT)
Call trace:
[<ffffff800808a078>] dump_backtrace+0x0/0x1d8
[<ffffff800808a274>] show_stack+0x24/0x30
...
mali e82c0000.mali: Couldn't find power_model DT node matching 'arm,mali-g71-power-model'
mali e82c0000.mali: Using configured power model mali-g71-power-model, and fallback mali-simple-power-model
mali e82c0000.mali: Probed as mali0

#35

Hi Loic,

Please let me know once this problem is solved. Then I will update my kernel also.
Can you please let me know how to disable flow control for UART3(/dev/ttyAMA3)?

Thanking you,

Regards,
Arnab Dey


#36

On host side flow control can be configured via hciattach and is enabled by default with ‘any’ devices.
You can disable it with the noflow parameter:
$ hciattach /dev/ttyUSBx any 115200 noflow


#37

Hi Loic,

Thank you. Now I am trying to put the hciattach command in a script (inside /system/vendor/bin) and run the script as a service from init.rc. I am getting selinux permission denials as system/bin/sh is in shell context and hciattach is in hci_attach_exec context. Can you please guide how to execute the script at init? Can I change the contexts in rc/file_contexts only or I will have to change init.te/hci_attach.te files also?

Thanking you,

Regards,
Arnab Dey


#38

Please, always provide selinux log which is really useful for debugging.

Now that you execute a shell script, I think the first think to do is allowing domain transition from shell to hci_attach, something like that:
domain_auto_trans(shell, hci_attach_exec, hci_attach)


#39

Hi Loic,

I am getting the following error :

type=1400 audit(16.859:59): avc: denied { getattr } for pid=2166 comm=“sh” path="/system/vendor/bin/hciattach" dev=“sdd10” ino=2554 scontext=u:r:shell:s0 tcontext=u:object_r:hci_attach_exec:s0 tclass=file permissive=0
[ 9.424608] type=1400 audit(16.859:59): avc: denied { getattr } for pid=2166 comm=“sh” path="/system/vendor/bin/hciattach" dev=“sdd10” ino=2554 scontext=u:r:shell:s0 tcontext=u:object_r:hci_attach_exec:s0 tclass=file permissive=0

I have the following in my init.common.rc file -

service hciattach_service /system/bin/sh /system/vendor/bin/test.sh
class main
user bluetooth
group bluetooth net_bt_admin system
seclabel u:r:shell:s0
oneshot

and my test.sh has -

#!system/bin/sh
/system/vendor/bin/hciattach -s 115200 /dev/ttyAMA3 any

audit2allow gives the following suggestion for shell

allow shell hci_attach_exec:file getattr;

What can be done for a smooth transition from shell to hci_attach domain? Please help.

Is there any way I can modify device specific .te files i.e. /device/linaro/hikey/sepolicy/*.te rather than modifying shell.te to add domain_auto_trans as suggested?

Thanking you,

Regards,
Arnab Dey


#40

Ideally, you should run in permissive mode, in that case seLinux rules are not applied but error are still reported/logged. This allows to get all selinux errors in one shot instead of resolving permission one by one.

You have already allowed domain transition from shell to hci_attach, however you need to add permission for the execution of hciattach.
allow shell hci_attach_exec:file rx_file_perms;
(rx_fil_perm is a macros grouping several permissions, getattr, execute…)

Why not adding all these rules in /device/linaro/hikey/sepolicy/hci_attach.te?