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

starfive visionfive2: use mainline kernel #958

Merged
merged 4 commits into from
May 28, 2024

Conversation

NickCao
Copy link
Member

@NickCao NickCao commented May 25, 2024

Description of changes

See https://rvspace.org/en/project/JH7110_Upstream_Plan for support status.

Things done
  • Tested the changes in your own NixOS Configuration
  • Tested the changes end-to-end by using your fork of nixos-hardware and
    importing it via <nixos-hardware> or Flake input

@malteneuss
Copy link
Contributor

Oh wow, the upstream support seems to be quite advanced. Does that mean that with the latest kernel 6.9 in Nixpkgs https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/kernel/kernels-org.json we can expect a normal installation to just work? Even booting from an NVMe PCIe ssd?

@NickCao
Copy link
Member Author

NickCao commented May 25, 2024

Oh wow, the upstream support seems to be quite advanced. Does that mean that with the latest kernel 6.9 in Nixpkgs https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/kernel/kernels-org.json we can expect a normal installation to just work? Even booting from an NVMe PCIe ssd?

I think so, except that display/camera won't be working.

@malteneuss
Copy link
Contributor

malteneuss commented May 26, 2024

I have just tried the following setup with nixpkgs-unstable and your nixos-hardware branch (in case someone else would like to try it as well) and booted from an SD card:

{
  inputs.nixos-hardware-visionfive2.url = "github:NickCao/nixos-hardware/visionfive2-mainline";
  inputs.nixpkgs-unstable.url = "nixpkgs/nixos-unstable";

  outputs =
    inputs@{ self
    , nixos-hardware-visionfive2
    , nixpkgs-unstable
    , ...
    }: {
      nixosConfigurations.visionfive2 = nixpkgs-unstable.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          "${nixos-hardware-visionfive2}/starfive/visionfive/v2/sd-image-installer.nix"
          ({ pkgs, ... }: {
            nixpkgs.crossSystem = {
              config = "riscv64-unknown-linux-gnu";
              system = "riscv64-linux";
            };
            # needed for 8GB RAM model
            hardware.deviceTree.overlays = [{
              name = "8GB-patch";
              dtsFile = "${nixos-hardware-visionfive2}/starfive/visionfive/v2/8gb-patch.dts";
            }];
            sdImage.compressImage = false;
            system.stateVersion = "23.11";
          })
        ];
      };
    };
}

To build it run nix build .\#nixosConfigurations.visionfive2.config.system.build.sdImage -v.

As expected (i think) i see nothing through HDMI, but the green LED on the board, which appears with the custom Visionfive 2 Debian, doesn't light up; i only see the red LED. So i guess NixOS is not booting. I will try the current NixOS-hardware setup with the custom Starfive Linux kernel.

edit: Do i need to update the firmware first? E.g. use the current NixOS or Visionfive Debian, flash the firmware, and then boot with the normal latest upstream kernel?

I have set the boot mode pins to SDIO (to boot from SD card i think), but maybe i have to set it to QSPI (although i have no idea if that could still boot from SD) -> also with QSPI i can boot the Visionfive2 Debian from an SD card.
See boot mode pictures at https://doc-en.rvspace.org/VisionFive2/Quick_Start_Guide/VisionFive2_SDK_QSG/boot_mode_settings.html

@malteneuss
Copy link
Contributor

malteneuss commented May 26, 2024

Oh wow, the current NixOS-hardware setup with the custom kernel doesn't show any HDMI output, doesn't show a green LED, but is reachable through ethernet with ping (and SSH if configured)!! I will test this PR again next.

@malteneuss
Copy link
Contributor

@NickCao This PR doesn't seem to boot. I can't even reach it through ethernet. Could it be something with u-boot that needs manual typing in something? I wouldn't be able to, because there's no HDMI output and i don't have any USB serial adapter or anything.

@NickCao
Copy link
Member Author

NickCao commented May 26, 2024

@NickCao This PR doesn't seem to boot. I can't even reach it through ethernet. Could it be something with u-boot that needs manual typing in something? I wouldn't be able to, because there's no HDMI output and i don't have any USB serial adapter or anything.

