Differences between revisions 55 and 58 (spanning 3 versions)
Revision 55 as of 2018-04-09 20:54:16
Size: 29118
Editor: ?VagrantCascadian
Comment: Add section on using merged repository with debootstrap and qemu-user-static
Revision 58 as of 2018-04-10 01:12:36
Size: 29143
Editor: ?VagrantCascadian
Comment: updated debootstrap instructions, as --variant=minbase is no longer needed
Deletions are marked like this. Additions are marked like this.
Line 187: Line 187:
=== Installing with apt ===
Line 193: Line 195:
The repository is signed by vagrant, key available in the debian-keyring package. The repository is signed by vagrant, key available in the
debian-keyring package.

=== Manual Installation ===
Line 291: Line 295:
==== Creating a chroot with qemu-user-static, debootstrap and merged repository ==== ==== Creating a chroot with debootstrap and merged repository ====
Line 304: Line 308:
}}}
 debootstrap --arch=riscv64 --variant=minbase --include=debian-ports-archive-keyring --keyring=/usr/share/keyrings/debian-keyring.gpg sid ROOT https://people.debian.org/~vagrant/debian-riscv64/
{{{
 debootstrap --arch=riscv64 --include=debian-ports-archive-keyring --keyring=/usr/share/keyrings/debian-keyring.gpg sid ROOT https://people.debian.org/~vagrant/debian-riscv64/

This page contains details about a port of Debian for the RISC-V architecture called riscv64.

In a nutshell

What is RISC-V?

From the Wikipedia entry for RISC-V:

RISC-V (pronounced "risk-five") is an open source instruction set architecture (ISA) based on established reduced instruction set computing (RISC) principles.

In contrast to most ISAs, RISC-V is freely available for all types of use, permitting anyone to design, manufacture and sell RISC-V chips and software. While not the first open ISA, it is significant because it is designed to be useful in modern computerized devices such as warehouse-scale cloud computers, high-end mobile phones and the smallest embedded systems. Such uses demand that the designers consider both performance and power efficiency. The instruction set also has a substantial body of supporting software, which fixes the usual weakness of new instruction sets.

The project was originated in 2010 by researchers in the Computer Science Division at UC Berkeley, but many contributors are volunteers and industry workers that are unaffiliated with the university.

There are different versions of the instruction set for 32, 64 and 128 bits; operating as little-endian by default.

What is a Debian port?

In short, a port in Debian terminology means to provide the software normally available in the Debian archive (over 20,000 source packages) ready to install and run on systems based in a given computer architecture with the Linux kernel, or kernel-architecture combinations, with other kernels including GNU Mach (from GNU/Hurd) and kFreeBSD (from GNU/kFreeBSD).

See https://www.debian.org/ports/ and DebianPorts for more information.

What are the goals of this project in particular?

In this project the goal is to have Debian ready to install and run on systems implementing a variant of the RISC-V ISA:

  • Software-wise, this port will target the Linux kernel

  • Hardware-wise, the port will target the 64-bit variant, little-endian

This ISA variant is the "default flavour" recommended by the designers, and the one that seems to attract more interest for planned implementations that might become available in the next few years (development boards, possible consumer hardware or servers).

While 32-bit and 128-bit implementations are possible, there are problems with this:

  • In the context of RISC-V design, they have not been explored as deeply, and tools and resources (e.g. simulators, research cores) as not as well studied and adapted;
  • For general purpose computers, the focus shifted to 64-bit for many years already, and there isn't a lot of interest in 32-bit architectures except for specific purposes;
  • 32-bit ports in Debian already struggle to compile some large packages of the archive in the last few months/years, a problem that will become worse with time;
  • and 128 is simply not realistic at this time.

Progress

Percentage of packages that build on RISC-V (bottom right, grey line)

progress chart

Upstream project / Architecture / Hardware

Upstream project / Community

Architecture details

Hardware

FPGA implementations

There are freely available softcores which can be synthesized to an FPGA, such as Rocket, a 64-bit RISC-V in-order core (optionally including an MMU and an IEEE 754-2008-compliant FPU).

ASIC implementations, i.e. "real" CPU chips

  • At FOSDEM 2018, working production samples of the SiFive "Freedom U540" SoC (quad-core RV64GC) and a corresponding development board ("HiFive Unleashed") have been presented. As of February 2018, availability of a limited number of boards from the first production run is planned for March 2018; general availability is planned for end of June 2018.

  • For the future further RISC-V-based ASICs are expected, among them a SoC from the lowRISC project, which has described itself as follows:

"lowRISC is a not-for-profit organisation working closely with the University of Cambridge and the open-source community.
lowRISC is creating a fully open-sourced, Linux-capable, RISC-V-based SoC, that can be used either directly or as the basis for a custom design. [...]
Our open-source SoC (System-on-a-Chip) designs will be based on the 64-bit RISC-V instruction set architecture. Volume silicon manufacture is planned as is a low-cost development board. [...]"

Toolchain upstreaming status

  • binutils: upstreamed (2.28 is the first release with RISC-V support)
  • gcc: upstreamed (7.1 is the first release with RISC-V support)
  • glibc: upstreamed (2.27 is the first release with RISC-V support)
  • linux kernel: upstreaming in progress (the architecture core code is in kernel 4.15; for full system support additional driver code is necessary which is planned to go into kernel 4.16/4.17)
  • gdb: not upstreamed yet
  • qemu: merged upstream, targets the 2.12 release. For more information about qemu please refer to the qemu section below.

Debian port information

Hardware baseline and ABI choice

The Debian port uses RV64GC as the hardware baseline and the lp64d ABI (the default ABI for RV64G systems).

Making the C extension a part of the default hardware baseline for general-purpose binary Linux distributions has been agreed upon between Fedora porters, Debian porters and members of the RISC-V foundation. According to the chairman of the board of the RISC-V foundation, the foundation will provide "a profile for standard RISC-V Unix platforms that will include C as mandatory".

Resources

Mailing list

IRC

  • irc.oftc.net / irc.debian.org (https://www.oftc.net/)

    • #debian-riscv
    • #debian-bootstrap (general port bootstrap efforts)

    • #lowRISC (not exactly Debian specific, but many interested people within Debian participate)

Bugs (BTS)

To: submit@bugs.debian.org
Subject: foo: FTBFS on riscv64

Package: foo
Version: 1.2.3-4
X-Debbugs-CC: debian-riscv@lists.debian.org
User: debian-riscv@lists.debian.org
Usertags: riscv64

The version of the package currently FBTFS on the riscv64 port:

  URL_of_the_log

or

To: control@bugs.debian.org
Subject: riscv64 usertags for #BUGNUMBER
CC: debian-riscv@lists.debian.org

user debian-riscv@lists.debian.org
usertag BUGNUMBER + riscv64
stop

or

To: BUGNUMBER@bugs.debian.org
Subject: Setting riscv64 usertags
CC: debian-riscv@lists.debian.org

Control: user debian-riscv@lists.debian.org
Control: usertag -1 + riscv64

Cross compilation

Pre-built toolchains

Since 2018-03-23 both gcc-7-based as well as gcc-8-based cross-toolchains targeting riscv64 are available in unstable. These include glibc and related basic libraries for riscv64 in arch:all packages. As those packages use different library paths than the corresponding "native" (i.e. arch:riscv64) packages and don't include some of the configuration that is part of their "native" counterparts, making full use of them for building packages in a multiarch configuration requires the following steps:

$ sudo dpkg --add-architecture riscv64
$ sudo apt-get install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
$ sudo cat >/etc/ld.so.conf.d/riscv64-linux-gnu.conf <<EOF
/usr/local/lib/riscv64-linux-gnu
/lib/riscv64-linux-gnu
/usr/lib/riscv64-linux-gnu
/usr/riscv64-linux-gnu/lib/
EOF
$ sudo ln -s /usr/riscv64-linux-gnu/lib/ld-linux-riscv64-lp64d.so.1 /lib

Building a toolchain with rebootstrap

Another option of getting a Debian multiarch-capable cross-toolchain for riscv64 is to build one locally with rebootstrap:

$ sudo apt-get install pbuilder
$ sudo pbuilder create --distribution unstable
$ git clone https://anonscm.debian.org/git/users/helmutg/rebootstrap.git
$ cd rebootstrap
$ mkdir -p /tmp/repo && sudo pbuilder execute --bindmounts /tmp/repo bootstrap.sh HOST_ARCH=riscv64 REPODIR=/tmp/repo GCC_VER=7

As pbuilder works in a throwaway chroot and deletes it again after it has finished, it is important to bind-mount the directory into which the created packages are to be placed ("/tmp/repo" in the example above) from the host filesystem into the chroot, as otherwise the freshly built packages would be deleted again when pbuilder removes the throwaway chroot. This can be achieved by either passing a "--bindmounts" parameter to pbuilder as above or by adding a BINDMOUNTS entry to pbuilderrc.

Rebootstrap supports building gcc-7-based and gcc-8-based cross-toolchains; just set the "GCC_VER" parameter accordingly. After the build process has finished, you can find a repository with a cross-toolchain and a number of cross-built packages in /tmp/repo. Don't worry when rebootstrap stops the build process with an error - that is expected as rebootstrap tries to build further packages after the toolchain is ready and some of those don't yet properly cross-build for riscv64.

Please note that you have to delete the repository directory ("/tmp/repo" in the example above) if you want to re-run rebootstrap as rebootstrap currently doesn't properly handle a pre-filled repository directory.

Qemu

Starting from 2018-03-09, upstream qemu git contains RISC-V support. In system-emulation mode, it implements a "virt" board that allows running upstream kernels with virtio block and network devices and a serial console, and a "spike"-compatible board.

893767 has been filed to enable riscv64 targets.

Installing with apt

A limited set of packages are available, including qemu-system-misc and qemu-user-static with riscv64 enabled, until the packaging is included in Debian:

 deb [signed-by=/usr/share/keyrings/debian-keyring.gpg] https://people.debian.org/~vagrant/debian-riscv64 UNRELEASED main

The repository is signed by vagrant, key available in the debian-keyring package.

Manual Installation

The Linux kernel has a very useful "binfmt-misc" feature that allows to transparently run foreign-architecture user-mode binaries with qemu. Debian supports this out-of-the-box for the release architectures with the qemu-user-static package; riscv64-support can be added as follows:

Build a static qemu binary with support for user-mode emulation:

$ git clone https://git.qemu.org/git/qemu.git
$ cd qemu
$ ./configure --static --disable-system --target-list=riscv64-linux-user
$ make
$ sudo cp riscv64-linux-user/qemu-riscv64 /usr/bin/qemu-riscv64-static

Create a binfmt-support config file and register it:

$ cat >/tmp/qemu-riscv64 <<EOF
package qemu-user-static 
type magic
offset 0
magic \x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00
mask \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff
interpreter /usr/bin/qemu-riscv64-static
EOF
$ sudo update-binfmts --import /tmp/qemu-riscv64

With this it is now possibe to transparantly run user-mode riscv64 binaries on another architecture:

$ uname -m
x86_64
$ file busybox 
busybox: ELF 64-bit LSB executable, UCB RISC-V, version 1 (SYSV), statically linked, for GNU/Linux 3.0.0, stripped
$ ./busybox touch foo
$ ls foo
foo

This also works in chroots if the /usr/bin/qemu-riscv64-static binary is available inside the chroot.

For the use of qemu in the bootstrap process of other ports, please see

Package repositories

Debian-Ports Repository

The Debian-Ports repository is now the main package repository for the Debian riscv64 port - unless there are special circumstances, this is the repository that should be used as the base for further work on the port. A basic set of riscv64 packages has been imported into Debian-Ports on the weekend of 2018-03-24/25 and there are autobuilders running to keep the repository up-to-date.

For accessing the Debian-Ports repository, please follow the instructions at https://www.ports.debian.org/archive. Example /etc/apt/sources.list:

 deb http://ftp.ports.debian.org/debian-ports/ sid main
 deb http://ftp.ports.debian.org/debian-ports/ unreleased main
 deb-src http://ftp.ports.debian.org/debian-ports/ sid main

Mirrors are available (please use them if possible): https://www.ports.debian.org/mirrors

Creating a riscv64 chroot from the Debian-Ports repository

Currently there are still a number of RISC-V-specific patches for essential packages that are only available in the "unreleased" suite, but not in the "unstable" suite. This poses a problem when trying to use debootstrap to build a riscv64 chroot due to the fact that debootstrap can only use one single suite as its package source. For the time being, the easiest way to create a very bare-bones riscv64 chroot is the use of multistrap. In comparison to debootstrap, multistrap has the limitations of only working on Debian systems while debootstrap is designed to be distribution-agnostic, and several of the configuration options that debootstrap provides don't have a direct equivalent in multistrap.

To build a bare-bones riscv64 chroot on a Debian/unstable system of a different architecture, perform the following steps:

$ sudo apt-get install multistrap debian-ports-archive-keyring
$ cat >/tmp/multistrap-riscv64.conf <<EOF
[General]
arch=riscv64
aptsources=Unstable Unreleased Sid-main
bootstrap=Unstable Unreleased Sid-main

[Sid-main]
source=http://deb.debian.org/debian
suite=unstable
omitdebsrc=true
keyring=debian-archive-keyring

[Unstable]
source=http://deb.debian.org/debian-ports
suite=unstable
omitdebsrc=true
keyring=debian-ports-archive-keyring

[Unreleased]
source=http://deb.debian.org/debian-ports
suite=unreleased
omitdebsrc=true
EOF
$ sudo multistrap -d /tmp/riscv64-chroot -f /tmp/multistrap-riscv64.conf

This provides a (very bare-bones) riscv64 chroot in /tmp/riscv64-chroot. Performing these steps on a Debian/stable system requires installing the debian-ports-archive-keyring package from unstable beforehand.

Creating a chroot with debootstrap and merged repository

There is a minimal repository essentially merging debian-ports unstable+unreleased repositories, with enough packages to debootstrap a minimal chroot.

For this to work, you'll need to install debootstrap and the debian-keyring package.

For cross-architecture install, you'll also need qemu-user-static 2.12~rc2 or newer (see previously mentioned qemu apt repository if not yet available in Debian).

 debootstrap --arch=riscv64 --include=debian-ports-archive-keyring --keyring=/usr/share/keyrings/debian-keyring.gpg sid ROOT https://people.debian.org/~vagrant/debian-riscv64/

Once installed, you'll want to edit ROOT/etc/apt/sources.list* to use the standard unstable and unreleased repositories from debian-ports.

Cross-bootstrap repository, based on upstream gcc/glibc/kernel

A number of Debian packages that have been cross-built for riscv64 with a cross-toolchain based on upstream gcc/glibc/kernel are available in an apt repository. This repository is work-in-progress, incomplete and packages in it may well be broken - use at your own risk! It targets Debian developers working on riscv64 support and cross-bootstrappability issues in Debian and is neither suitable nor intended for use by end-users.

For more detailed information, please read the README.riscv64-bootstrap in the repository.

Historic repository, based on pre-upstream glibc/gcc/kernel

IMPORTANT NOTE: Due to ABI breaks during the kernel and glibc upstreaming process, the packages in this repository are ABI-incompatible with modern toolchains and modern kernels.

Unofficial repository (WIP, incomplete and probably not working for you at the moment): http://riscv.mit.edu/

See https://people.debian.org/~mafm/posts/2017/20170422_debian-gnulinux-port-for-risc-v-64-bit-riscv64/ for more details.

To use it, in /etc/apt/sources.list:

  deb [ arch=riscv64 signed-by=/usr/share/keyrings/debian-keyring.gpg ] http://riscv.mit.edu/debian unstable main
  deb-src [ signed-by=/usr/share/keyrings/debian-keyring.gpg ] http://riscv.mit.edu/debian unstable main

The repository is signed with the key from Manuel as Debian Developer, contained in the file /usr/share/keyrings/debian-keyring.gpg, which is part of the package debian-keyring (available from Debian and derivatives).

buildd (build-daemon) information

Porterboxes

Currently there are no porterboxes available. Please refer to the qemu section for installing a riscv64 virtual machine locally.

Status Log

2018-03-28

We have now both gcc-7-based as well as gcc-8-based cross-toolchains for riscv64 in unstable.

2018-03-23/24

Port added to debian-ports, the first automatic builds start to build packages after the initial seed of the minimal set.

2018-03-09

The upstream qemu maintainers have accepted the RISC-V patchset.

2018-03-04

The dpkg 1.18.25 update for stable that would (among other things) have made the riscv64 architecture known to dak - and thereby have allowed uploads of packages that mention riscv64 in their control file to the archive - has been rejected by the stable release managers. The rejection hasn't been because of the riscv64 support but because of other factors, but it means it will unfortunately still take some time before we will be able to upload a number of core packages (e.g. linux and glibc) with riscv64 support enabled to the main archive.

2018-02-27

A pull request to include RISC-V support into upstream qemu has been sent.

2018-02-19

Cross-binutils targeting RV64 are now available in unstable/testing and version 5 of the qemu upstreaming patchset has been posted to the qemu-devel mailinglist.

2018-02-05

Glibc 2.27 has been released with support for RV64. Support for RV32 hasn't been fully ready in time for the 2.27 release and will be added later on. A Debian package of glibc 2.27 has been uploaded to experimental.

Since version 1.19.0.5 dpkg includes support for the riscv64 architecture. Uploading of packages that reference riscv64 in their control file to the archive isn't yet possible though, as the Debian archive management software runs on Debian/stable and a corresponding stable update is still pending.

Version 4 of the qemu upstreaming patchset has been posted to the qemu-devel mailinglist.

2018-01-29
Support in glibc has been accepted and committed in the master branch, the release of glibc 2.27 should happen in the next few days.
Linux 4.15 was released a few days ago as well, with support for the userspace ABI needed by glibc. Drivers for this arch will be left for future releases, but ABI was the most important part.
2018-01-02

A first version of the qemu upstreaming patchset has been posted to the qemu-devel mailinglist.

2017-12-22

A new version of the glibc upstreaming patchset which matches the kernel code in Linux 4.15rc3 has been posted to the libc-alpha list.

2017-11-15

The pull request for the kernel has been accepted and the architecture-core patchset has been merged into the upstream kernel repository.

2017-11-13

A pull request for inclusion of the RISC-V architecture-core patchset into kernel 4.15 has been sent to Linus Torvalds.

2017-10-31

The RISC-V Linux kernel upstreaming patchset has been included into linux-next.

2017-10-05

Version 9 of the kernel upstreaming patchset has been posted to LKML on 2017-09-26. As planned after v8, it has been split into an architecture-core and a driver patchset. The RISC-V architecture maintainer has a kernel.org account now, which is a prerequisite for getting the patches into linux-next, but the actual inclusion into linux-next is still pending as the linux-next maintainer has announced that updating the linux-next tree will be on hold during the whole of October 2017.

2017-09-17

The kernel upstreaming patchset hasn't made it in into the kernel 4.14 merge window, so it now targets kernel 4.15. Version 8 of the patchset has been posted to LKML recently (note: the archive of the corresponding thread on lkml.org appears to be incomplete). While the patchset has received an overall positive review from kernel developer Arnd Bergmann, he and two other kernel developers have pointed out a few minor points that require some further discussion and probably some restructuring of the timer code. The plan for version 9 of the patchset is to address those issues and split the patchset into an architecture-core and a driver patchset. The architecture-core patchset can then hopefully be soon included in linux-next as a preparation for getting it merged during the kernel 4.15 merge window.

2017-07-30
The RISC-V upstream kernel patchset has gone through a number of review cycles, but hasn't made it into the kernel 4.13 merge window. Judging from the review comments, chances for an inclusion into kernel 4.14 look quite good, though. There are a number of open questions concering the RISC-V memory model, whose formal specification is still work-in-progress. The corresponding RISC-V foundation working group has announced that the formal memory model specification should be published in the near future (before end of 2017).
The upstream glibc maintainers have made clear that they require the kernel port to be accepted (at least as part of linux-next, preferably as part of a Linux release candidate) before the glibc support can be accepted for upstream inclusion. As a result, the upcoming glibc 2.26 release won't have RISC-V support. The earliest upstream glibc version that could have RISC-V support will therefore be 2.27, which is planned to be released around 02/2018.
2017-06-14

The first version of an upstreaming patchset for glibc has been posted to the upstream glibc development list (libc-alpha).

2017-05-22

The first version of an upstreaming patchset for the Linux kernel has been posted to the upstream Linux kernel mailinglist.

2017-05-02

Upstream GCC 7.1 has been released with RISC-V support.

2017-04-22

Unofficial repository published (WIP, incomplete and probably not working for you at the moment): http://riscv.mit.edu/

More information about details and story in https://people.debian.org/~mafm/posts/2017/20170422_debian-gnulinux-port-for-risc-v-64-bit-riscv64/

2017-03-04
Upstream binutils 2.28 have been released with RISC-V support on 2017-03-02.
2017-02-06

The GCC support for RISC-V has been committed to the upstream GCC repository and will be part of the GCC 7 release. Commit list: 1 2 3 4 5 6

2017-01-18
The binutils support for RISC-V has been accepted upstream in November/December 2016 and will be part of binutils 2.28 (expected to be released in Q1/2017).

The GCC support for RISC-V has been accepted for upstream inclusion by the GCC Steering Committee but is still pending the final stages of the technical review as there have been a number of review comments that need to be addressed in a new version of the upstreaming patchset. There is reason for hoping that the RISC-V support could make it into the GCC 7 release, but this depends on how fast the review process can be finished.

2016-02-19
The preparations for this port started in private a while ago, but nothing has been made public so far and nothing useful yet for users and developers.

The main reason is the lack of official support for this architecture in fundamental pieces of the toolchain (binutils, gcc, glibc), the main OS kernel (linux) or even other software that might help with the port (e.g. qemu). All of the mentioned pieces have support in progress and are considered to submit for upstreaming, but nothing definitive has happened at the moment.

In particular, a recent message informed about some upcoming changes to the supervisor specifications (the ABI), which will affect binutils at least. Starting a Debian port without the ISA being settled is not very good, since the effort will need to be restarted from scratch.

It is expected that this situation will change soon (within few months) and that progress on this port can be resumed.

Credits

Porters:

Hardware Sponsors:

  • Bytemark provides hardware to help to kick-start this port. Bytemark is a long-time partner of Debian

  • Also using personal computers and regular Debian infrastructure

History

2016-02-19
Created page of the port in the wiki


CategoryPorts