(no commit message)
[libreriscv.git] / HDL_workflow / microwatt.mdwn
1 # Build instructions for Microwatt
2
3 WIP integrate from <https://libre-soc.org/irclog/%23libre-soc.2022-01-26.log.html>
4
5 * install verilator: <https://git.libre-soc.org/?p=dev-env-setup.git;a=blob;f=verilator-install;hb=HEAD>
6 * install yosys <https://git.libre-soc.org/?p=dev-env-setup.git;a=blob;f=hdl-tools-yosys;hb=HEAD>
7 * install ghdl-yosys-plugin
8
9 After installing ghdl-yosys-plugin use schroot to switch environment
10
11 schroot -c bullseye_ghdl
12 git clone https://git.libre-soc.org/git/microwatt.git
13 git checkout -b verilator_trace
14 export FPGA_TARGET=verilator
15 make microwatt-verilator
16
17 Then run the resulting binary
18
19 time ./microwatt-verilator
20
21 If everything works correcly it will print out an light bulb in ascii art
22 with the message Microwatt, it works. On my ASUS KGPE D16 this takes
23
24 real 1m4.986s
25 user 1m4.373s
26 sys 0m0.013s
27
28 ## Building the kernel
29 On a POWER9 there is no need to install gcc-powerpc64le-linux-gnu,
30 you can omit CROSS_COMPILE and ARCH in this case
31
32 apt install gcc-powerpc64le-linux-gnu
33 apt install flex bison lz4
34 git clone -b microwatt-5.7 https://git.kernel.org/pub/scm/linux/kernel/git/joel/microwatt.git
35 cd microwatt
36 wget https://ftp.libre-soc.org/microwatt-linux-5.7.patch
37 patch -p1 < microwatt-linux-5.7.patch
38 wget http://ftp.libre-soc.org/rootfs.cpio
39 CROSS_COMPILE="ccache powerpc64le-linux-gnu-" ARCH=powerpc make -j8 O=microwatt microwatt_defconfig
40 CROSS_COMPILE="ccache powerpc64le-linux-gnu-" ARCH=powerpc make -j8 O=microwatt
41
42 This will produce a file
43 microwatt/arch/powerpc/boot/dtbImage.microwatt
44
45 ## Building sdram_init.bin
46 This needs gcc-powerpc64le-linux-gnu if cross compilation is used.
47
48 cd microwatt
49 cd litedram/gen-src/sdram_init/
50 make
51
52 ## Building microwatt-verilator using the libre-soc core
53 cd /path/to/soc
54 make microwatt_external_core
55 cp external_core_top.v /path/to/microwatt
56 cd /path/to/microwatt
57 export FPGA_TARGET=verilator
58 export GHDLSYNTH=ghdl
59 make microwatt-verilator
60
61 ## Running the simulation
62 cp microwatt/arch/powerpc/boot/dtbImage.microwatt
63 ./microwatt-verilator sdram_init.bin dtbImage.microwatt
64
65 ## TODO: buildroot
66
67 * https://github.com/shenki/buildroot/commits/microwatt
68 * https://codeconstruct.com.au/docs/microwatt-orangecrab/