Hello,
there has been some discussion by email between a number of
interested people about the ideas outlined at
https://github.com/SymbiFlow/ideas/issues/35 ("Getting started with
Debian Linux on RISC-V with SymbiFlow tutorial") as not everybody
involved has a github account and contributing to issues on github
is impossible for people without a github account. During this
email exchange it has been proposed to move the discussion to the
linux-litex list, therefore I'd hereby like to post a summary of
what has been previously discussed:
- To implement usable Linux-capable SoCs on small- to
medium-sized FPGAs the only reasonable base ISA is RV32;
RV64 is not practical there.
- Debian currently only supports RV64.
A Debian port for RV32 is possible in principle once we have a
stable ABI for RV32 (which will hopefully be the case with the
release of glibc 2.30) and there are people who are willing to
work on a bootstrap, but there are a number of things to
consider:
- Debian is a general-purpose Linux distribution and a
significant part of its users are in the desktop and server
space. As such, Debian builds its packages with a lot of
optional functionality enabled and therefore the memory
footprint of Debian packages is usually significantly larger
than the memory footprint of code built by build-systems
specifically targeting low-memory fixed-function embedded
devices such as e.g. buildroot.
Most FPGA boards come with very small amounts of RAM; the ECP5
board with the largest amount of memory appears to be the ECP5
versa board, and that has only 128MB of DRAM. Running Debian
in 128MB of RAM is technically possible, but it isn't fun.
Anything even remotely practically usable requires at least
256MB of RAM. The typical amount of memory on today's
single-board computers (which define the lower end of what
general-purpose Linux distributions usually target) is 1GB of
RAM (2GB on the better-equipped models) and compiling/linking
big packages nowadays often requires 4GB of RAM or even more.
The only commonly available and hobbyist-affordable FPGA board
with more than 128MB of RAM appears to be the Digilent Arty-A7
which comes with 256MB of RAM, but isn't yet supported by the
open-source FPGA toolchains. Tim is rather confident though
that Project X-Ray will have made enough progress by the end of
the year to make building VexRiscV for the Artix-7 possible.
- If we are to start a Debian port for RV32, we have to define an
appropriate hardware baseline. The Debian riscv64 port uses
RV64GC=RV64IMAFDC as its baseline, but for FPGA implementations,
having the F and D extensions doesn't really make sense as they
would probably require vastly more logic ressources than the
complete rest of the SoC together, so RV32GC doesn't make much
sense when also targeting FPGAs. The work-in-progress RISC-V
unix platform specification will probably declare the C
extension as mandatory, the A extention is mandatory for Linux,
so that leaves RV32IMAC or RV32IAC as potential hardware
baselines for anything that would also target FPGA
implementations. As has been pointed out in the previous
discussion, implementing hardware multiply doesn't seem to be
much of a problem, but hardware division appears to be. ISTR
that an older version of the RISC-V ISA spec explicitly allowed
claming support for the M extension if only multiply was
implemented in hardware and divide was emulated via an M-mode
trap handler, but I cannot find that anymore in the current
spec. Does anybody have further information on this?
I don't have any access to the closed-door discussions of the
RISC-V foundation's unix platform spec working group, but based
on previous public discussions I would guess that the WIP
RISC-V unix platform spec will probably define RV32IMAC as its
baseline for RV32.
- An RV32IMAC port would play roughly in the same league as the
existing Debian armel (armv5 without FPU) port and there have
already been multiple attempts at phasing out the armel port
and only keeping the armhf port (armv7 + vfp3d16 FPU) in
Debian. For the current release cycle (Buster), armel will be
kept, but for how long afterwards has to be seen.
There are a number of reasons for dropping the armel port. Some
of them potentially also apply to an RV32IMAC port, some don't:
- Devices targeted by armel are usually severely
memory-constrained. This is something they share with most
off-the-shelf FPGA boards.
- There are more and more toolchain issues and many upstream
projects are dropping support for anything before armv7.
For RV32, the toolchain is actively maintained, so that's
currently not an issue. Last time I looked, there were quite
a number of upstream projects which had support for RV64,
but not for RV32, though. How things develop there will have
to be seen.
- Lack of appropriate build hardware. Most systems targeted
by the armel port aren't "beefy" enough both in terms of
memory and CPU power to keep up with building the archive.
Running armv5 code on modern arm64 systems doesn't work as
ARM has done some incompatible changes in the ISA after v5.
For RÍSC-V we are in a similar situation as RV32 and RV64 are
incompatible ISAs, i.e. we cannot just run an RV32 builder
in a chroot on a beefy RV64 system. For a second-tier port
(i.e. one in the "Debian-Ports" archive), running builders
in qemu VMs is acceptable, but for first-tier ports it's not.
Bootstrapping a Debian port for RV32 is therefore only useful if
there are systems with enough memory to make use of it, and
regarding off-the-shelf-hardware things look rather dire at the
moment. What would give the whole topic of running Linux/RISC-V
on FPGAs a big boost would be the availability of a suitable FPGA
board aimed at being used as a single-board computer, i.e. with
a large FPGA such as an ECP5-85k, enough DRAM, an SD-card slot,
an ethernet PHY and if possible some further SBC-typical I/O
interfaces. Until recently, the lack of a working open-source
DDR DRAM controller for the ECP5 was a big hindrance for using
DDR2/DDR3 RAM on OSHW FPGA boards, but since David Shah has
ported LiteDRAM to the ECP5, this has become possible now.
Is there perhaps somebody around who is interested and has the
necessary skills to tackle such a hardware design? In principle
designing such a board should be possible with an all-open-source
workflow if one looks e.g. at the Olimex A64-OLinuXino, an arm64
single-board computer with 2GB of DDR3 memory, gigabit ethernet and
everything else that one usually expects from an SBC, which has
been designed completely with only open-source tools:
https://www.olimex.com/Products/OLinuXino/A64/A64-OLinuXino/open-source-hardware
Regards,
Karsten
--
Ich widerspreche hiermit ausdrücklich der Nutzung sowie der
Weitergabe meiner personenbezogenen Daten für Zwecke der Werbung
sowie der Markt- oder Meinungsforschung.