Skip to content

Instantly share code, notes, and snippets.

@eballetbo
Last active October 11, 2023 10:50
Show Gist options
  • Save eballetbo/ac65b1ca12ed4ac98496ae17ed9f8f98 to your computer and use it in GitHub Desktop.
Save eballetbo/ac65b1ca12ed4ac98496ae17ed9f8f98 to your computer and use it in GitHub Desktop.

Kernel development notes

Compiling and Building the Package

NOTE: Clean up before rebuilding

Example for x86_64:

$ make x86_64_defconfig
$ make deb-pkg LOCALVERSION=-foo KDEB_PKGVERSION=$(make kernelversion)-1

Example for armhf (cross compilation):

$ make multi_v7_defconfig
$ make deb-pkg ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOCALVERSION=-foo KDEB_PKGVERSION=$(make kernelversion)-1

If you want to build the package without clean the kernel you can use bindeb-pkg instead.

$ make bindeb-pkg ...

Speeding up cross-compiling with ccache

Install the c compiler cache, i.e

$ apt-get install ccache

Add symlinks so ccache can invoke the compiler, /usr/local/bin is usually in the path before /usr/bin, so that is where we put the symlinks. The CROSS_COMPILE environment variable should be empty native builds, it could be something like arm-linux-gnueabihf- for cross-building on a host.

$ cd /usr/local/bin
$ ln -s $(which ccache)  $(echo $CROSS_COMPILE)gcc
$ ln -s $(which ccache)  $(echo $CROSS_COMPILE)g++
$ ln -s $(which ccache)  $(echo $CROSS_COMPILE)cpp
$ ln -s $(which ccache)  $(echo $CROSS_COMPILE)c++

Setup environment variables. You may want to add these to your .bashrc file so they are applied for each new shell

$ export CCACHE_DIR=/home/$USER/.ccache
$ export CCACHE_HASHDIR=$CCACHE_DIR

Note: To clear the ccache

$ ccache -c

Show commit per author

git shortlog v4.6..v4.7 --author='collabora' -nse

or without -nse to see the patches

git shortlog v4.6..v4.7 --author='collabora'

How do I “git blame” a deleted line?

git log -S <string> path/to/file

Show commit per signed-off when author is different

git shortlog v4.11..v4.12-rc7 --perl-regexp --author='^((?!Enric Balletbo i Serra <enric.balletbo@collabora.com>).*)$' --grep "Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>"

Prepend all commit messages in interactive rebase

git -c core.editor='sed -i "1s/^/PREFIX: /"' -c sequence.editor=vim rebase -i abcdef

Creating and alias to tag commit FROMLIST

git config --global alias.tag-fromlist "-c core.editor=\"sed -i '1s/^/FROMLIST: /'\" -c sequence.editor=vim rebase -i"

Then, run with:

git tag-fromlist <commit sha>

Adding Reviewed-by and Acked-by Tags with Git

How download complete patch series from patchwork?

https://www.collabora.com/news-and-blog/blog/2019/04/18/quick-hack-git-pw/

or the old way

i.e Get the list of patches

pwclient list -w <submitter> -s New "<search-string>"

i.e Get the list of patches and apply the patches

pwclient list -w <submitter> -s New -f %{id} "<search-string>" | egrep '^[0-9]' | xargs pwclient git-am
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment