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

Bumble with Cuttlefish and Android 14 #635

Open
crisstinab opened this issue Jan 27, 2025 · 6 comments
Open

Bumble with Cuttlefish and Android 14 #635

crisstinab opened this issue Jan 27, 2025 · 6 comments

Comments

@crisstinab
Copy link

I'm trying to work out how to setup Bumble / Cuttlefish with Android 14 so that I can use my physical Bluetooth on my board to check connectivity with real devices.

I've been reading and trying the instructions found here: #413
They work perfectly on an Android 15 image but on Android 14_r3 I am unable to pin point what the issue is.

To setup Bumble and start the HCI Bridge I do this:

sudo hciconfig hci0 down
python bumble/apps/hci_bridge.py android-netsim:_:7300,mode=controller hci-socket:0

Afterwards, I start Cuttlefish like this:
launch_cvd -display0=width=1920,height=720,dpi=160 -gpu_mode=gfxstream -enable_audio -verbosity="DEBUG" -enable_audio="true" -cpus="4" -base_instance_num=2 -rootcanal_instance_num=1 -extra_kernel_cmdline="androidboot.selinux=permissive"

However, nothing is printed in the HCI Bridge console on Android 14 and BT is not working in Android. Same commands are successful on Android 15.

Do you have any ideas on how to debug this issue?

@zxzxwu
Copy link
Collaborator

zxzxwu commented Jan 28, 2025

You should check the Bluetooth HCI HAL status on Cuttlefish, from logcat or dumpsys. I guess it's probably about rootcanal client configuration.

@crisstinab
Copy link
Author

hey @zxzxwu thank you for the suggestion! I've noticed that indeed HCI HAL was not starting on Android 14.
That brought me to the discovery that netsim_bt was set by default on false and it is marked as experimental. So there is this difference between Android 14 and 15, at least.

Settings netsim_bt in the launch_cvd command started netsim and also HCI HAL. However, no packets are received in the Bumble HCI Bridge yet.

I am a bit unsure about rootcanal still. In #413 I've understood that netsim would use an external rootcanal in this approach? What I've seen is that whenever I launch_cvd with -rootcanal_instance_num=1 or 2 (different from the default 0), start_rootcanal in the Cuttlefish configuration is set to false. Only when using the default rootcanal instance start_rootcanal is set to true. This is the same for Android 15 where this setup works.

Is there a different approach to achieve this without android_netsim? If there is indeed some limitation from netsim on this experimental version in Android 14.

@barbibulle
Copy link
Collaborator

A couple of things to check:

  1. when choosing a port number for the HCI bridge to listen on, avoid port 7300, as this is likely to be used by the netsimd daemon as its own HCI port number. Use some other unused port number.
  2. launch the HCI bridge with DEBUG logging enabled: BUMBLE_LOGLEVEL=DEBUG python apps/hci_bridge.py ..., so you can see when a connection is made
  3. launch cuttlefish with -rootcanal_instance_num=2. Somehow, when launching with -rootcanal_instance_num=1, even though any non-zero value should instruct cuttlefish to use an "external" rootcanal, it seems that only if the instance is >= 2 does cuttlefish work in that mode
  4. cuttlefish always starts its own instance of netsimd, regardless of -rootcanal_instance_num, but when the instance number is >= 2, netsimd runs in packet forwarding mode, exchanging HCI packets with an external instance. In our case, that external instance is going to be the Bumble HCI bridge, not another instance of netsimd
  5. check the command line used by cuttlefish to run its local (packet forwarding) netsimd: use ps to find the PID of netsimd, and then cat /proc/<pid>/cmdline. When netsimd is running in packet forwarding mode, it will have been invoked with the --connector_instance_num=X option (in our case, --connector_instance_num=2).

@crisstinab
Copy link
Author

Hey @barbibulle thank you so much for the hints!

I've discovered that this revision of Android (android-14.0.0_r3) does not have the --connector_instance_num flag defined. It was defined starting with android-14.0.0_r29. Since this option was missing from cmdline with several -rootcanal_instance_num that I've tried, I checked the history of the cuttlefish repo and discovered when it was introduced.

I am currently creating an image with a later Android 14 to re-do the test and will get back with an update.

Do I have other options with the Bumble HCI Bridge for this version android-14.0.0_r3 where netsimd lacks the --connector_instance_num option?

@crisstinab
Copy link
Author

Hello, I was able to test on a later version of Android 14 where netsimd has the connector_instance_num option and it is working as expected. Thank you for helping me debug this! I have a better understanding now on how the bridge and android communicate and how to configure cuttlefish for this.

On an older version of Android and netsimd without the connector_instance_num option, can I still use the bridge to get the BT packets from cuttlefish? Maybe using something different than android-netsim when starting the bridge? I might not be able to upgrade to a newer Android 14 version.

@barbibulle
Copy link
Collaborator

One option for supporting older versions of cuttlefish may be to replace netsimd in the older cuttlefish install with a more recent version (netsimd can be compiled by itself as a standalone tool), and use the -rootcanal_args option of launch_cvd to pass --connector_instance_num option yourself.
Unfortunately, this isn't something that can be changed from the Bumble HCI bridge, since the issue here is to get cuttlefish to connect to an existing netsimd-compatible interface (that's what the mode=controller modifier does in the HCI bridge invocation), so unless cuttlefish is able to connect out that way, it doesn't matter what Bumble does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants