From 1bac06b4bdfe6c45753e58ad18ce25d2c46d6038 Mon Sep 17 00:00:00 2001 From: Raptor Engineering Development Team Date: Thu, 7 Jul 2022 18:35:41 +0000 Subject: [PATCH] Add build scripts for Kesrel Zephyr firmware image --- build_kestrel_firmware | 43 +++++++++++++++++++++++++++++++++++++++ firmware-kestrel-repos | 28 +++++++++++++++++++++++++ install-firmware-apt-reqs | 24 ++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100755 build_kestrel_firmware create mode 100755 firmware-kestrel-repos create mode 100755 install-firmware-apt-reqs diff --git a/build_kestrel_firmware b/build_kestrel_firmware new file mode 100755 index 0000000..5ad92ae --- /dev/null +++ b/build_kestrel_firmware @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Copyright 2022 Raptor Engineering, LLC +# Licensed under the terms of the GNU LGPLv3+ +# +# Ensure that the LibreSoC packages and HDL tools +# are installed prior to running this script, +# as well as the kestrel repos +# +# ./install-hdl-apt-reqs +# ./hdl-dev-repos +# ./hdl-tools-yosys +# ./ppc64-gdb-gcc +# ./nextpnr-ecp5 +# ./hdl-kestrel-repos + +set -e + +export PATH=/usr/local/libtrellis/bin:$PATH +export PATH=/usr/local/nextpnr-ecp5/bin:$PATH + +export KESTREL=/home/$SUDO_USER/src/kestrel +echo "Building ppc64el soft floating point library..." +cd $KESTREL/firmware/gcc/libgcc/soft-fp +# Ignore expected errors +set +e +gcc -c -O2 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -mstrict-align -fno-stack-protector -m64 -mabi=elfv2 -mcmodel=small -I../config/rs6000/ -I../../include -I.. *.c &> /dev/null +set -e +ar -crv libsoft-fp.a *.o +cp -Rp libsoft-fp.a ../../../ + +echo "Building Zephyr..." +cd $KESTREL/firmware +export SOURCE_ROOT_DIR=$(pwd) +cd zephyr-rtos +rm -rf build +mkdir build +cd build +ZEPHYR_BASE=${SOURCE_ROOT_DIR}/zephyr-rtos ZEPHYR_TOOLCHAIN_VARIANT=host cmake -DZEPHYR_MODULES="${SOURCE_ROOT_DIR}/zephyr-littlefs;${SOURCE_ROOT_DIR}/zephyr-mbedtls;${SOURCE_ROOT_DIR}/zephyr-civetweb" -DBOARD=litex_kestrel ${SOURCE_ROOT_DIR}/zephyr-firmware +cp -Rp ../../libsoft-fp.a zephyr/ +make -j32 + +echo "Zephyr firmware binary now in $KESTREL/firmware/zephyr-rtos/build/zephyr/zephyr.bin" diff --git a/firmware-kestrel-repos b/firmware-kestrel-repos new file mode 100755 index 0000000..c010ba0 --- /dev/null +++ b/firmware-kestrel-repos @@ -0,0 +1,28 @@ +#!/bin/bash +if [ "$EUID" -ne 0 ] + then echo "Please run as root using 'sudo bash'" + exit +fi + +runuser $SUDO_USER --preserve-environment -c ' +cd /home/$SUDO_USER +mkdir -p src/kestrel/firmware +cd src/kestrel/firmware +git clone https://gitlab.raptorengineering.com/kestrel-collaboration/kestrel-firmware/zephyr-rtos +git clone https://gitlab.raptorengineering.com/kestrel-collaboration/kestrel-firmware/zephyr-firmware +cd zephyr-firmware +git submodule init +git submodule update +cd .. +git clone https://gitlab.raptorengineering.com/kestrel-collaboration/kestrel-firmware/zephyr-littlefs +git clone https://gitlab.raptorengineering.com/kestrel-collaboration/kestrel-firmware/zephyr-mbedtls +git clone https://gitlab.raptorengineering.com/kestrel-collaboration/kestrel-firmware/zephyr-civetweb +git clone https://gitlab.raptorengineering.com/kestrel-collaboration/kestrel-tooling/gcc +' +cd ../ +chown -R $SUDO_USER . +chgrp -R $SUDO_USER . +echo -e " +\e[1;91mAll Libre-SOC Kestrel firmware dependencies should now be installed.\e[0m +" + diff --git a/install-firmware-apt-reqs b/install-firmware-apt-reqs new file mode 100755 index 0000000..1088957 --- /dev/null +++ b/install-firmware-apt-reqs @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Relies on install-hdl-apt-reqs being run first + +if [ "$EUID" -ne 0 ] + then echo "Please run as root" + exit +fi +# for qemu 5.2 use debian/buster backports +cat << EOF > /etc/apt/sources.list.d/buster_backports.list +deb http://deb.debian.org/debian buster-backports main +EOF + +# oooo annoying, pin preferences for buster-backports +cat << EOF > /etc/apt/preferences.d/99buster-backports +Package: * +Pin: release a=buster-backports +Pin-Priority: 900 +EOF + +apt-get update -y +apt-get upgrade -y +apt-get install -y python3-pykwalify \ + python3-pyelftools -- 2.30.2