VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   30 Branches   50 Tags
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200   1) # Linux kernel for the BeagleV Starlight
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200   2) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200   3) ## What is this?
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200   4) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200   5) The [BeagleV Starlight][bborg] board is a new Linux-capable 64bit RISC-V
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200   6) development board. It has not shipped yet, but [beta versions][beta] are out to
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200   7) developers. Consequently the board is not yet supported by upstream Linux. This
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200   8) tree is meant to collect all the in-development patches for running Linux on
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200   9) the board.
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  10) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  11) [bborg]: https://beagleboard.org/beaglev
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  12) [beta]: https://github.com/beagleboard/beaglev-starlight
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  13) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  14) ## Cross-compiling
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  15) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  16) Cross-compiling the Linux kernel is surprisingly easy since it doesn't depend
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  17) on any (target) libraries and most distributions already have packages with a
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  18) working cross-compiler. We'll also need a few other tools to build everything:
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  19) ```shell
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  20) # Debian/Ubuntu
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  21) sudo apt-get install libncurses-dev libssl-dev bc flex bison make gcc gcc-riscv64-linux-gnu
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  22) # Fedora
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  23) sudo dnf install ncurses-devel openssl openssl-devel bc flex bison make gcc gcc-riscv64-linux-gnu
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  24) # Archlinux
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  25) sudo pacman -S --needed ncurses openssl bc flex bison make gcc riscv64-linux-gnu-gcc
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  26) ```
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  27) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  28) The build system needs to know that we want to cross-compile a kernel for
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  29) RISC-V by setting `ARCH=riscv`. It also needs to know the prefix of our
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  30) cross-compiler using `CROSS_COMPILE=riscv64-linux-gnu-`. Also let's assume
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  31) we're building on an 8-core machine so compilation can be greatly sped up by
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  32) telling make to use all 8 cores with `-j8`.
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  33) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  34) First we need to configure the kernel though. Linux has a *very* extensive
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  35) configuration system, but you can get a good baseline configuration for the
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  36) board using:
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  37) ```shell
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  38) make -j8 ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- beaglev_defconfig
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  39) ```
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  40) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  41) There is nothing magic about this configuration other than it has all the
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  42) drivers enabled that are working for the hardware on the board. In fact it has
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  43) very little extra features enabled which is great for compile times, but you
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  44) are very much encouraged to add additional drivers and configure your kernel
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  45) further using
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  46) ```shell
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  47) make -j8 ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- nconfig
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  48) ```
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  49) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  50) Now compile the whole thing with
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  51) ```
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  52) make -j8 ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  53) ```
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  54) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  55) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  56) ## Installing
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  57) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  58) Once the build has finished the resulting kernel can be found at
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  59) ```shell
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  60) arch/riscv/boot/Image
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  61) ```
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  62) You'll also need the matching device tree at
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  63) ```shell
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  64) arch/riscv/boot/dts/starfive/jh7100-beaglev-starlight.dtb
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  65) ```
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  66) These two files should be copied to the boot partition on the SD card. That is
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  67) onto the same file system that contains the `extlinux/extlinux.conf`. On the
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  68) default Fedora image this is mounted at `/boot`.
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  69) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  70) Now add the following entry to the `extlinux/extlinux.conf` file:
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  71) ```
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  72) label My New Kernel
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  73) kernel /Image
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  74) fdt /jh7100-beaglev-starlight.dtb
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  75) append earlycon console=ttyS0,115200n8 root=/dev/mmcblk0p2 rootwait stmmac.chain_mode=1
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  76) ```
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  77) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  78) This assumes your root file system is at `/dev/mmcblk0p2` which it is on the
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  79) default Fedora image. Also if your kernel is very big it might be beneficial to
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  80) use the compressed `Image.gz` rather than the uncompressed `Image`.
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  81) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  82) The `beaglev_defconfig` doesn't enable modules, but if you enabled them in
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  83) your build you'll also need to install them in `/lib/modules/` on the root file
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  84) system. How to do that best is out of scope for this README though.
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  85) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  86) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  87) ## Status
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  88) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  89) #### SoC
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  90) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  91) - [x] Pinctrl/Pinmux
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  92) - [x] GPIO
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  93) - [x] Serial port
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  94) - [x] I2C
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  95) - [x] SPI
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  96) - [x] MMC / SDIO / SD card
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  97) - [x] Random number generator
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  98) - [x] Temperature sensor
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200  99) - [x] Ethernet, though a little flaky and `stmmac.chain_mode=1` needed on the cmdline
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 100) - [x] USB, USB 3.0 is broken with `CONFIG_PM` enabled
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 101) - [x] Framebuffer, fbdev driver so not upstreamable
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 102) - [x] NVDLA
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 103) - [ ] Clock tree, statically set up by u-boot, WIP clock driver
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 104) - [ ] Watchdog
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 105) - [ ] Security Engine
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 106) - [ ] MIPI-DSI
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 107) - [ ] ISP
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 108) - [ ] MIPI-CSI
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 109) - [ ] Video Decode
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 110) - [ ] Video Encode
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 111) - [ ] NNE50
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 112) - [ ] Vision DSP
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 113) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 114) #### Board
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 115) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 116) - [x] LED
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 117) - [x] PMIC / Reboot
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 118) - [x] Ethernet PHY
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 119) - [x] HDMI, working with [some screens][hdmi]
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 120) - [x] AP6236 Wifi
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 121) - [ ] AP6236 Bluetooth
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 122) - [ ] GD25LQ256D SPI flash
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 123) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 124) [hdmi]: https://forum.beagleboard.org/t/hdmi-displays-compatible-list/
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 125) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 126) ## Contributing
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 127) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 128) If you're working on cleaning up or upstreaming some of this or adding support
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 129) for more of the SoC I'd very much like to incorporate it into this tree. Either
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 130) send a pull request, mail or contact Esmil on IRC/Slack.
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 131) 
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 132) Also I think of this tree mostly as a collection of patches that will hopefully
44d398faf45e0 (Emil Renner Berthing 2021-05-05 20:03:04 +0200 133) mature enough to be submitted upstream. So expect regular rebases.