Input method in FreeBSD virtual terminal (Week1 & 2)

Date: 06/07-06/19

During these two weeks, I was preparing my kernel development environment, since this was the first time I tried to modify the freebsd kernel. Also I decided to take notes of the whole process of configuring the environment.

Environment Preparation

Building from Custom Source

Preparing Source

I forked FreeBSD source code on github:

And clone the project into /usr/src/. But /usr/src is a zfs dataset, we can not backup the old /usr/src by simply renaming it. So I copied it into other directory and remove all old files in usr/src then clone the source code.

cp /usr/src /usr/src.bak
cd /usr/src
rm -rf ./* ./.*

Download the source code:

git remote add origin
git fetch origin

Building and Installing Custom Source

To build the custom kernel, copy the GENERIC kernel config file first:

cp /usr/src/sys/amd64/conf/GENERIC /root/MYKERNEL
cd /usr/src/sys/amd64/conf
ln -s /root/MYKERNEL .

But actually I didn't modify any configurations from GENERIC kernel config except for the ident column.


Now we are ready to build world and kernel:

First we need to install bear to index kernel source and generate compile_commands.json for LSP

pkg install py37-bear

Now we can build and install them:

cd /usr/src
make -DNO_CLEAN -j 8 buildworld
bear make -DNO_CLEAN -j 8 buildkernel KERNCONF=MYKERNEL
make installworld
make installkernel KERNCONF=MYKERNEL

After rebooting, use uname -a to check if our system version and the kernel profile are correct:

The results:

FreeBSD 14.0-CURRENT FreeBSD 14.0-CURRENT #1 tmp-n248823-ced2dcadccfc-dirty: Fri Aug 20 21:32:02 CST 2021  amd64


Developing on FreeBSD

Install clangd:

pkg install llvm12

Make an alias for clangd12:

ln -s clangd12 clangd

SummerOfCode2021Projects/InputMethodInFreeBSDVirtualTerminal/Week1&2 (last edited 2021-08-23T04:38:17+0000 by LiWenHsu)