How to boot Linux on SHAKTI SoC?

  • Post author:
  • Reading time:8 mins read
  • Post category:Tutorials
You are currently viewing How to boot Linux on SHAKTI SoC?

Linux is a widely used open-source Operating system. Though originally Linux was developed for desktop computers. For instance, fedora, Debian, Ubuntu, etc. We cannot install these Linux distributions on embedded systems because there are lots of changes from desktop PC environments to embedded systems. The major difference is embedded systems don’t support BIOS, unlike desktop PC. They are resource-constrained and hence can’t run the bulky OS. They are battery-operated and require real-time performance.

So a minimal Linux was used in these embedded systems. In this article, we are going to see how to boot Linux on Shakti SoC vajra

Step 1: Setting up the Build Environment 

  1. Clone the latest RISC-V tool chain
$ git clone --recursive
  1. Then, install the necessary packages,
$ sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
  1. Then, install the tool chain,

Pick an install path. If you choose, say, /opt/riscv, then add /opt/riscv/bin to your PATH now. Then simply run the following command,

$ cd riscv-gnu-toolchain
$ ./configure --prefix=/opt/riscv --with-arch=rv64imac --with-abi=lp64  --with-cmodel=medany
$ sudo make && sudo make linux

Once the above steps are completed you can find the cross-compile and bare metal binaries in the respective path ‘/opt/riscv/bin‘.

For instance,

export PATH=$PATH:/opt/riscv/bin
#As we need OpenOCD, path to shakti-tools openocd

Note: Please delete or comment all the other shakti or riscv tool chains you might have installed in your system.

Assuming you have added it to the PATH variable you can proceed to build linux.

Step 2: Getting started on Linux Development

  • Firstly, clone the linux-devkit repository.
$ git clone --recursive

Note: shakti-software is currently a private repository. Please login or sign up to Gitlab and request access here before using any repository.

The development package Supports C-Class 64bit Core, here we use Vajra which boots linux on top of Proxy Kernel.

Step 3: Rapid deployment using BBL as a boot loader

Linux can be built as a payload to BBL by doing the below command. As shakti C-Class is based on RV64IMAC, we alter the config file.

Note: For all extensions(I,M,A,F,D,C) you can skip this step.

Location : <Your linux-devkit dir>/buildroot/package/busybox/busybox.config

CONFIG_EXTRA_CFLAGS="-g -march=rv64imac -mabi=lp64"
CONFIG_EXTRA_LDFLAGS="-g -march=rv64imac -mabi=lp64"

Once the above is done, please build it.

cd linux-devkit
make bbl

Step 4: Using SOC to Boot Linux

Currently the Linux kernel boots on ARTY A7 100t with C-Class (vajra). Assuming you have programmed the board with vajra and ready to deploy the bbl.

Open three terminals,

  • Firstly, open serial monitor using miniterm with a baud rate of 19200 and port as /dev/ttyUSB
sudo /dev/ttyUSB1 19200
  • Then, connect to the board using OpenOCD,
cd ~/shakti-sdk/bsp/third_party/vajra
sudo $(which openocd) -f ftdi.cfg
  • Also, connect to riscv64-unknown-elf-gdb
(gdb) set remotetimeout unlimited
(gdb) target remote localhost:3333
(gdb) file path/to/linux-devkit/bootloaders/riscv-pk/build/bbl 
(gdb) load #takes a lot of time
(gdb) x/10x 0x80000000
(gdb) c

Output in miniterm

Login ID : root
Password : shakti
Fig. Linux after login

Commonly faced Errors

  1. Unhandled signal error occurs as soon as we load the bbl. 

Solution: This occurs when the tool chain is not properly installed. Check if rv64imac tool chain is installed correctly. Then “make clean” and “make bbl” inside the linux-devkit repository. Then try again.

Fig. Error 1

This Post Has 2 Comments

  1. Rakesh Khandelwal

    I think Desktop is a very critical & vast market for Processors & it would really help if we get a SOC for S-class with say 2gb/4gb ram…it can trigger massive movement for Custom linux distros…& the potential would force motherboard providers to provide commercial options also…
    Indian Linux distro Aryalinux ( already uses source build chains for end user experience…would love to see AryaShakti boot up with gnome / xfce…
    Hopefully soon..

    1. Akshaya B

      Yeah Hopefully soon!

Comments are closed.