(no commit message)
[libreriscv.git] / HDL_workflow / microwatt.mdwn
1 # Build instructions for Microwatt
2
3 TODO WIP integrate from <https://libre-soc.org/irclog/%23libre-soc.2022-01-26.log.html>
4
5 useful links:
6
7 * <https://codeconstruct.com.au/docs/microwatt-orangecrab/>
8 * <https://shenki.github.io/boot-linux-on-microwatt/>
9
10 prerequisite tools:
11
12 * install verilator: <https://git.libre-soc.org/?p=dev-env-setup.git;a=blob;f=verilator-install;hb=HEAD>
13 * install yosys <https://git.libre-soc.org/?p=dev-env-setup.git;a=blob;f=hdl-tools-yosys;hb=HEAD>
14 * install ghdl-yosys-plugin
15
16 After installing ghdl-yosys-plugin use schroot to switch environment
17
18 schroot -c bullseye_ghdl
19 git clone https://git.libre-soc.org/git/microwatt.git
20 git checkout -b verilator_trace
21 export FPGA_TARGET=verilator
22 make microwatt-verilator
23
24 Then run the resulting binary
25
26 time ./microwatt-verilator
27
28 If everything works correcly it will print out an light bulb in ascii art
29 with the message Microwatt, it works. On my ASUS KGPE D16 this takes
30
31 real 1m4.986s
32 user 1m4.373s
33 sys 0m0.013s
34
35 ## Building the kernel
36 On a POWER9 there is no need to install gcc-powerpc64le-linux-gnu,
37 you can omit CROSS_COMPILE and ARCH in this case
38
39 apt install gcc-powerpc64le-linux-gnu
40 apt install flex bison lz4
41 git clone -b microwatt-5.7 https://git.kernel.org/pub/scm/linux/kernel/git/joel/microwatt.git
42 cd microwatt
43 wget https://ftp.libre-soc.org/microwatt-linux-5.7.patch
44 patch -p1 < microwatt-linux-5.7.patch
45 wget http://ftp.libre-soc.org/rootfs.cpio
46 CROSS_COMPILE="ccache powerpc64le-linux-gnu-" ARCH=powerpc make -j8 O=microwatt microwatt_defconfig
47 CROSS_COMPILE="ccache powerpc64le-linux-gnu-" ARCH=powerpc make -j8 O=microwatt
48
49 This will produce a file
50 microwatt/arch/powerpc/boot/dtbImage.microwatt
51
52 ## Building sdram_init.bin
53 This needs gcc-powerpc64le-linux-gnu if cross compilation is used.
54
55 cd microwatt
56 cd litedram/gen-src/sdram_init/
57 make
58
59 ## Building microwatt-verilator using the libre-soc core
60 cd /path/to/soc
61 make microwatt_external_core
62 cp external_core_top.v /path/to/microwatt
63 cd /path/to/microwatt
64 export FPGA_TARGET=verilator
65 export GHDLSYNTH=ghdl
66 make microwatt-verilator
67
68 ## Running the simulation
69 cp microwatt/arch/powerpc/boot/dtbImage.microwatt
70 ./microwatt-verilator sdram_init.bin dtbImage.microwatt
71
72 ## TODO: buildroot
73
74 * https://github.com/shenki/buildroot/commits/microwatt
75 * https://codeconstruct.com.au/docs/microwatt-orangecrab/
76
77 # Notes for ulx3s
78
79 notes for how to compile for ulx3s
80
81 git clone https://git.libre-soc.org/git/microwatt.git
82 git checkout -b verilator_trace
83 export FPGA_TARGET=ulx3s
84 make microwatt.svf
85
86 # Notes for nextpnr-xilinx
87
88 for compiling nextpnr-xilinx and making it useable for nmigen
89 to compile for the digilent arty-a7-100t, requires a little
90 futzing around, using the symbiflow version of prjxray-db
91 instead of the one recommended as a submodule
92
93 git clone https://github.com/gatecat/nextpnr-xilinx
94 cd nextpnr-xilinx
95 git checkout cd8b15db6ff5c1a7f10a9e
96 git submodule init
97 git submodule update
98 cd xilinx/external
99 mv prjxray-db prjxray-db-no
100 git clone https://github.com/SymbiFlow/prjxray-db
101 cd prjxray-db
102 git checkout 0a0addedd73e7
103 cp ./artix7/xc7a100t/*.json \
104 ./artix7/xc7a100tcsg324-1
105 cd ../../..
106 cmake -DARCH=xilinx .
107 make
108 make install
109 python3 xilinx/python/bbaexport.py --device xc7a100tcsg324-1 --bba xilinx/xc7a100t.bba
110 ./bbasm --l xilinx/xc7a100t.bba xilinx/xc7a100t.bin
111 mkdir -p /usr/share/nextpnr/xilinx-chipdb
112 cp xilinx/*.bin /usr/share/nextpnr/xilinx-chipdb
113 cp -aux xilinx/external/prjxray-db /usr/share/nextpnr