c57b243cec048e854adcaafa70a9cb1334b97ce3
[libreriscv.git] / HDL_workflow / debian-sffs.mdwn
1 # Tutorial for bootstrapping Debian Bookworm (12) from source.
2
3 Useful Links (External):
4
5 * [Read about sbuild and understand how it works](https://wiki.debian.org/sbuild)
6 * [dpkg-buildflags man page](https://manpages.debian.org/bookworm/dpkg-dev/dpkg-buildflags.1.en.html) (optional, in case some flags need to be changed)
7 * [apt-ftparchive man page](https://manpages.debian.org/bookworm/apt-utils/apt-ftparchive.1.en.html) (optional, in case you want to customize the repo)
8 * [debootstrap wiki page](https://wiki.debian.org/Debootstrap) (optional, in case you want to customize your chroot)
9
10 Useful links (Libre-SOC):
11
12 * Devscripts Libre-SOC page: [[devscripts]]
13 * [Libre-SOC devscripts repo](https://git.libre-soc.org/?p=dev-env-setup.git;a=tree)
14
15 ## Video Tutorial
16
17 [todo](todo)
18
19 ## Reasoning:
20
21 Libre-SOC builds upon the OpenPOWER ISA v3.0 but does not include many parts of the architecture typically found on production silicon, like AltiVec, VSX, and 128-bit hardware floating point. Because of this, we need (at this time, might change in the future when glibc supports detecting VSX vs SVP64 etc) to rebuild the full software repository to not include any of those instructions, making it compliant with [sffs (slides 5 & 6)](https://ics2020.bsc.es/sites/default/files/uploaded/brian_thompto_ICS2020_SLIDES.pdf).
22
23 You can approach this in two ways: either build the full base Debian chroot packages yourself using Debian's build tools, optionally automated with our [scripts](https://git.libre-soc.org/?p=dev-env-setup.git;a=tree), or use the [prebuilt rootfs] in a compressed tar archive.
24
25 ## System requirements
26
27 - A POWER system that can run Debian Bookworm (meaning POWER8 and newer)
28 - At least 80GB of hard disk space
29
30 Cross compiling will make this process much more complicated and is generally not recommended.
31
32 ## Development Setup Scripts
33
34 If you haven't already, clone Libre-SOC's development environment setup scripts.
35 These are bash scripts, and greatly simplify the time it takes to create a:
36
37 - Stable environment
38 - With all software and libraries at specific versions
39 (which are known to work).
40
41 These attributes are absolutely critical, and no support will be
42 provided, unless you use these scripts to setup a development environment. This
43 helps us fix any bugs in the scripts, and make sure everyone runs on the same
44 page.
45
46 $ git clone https://git.libre-soc.org/git/dev-env-setup.git
47
48 Do *look through* the
49 [code](https://git.libre-soc.org/?p=dev-env-setup.git;a=tree) before running
50 any of those scripts.
51 This is your own legal responsibility (to not run
52 arbitrary code off of the internet) and we take no responsibility or accept
53 any liability whatsoever for your use or misuse of them.
54
55 It is expected for you to use Debian for the host OS (anything else is unsupported: many contributors have repeatedly gotten into trouble by not following this advice), while all the chroots - which are developed very specifically for "reproducible builds" - run Debian 10 (Buster).
56
57 ## Setting up the build schroot
58
59 Scripts we will be using for the setup are:
60
61 * `install-sbuild-apt-reqs` for installing sbuild and configuring it to Debian's defaults
62 * `mk-schroot-bookworm` for creating the bookworm schroot used by sbuild and adding our dpkg-buildflags to build for sffs
63 * `build-bookworm-sffs` to build the packages needed for a debootstrap chroot directory
64 * `create-deb-repo` to create a local dpkg repository of the built packages
65 * `mk-sffs-chroot` to finally create the chroot using the repository of built packages
66
67 Commands to run in terminal to rebuild Debian 12 with sffs compliance:
68
69 $ cd dev-env-setup
70 $ sudo bash
71 # ./install-sbuild-apt-reqs
72 # ./mk-schroot-bookworm
73 # exit
74 $ ./build-bookworm-sffs
75 $ ./create-deb-repo
76 $ ./mk-sffs-chroot
77
78 ## Using prebuilt tarball
79
80 If you prefer to use the prebuilt tarball (which will save days of your time), you could simply download and extract the tarball to a convenient location and chroot into it.
81
82 $ curl -O [link to be added]
83 $ mkdir bookworm-sffs && cd bookworm-sffs
84 $ tar xpvf bookworm-sffs.tar.xz --xattrs-include='*.*' --numeric-owner
85 $ cd ..
86 $ sudo chroot bookworm-sffs
87
88 ## Notes and issues
89
90 * Some packages will refuse to build with sffs compliant build flags and need workarounds, this will be handled in the future.
91 * The Linux kernel cannot boot without AltiVec and VSX, even though they are build-time options. The solution for now is to use [microwatt's 5.7 kernel](https://lore.kernel.org/all/CAPweEDw710zFK8KLZY5gsQxEkQKrDiFkNRgABY9HJZ1rxpeVCg@mail.gmail.com/T/) and to incorporate the needed patches upstream in the future.
92 * Previous note also means this is purely a chroot environment, this page will be updated once it becomes possible to boot a full VM of this build.
93 * glibc *may* have some issues on sffs, the only way to test this is to run on microwatt which will be done soon.