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