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
- Clone the latest RISC-V tool chain
$ git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
- 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
- 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 ‘
export PATH=$PATH:/opt/riscv/bin #As we need OpenOCD, path to shakti-tools openocd SHAKTITOOLS=/home/akshaya/shakti-tools export PATH=$PATH:$SHAKTITOOLS/bin
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
Step 2: Getting started on Linux Development
- Firstly, clone the
$ git clone --recursive https://gitlab.com/shaktiproject/software/linux-devkit.git
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
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.
<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
minitermwith a baud rate of 19200 and port as /dev/ttyUSB
sudo miniterm.py /dev/ttyUSB1 19200
- Then, connect to the board using
cd ~/shakti-sdk/bsp/third_party/vajra sudo $(which openocd) -f ftdi.cfg
- Also, connect to
(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
Commonly faced Errors
- 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.
Akshaya currently works at the RISE labs. Her favorite subjects are Web designing and Microprocessors. She loves learning about new things and writing about them!
This Post Has 2 Comments
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 (https://sourceforge.net/projects/aryalinux/) already uses source build chains for end user experience…would love to see AryaShakti boot up with gnome / xfce…
Yeah Hopefully soon!
Comments are closed.