nixos-riscv/notes.md

174 lines
7.2 KiB
Markdown

# dev/build TLDRs
* `nix flake show .`
* `nix repl` followed by `:lf .` to much about in a REPL
* `nix build .#nixosConfigurations.asgaut.config.system.build.sdImage`
* `nix build .#images.asgaut-sd` to cross build
* `TODO` to build via binfmt emulation
* `zstd -vdcfT4 result/sd-image/*.img.zst | dd of=/dev/sda2 status=progress; sync`
## VF2 Overview
* The VisionFive 2
* Shortname: `vf2`
* https://www.kickstarter.com/projects/starfive/visionfive-2
* https://wiki.rvspace.org/
* StarFive JH7110 64-bit CPU
* CPU: quad SiFive U74 1.5GHz cores and comes paired with
* GPU: BXE-4-32 GPU from Imagination Technologies.
* OpenGL ES 3.2
* OpenCL 1.2
* Vulkan 1.2
* 2/4/8 GB RAM
* IO
* 1x HMDI (up to 4kp30)
* H.264 decode
* H.265 decode/encode
* 2x Gigabit Ethernet
* 2x USB 2.0
* 2x USB 3.0
* 2x M.2 NVMe
* MIPI CSI
* MIPI DSI
* MIPI LCD
* 4pin GPIO
* power:
* 5v DC via USB-C PD up to 30W
* 5v Dc via GPIO minimum 3A
* PoE (requires separate hardware module?)
* Storage
* SD
* NVMe
* SPI flash
* Their linux tree
* U-Boot
* used as firmware and bootloader (instead of GRUB like for x86) on ARM and RISCV
* [Generic Distro Configuration Concept](https://github.com/u-boot/u-boot/blob/master/doc/develop/distro.rst)
* U-Boot is scripted to scan all attached storage devices & partitions and look for a file named /extlinux/extlinux.conf or /boot/extlinux/extlinux.conf
## Some VisionFive/RISCV/U-Boot reading
* https://lobste.rs/s/4gmbhc/hands_on_experience_with_starfive
* https://rvspace.org/en/project/JH7110_Upstream_Plan
* https://nixos.wiki/wiki/NixOS_on_ARM
* https://nixos.wiki/wiki/NixOS_on_ARM/UEFI
* https://doc-en.rvspace.org/VisionFive2/PDF/VisionFive2_QSG.pdf
* https://github.com/MatthewCroughan/visionfive-nix/tree/master/visionfive2
* https://www.youtube.com/watch?v=cmjK8SLIx9E
## Nix flakes
I'm new lol
* https://nixos.wiki/wiki/Flakes
* https://zero-to-nix.com/concepts/flakes
* https://github.com/dali99/nix-dotfiles/blob/master/flake.nix
## nixos builders
* https://nixos.org/guides/building-bootable-iso-image.html
* https://rbf.dev/blog/2020/05/custom-nixos-build-for-raspberry-pis/
* https://gist.github.com/tarnacious/f9674436fff0efeb4bb6585c79a3b9ff
* https://jade.fyi/blog/nixos-disk-images-m1/
* https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/sd-card/sd-image.nix
* https://github.com/NixOS/nixpkgs/blob/master/nixos/lib/make-ext4-fs.nix
* https://github.com/NixOS/nixpkgs/blob/master/nixos/lib/make-disk-image.nix
# [github:NickCao/nixos-riscv](https://github.com/NickCao/nixos-riscv)
* https://github.com/NickCao/u-boot-starfive - likely just rebased on upstream uboot
* https://github.com/starfive-tech/u-boot/tree/JH7110_VisionFive2_devel
* https://github.com/sifive/meta-sifive/tree/master - BSP layer for OpenEmbedded/Yocto
* https://github.com/NickCao/starfive-tools - `spl_tool` and `uboot_its`
sources of interest:
* https://github.com/NickCao/nixos-riscv/blob/master/common.nix
* https://github.com/NickCao/nixos-riscv/blob/master/visionfive2.nix
```
$ nix flake show github:NickCao/nixos-riscv
github:NickCao/nixos-riscv/4ebf1f02b169f2bf6103776633e873d7968bdb32
├───hydraJobs
│ ├───bootrom-unmatched: derivation 'bootrom'
│ ├───bootrom-visionfive: derivation 'bootrom-visionfive'
│ ├───firmware-vf2: derivation 'firmware-vf2-riscv64-unknown-linux-gnu'
│ ├───linux-vf2: derivation 'linux-riscv64-unknown-linux-gnu-6.1.0-vf2'
│ ├───opensbi: derivation 'opensbi-riscv64-unknown-linux-gnu-1.2'
│ ├───opensbi-vf2: derivation 'opensbi-riscv64-unknown-linux-gnu-1.2'
│ ├───qemu: derivation 'qemu-riscv64-unknown-linux-gnu-7.2.0'
│ ├───uboot-unmatched: derivation 'uboot-sifive_unmatched_defconfig-riscv64-unknown-linux-gnu-2022.10'
│ ├───uboot-unmatched-ram: derivation 'uboot-sifive_unmatched_defconfig-riscv64-unknown-linux-gnu-2022.10'
│ ├───uboot-vf2: derivation 'uboot-starfive_visionfive2_defconfig-riscv64-unknown-linux-gnu-f1d959f'
│ ├───uboot-visionfive: derivation 'uboot-starfive_jh7100_visionfive_smode_defconfig-riscv64-unknown-linux-gnu-e068256b4ea2d01562317cd47caab971815ba174'
│ ├───unmatched: derivation 'nixos-sd-image-23.05.20230119.c75b147-riscv64-linux.img-riscv64-unknown-linux-gnu'
│ ├───visionfive: derivation 'nixos-sd-image-23.05.20230119.c75b147-riscv64-linux.img-riscv64-unknown-linux-gnu'
│ └───visionfive2: derivation 'nixos-sd-image-23.05.20230119.c75b147-riscv64-linux.img-riscv64-unknown-linux-gnu'
├───nixosConfigurations
│ ├───qemu: NixOS configuration
│ ├───unmatched: NixOS configuration
│ ├───visionfive: NixOS configuration
│ └───visionfive2: NixOS configuration
└───overlay: Nixpkgs overlay
```
# [github:zhaofengli/nixos-riscv64](https://github.com/zhaofengli/nixos-riscv64)
... no visionfive 2?
* https://github.com/NixOS/nixpkgs/issues/101651#issuecomment-852725823
* https://gist.github.com/zhaofengli/275d1a0de14eceba90fd4e399af34b5c
* https://github.com/zhaofengli/nixos-riscv64/issues/3
```
$ nix flake show github:zhaofengli/nixos-riscv64
github:zhaofengli/nixos-riscv64/def02c67833bf551288c5cbd8ed6652b255d2fe8
├───hydraJobs
│ └───world
│ ├───simpleSystem: derivation 'nixos-system-nixos-23.05pre-git'
│ ├───tier0: derivation 'tier0'
│ ├───tier1: derivation 'tier1'
│ └───tier2: derivation 'tier2'
├───legacyPackages
│ └───riscv64-linux omitted (use '--legacy' to show)
├───nixosModules
│ ├───unmatched: NixOS module
│ └───visionfive: NixOS module
└───overlay: Nixpkgs overlay
```
# BARF
https://www.waveshare.com/wiki/VisionFive2
https://doc-en.rvspace.org/Doc_Center/visionfive_2.html
https://github.com/starfive-tech/VisionFive2
https://github.com/starfive-tech/u-boot
https://github.com/u-boot/u-boot/blob/master/doc/board/starfive/visionfive2.rst
http://forum.rvspace.org/t/usb-serial-needed/897/4
https://reddit.com/r/RISCV/comments/zy30vl/comment/j3zhzkx/
https://forum.rvspace.org/t/nvme-boot-using-visionfive2-software-v2-11-5/2464/1
https://forum.rvspace.org/t/i-tried-the-v3-0-4-sdcard-img-from-sdcard-and-from-nvme/2965
https://u-boot.readthedocs.io/en/latest/board/starfive/visionfive2.html
* base: https://github.com/NixOS/nixos-hardware/blob/master/starfive/visionfive/v2/
* make-sd-image: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/sd-card/sd-image.nix
* make-disk-image:
* https://github.com/NixOS/nixpkgs/blob/master/nixos/lib/make-disk-image.nix
* https://github.com/nix-community/nixos-generators/blob/master/formats/raw.nix
* https://github.com/nix-community/nixos-generators/blob/master/formats/raw-efi.nix
* riscv efi: https://github.com/dramforever/nixos-riscv-efi/
* https://github.com/dramforever/nixos-riscv-efi
* gpu?: https://github.com/dramforever/nixos-visionfive
* qemu: https://github.com/NickCao/nixos-riscv
* Distroboot u-boot: https://github.com/NickCao/u-boot-starfive
* ?? https://github.com/zhaofengli/nixos-riscv64