This repository contains all the glue for building a Yocto image that can be run on BlackParrot.
Should be as easy as:
- Put
riscv64-unknown-linux-gnu-
toolchain on yourPATH
(considerPATH=$PATH:/path/to/bp-sdk/install/bin
) - Run
make
.
Make sure you checkout submodules; the Makefile doesn't do it for you.
- Make sure
dromajo
is on yourPATH
. make run_dromajo
.
First, if you're on kk9, you need to do some things the Makefile takes care of for you.
make work/bin/tar
and put work/bin/ on yourPATH
. The CentOS version oftar
is too old.- Run
ulimit -u 32768
. This fixes a "resource temporarily unavailable" error.
Next, set up the Poky environment.
- Have your working directory be the root of this repository (the one with
bp-yocto-layer
,Makefile
,poky
, and friends in it). source poky/oe-init-build-env
. This will change your working directory for you, which is a little confusing.- Edit
./conf/local.conf
(in the build directory that you got changed into) and setMACHINE = "blackparrot"
. An environment variable would also work, but if you do this then you'll never be confused by having forgotten to set the environment variable. - Make sure the bitbake layers are set up.
make build/conf/bblayers.conf
will do this for you. - You're now good to go and can use bitbake directly.
Some useful things to do with bitbake:
bitbake core-image-minimal
, to build a somewhat leaner image.bitbake -c cleansstate <package>
(clean-s-state, not clean-state), which is the equivalent ofmake clean
'ing a particular package.bitbake linux-stable
to build just the kernel.bitbake opensbi
to build just OpenSBI.
build/conf/local.conf
- Configuration for your current build. It's helpful to setMACHINE = blackparrot
in here.build/conf/bblayers.conf
- Specifies which layers affect the current build. It's important to havebp-yocto-layer
as well asmeta-linux-mainline
in here. You can manipulate this with thebitbake-layers
command.build/tmp/deploy/images/blackparrot
- This is where the build artifacts go. This is the Good Stuff that you probably want.build/tmp/work/blackparrot-poky-linux/*/
- Sources and build directories for each package.build/tmp/work/blackparrot-poky-linux/linux-stable/5.15.24-r0/build/vmlinux
- Kernel ELF, helpful for debugging.bp-yocto-layer/recipes-bsp/opensbi/opensbi_git.bb
- Build parameters for opensbi come from here, including PLATFORM_RISCV_ISA, PLATFORM_HART_COUNT.bp-yocto-layer/recipes-kernel/linux/linux-stable_%.bbappend
- Manifest for kernel patches and configuration. Start here if you want to change kernel patches/config/device tree.bp-yocto-layer/conf/machine/blackparrot.conf
- Selects kernel version, SBI platform, SBI device tree, and SBI payload.
- Clone Linux sources somewhere
- Checkout v5.15
- Apply patches from
bp-yocto-layer/recipes-kernel/linux/files/blackparrot/
- Modify (or add new) device trees in
arch/riscv/boot/dts/blackparrot/
- Commit (or amend previous commit)
- Use
git-format-patch v5.15
to create new patch files. - Copy them back into
bp-yocto-layer/recipes-kernel/linux/files/blackparrot/
- If you added a new patch file, you need to list it in
bp-yocto-layer/recipes-kernel/linux/linux-stable_%.bbappend
Oneliner: bitbake linux-stable && bitbake -c cleansstate opensbi && bitbake opensbi
.
- Rebuild the kernel to compile the device trees with
bitbake linux-stable
. Bitbake will notice that you changed the sources (patches count as sources) and Do the Right Thing. - OpenSBI slurps the device trees out of the "deploy" directory in
build/tmp/deploy/
, and doesn't have a real dependency on them, so bitbake does not Do the Right Thing here and you need to rebuild it from scratch. 10.a.bitbake -c cleansstate opensbi
(not that this is clean-s-state, not clean-state). 10.b.bitbake opensbi
$ dtc -I dts -O dtb -o ../yocto_repro/build/tmp/deploy/images/blackparrot/bp-1hart--5.15.24-r0-blackparrot-20220322003612.dtb arch/riscv/boot/dts/blackparrot/bp-1hart.dts
$ bitbake -c cleansstate opensbi && bitbake -c deploy opensbi
- The
%
sign in a.bbappend
filename acts as a wildcard so it will apply to any version. - Even though the device trees are part of the kernel sources, they get slurped into OpenSBI and not the kernel. The yocto build process has a special procedure where it copies a device tree named by the
KERNEL_DEVICETREE
variable into thedeploy/images
directory, which OpenSBI finds through a combination ofRISCV_SBI_FDT
and some Python glue inopensbi-payloads.inc
. - OpenSBI includes the kernel and device tree because it's built in FW_PAYLOAD mode, but it doesn't have a dependency on the kernel. Stay mindful of this. If you change the kernel and need to force an OpenSBI rebuild, use
bitbake -c cleansstate opensbi
. - If you need to increase the size of the mtd-ram rootfs, follow the above procedure to modify the device tree, then tweak the link script (
final_link.T
) accordinly.
This appears in the middle of a giant Python error. You probably forgot ulimit -u 32768
.