diff --git a/README.md b/README.md index 73a1738..05b05d8 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,7 @@ -# VisionFive-Nix +# NixOS on RISC-V -This repository contains primarily instructions for the VisionFive 1 board. +For now let's try to boot it in qemu. -For experimental support for VisionFive 2, see [visionfive2/README.md](visionfive2/README.md). + $ nix build .#nixosConfigurations.visionfive-cross.config.system.build.vm -# Flashing the Bootloader (VisionFive 1) - -1. Do not apply power to the board -2. Attach the board via serial to your system, ensuring power is still not applied -3. Ensure the serial shows up in `/dev/ttyUSB*`, you can see this by running `dmesg` after plugging in the device - - ``` - ❯ dmesg - [200199.253566] usb 1-2: new full-speed USB device number 79 using xhci_hcd - [200199.386983] usb 1-2: New USB device found, idVendor=0403, idProduct=6001, bcdDevice= 6.00 - [200199.386988] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 - [200199.386990] usb 1-2: Product: FT232R USB UART - [200199.386991] usb 1-2: Manufacturer: FTDI - [200199.386992] usb 1-2: SerialNumber: A50285BI - [200199.390344] ftdi_sio 1-2:1.0: FTDI USB Serial Device converter detected - [200199.390363] usb 1-2: Detected FT232RL - [200199.391207] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0 - ^^^^^^^ - ^ This becomes /dev/ttyUSB0 - ``` - -4. `nix run github:matthewcroughan/visionfive-nix#flashBootloader /dev/ttyUSB0` -5. Wait to be told to apply power to the board this may take a while as U-Boot and OpenSBI are being cross-compiled. - ``` - Terminal ready - - ### Apply power to the VisionFive Board ### - ``` - Once power is applied, picocom will send the OpenSBI/U-Boot payload via XMODEM. You can then flash NixOS or any other distribution that follows the Distro Boot specification[^1] to an SD card and boot it. - -###### Why do I need to flash the bootloader? - -https://github.com/starfive-tech/u-boot/issues/30 - -The VisionFive ships with a version of OpenSBI/U-Boot that does not follow the distro-boot specification. NixOS and other distros would like to remain generic, without vendor specific details entering their system. This means booting NixOS requires flashing the bootloader as described above. - -[^1]: https://source.denx.de/u-boot/u-boot/-/blob/v2022.04/doc/develop/distro.rst +That would cross-build a bootable RISC-V qemu VM from x86. diff --git a/flake.nix b/flake.nix index 2a7d644..a346b1c 100644 --- a/flake.nix +++ b/flake.nix @@ -70,71 +70,6 @@ { inherit (pkgs.pkgsCross.riscv64.linux) linuxPackages_visionfive; }; - apps.${system} = { - flashBootloader = - let - expectScript = pkgs.writeScript "expect-visionfive.sh" '' - #!${pkgs.expect}/bin/expect -f - set timeout -1 - spawn ${pkgs.picocom}/bin/picocom [lindex $argv 0] -b 115200 -s "${pkgs.lrzsz}/bin/sz -X" - expect "Terminal ready" - send_user "\n### Apply power to the VisionFive Board ###\n" - expect "bootloader" - expect "DDR" - send "\r" - expect "0:update uboot" - expect "select the function:" - send "0\r" - expect "send file by xmodem" - expect "CC" - send "\x01\x13" - expect "*** file:" - send "${pkgs.pkgsCross.riscv64.firmware-visionfive}/opensbi_u-boot_visionfive.bin" - send "\r" - expect "Transfer complete" - ''; - program = pkgs.writeShellScript "flash-visionfive.sh" '' - if $(groups | grep --quiet --word-regexp "dialout"); then - echo "User is in dialout group, flashing to board without sudo" - ${expectScript} $1 - else - echo "User is not in dialout group, flashing to board with sudo" - sudo ${expectScript} $1 - fi - ''; - in - { - type = "app"; - program = "${program}"; - }; - flashOriginal = - let - flashScript = pkgs.writeScript "jh7100-recover-visionfive.sh" '' - set -x - ${pkgs.lib.getExe self.packages.${system}.jh7100-recover} \ - -D $1 \ - -r ${jh7100_recovery_binary} \ - -b ${jh7100_secondBoot} \ - -d ${jh7100_ddrinit} - ''; - program = pkgs.writeShellScript "flash-visionfive.sh" '' - if $(groups | grep --quiet --word-regexp "dialout"); then - echo "User is in dialout group, flashing to board without sudo" - ${flashScript} $1 - else - echo "User is not in dialout group, flashing to board with sudo" - sudo ${flashScript} $1 - fi - ''; - in - { - type = "app"; - program = "${program}"; - }; - } // import ./visionfive2/commands.nix { inherit inputs pkgs; }; - packages.${system} = { - jh7100-recover = pkgs.writeCBin "jh7100-recover" (builtins.readFile "${jh71xx-tools}/jh7100-recover.c"); - }; images = { visionfive-cross = self.nixosConfigurations.visionfive-cross.config.system.build.sdImage; visionfive-native = self.nixosConfigurations.visionfive-native.config.system.build.sdImage; @@ -146,15 +81,7 @@ visionfive2-sd-image = importApply ./visionfive2/sd-image.nix { inherit inputs importApply; }; visionfive2-kernel = importApply ./visionfive2/kernel/nixos-module.nix { inherit inputs importApply; }; }; - nixosConfigurations = - let - visionfive2-example-modules = [ - ./base.nix - ./configuration.nix - self.nixosModules.visionfive2-sd-image - ]; - in - { + nixosConfigurations = { visionfive-cross = nixpkgs.lib.nixosSystem { system = "${system}"; modules = modules ++ [ @@ -169,21 +96,6 @@ system = "riscv64-linux"; modules = modules; }; - - visionfive2-cross = nixpkgs.lib.nixosSystem { - system = "${system}"; - modules = visionfive2-example-modules ++ [ - { - nixpkgs.crossSystem = { - system = "riscv64-linux"; - }; - } - ]; - }; - visionfive2-native = nixpkgs.lib.nixosSystem { - system = "riscv64-linux"; - modules = visionfive2-example-modules; - }; }; }; }