I'm not sure, don't have access to the board now. Let's keep this as a draft and revisit later.

@malteneuss
Copy link
Contributor

Alright. Do you have any suggestion what i could try in the mean time?

@NickCao
Copy link
Member Author

NickCao commented May 26, 2024

Alright. Do you have any suggestion what i could try in the mean time?

Play with the kernel config? Very likely defconfig is missing a bunch of required drivers.

@onny
Copy link
Contributor

onny commented May 27, 2024

@NickCao This PR doesn't seem to boot. I can't even reach it through ethernet. Could it be something with u-boot that needs manual typing in something? I wouldn't be able to, because there's no HDMI output and i don't have any USB serial adapter or anything.

have you checked UART/serial output of your board? https://wiki.nixos.org/wiki/NixOS_on_RISCV/VisionFive_2#Usage

would be nice to see the failure log why the board fails to boot

@malteneuss
Copy link
Contributor

@onny Unfortunately, i don't have a device to connect UART/serial. Would you be able to test it out?

@misuzu
Copy link

misuzu commented May 27, 2024

@onny
Copy link
Contributor

onny commented May 27, 2024

I have just tried the following setup with nixpkgs-unstable and your nixos-hardware branch (in case someone else would like to try it as well) and booted from an SD card:

can you please update the snippet, I'm unable to build it because of syntax errors. which build command did you use?

@malteneuss
Copy link
Contributor

malteneuss commented May 27, 2024

Should build now with nix build .\#nixosConfigurations.visionfive2.config.system.build.sdImage -v
@NickCao Do you see any possibility to get cross-compiled (or native compiled) RISCV64 linux kernels like the latest via hydra? Building that locally takes ~2h on an average laptop (cross-compiled) and ~4h (native) on an Visionfive2 board. I've added some hints to the Wiki on how to build native packages: https://wiki.nixos.org/wiki/NixOS_on_RISCV/VisionFive_2#Using_the_Visionfive_2_as_a_remote_builder_to_build_native_RISCV_packages_for_e.g._the_Visionfive_2

@malteneuss
Copy link
Contributor

malteneuss commented May 27, 2024

https://patchew.org/linux/20240506034627.66765-1-hal.feng@starfivetech.com/

@misuzu Would you know how to apply this patch to @NickCao's PR or bump the nixpkgs latest kernel version? My kernel knowlege is quite limited xD i'd be happy to try it out then.

@NickCao
Copy link
Member Author

NickCao commented May 27, 2024

@misuzu Would you know how to apply this patch to @NickCao's PR or bump the nixpkgs latest kernel version? My kernel knowlege is quite limited xD i'd be happy to try it out then.

Applied.

@NickCao
Copy link
Member Author

NickCao commented May 27, 2024

@NickCao Do you see any possibility to get cross-compiled (or native compiled) RISCV64 linux kernels like the latest via hydra?

A cross compiled sd image is available at https://hydra.nichi.co/job/nixos/riscv/visionfive2

@NickCao
Copy link
Member Author

NickCao commented May 27, 2024

Also @leifhelm, do we still need 87e3122? I see that the partition size is 0x80000 in upstream dts.

@malteneuss
Copy link
Contributor

malteneuss commented May 27, 2024

@NickCao @misuzu It works with the new patch!!

@NickCao NickCao marked this pull request as ready for review May 27, 2024 21:12
@malteneuss
Copy link
Contributor

Also @leifhelm, do we still need 87e3122? I see that the partition size is 0x80000 in upstream dts.

What about this partition value?

@NickCao
Copy link
Member Author

NickCao commented May 27, 2024

Oh wow, the current NixOS-hardware setup with the custom kernel doesn't show any HDMI output, doesn't show a green LED

Since the current vendor kernel doesn't have working HDMI either. I think we are not losing functionality?

@NickCao
Copy link
Member Author

NickCao commented May 27, 2024

Also @leifhelm, do we still need 87e3122? I see that the partition size is 0x80000 in upstream dts.

What about this partition value?

Try reverting that commit and do a firmware update with visionfive2-firmware-update-flash

