AsteroidOS / meta-smartwatch

OpenEmbedded layer that provides support for various smartwatches.
25 stars 18 forks source link

Bluetooth not enable #12

Open ShuP1 opened 7 years ago

ShuP1 commented 7 years ago

Is bluetooth support possible and/or plained ? Every thing else works fine just date reset on reboot.

anyc commented 7 years ago

I will try to enable it but don't hold your breath as I don't have much time for the watch right now and I planned to enable sensor support first. If it helps, wifi works but you have to configure it using adb shell.

toadicus commented 6 years ago

Anything I can do to help with this? I've got an ASUS Zenwatch 3 that's too slow to use with WearOS so I'm happy to test this.

anyc commented 6 years ago

I pushed some files to: http://kicherer.org/aos/bt/ Fastboot with the boot.img and then scp the .ko files to the watch and execute the steps in the start.sh. This should enable BT on the watch.

However, when I pair the watch with my phone, the watch shows "connected" but the phone app (v0.11) times out and the watch disconnects again. So, something is still missing during these steps. I am not sure if the hci_qcomm_init command is really required as it wants to read from /dev/ttyHS0 which is not there.

Also, if your watch still has the Android Wear 1.5 firmware, update to Wear 2.0 beforehand. I wasn't able to figure out what changes in the 2.0 kernel made it unbootable on a v1.5 watch.

anyc commented 6 years ago

If you want to build the kernel yourself, you can checkout the sources here: https://github.com/anyc/linux-zenwatch3 To create the boot.img you need https://github.com/osm0sis/mkbootimg and unpack an existing zImage-dtb-swift.fastboot and pack it again with a command similar to:

../mkbootimg/mkbootimg --base "80000000" --board "swift" --cmdline "sched_enable_hmp=0 \
console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=swift \
msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 earlyprintk \
androidboot.bootdevice=7824900.sdhci androidboot.serialno=GANZCY00151841D \
androidboot.bootloader=swift1003307 HW_ID=SWIFT_PR CPU_RV=000520e1 \
androidboot.bootreason=reboot quiet androidboot.rebootmode=0x77665501 oem_perf_on \
androidboot.baseband=apq mdss_mdp3.panel=1:dsi:0:qcom,mdss_dsi_h139bln01_400_cmd:1:none" \
--hash "sha1" --pagesize "2048" --ramdisk_offset "01000000" --kernel_offset "00008000" \
--tags_offset "00000100" --second_offset "00f00000" \
--ramdisk zImage-dtb-swift.fastboot-ramdisk.gz -o boot.img --kernel zImage-dtb
mortenbh commented 6 years ago

@anyc I tried following your steps, fastbooting boot.img, scp over the modules and following the steps in start.sh. Unfortunately, the setprop step fails:

root@swift:~# setprop ro.qualcomm.bt.hci_transport smd could not set property

I would love to help out with the porting effort, but I'll probably need a few pointers to get started. :)

anyc commented 6 years ago

I also noticed that this failed but I think it worked before I tested different kernel configs. I think the command fails because the android init process segfaults before it starts the android services (log & service). Unfortunately, strace does not show anything useful and I would have to rebuild the android executables with debug information to find the issue.

VictorRyabov commented 6 years ago

@anyc Please, look into it if you have time. Lack of BT is a dealbreaker :(

midirhee12 commented 5 years ago

Is there any plans for this still? I have the Zenwatch 3 and would love to help where I can.

midirhee12 commented 5 years ago

@anyc Please, look into it if you have time. Lack of BT is a dealbreaker :(

I would also look into trying to do the same over wifi. P2P and maybe even over WLAN could be useful. P2P when the phone is not connected to a wireless network and LAN when the phone is. I think that might be the next alternative if this really is out of reach.

@anyc Also, I still have AsteroidOS on temporary install, so I can do whatever tests and updates needed to complete this feature.

johnnyktadfas commented 4 years ago

@anyc anything new about bluetooth on asus zenwatch 3?

sergiosk39 commented 2 years ago

@anyc Thank you for such a pretty OS for my ZenWatch 3. Please enable bluetooth if it is possible! It'll give a whole new life to my zenwatch...)

MagneFire commented 2 years ago

This issue is worth an update since I also did some digging into this specific issue a while back.

Background

I think some background is needed since swift (Asus Zenwatch 3) is in the minority of not functioning Bluetooth. Generally a dedicated Bluetooth chip is connected to the main processor by a serial interface. In our case most supported watches use a Qualcomm Snapdragon 400 or Wear 2100/3100 SoC. Most (maybe all?) of them use a Broadcom Bluetooth chip.

The biggest difference with swift compared to other watches is the serial interface. Most of them use a dedicated UART peripheral and kernel driver to communicate with the Bluetooth chip. As this is a generic solution, a separate kernel driver (bluesleep or more recently nitrous) is used to setup the interrupts so that the Bluetooth chip can wake the SoC when it sleeps. A userspace program named brcm-patchram-plus^1 is responsible for flashing a firmware to the Bluetooth chip and enabling the low power mode.

However, swift uses something known as Qualcomm SMD^5. This means that something embedded in the SoC handles the communication with the Bluetooth chip. A kernel driver still handles the communication but in addition also handles the flashing of the firmware to the Bluetooth chip and interrupts are also handled by the same driver. I'm not sure if it handles the setup of the low power modes, this may be part of an Android binary. After some reverse engineering of those binaries I did not find anything useful.

Bluebinder

We've had newer watches that support Bluetooth that appear to be close to identical when it comes to the hardware configuration. With these newer watches we use bluebinder^2 to directly talk to the Android libraries responsible for setting up Bluetooth. This will, however, only work on Android 8 bases and above. swift unfortunately never got an update to this version.

I also own a ray (Skagen Falster 2) that uses the same SoC, it also uses Qualcomm SMD to setup the Bluetooth chip and it's required low power mode. Due to the lack of support for bluebinder on swift I decided to port swift from an Android 6 base to the Android 7 base. This will reduce the chance of missing symbols in binaries when you try to execute Android binaries from another watch. Realistically, it meant that I could execute the required Android binary^3 that would setup the Bluetooth device and allow for communication with bluebinder. But it also required my to backport the binder kernel driver^4 from ray to swift. All this worked, but it lead to the original issue where you could pair your phone with the watch but it would disconnect after that. This make me suspicious of the Bluetooth firmware files used. But I'm not entirely sure how to debug firmware related issues. I may try to switch to the narwhal binary as it appears to be a little bit different.

loopaware commented 2 years ago

Thank you for your hard work, please keep it up! :) I have a handful of zenwatch 3, all running Asteroid OS. Dreaming of a future where the bluetooth works on them.