Linux is a widely used open-source Operating systems. 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 environment to embedded systems. The major differences are embedded systems don’t support BIOS unlike desktop PC. They are resource constrained and hence can’t run 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 ‘
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
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, connect to the board using
cd ~/shakti-sdk/bsp/third_party/vajra sudo $(which openocd) -f ftdi.cfg
- Then, open serial monitor using
minitermwith a baud rate of 19200 and port as /dev/ttyUSB
sudo miniterm.py /dev/ttyUSB1 19200
- 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!