-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
NixOS on Raspberry Pi 4 Model B | bluetoothctl issue: No default controller available #123725
Comments
Looking at google results it seems that some kernels broke Bluetooth support, so updating kernel to the latest revision in style of #118548 might fix it. |
fkms-3d overlay can't be built with
|
Sorry, I meant packaging the latest raspberrypi kernel revision. |
Oh, ok. I'll try it |
A bit newer release doesn't fix the problem. Latest revisions from both rpi-5.11.y and rpi-5.12.y have compilation issues |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/raspberry-pi-4-bluetooth-audio/13876/2 |
What are the compilation issues? Are they not fixable? |
Same issues here, I tried https://github.com/raspberrypi/linux/releases/tag/1.20211007 version. |
This remains to be an issue. Have hit this today using the |
I noticed that {
imports = [ (modulesPath + "/installer/sd-card/sd-image-aarch64.nix") ];
hardware = {
bluetooth = {
package = pkgs.bluez;
enable = true;
powerOnBoot = false;
};
};
} nixpkgs@ 35db2e6, I edited the kernel command line in extlinux.conf by hand for now, nixified it would probably look like this: {
# via sd-image: boot.kernelParams = ["console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0"];
boot.kernelParams = lib.mkForce ["console=ttyS0,115200n8" "console=tty0"];
} |
@pschyska Could you share a full config with working bluetooth? And just in case, could you also share your
but
but I do not have the problematic kernel command line params you referenced. |
@Majiir I'm afraid I can't. |
@Majiir I recently worked on my system again, and was able to use bluetooth with upstream kernels 5.15.63 (linuxPackages @ nixos-unstable) and 5.19.4 (linuxPackages_latest). I didn't do anything special. I'm not importing nixos-hardware. config.txt: arm_64bit=1
enable_uart=1
uart_2ndstage=1
enable_gic=1
armstub=RPI_EFI.fd
disable_commandline_tags=1
disable_overscan=1
device_tree_address=0x1f0000
device_tree_end=0x200000
dtoverlay=miniuart-bt
#dtoverlay=upstream-pi4 (upstream-pi4 always crashed the system during boot) relevant nix config: {pkgs, ...}: {
boot = {
loader = {
timeout = 3;
# requires uefi firmware!
systemd-boot = {
enable = true;
consoleMode = "max";
};
efi.canTouchEfiVariables = true;
generic-extlinux-compatible.enable = false;
};
kernelPackages = pkgs.linuxPackages_latest; # or without _latest
# kernelParams not set, defaults to = ["loglevel=4"];
initrd.availableKernelModules = [ "pcie-brcmstb" "reset-raspberrypi" ]; # USB hid in initrd to unlock luks devices
};
hardware.enableRedistributableFirmware = true;
hardware.deviceTree.filter = "bcm2711-rpi-4-b.dtb";
systemd.services."getty@".enable = false;
powerManagement.cpuFreqGovernor = "schedutil";
} Bear in mind that depending on you UART settings, the bluetooth device is either /dev/ttyAMA0, or one of the /dev/ttyS* (IIRC it was /dev/ttyS1 for me with miniuart-bt, but for most it's /dev/ttyS0, IDK why it moved to the 1 for me ¯\(ツ)/¯). In either case, make sure you don't put a linux console onto this device (e.g. with the referenced kernel params, or via enabling getty@tty* or similar). If you use mini UART, you have to update I can't give you the full config, is split up into many modules within my system flake, but I can query specific config values in repl for you if you want to know more. |
Thanks, @pschyska. I tried pieces of your config, and I narrowed the issue down to, believe it or not, the kernel: (Also, I'm using I don't think the issue is in the kernel itself, since I had bluetooth working when running the same kernel version on Raspberry Pi OS. I'll run some more experiments to verify one way or the other. |
I assume you mean |
Is |
There's also the
I read that Thing is, I haven't been able to get
|
@Majiir Thanks for the mention of I have Here is what works for me. configuration.nix
(I think those are the only relevant lines) config.txt
Perhaps that can help you narrow down what isn't working for you? Happy to provide any extra information. |
@ChanceHarrison Could you share the |
Of course! I knew I was forgetting something.
|
Edit: It works just fine for me, if you type it correctly. 😉 Original text: |
I'm not well-versed in it either, but I only needed the Your post says |
D'oh! The typo made its way into the config first, actually. Thank you for catching it. It works as advertised if you actually type it correctly. I think there are some lessons learned here that can be documented on the wiki, perhaps? I would be happy to try my hand at those changes, though I have never done so before. As for your issue, did you have any luck finding why Bluetooth (either via |
No such luck! I tried using the same
but still no working Bluetooth:
In all of my testing, the only thing that works is switching to the default kernel instead of I put together a minimal-ish system flake for testing this: https://github.com/Majiir/btpi You can build an SD image with @ChanceHarrison Would you be willing to build a fresh SD image and give that a try? If it works, then that narrows the issue down to hardware or firmware. If it doesn't, then maybe you can make adjustments or offer an alternative flake that does work. [EDIT] Just to rule out this one device being the problem, I tested the |
I would be willing to give it a try, yes. I'll get back to you in a few days once I have a new spare SD card to use. To make sure I'm clear on the process:
Or, would I just do step 2 (on an existing NixOS system) and Of note, I am not using the SD image to get NixOS on my Pi. I used the aarch64 minimal installer (specific version |
We have a few different options. For best reproducing my setup, you should do something like this:
Then, you can write that image to an SD card, boot the Pi, and log in with The SD image will create a If you do all that, you won't have anything in My thinking is that by using a flake and building the whole SD image, we ideally get the exact same setup, and Bluetooth should fail for you with that setup. If it does, you could try taking your existing, working system (after taking a backup!) and deploy the minimal flake with Meanwhile, I will see if I can replicate your install steps. |
@Majiir I finally got my spare SD card(s) and I went ahead and booted my Pi with your minimal example. Thanks for the guidance on using it. Sure enough, I run into the same Bluetooth issues. Adding I compared dmesg output between my known-good system and the minimal example system. Here's the two outputs: Known good:
btpi (with
I also confirmed that switching to the non-rpi4 kernel (I tried with
So now I am very interested how I have my known-good system working with the rpi4 kernel but I can't get it to boot with the normal kernel... I haven't tried
Is relying on being able to boot the previous generation a sufficient backup? 🤔 I hope we can work together to figure this out. Hopefully others will chime in if they know something or have any suggestions. |
I'm a newcomer to this issue. Today I was playing with my newly acquired Raspberry Pi 4B, 4GB and played around with this issue. I would like to confirm this bug with the current nixpkgs, and I would like to provide a summary of the current status: My nixpkg revision is 5dc7114. It's I played with a couple of kernels. A summary is below: Raspberry Pi KernelFollowing the wiki and the linked nix.dev article sets up an install using the generic aarch64 SD image. After following these guides, one ends up importing This setup has the following problems:
Upstream kernel 5.15One can use kernel 5.15, by setting
Here is a (reduced) version of the config that works for me: { config, pkgs, lib, ... }:
{
hardware = {
bluetooth.enable = true;
enableRedistributableFirmware = true;
pulseaudio.enable = true;
deviceTree.filter = "bcm2711-rpi-*.dtb";
};
boot = {
# Bluetooth doesn't work with rpi4 kernel
# https://github.com/NixOS/nixpkgs/issues/123725
kernelPackages = pkgs.linuxPackages;
# Not sure how much of this this is relevant
initrd.availableKernelModules = [
"usbhid"
"usb_storage"
"vc4"
"pcie_brcmstb" # required for the pcie bus to work
"reset-raspberrypi" # required for vl805 firmware to load
];
loader = {
generic-extlinux-compatible.enable = true;
};
};
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
options = [ "noatime" ];
};
};
} Some elements taken from Upstream kernel 6.0.9This kernel can be used by setting Edit 28-11: interestingly, this article states that video driver support was merged for kernel version 6, but implies there are some bugs. That may explain the SEGFAULTs I'm seeing. I haven't looked further into this. Kernels between 5.15 and 6.0.9 have dropped upstream support, and have been removed from nixpkgs. Therefore I haven't tried them. Edit: I've added a link to this issue in the Wiki page: https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_4 |
One way to get bluetooth to work is by copying the firmware and kernel from a raspbian image and then hacking it into NixOS. Here's how. |
@avieth If I already have a configured raspberry pi, is there a way to update it in place with this? |
The typical update step from the README on the page I linked should work fine since it's just a typical
What's missing is the bootloader setup and it's a bit weird. You could build the initial image just like in the README
and then mount the boot partition of the image
and replace your existing Pi's boot with the contents of this. But also edit |
The firmware does some manipulation before passing the device tree to the kernel. The device tree in the raspberry pi kernel seems to expect this manipulation to happen, as the device tree in their fork isn't fully configured like the one in the mainline kernel. This is problematic since NixOS does not (by default) use the device tree provided by the firmware and instead supplies its own. In this case I believe the problem is that the firmware configures the bluetooth flow control pins. I have fixed the bluetooth issue in the past by creating an overlay that mimics the firmware manipulation. Something like:
It is tedious and error prone to maintain these patches. So, more recently I have pursued using the device tree that the firmware provides (using u-boot's I packaged up this approach here and an example with working bluetooth can be found here. |
@tstat That looks promising. Is there any guide to migrating an existing deploy onto your Right now my system is configured to use |
There isn't a guide for migrating an existing deploy. In your case it sounds the steps would be:
If you are using If you want to be cautious you could always back up an image of your sd-card before attempting, or you could be less cautious and only backup your firmware partition as that is destructively modified, whereas your root partition is not (edit: I just recalled that modifying The readme of If you end up attempting a migration please let me know how it goes! |
@tstat I just attempted it tonight, but I ran into a roadblock which is that compiling the kernel requires the |
|
@tstat Thanks for trying! Unfortunately it's not working for me. I'm guessing this is because I'm doing this on aarch64-darwin and based on the narHash issue I filed on your repo it looks like the linux source is affected by being unpacked and hashed on APFS, which presumably changes the resulting out path. I'm attempting to get access to a |
@tstat I finally managed to build and deploy to my raspberry pi, and now it can't find bluetooth. I double-checked and the Do you have any idea what's wrong? EDIT: I'm going to file an issue on your repo for this instead. |
For those looking to fix this when using
With that I was able to:
I'm probably going to contribute that back to the |
I've been tinkering with this for the past few days. I'm using the rpi kernel (via nixos-hardware) on my Pi 4, in large part so I have access to For my Pi4, which uses the
I did have to use:
I would rather be using the mainline kernel, but then I don't know how to get |
I'm on ZFS root and tried switching over to the uefi firmware and grub with hci0 appears with I see the following in dmesg after
I also seem to only get 2 GPIO pins listed under
Boot fails when I try to switch to the rpi kernel. |
I feel bad that I never followed up above. My Pi4 has been running fairly well for the last several months with the following setup, which provided functional GPIO and bluetooth
Unfortunately I updated to 23.11 a few days ago and bluetooth is gone again. EDIT: Bluetooth is working again on 23.11, I think the issue was with my UEFI setup, after reconfiguring that and a reboot I'm back in business. |
I decided to checkout that PR referencing this issue above. It fixed the issue for me. Step 1: imports = [
"${builtins.fetchGit { url = "https://github.com/NixOS/nixos-hardware.git"; }}/raspberry-pi/4"
]; Step 2: # Bluetooth
hardware.raspberry-pi."4".bluetooth.enable = true;
hardware.bluetooth =
{
enable = true;
powerOnBoot = true;
}; Your specific Bluetooth device may require additional drivers or permissions. In my case it was a PS4 controller I'm using to drive a robot, so I needed to add the user running my ROS nodes to the |
Issue description
"No default controller available" issue while trying to use
bluetoothctl
tool. I've recently installed NixOS on a Raspberry Pi 4 Model B using this very cool tutorial and everything seems to be fine for now except for this bluetooth functionality. I've read that https://github.com/RPi-Distro/pi-bluetooth is used in most similar cases, but, as far as I understand,btattach
systemd service (https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_3#Bluetooth) is already doing the same (if it is suitable for both rpi 3 and 4)rpi-related imports:
systemd services:
hardware:
Steps to reproduce
Technical details
"aarch64-linux"
Linux 5.10.17, NixOS, 21.05pre-git (Okapi)
yes
yes
nix-env (Nix) 2.3.11
""
"home-manager, nixos"
/nix/var/nix/profiles/per-user/root/channels/nixos
The text was updated successfully, but these errors were encountered: