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

pine64-pinephone-braveheart: kernel 5.6.0 #146

Closed
wants to merge 7 commits into from

Conversation

@masipcat
Copy link

@masipcat masipcat commented May 10, 2020

This kernel is based on the latest commit in master (https://gitlab.com/pine64-org/linux/-/tree/pine64-kernel-5.6.y/) and uses the pmOS config file, with only two changes: CONFIG_RTL8723CS is set to n (failes to build when enabled) and CONFIG_RTL8723CS_NEW set to y (instead of m).

Tested on Pinephone braveheart:

  • Touchscreen / display works
  • WiFi works
  • Audio not works (I don't know if this was working with kernel 5.5.0)
masipcat added 2 commits May 10, 2020
Copy link
Member

@samueldr samueldr left a comment

👋 Thanks for the contribution!

It's always nice to see new contributors here!

Some thoughts follow.

];
}).overrideAttrs({ postInstall ? "", ... }: {
installTargets = [ "install" "dtbs" ];
postInstall = postInstall + ''
mkdir -p "$out/dtbs/allwinner"
cp -v "$buildRoot/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtb" "$out/dtbs/allwinner/"
cp -v "$buildRoot/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dtb" "$out/dtbs/allwinner/sun50i-a64-pinephone.dtb"

This comment has been minimized.

@samueldr

samueldr May 11, 2020
Member

This is a hard problem to solve.

U-Boot will, at some point, be updated to one that detects between 1.1 and 1.2, and at that moment it will need the appropriately "1.1" filename.

I think the solution, for the time being, will be to copy it both to the new name, and to the old name at that location. This way the kernel build will stay compatible with previous U-Boot builds, while allowing support with the new one.

Suggested change
cp -v "$buildRoot/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dtb" "$out/dtbs/allwinner/sun50i-a64-pinephone.dtb"
# Filename expected by older U-Boot revisions for the Pinephone.
cp -v "$buildRoot/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dtb" "$out/dtbs/allwinner/sun50i-a64-pinephone.dtb"
# Hardware-versioned filenames.
cp -v "$buildRoot/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dtb" "$out/dtbs/allwinner/"

This comment has been minimized.

@masipcat

masipcat May 11, 2020
Author

Btw, there is also a 1.0.dtb. Should we add it as well?

This comment has been minimized.

@samueldr

samueldr May 11, 2020
Member

Yes, please. Though I'm not sure it'll be useful for anyone, we should strive to be a good example in maximizing compatibility.

This comment has been minimized.

@samueldr
Copy link
Member

@samueldr samueldr commented May 11, 2020

I'll have to see with the config file, but I don't know that we want to follow exactly the PostmarketOS configuration. Though, with that said, it's likely we want to enable all options they enable.

masipcat and others added 2 commits May 11, 2020
Co-authored-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
@masipcat
Copy link
Author

@masipcat masipcat commented May 11, 2020

I'll have to see with the config file, but I don't know that we want to follow exactly the PostmarketOS configuration. Though, with that said, it's likely we want to enable all options they enable.

I don't have experience tunning/configuring a kernel so it's ok for me any change

@samueldr
Copy link
Member

@samueldr samueldr commented May 11, 2020

What is the provenance of disable-power-save.patch? I mean, the patch is trivial it doesn't really need a source, but I'm thinking more about the reason it's included.

Is it recommended somewhere? If so, where, who? What does it help fixing?

@masipcat
Copy link
Author

@masipcat masipcat commented May 12, 2020

What is the provenance of disable-power-save.patch? I mean, the patch is trivial it doesn't really need a source, but I'm thinking more about the reason it's included.

Is it recommended somewhere? If so, where, who? What does it help fixing?

Taken from here: https://gitlab.com/postmarketOS/pmaports/-/blob/master/main/linux-postmarketos-allwinner/disable-power-save.patch

@masipcat masipcat marked this pull request as ready for review May 16, 2020
@masipcat
Copy link
Author

@masipcat masipcat commented May 16, 2020

Btw, with this version the led indicator doesn't turn off after stage-1. Any idea?

@samueldr
Copy link
Member

@samueldr samueldr commented May 26, 2020

Btw, with this version the led indicator doesn't turn off after stage-1. Any idea?

The LED should turn green and stay green. Yet undocumented, but I want to default an LED to "on" for all devices that has one, up until the "phone environment" (like desktop environments) takes over and does whatever it wants with the LED.

So, it sounds like everything is alright. You may have been comparing with a kernel build from before I implemented it for the Pinephone.

@masipcat
Copy link
Author

@masipcat masipcat commented May 26, 2020

Btw, with this version the led indicator doesn't turn off after stage-1. Any idea?

The LED should turn green and stay green. Yet undocumented, but I want to default an LED to "on" for all devices that has one, up until the "phone environment" (like desktop environments) takes over and does whatever it wants with the LED.

👍

So, it sounds like everything is alright. You may have been comparing with a kernel build from before I implemented it for the Pinephone.

Yes, that's correct.


I've been testing for some weeks with this kernel and I tested the following things:

  • Wifi: works
  • Modem: seems to work after giving power using a custom script. Couldn't test calls/sms/lte because ofono was crashing (NixOS/nixpkgs#88178)
  • Bluetooth: doesn't work:
[    4.162723] Bluetooth: hci0: RTL: loading rtl_bt/rtl8723cs_xx_fw.bin
[    4.162775] bluetooth hci0: Direct firmware load for rtl_bt/rtl8723cs_xx_fw.bin failed with error -2
[    4.174926] Bluetooth: hci0: RTL: firmware file rtl_bt/rtl8723cs_xx_fw.bin not found

I created a custom package that adds these binaries but for some reason nixos doesn't find the files. I don't know if this happens because it tries to load this files before the root fs is mounted... Any idea?

  • Audio: doesn't work. ALSA detects a sunxi device but only plays white noise (still investigating).

Did you try this things with kernel 5.5? I'm not sure if the non-working parts are because the kernel or missing configuration in nixos

@samueldr
Copy link
Member

@samueldr samueldr commented May 26, 2020

Other than Wi-Fi, I don't think I tested anything else you mentioned.

For the bluetooth firmware, check if using mobile.boot.stage-1.kernel.firmwares helps, it should place it all at the appropriate place.

@masipcat
Copy link
Author

@masipcat masipcat commented May 26, 2020

Other than Wi-Fi, I don't think I tested anything else you mentioned.

For the bluetooth firmware, check if using mobile.boot.stage-1.kernel.firmwares helps, it should place it all at the appropriate place.

I just tried this and didn't work. Maybe I've done something wrong. In my local.nix:

rtl8723bt = callPackage ./my_pkgs/rtl8723bt.nix { };

# ...

mobile.boot.stage-1.kernel.firmwares = [rtl8723bt];

hardware.firmware = [
    (pkgs.runCommandNoCC "rtl8723bt" {} ''
      mkdir -p "$out/lib/firmware/rtl_bt"
      cp ${rtl8723bt}/lib/firmware/rtl_bt/*.bin "$out/lib/firmware/rtl_bt"
    '')
];

and here is the derivation:

{ stdenv, fetchFromGitHub }:
with stdenv;
stdenv.mkDerivation rec {
  pname = "rtl8723bt-firmware";
  version = "master";
  # inherit (linuxPackages.rtl8723bt) src;

  src = fetchFromGitHub {
    owner = "anarsoul";
    repo = pname;
    
    rev = "39da5959deff5041160fa85e62dddb89066471b3";
    sha256 = "03ff7j9scf9dsjdv2hz7gd2vq6932zkd8fl5d7qmx4kvrzww4dhp";
  };

  phases = [ "unpackPhase" "installPhase" ];

  installPhase = ''
    mkdir -p "$out/lib/firmware/rtl_bt"
    cp rtl_bt/rtl8723cs_xx_fw.bin "$out/lib/firmware/rtl_bt"
    cp rtl_bt/rtl8723cs_xx_config-pinebook.bin "$out/lib/firmware/rtl_bt/rtl8723cs_xx_config-pinephone.bin"
  '';

  meta = with stdenv.lib; {
    description = "Firmware for RealTek 8723bs";
    homepage = "https://github.com/hadess/rtl8723bs";
    license = licenses.unfreeRedistributableFirmware;
    maintainers = with maintainers; [ elitak ];
    platforms = with platforms; linux;
  };
}

And here is what I have on the built image:

$ ls /run/current-system/firmware/rtl_bt/rtl8723cs_xx_*
/run/current-system/firmware/rtl_bt/rtl8723cs_xx_config-pinephone.bin
/run/current-system/firmware/rtl_bt/rtl8723cs_xx_fw.bin
@masipcat
Copy link
Author

@masipcat masipcat commented Jun 1, 2020

@samueldr I just realized that I was building the image + kernel from this branch that doesn't have this changes 114f545 . Now I'm trying to build the image from master but I get this error:

Fail: bits (mrbgems: mruby-os)
 - Assertion[1]
    Expected [32, 64] to include nil.
Fail: bits(machine) (mrbgems: mruby-os)
 - Assertion[1]
    Expected [32, 64] to include nil.
Skip: Logger.log [path] => open /nix/store/spj6485y9qv5qnlqn6hic48j8blqbc5f-source/test/log.txt (mrbgems: mruby-logger)
  Total: 1497
     OK: 1417
     KO: 2
  Crash: 0
Warning: 65
   Skip: 13
   Time: 17.42 seconds
  CC      cmd/pxe_utils.o
rake aborted!
Command Failed: [build/test/bin/mrbtest]

builder for '/nix/store/6z9dlcr6cwlvqghsr9l9kjkjm9kv906c-mruby-2.1.0.drv' failed with exit code 1
cannot build derivation '/nix/store/ghi1lxwmfdi17xjyjmfcqh8mzxmfdqgd-mobile-nixos-script-loader-0.2.0.drv': 1 dependencies couldn't be built
building '/nix/store/7zbvhlb3znkfjvk3vk2n2rc2qbiyvplm-unit-script-nix-gc-start.drv'...
cannot build derivation '/nix/store/07l378vyq6mmpbbjrkw6gfiiyjmnpyx3-extra-utils-pine64-pinephone-braveheart-extra-utils.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/492ifbm559y49ydsf2lfxqchnq1mkwqz-initrd-pine64-pinephone-braveheart.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/ixh7fzn7a33b1v2g086riv4wk2vv9y68-initrd-pine64-pinephone-braveheart.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/l5jcj2y9f7ws6yc2r7fpw8xd1l3y4hm2-partition-mobile-nixos-boot.drv': 1 dependencies couldn't be built
building '/nix/store/2cgd7s4vci9mmn3aszhkdhx2f8735xd9-unit-systemd-udevd.service.drv'...
building '/nix/store/fx6fsn56770gw8mylcqlh73mbd5kadkh-xdg-portals.drv'...
building '/nix/store/z0r323d2gibdhiwdysf8f7mbyina9syy-xserver.conf.drv'...
cannot build derivation '/nix/store/f938rvcmr716phj0dxnib2hnf1s109ig-disk-image-mobile-nixos.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/44spc91qj7iffq2z09n9sl8f87bhkv46-pine64-pinephone-braveheart_full-disk-image.img.drv': 1 dependencies couldn't be built
error: build of '/nix/store/44spc91qj7iffq2z09n9sl8f87bhkv46-pine64-pinephone-braveheart_full-disk-image.img.drv' failed

I'm building this on a nixos 20.09 running in a rpi 4

@samueldr
Copy link
Member

@samueldr samueldr commented Jun 11, 2020

I've been working off of cross-compilation mainly, and it's been stuck in a bad place for a couple of weeks, getting better though.

There must have been a change in Nixpkgs that causes mruby to fail to build properly.

In the mean time, you can use samueldr/nixpkgs@22a3bf9 to build, it is a commit that is known to build with cross-compilation.

@masipcat
Copy link
Author

@masipcat masipcat commented Jun 11, 2020

Well, I wasn't cross-compiling. I was building this on a Raspi 4. This past weekend I bypassed the errorm commenting the doCheck. Everything works fine.

@masipcat
Copy link
Author

@masipcat masipcat commented Jun 11, 2020

About this PR, for me it can wait a couple of weeks and maybe I'll go for 5.7.0, if you are ok with this

@samueldr
Copy link
Member

@samueldr samueldr commented Jun 11, 2020

Yes, sorry, I meant that since I've been relying on that older commit, I haven't been faced with that compilation issue yet. I'm looking into it.

And yeah, going with 5.7 is probably fine too.

@masipcat
Copy link
Author

@masipcat masipcat commented Jun 11, 2020

Yes, sorry, I meant that since I've been relying on that older commit, I haven't been faced with that compilation issue yet. I'm looking into it.

No worry. Thank you :)

@masipcat masipcat closed this Aug 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.