1 # Refer to the README file to understand how Fedora on RISC-V is
4 # Note these are chosen very specifically to ensure the different
5 # versions work together. Don't blindly update to the latest
7 # https://github.com/riscv/riscv-pk/issues/18#issuecomment-206115996
8 RISCV_QEMU_COMMIT = 94f5eb73091fb4fe272db3e943f173ecc0f78ffd
9 RISCV_QEMU_SHORTCOMMIT = 94f5eb73
10 RISCV_GNU_TOOLCHAIN_COMMIT = 728afcddcb0526a0f6560c4032da82805f054d58
11 RISCV_GNU_TOOLCHAIN_SHORTCOMMIT = 728afcdd
12 RISCV_PK_COMMIT = 85ae17aa149b9ea114bdd70cc30ea7e73813fb48
13 RISCV_PK_SHORTCOMMIT = 85ae17aa
15 # For the correct versions, see
16 # riscv-gnu-toolchain/Makefile.in *_version variables
17 BINUTILS_VERSION = 2.25.1
20 NEWLIB_VERSION = 2.2.0
22 all: stage1 stage2 stage3 stage4
26 stage1: stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz \
27 stage1-riscv-qemu/riscv-qemu.spec \
28 stamp-riscv-qemu-installed
30 stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz:
32 wget -O $@-t 'https://github.com/riscv/riscv-qemu/archive/$(RISCV_QEMU_COMMIT)/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz'
35 stage1-riscv-qemu/riscv-qemu.spec: stage1-riscv-qemu/riscv-qemu.spec.in
36 sed -e 's/@COMMIT@/$(RISCV_QEMU_COMMIT)/g' \
37 -e 's/@SHORTCOMMIT@/$(RISCV_QEMU_SHORTCOMMIT)/g' \
41 stamp-riscv-qemu-installed:
43 @rpm -q riscv-qemu >/dev/null || { \
44 echo "ERROR: You must install riscv-qemu:"; \
46 echo " dnf copr enable rjones/riscv"; \
47 echo " dnf install riscv-qemu"; \
49 echo "OR: you can build it yourself from the stage1-riscv-qemu directory."; \
53 @qemu-system-riscv --version || { \
54 echo "ERROR: qemu-system-riscv is not working."; \
55 echo "Make sure you installed the riscv-qemu package."; \
62 stage2: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz \
63 stage2-riscv-gnu-toolchain/binutils-$(BINUTILS_VERSION).tar.gz \
64 stage2-riscv-gnu-toolchain/gcc-$(GCC_VERSION).tar.gz \
65 stage2-riscv-gnu-toolchain/glibc-$(GLIBC_VERSION).tar.gz \
66 stage2-riscv-gnu-toolchain/newlib-$(NEWLIB_VERSION).tar.gz \
67 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec \
68 stamp-riscv-gnu-toolchain-installed \
69 stage2-riscv-pk/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz \
70 stage2-riscv-pk/riscv-pk.spec \
71 stamp-riscv-pk-installed
73 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz:
75 wget -O $@-t https://github.com/lowRISC/riscv-gnu-toolchain/archive/$(RISCV_GNU_TOOLCHAIN_COMMIT)/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz
78 stage2-riscv-gnu-toolchain/binutils-$(BINUTILS_VERSION).tar.gz:
80 wget -O $@-t http://mirrors.kernel.org/gnu/binutils/binutils-$(BINUTILS_VERSION).tar.gz
83 stage2-riscv-gnu-toolchain/gcc-$(GCC_VERSION).tar.gz:
85 wget -O $@-t http://mirrors.kernel.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.gz
88 stage2-riscv-gnu-toolchain/glibc-$(GLIBC_VERSION).tar.gz:
90 wget -O $@-t http://mirrors.kernel.org/gnu/glibc/glibc-$(GLIBC_VERSION).tar.gz
93 stage2-riscv-gnu-toolchain/newlib-$(NEWLIB_VERSION).tar.gz:
95 wget -O $@-t ftp://sourceware.org/pub/newlib/newlib-$(NEWLIB_VERSION).tar.gz
98 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec.in
99 sed -e 's/@COMMIT@/$(RISCV_GNU_TOOLCHAIN_COMMIT)/g' \
100 -e 's/@SHORTCOMMIT@/$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT)/g' \
101 -e 's/@BINUTILS_VERSION@/$(BINUTILS_VERSION)/g' \
102 -e 's/@GCC_VERSION@/$(GCC_VERSION)/g' \
103 -e 's/@GLIBC_VERSION@/$(GLIBC_VERSION)/g' \
104 -e 's/@NEWLIB_VERSION@/$(NEWLIB_VERSION)/g' \
108 stamp-riscv-gnu-toolchain-installed:
110 @rpm -q riscv-gnu-toolchain >/dev/null || { \
111 echo "ERROR: You must install riscv-gnu-toolchain:"; \
113 echo " dnf copr enable rjones/riscv"; \
114 echo " dnf install riscv-gnu-toolchain"; \
116 echo "OR: you can build it yourself from the stage2-riscv-gnu-toolchain directory."; \
120 @riscv64-unknown-elf-gcc --version || { \
121 echo "ERROR: riscv64-unknown-elf-gcc (cross compiler) is not working."; \
122 echo "Make sure you installed the riscv-gnu-toolchain package."; \
127 stage2-riscv-pk/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz:
129 wget -O $@-t https://github.com/lowRISC/riscv-pk/archive/$(RISCV_PK_COMMIT)/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz
132 stage2-riscv-pk/riscv-pk.spec: stage2-riscv-pk/riscv-pk.spec.in
133 sed -e 's/@COMMIT@/$(RISCV_PK_COMMIT)/g' \
134 -e 's/@SHORTCOMMIT@/$(RISCV_PK_SHORTCOMMIT)/g' \
138 stamp-riscv-pk-installed:
140 @rpm -q riscv-pk >/dev/null || { \
141 echo "ERROR: You must install riscv-pk:"; \
143 echo " dnf copr enable rjones/riscv"; \
144 echo " dnf install riscv-pk"; \
146 echo "OR: you can build it yourself from the stage2-riscv-pk directory."; \
154 stage3: stage3-kernel/linux-4.6.2.tar.xz \
155 stage3-kernel/linux-4.6.2/vmlinux
157 stage3-kernel/linux-4.6.2.tar.xz:
159 wget -O $@-t https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.6.2.tar.xz
162 stage3-kernel/linux-4.6.2/vmlinux:
163 rm -rf stage3-kernel/linux-4.6.2
164 cat stage3-kernel/linux-4.6.2.tar.xz | tar -x --xz -C stage3-kernel
165 cd stage3-kernel/linux-4.6.2 && \
167 cd stage3-kernel/linux-4.6.2 && \
168 git remote add origin https://github.com/lowrisc/riscv-linux.git
169 cd stage3-kernel/linux-4.6.2 && \
171 cd stage3-kernel/linux-4.6.2 && \
172 git checkout -f -t origin/debug-v0.3
173 cd stage3-kernel/linux-4.6.2 && \
174 patch -p1 < spi_sd_power_hack.patch
175 cd stage3-kernel/linux-4.6.2 && \
176 make ARCH=riscv defconfig
177 cd stage3-kernel/linux-4.6.2 && \
178 make ARCH=riscv CONFIG_CROSS_COMPILE=riscv64-unknown-elf- vmlinux