-
Notifications
You must be signed in to change notification settings - Fork 23
RISCV hardware testing
- RISCV SiFive HiFive Unleashed SBC.
- A working linux desktop or Laptop. (This tutorial was made based on running on a Ubuntu machine with i5 8th Gen x86 machine. Laptop Model Acer Switft 3) (Also tested on Dell XPS 13).
- Download the following files.
Item | Filename | URL |
---|---|---|
Prebuilt sifive disk image | demo-coreip-cli-freedom-u540-20200607233715.rootfs.wic.gz | https://drive.google.com/file/d/1Sl6jGANckoA0CppHtRA_LuTr34TGIi8p |
Popcorn Kernel patch | popcorn-kernel.diff | https://drive.google.com/file/d/1eIBaIqbhBD1GnGcPR0uS6omkYl7Bk0zg |
- We have to update the kernel in the laptop to v5.2.21. (Downgrade if the distro is up to date).
- Follow the steps below to change the laptop kernel with popcorn sub system.
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git && cd linux
$ git checkout v5.2.21
$ patch -p1 < popcorn-kernel.patch
(Use the right kconfig e.g., $cp kernel/popcorn/configs/config-x86_64-<HOST> .config)
$ make oldconfig
- Now we have a basic .config file for the laptop. -After this open the .config file and Enable the following switches
-- CONFIG_ARCH_SUPPORTS_POPCORN
- Disable all the following configurations in .config file
-- CONFIG_TRANSPARENT_HUGEPAGE
-- CONFIG_SWAP
-- CONFIG_CMA
-- CONFIG_KSM
-- CONFIG_MEM_SOFT_DIRTY
-- CONFIG_MIGRATION
-- CONFIG_COMPACTION
- After disabling these switches , we will be able to include popcorn into the kernel.
$ make -j24
$ sudo make modules_install
$ sudo make install
$ sudo update-grub
Make the following changes to your /etc/default/grub for safety , incase the kernel is corrupted.
-- Comment the lines with GRUB_HIDDEN*. (Use # for comments)
-- Change GRUB_TIMEOUT to -1. ( GRUB_TIMEOUT=-1)
- Now reboot your system to boot the popcorn kernel.
- Now you have a popcorn enabled kernel in your system.
- Easy Way If you do no want to do the 3 hour long build , then use the *.rootfs.wic.gz file downloaded.
$ zcat demo-coreip-cli-freedom-u540-*.rootfs.wic.gz | sudo dd of=/dev/sdd
bs=512K iflag=fullblock oflag=direct conv=fsync status=progress
- Complex Way The following steps is for bbuilding the rootfs image yourself.This build takes around 75GB and 2-3 hours of compilation , dependin on your system power.
- Yocto is used for building the kernel and ram-disk Image.
- The yocto build structure will look like below
riscv-sifive/
meta-openembedded/
meta-riscv/
meta-sifive/
openembedded-core/
- Follow the steps below to setup the Yocto enironment to build riscv.
$ mkdir riscv-sifive
$ cd riscv-sifive
$ repo init -u git://github.com/sifive/meta-sifive -b v201908-branch -m tools/manifests/sifive.xml
$ repo sync
$ cd meta-sifive
$ patch -p1 < meta-sifive-v201908-branch.diff
$ cd ../openembedded-core
$ patch -p1 < oe-v201908-branch.diff
$ cd ..
$ . ./meta-sifive/setup.sh
$ MACHINE=freedom-u540 bitbake demo-coreip-cli
$ zcat tmp-glibc/deploy/images/freedom-u540/demo-coreip-cli-freedom-u540-*.rootfs.wic.gz | sudo dd of=/dev/sdd
bs=512K iflag=fullblock oflag=direct conv=fsync status=progress
-
Warning : Make sure to point to the right device for the SD card in the last step. Pointing to a wrong device can destroy the system. (dd == device destroy)
-
With the above steps you can insert the SD card into the SiFive Hifive board.Provide the board with a ethernet connection. Either through USB or secure shell connect to the Sifive Board.
Do the following in both the x86 system and the Sifive board.
- Create a folder /etc/popcorn
- Create a file /etc/popcorn/nodes
- Both the files must contain identical nodes file. The file must contain x86's IP address in the first line and riscv ip address in seccond line.
Example:
$ cat /etc/popcorn/nodes
10.4.4.100
10.4.4.101
This must be the file in both machines. Very imporrtant.
10.4.4.100 --> Suppose x86 machine's IP is
10.4.4.101 --> Suppose riscv board's IP is
Now execute the following command in both the machines:
In the sifive board : root@freedom-u540:~# modprobe msg_socket
In the x86 machiens : user@x86 # modprobe msg_socket
- If all works fine you are set with environment.
Warning : You must ensure that the applications are present in identical locations in both machines.
- Refer this Wiki on how get the applications compiled for x86<->riscv https://github.com/ssrg-vt/popcorn-kernel/wiki/RISCV-VM-testing-of-popcorn
-The steps to follow in that Wiki :
- Compiling the RISCV GNU toolchain. Link --> https://github.com/ssrg-vt/popcorn-kernel/wiki/RISCV-VM-testing-of-popcorn#compiling-the-riscv-gnu-toolchain
- Compiling the popcorn compiler with riscv support. Link --> https://github.com/ssrg-vt/popcorn-kernel/wiki/RISCV-VM-testing-of-popcorn#compiling-the-popcorn-compiler-with-riscv-support
- Compiling NPB applications for testing --> https://github.com/ssrg-vt/popcorn-kernel/wiki/RISCV-VM-testing-of-popcorn#compiling-npb-applications-for-testing
Executing the applications on x86 <-> RISCV environment(Appication needs to be in identical locations in both machines)
- Refer this Wiki on how to run the applications on x86<->riscv hardwares . Link --> https://github.com/ssrg-vt/popcorn-kernel/wiki/RISCV-VM-testing-of-popcorn#testing-the-x86---riscv-popcorn-system