whoops add wget to coriolis-install
[dev-env-setup.git] / build_kestrel_firmware
1 #!/bin/bash
2 #
3 # Copyright 2022 Raptor Engineering, LLC
4 # Licensed under the terms of the GNU LGPLv3+
5 #
6 # Ensure that the LibreSoC packages and HDL tools
7 # are installed prior to running this script,
8 # as well as the kestrel repos
9 #
10 # ./install-hdl-apt-reqs
11 # ./hdl-dev-repos
12 # ./hdl-tools-yosys
13 # ./ppc64-gdb-gcc
14 # ./nextpnr-ecp5
15 # ./hdl-kestrel-repos
16
17 set -e
18
19 export PATH=/usr/local/libtrellis/bin:$PATH
20 export PATH=/usr/local/nextpnr-ecp5/bin:$PATH
21
22 export KESTREL=/home/$SUDO_USER/src/kestrel
23 echo "Building ppc64el soft floating point library..."
24 cd $KESTREL/firmware/gcc/libgcc/soft-fp
25 # Ignore expected errors
26 set +e
27 gcc -c -O2 -msoft-float -mno-string -mno-multiple -mno-vsx \
28 -mno-altivec -mlittle-endian -mstrict-align \
29 -fno-stack-protector -m64 -mabi=elfv2 -mcmodel=small \
30 -I../config/rs6000/ -I../../include -I.. *.c &> /dev/null
31 set -e
32 ar -crv libsoft-fp.a *.o
33 cp -Rp libsoft-fp.a ../../../
34
35 echo "Building Zephyr..."
36 cd $KESTREL/firmware
37 export SOURCE_ROOT_DIR=$(pwd)
38 cd zephyr-rtos
39 rm -rf build
40 mkdir build
41 cd build
42 export ZEPHYR_MODULES="${SOURCE_ROOT_DIR}/zephyr-littlefs"
43 export ZEPHYR_MODULES="${ZEPHYR_MODULES};${SOURCE_ROOT_DIR}/zephyr-mbedtls;"
44 export ZEPHYR_MODULES="${ZEPHYR_MODULES};${SOURCE_ROOT_DIR}/zephyr-civetweb"
45 ZEPHYR_BASE=${SOURCE_ROOT_DIR}/zephyr-rtos \
46 ZEPHYR_TOOLCHAIN_VARIANT=host \
47 cmake -DZEPHYR_MODULES="${ZEPHYR_MODULES}" \
48 -DBOARD=litex_kestrel ${SOURCE_ROOT_DIR}/zephyr-firmware
49 cp -Rp ../../libsoft-fp.a zephyr/
50 make -j32
51
52 echo -n "Zephyr firmware binary now in "
53 echo "$KESTREL/firmware/zephyr-rtos/build/zephyr/zephyr.bin"