top of page
Writer's pictureAnup Halarnkar

Bring up Yocto for RISC-V deployment

Updated: Dec 3


Yocto Logo

What is YOCTO

We at Whileone Techsoft pvt ltd understood the requirements of our customer who wanted to have a basic Yocto based RiscV deployment for their custom SoC chip. The customer intended to share this basic deployment with their clients who wished to make use of our customer’s SoC in their products. 


Our customer was unaware of Yocto and what was needed to ensure a favorable deployment. They had their own custom patched Linux kernel, Root file system, Toolchain and custom Bootloader and a custom simulator as well to boot the final image. Their client insisted on Yocto instead of their default BuildRoot deployment.


As Yocto has its own tools, compiler and dependencies, the challenge was to ensure the final Image generated by Yocto was compatible enough to be run by their custom simulator.


Introduction to Yocto:


Overview of Yocto

With the Opensource Yocto Project, we can create custom Linux based systems for embedded products. It is quite possible to tailor the Linux images as per requirements with a set of flexible tools and friendly customizable scripts. Yocto provides a reference embedded distribution called ‘Poky’ that was used for this project



Poky

Kernel Version Compatibility Check

The customer’s custom patched Linux Kernel was of a much smaller version than the current that was available in the kernel.org website. So, initially when we went with the latest Yocto version (Mickledore, v4.2) which featured GCC compiler version 12.x, we got errors during Kernel build. The errors pointed to some unknown assembly instructions. The reason was that our custom kernel version was old and it wasn’t updated. As the Customer was already using GCC 11.x in their build infrastructure, we did a search for a match of Yocto version that provided the nearest GCC 11.x and that was found to be Yocto Honister (v3.4). Initial test build was successful with Honister and so we finalized this version before moving ahead.



Finding right Yocto Version

Bitbake

Yocto uses Bitbake as its build tool. So, whenever we plan to create recipes in Yocto, we should create a separate folder inside poky that starts with “meta-<custom name>” as per the Yocto manual. Also, referring to similar meta folders like meta, meta-yocto-bsp, meta-poky; we came up with our own “meta-riscv-custom”.


Creating custom Meta Layer

To add a new meta layer, make use of bitbake commands, such as the one given below,


$> bitbake-layers add-layer meta-riscv-custom

Yocto Configuration options:


Yocto Configuration options

As we were using the sample Poky distribution of Yocto and to let Poky know that we intend to use our custom “meta-riscv-custom” folder in the build process, we have to update a file “bblayers.conf” in the build/conf directory. This build/conf directory is generated after we initialize the environment by executing “source oe-init-build-env” in the Poky root folder.

Also, we have to modify the variable “MACHINE” among others in the location “build/conf/local.conf” to “qemuriscv64” and comment out the default value.

There are other options in the file “local.conf” that we can modify to get image output in a desired format. The variable IMAGE_FSTYPES = “tar cpio” will generate the image in both tar and cpio formats. This is especially useful when we want to generate a root file system in this format.


Creating recipes:


Creating Recipes

Recipes are like script files that are created under the meta-<name> folders. Files like riscv-linux.bb which is a recipe for building Linux kernel, riscv-boot.bb for building bootloader and so on.


YOCTO configuration options

Custom changes:


Custom Directory and File Creation

The customer was also interested to know how one could add a custom directory and files and make custom changes to existing files in the file system.

Yocto has its own package group recipe file “packagegroup-core-boot.bb” that can be modified. For example,


1. We can disable UDEV by commenting it out

2. Similarly, we can also comment out HWCLOCK in the same file

To create a custom folder “custom-riscv” inside root (“/”) and a file named “custom.conf” with some configuration options and comments, we had to modify a recipe file “base-files_3.0.14.bb”.



Package Group


Custom Changes 1


Custom Changes 2



Custom Conf

Build:


Build the project

Yocto uses Bitbake as its build tool. To build, we make use of the following commands.


$> bitbake -cclean riscv-linux
$> bitbake riscv-linux

The above command skips the extension “.bb”. Also, if we had not added the folder path of “meta-riscv-custom” to bblayers.conf, then we would get an error here after running the above command.


Build artifacts:


Build Artifacts

The artifacts are generated in the work directory under the path,

Poky/build/tmp/work/riscv64-poky-linux/riscv-linux/1.0-r0/custom-linux/*

22 views0 comments

Recent Posts

See All

Comments


bottom of page