Skip to content

RISCV hardware testing

AshwinKrishn edited this page Jun 18, 2020 · 19 revisions

Hardware required

  • 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 patch files and support files

Setting up the x86 Machine

  • 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.diff
  $ 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 
-- CONFIGKSM
-- 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
  $ sude 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.

Setting up the Sifive board

  • Easy Way If you do no want to do the 3 hour long build , then use the *.rootfs.wic.gz file present in the riscv_support_dir. In this case just navigate to the riscv_support_drectory and execute only this command.
$ 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.

Setting up the machines

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

Setting up messaging layer

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.

Compiling applications for x86<-> riscv

-The steps to follow in that Wiki :

  1. Compiling the RISCV GNU toolchain. Link --> https://github.com/ssrg-vt/popcorn-kernel/wiki/RISCV-VM-testing-of-popcorn/_edit#compiling-the-riscv-gnu-toolchain

  2. Compiling the popcorn compiler with riscv support. Link --> https://github.com/ssrg-vt/popcorn-kernel/wiki/RISCV-VM-testing-of-popcorn/_edit#compiling-the-popcorn-compiler-with-riscv-support

  3. Compiling NPB applications for testing --> https://github.com/ssrg-vt/popcorn-kernel/wiki/RISCV-VM-testing-of-popcorn/_edit#compiling-npb-applications-for-testing

Executing the applications on x86 <-> RISCV environment