User Tools

Site Tools


developers:env_prepare

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
developers:env_prepare [2018/10/22 15:38]
mick
developers:env_prepare [2019/04/10 20:30] (current)
mick [riscv-gnu-toolchain how to]
Line 22: Line 22:
 These settings are used for sending patches and patchsets through email These settings are used for sending patches and patchsets through email
  
-=== SMTP server ​configuration ​===+=== 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 [[https://​support.google.com/​mail/​answer/​185833?​hl=en | app-specific password]]. 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 [[https://​support.google.com/​mail/​answer/​185833?​hl=en | app-specific password]].
Line 48: Line 48:
 ==== Your preferences ==== ==== 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 ​d+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.
  
 <​code>​ <​code>​
Line 60: Line 60:
 $ git config --global merge.tool meld $ git config --global merge.tool meld
 $ git config --global mergetool.prompt false $ git config --global mergetool.prompt false
 +</​code>​
 +
 +===== Prepare the toolchain =====
 +
 +For building the Linux kernel on RISC-V, you'll need a recent toolchain. You may use [[https://​crosstool-ng.github.io/​docs/​ | Crosstool-NG ]] with the [[https://​github.com/​crosstool-ng/​crosstool-ng/​tree/​master/​samples/​riscv64-unknown-linux-gnu | riscv64-unknown-linux-gnu ]] sample, using source code from upstream gcc/​binutils/​glibc or using the [[https://​github.com/​riscv/​riscv-gnu-toolchain | riscv-gnu-toolchain]] repository. Your distribution may also provide cross-toolchains,​ e.g. [[https://​packages.debian.org/​sid/​gcc-riscv64-linux-gnu | debian]].
 +
 +==== Crosstool-NG how to ====
 +
 +Install the [[https://​crosstool-ng.github.io/​docs/​os-setup/​ | dependencies]] for your distro
 +
 +Get the latest crosstool-ng source from github (the current releases don't contain the riscv samples)
 +<​code>​
 +$ git clone https://​github.com/​crosstool-ng/​crosstool-ng
 +</​code>​
 +
 +Run the bootstrap script
 +<​code>​
 +$ ./bootstrap
 +</​code>​
 +
 +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)
 +<​code>​
 +$ ./configure --enable-local
 +$ make
 +</​code>​
 +
 +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).
 +<​code>​
 +$ ./ct-ng riscv64-unknown-linux-gnu
 +$ ./ct-ng menuconfig
 +</​code>​
 +
 +Finally start the build process
 +<​code>​
 +$ ./ct-ng build
 +</​code>​
 +
 +==== 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 [[https://​github.com/​riscv/​riscv-gnu-toolchain/​blob/​master/​README.md | README]] file on the riscv-gnu-toolchain repository. Assuming you have your host's build environment ready it's straight-forward:​
 +
 +<​code>​
 +$ git clone --recursive https://​github.com/​riscv/​riscv-gnu-toolchain
 +$ cd riscv-gnu-toolchain
 +$ ./configure --prefix=<​install directory>​
 +$ make linux
 +</​code>​
 +
 +<WRAP Tip>
 +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.
 +</​WRAP>​
 +
 +<WRAP Info>
 +=== 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.
 +</​WRAP>​
 +
 +<WRAP Info>
 +=== musl-based toolchain ===
 +
 +It is possible to build a toolchain based on musl libc, to do this clone https://​github.com/​riscv/​riscv-musl.git on the risc-gnu-toolchain top directory and use musl32 and musl64 targets. Note that musl doesn'​t support multi-lib.
 +
 +<​code>​
 +$ cd riscv-gnu-toolchain
 +$ git clone --recursive https://​github.com/​riscv/​riscv-musl.git
 +$ ./configure --prefix=<​install directory>​
 +$ make musl<​xlen>​
 +</​code>​
 +</​WRAP>​
 +==== Using the toolchain ====
 +
 +Now that you are done, you should add <install directory>/​bin to your PATH
 +<​code>​
 +$ export PATH="​${PATH}:<​install directory>/​bin"​
 +</​code>​
 +
 +You should now be able to execute the toolchain binaries directly, here is an example of the available commands:
 +
 +<​code>​
 +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
 </​code>​ </​code>​
developers/env_prepare.1540211936.txt.gz ยท Last modified: 2018/10/22 15:38 by mick