User Tools

Site Tools


Set up git

Setting up git is pretty straight-forward. Git configuration can be done per repository -local configuration-, per user -global configuration- and per host -system configuration-. Local configuration is stored in the repository at .git/config, global configuration at ~/.gitconfig and system configuration at /etc/gitconfig (depends on your distro). In the examples below we'll assume you are setting up git for your user, so we'll set up the global configuration.

Your identity

Let's begin by telling git your name and e-mail address. This will be used on commit logs and when sending e-mails through git send-email.

$ git config --global "John Doe"
$ git config --global

Optionally you may also add your PGP key fingerprint, this is useful if you maintain your own tree and want to guarantee its integrity. For more information on this, check out the kernel maintainer's pgp guide

$ git config --global user.signingKey <key fingerprint / key id>

Your mail settings

These settings are used for sending patches and patchsets through email

SMTP server settings

These settings are used by git send-email, this is the most common way of sending patches, you may contact the SMTP server directly or through a local MTA. Note that you may also store your password here but it's not a good idea since it will be stored in plaintext. So leave it unset and git send-email will ask you for it. If you use Gmail you may use an app-specific password.

$ git config --global sendemail.smtpencryption tls
$ git config --global sendemail.smtpserver
$ git config --global sendemail.smtpuser
$ git config --global sendemail.smtppass myPass (DANGEROUS)
$ git config --global sendemail.smtpserverport 587

IMAP server settings

These settings are used by git imap-send when instead of an SMTP server, where an IMAP server or a local IMAP folder is used. This approach is not that common and the invocation of git imap-send won't be covered here, you may check out its man page for more infos.

$ git config --global imap.folder INBOX.Drafts
$ git config --global imaps://
$ git config --global imap.user
$ git config --global imap.pass myPass (DANGEROUS)
$ git config --global imap.port 993

Your preferences

Git allows you to use your favourite tools, in this example we'll use more for pager, nano for editor and meld for diff/merge. In order to use meld instead of the pager for displaying diffs. Note that for using the external tool for diff/merge you should use the git difftool/mergetool command instead of git diff.

$ git config --global core.pager "more"

$ git config --global core.editor "nano -w"

$ git config --global diff.tool meld
$ git config --global difftool.prompt false

$ git config --global merge.tool meld
$ git config --global mergetool.prompt false

Prepare the toolchain

For building the Linux kernel on RISC-V, you'll need a recent toolchain. You may use Crosstool-NG with the riscv64-unknown-linux-gnu sample, using source code from upstream gcc/binutils/glibc or using the riscv-gnu-toolchain repository. Your distribution may also provide cross-toolchains, e.g. debian.

Crosstool-NG how to

Install the dependencies for your distro

Get the latest crosstool-ng source from github (the current releases don't contain the riscv samples)

$ git clone

Run the bootstrap script

$ ./bootstrap

Configure and build Crosstool-NG for local execution, so that you don't have to install it, this way everything will be done on its source directory (easier to clean it up after you are done)

$ ./configure --enable-local
$ make

Tell Crosstool-NG to use the proper sample and then do a menuconfig for further fine-tuning (e.g. set CT_PREFIX_DIR, where the toolchain should be installed).

$ ./ct-ng riscv64-unknown-linux-gnu
$ ./ct-ng menuconfig

Finally start the build process

$ ./ct-ng build

riscv-gnu-toolchain how to

Note that this method is mostly intended for developers that want to play with the toolchain, it's not considered stable. In case you are interested you may follow the README file on the riscv-gnu-toolchain repository. Assuming you have your host's build environment ready it's straight-forward:

$ git clone --recursive
$ cd riscv-gnu-toolchain
$ ./configure --prefix=<install directory>
$ make linux

You may build a multi-lib toolchain (that can create both 32bit and 64bit binaries) by using the –enable-multilib argument on the configure command above.

newlib-based toolchain

Similar to the GNU-based toolchain, you may build a newlib-based toolchain by just typing make instead of make linux above. Make sure you use a different prefix path.

musl-based toolchain

It is possible to build a toolchain based on musl libc, to do this clone on the risc-gnu-toolchain top directory and use musl32 and musl64 targets. Note that musl doesn't support multi-lib.

$ cd riscv-gnu-toolchain
$ git clone --recursive
$ ./configure --prefix=<install directory>
$ make musl<xlen>

Using the toolchain

Now that you are done, you should add <install directory>/bin to your PATH

$ export PATH="${PATH}:<install directory>/bin"

You should now be able to execute the toolchain binaries directly, here is an example of the available commands:

riscv64-unknown-linux-gnu-addr2line  riscv64-unknown-linux-gnu-elfedit    riscv64-unknown-linux-gnu-gcc-ranlib  riscv64-unknown-linux-gnu-gprof    riscv64-unknown-linux-gnu-ranlib
riscv64-unknown-linux-gnu-ar         riscv64-unknown-linux-gnu-g++        riscv64-unknown-linux-gnu-gcov        riscv64-unknown-linux-gnu-ld       riscv64-unknown-linux-gnu-readelf
riscv64-unknown-linux-gnu-as         riscv64-unknown-linux-gnu-gcc        riscv64-unknown-linux-gnu-gcov-dump   riscv64-unknown-linux-gnu-ld.bfd   riscv64-unknown-linux-gnu-run
riscv64-unknown-linux-gnu-c++        riscv64-unknown-linux-gnu-gcc-8.2.0  riscv64-unknown-linux-gnu-gcov-tool   riscv64-unknown-linux-gnu-nm       riscv64-unknown-linux-gnu-size
riscv64-unknown-linux-gnu-c++filt    riscv64-unknown-linux-gnu-gcc-ar     riscv64-unknown-linux-gnu-gdb         riscv64-unknown-linux-gnu-objcopy  riscv64-unknown-linux-gnu-strings
riscv64-unknown-linux-gnu-cpp        riscv64-unknown-linux-gnu-gcc-nm     riscv64-unknown-linux-gnu-gfortran    riscv64-unknown-linux-gnu-objdump  riscv64-unknown-linux-gnu-strip
developers/env_prepare.txt · Last modified: 2019/04/10 20:30 by mick