@malteneuss
Copy link
Contributor

malteneuss commented May 27, 2024

@NickCao
Done with branch https://github.com/malteneuss/nixos-hardware/tree/visionfive2-mainline:

$ sudo visionfive2-firmware-update-flash
Erasing blocks: 35/35 (100%)
Writing data: 137k/137k (100%)
Verifying data: 137k/137k (100%)
Erasing blocks: 249/249 (100%)
Writing data: 994k/994k (100%)
Verifying data: 994k/994k (100%)

Still works after reboot. Anything else i should check?

@NickCao
Copy link
Member Author

NickCao commented May 27, 2024

Anything else i should check?

That's all.

@Mic92
Copy link
Member

Mic92 commented May 28, 2024

@mergify queue

Copy link
Contributor

mergify bot commented May 28, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at a44ddc2

@mergify mergify bot merged commit a44ddc2 into NixOS:master May 28, 2024
3 checks passed
@onny
Copy link
Contributor

onny commented May 28, 2024

for me it fails to boot, stuck at this point

image

i tried this image https://hydra.nichi.co/build/3383 maybe it was the older one missing the fixes?

@0x4A6F
Copy link
Member

0x4A6F commented May 28, 2024

For me it is also stuck:

switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:3...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
726 bytes read in 4 ms (176.8 KiB/s)
1:      NixOS - Default
Retrieving file: /boot/extlinux/../nixos/qm7c098fkq4ifpfb9b545gy72b38w3hh-initrd-linux-riscv64-unknown-linux-gnu-6.9.2-initrd
26407644 bytes read in 1106 ms (22.8 MiB/s)
Retrieving file: /boot/extlinux/../nixos/9bac223z193iq4b2r6lkwlmwlxbrrx0r-linux-riscv64-unknown-linux-gnu-6.9.2-Image
33392640 bytes read in 1087 ms (29.3 MiB/s)
append: init=/nix/store/bsyji1bscqf9zy0nhj6yl3j39qa06iia-nixos-system-nixos-24.11.20240527.615e5fe/init loglevel=7
Retrieving file: /boot/extlinux/../nixos/cfj32zxhcyfycm3nk92jacnc901xzngl-device-tree-overlays/starfive/jh7110-starfive-visionfive-2-v1.3b.dtb
36112 bytes read in 8 ms (4.3 MiB/s)
## Flattened Device Tree blob at 46000000
   Booting using the fdt blob at 0x46000000
   Using Device Tree in place at 0000000046000000, end 000000004600bd0f

Starting kernel ...

clk u5_dw_i2c_clk_core already disabled
clk u5_dw_i2c_clk_apb already disabled

@NickCao
Copy link
Member Author

NickCao commented May 28, 2024

Does it ping? Maybe Ethernet is working but serial is not.

@0x4A6F
Copy link
Member

0x4A6F commented May 28, 2024

No, doesn't ping.

@malteneuss
Copy link
Contributor

Could you check if the flake.lock commit points to the latest commit? For me nix flake update <nixos-hardware> sometimes didn't update the commit.

@malteneuss
Copy link
Contributor

Oh oh. I used an older nixos-hardware commit by mistake. I just checked the Linux kernel

uname -a
Linux visionfive2 6.6.0 #1-NixOS SMP Tue Jan  1 00:00:00 UTC 1980 riscv64 GNU/Linux

I'm deeply sorry. It's the Starfive custom kernel :(

I will check if the just the last 87e3122 revert has to be reverted or we have to start again.

@malteneuss
Copy link
Contributor

Unfortuneately, neither with our without the qspi patch it doesn't boot. Is there some quickfix we can apply from @onny and @0x4A6F logs?

@NickCao
Copy link
Member Author

NickCao commented May 28, 2024

Unfortuneately, neither with our without the qspi patch it doesn't boot. Is there some quickfix we can apply from @onny and @0x4A6F logs?

Sadly no, we might need to revert this.

@NickCao NickCao deleted the visionfive2-mainline branch May 30, 2024 19:21
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

Successfully merging this pull request may close these issues.

6 participants