Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel mainline #233

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ qdl/
.qemu_registered

.vscode
.vscode-ctags

edl_config.json
tools/edl_repo/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "agnos-binaries"]
path = agnos-binaries
url = ../../commaai/agnos-binaries.git
[submodule "kernel/linux"]
path = kernel/linux
url = https://github.com/andiradulescu/linux
47 changes: 27 additions & 20 deletions build_kernel.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
#!/bin/bash -e

DEFCONFIG=tici_defconfig
DEFCONFIG="defconfig sdm845.config"

# Get directories and make sure we're in the correct spot to start the build
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
ARCH=$(uname -m)
TOOLS=$DIR/tools
TMP_DIR=/tmp/agnos-builder-tmp
TMP_DIR=/tmp/agnos-builder-new-kernel-tmp
OUTPUT_DIR=$DIR/output
BOOT_IMG=./boot.img
cd $DIR
KERNEL_DIR=$DIR/kernel/linux

# Clone kernel if not done already
if git submodule status --cached agnos-kernel-sdm845/ | grep "^-"; then
git submodule update --init agnos-kernel-sdm845
fi
cd agnos-kernel-sdm845
cd $KERNEL_DIR

$DIR/tools/extract_tools.sh
if [ "$ARCH" != "arm64" ] && [ "$ARCH" != "aarch64" ]; then
$DIR/tools/extract_tools.sh

# Build parameters
export ARCH=arm64
export CROSS_COMPILE=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-
export CC=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-gcc
export LD=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-ld.bfd
# Build parameters
export ARCH=arm64
export CROSS_COMPILE=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-
export CC=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-gcc
export LD=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-ld.bfd
fi

# these do anything?
export KCFLAGS="-w"
Expand All @@ -31,21 +30,27 @@ export KCFLAGS="-w"
echo "-- First make --"
make $DEFCONFIG O=out
echo "-- Second make: $(nproc --all) cores --"
make -j$(nproc --all) O=out # Image.gz-dtb
make -j$(nproc --all) O=out # Image.gz

# Turn on if you want perf
# LDFLAGS=-static make -j$(nproc --all) -C tools/perf

# Create Image.gz-dtb
cd $KERNEL_DIR/out/arch/arm64/boot/
# cat Image.gz dts/qcom/comma-*.dtb > Image.gz-dtb
# cat Image.gz dts/qcom/comma-tici.dtb > Image.gz-dtb
cat Image.gz dts/qcom/sdm845-comma3.dtb > Image.gz-dtb

# Copy over Image.gz-dtb
mkdir -p $TMP_DIR
cd $TMP_DIR
cp $DIR/agnos-kernel-sdm845/out/arch/arm64/boot/Image.gz-dtb .
cp $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb .

# Make boot image
$TOOLS/mkbootimg \
--kernel Image.gz-dtb \
--ramdisk /dev/null \
--cmdline "console=ttyMSM0,115200n8 quiet loglevel=3 earlycon=msm_geni_serial,0xA84000 androidboot.hardware=qcom androidboot.console=ttyMSM0 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 service_locator.enable=1 androidboot.selinux=permissive firmware_class.path=/lib/firmware/updates net.ifnames=0 dyndbg=\"\"" \
--cmdline "console=ttyMSM0,115200n8 earlycon=qcom_geni,0xA84000" \
--pagesize 4096 \
--base 0x80000000 \
--kernel_offset 0x8000 \
Expand All @@ -63,6 +68,8 @@ cat $BOOT_IMG.nonsecure $BOOT_IMG.sig.padded > $BOOT_IMG
# Copy to output dir
mkdir -p $OUTPUT_DIR
mv $BOOT_IMG $OUTPUT_DIR/
cp $DIR/agnos-kernel-sdm845/out/techpack/audio/asoc/snd-soc-sdm845.ko $OUTPUT_DIR/
cp $DIR/agnos-kernel-sdm845/out/techpack/audio/asoc/codecs/snd-soc-wcd9xxx.ko $OUTPUT_DIR/
cp $DIR/agnos-kernel-sdm845/out/drivers/staging/qcacld-3.0/wlan.ko $OUTPUT_DIR/

# These will come from the kernel debs
# cp $DIR/agnos-kernel-sdm845/out/techpack/audio/asoc/snd-soc-sdm845.ko $OUTPUT_DIR/
# cp $DIR/agnos-kernel-sdm845/out/techpack/audio/asoc/codecs/snd-soc-wcd9xxx.ko $OUTPUT_DIR/
# cp $DIR/agnos-kernel-sdm845/out/drivers/staging/qcacld-3.0/wlan.ko $OUTPUT_DIR/
27 changes: 13 additions & 14 deletions build_kernel_headers.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
#!/bin/bash
set -e

DEFCONFIG=tici_defconfig
DEFCONFIG="defconfig sdm845.config"

# Get directories and make sure we're in the correct spot to start the build
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
ARCH=$(uname -m)
TOOLS=$DIR/tools
TMP_DIR=/tmp/agnos-builder-tmp
TMP_DIR=/tmp/agnos-builder-new-kernel-tmp
OUTPUT_DIR=$DIR/output
BOOT_IMG=./boot.img
cd $DIR
KERNEL_DIR=$DIR/kernel/linux

# Clone kernel if not done already
if [ ! -d agnos-kernel-sdm845 ]; then
git submodule init agnos-kernel-sdm845
fi
cd agnos-kernel-sdm845
cd $KERNEL_DIR

# Build parameters
export ARCH=arm64
if [ ! -f /TICI ]; then
if [ "$ARCH" != "arm64" ] && [ "$ARCH" != "aarch64" ]; then
# Build parameters
export ARCH=arm64
export CROSS_COMPILE=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-
export CC=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-gcc
export LD=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-ld.bfd
fi

rm -f *.deb *.buildinfo *.changes

# these do anything?
export KCFLAGS="-w"

Expand All @@ -36,9 +35,9 @@ ARGS=""
if [ -f /TICI ]; then
ARGS="sudo -E"
fi
$ARGS make bindeb-pkg -j$(nproc --all) O=out # Image.gz-dtb
$ARGS make bindeb-pkg -j$(nproc --all) O=out

# Copy output
mkdir -p $OUTPUT_DIR
cp linux-headers-*.deb $OUTPUT_DIR

rm -f $OUTPUT_DIR/linux-*.deb || true
cp *.deb $OUTPUT_DIR
8 changes: 5 additions & 3 deletions build_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export DOCKER_BUILDKIT=1
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR

ARCH=$(uname -m)

BUILD_DIR="$DIR/build"
OUTPUT_DIR="$DIR/output"

Expand All @@ -33,11 +35,11 @@ cp $OUTPUT_DIR/snd*.ko $DIR/userspace/usr/comma/sound/
# Download Ubuntu Base if not done already
if [ ! -f $UBUNTU_FILE ]; then
echo -e "${GREEN}Downloading Ubuntu: $UBUNTU_FILE ${NO_COLOR}"
wget -c $UBUNTU_BASE_URL/$UBUNTU_FILE --quiet
curl -C - -o $UBUNTU_FILE $UBUNTU_BASE_URL/$UBUNTU_FILE --silent
fi

# Register qemu multiarch
if [ "$(uname -p)" != "aarch64" ]; then
if [ "$ARCH" != "arm64" ] && [ "$ARCH" != "aarch64" ]; then
# Register qemu multiarch
docker run --rm --privileged multiarch/qemu-user-static:register --reset
fi

Expand Down
10 changes: 10 additions & 0 deletions clean_kernel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -e

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
KERNEL_DIR=$DIR/kernel/linux

cd $KERNEL_DIR

make $DEFCONFIG O=out mrproper
rm -rf out
rm *.deb *.buildinfo *.changes
1 change: 1 addition & 0 deletions kernel/linux
Submodule linux added at 019f8a
6 changes: 3 additions & 3 deletions load_kernel_headers.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
scp output/linux-headers*.deb comma:/tmp/
ssh comma "sudo apt install -yq /tmp/linux-headers*.deb"

scp output/linux-headers*.deb comma@comma:/tmp/
scp output/linux-image*.deb comma@comma:/tmp/
ssh comma@comma "sudo apt install -yq /tmp/linux-*.deb"
180 changes: 180 additions & 0 deletions userspace/compile-mesa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#!/bin/bash -e

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"

# MESA_REPO="https://gitlab.freedesktop.org/mesa/mesa.git"
MESA_DIR="$DIR/mesa"
BUILD_DIR="build"
INSTALL_DIR="$DIR/mesa_install"
# INSTALL_DIR="/usr/local"
# INSTALL_DIR="$(mktemp -d)"
# https://gitlab.freedesktop.org/mesa/mesa/-/branches/all
# MESA_VERSION="23.3.0"
MESA_VERSION="24.0.5"
MESA_TAR="mesa-${MESA_VERSION}.tar.xz"
MESA_URL="https://archive.mesa3d.org/${MESA_TAR}"

LLVM_VERSION="17"

# Install dependencies
sudo apt update
sudo apt install -y \
git \
build-essential \
meson \
cmake \
libglvnd-dev \
libvdpau-dev \
glslang-tools \
libomxil-bellagio-dev \
libva-dev \
rustc \
rustfmt \
libclc-$LLVM_VERSION-dev \
python3-mako \
python3-pycparser \
zlib1g-dev \
libzstd-dev \
libexpat1-dev \
libbsd-dev \
libdrm-dev \
libudev-dev \
llvm-$LLVM_VERSION-dev \
libllvm$LLVM_VERSION \
llvm-spirv-$LLVM_VERSION \
libllvmspirvlib-$LLVM_VERSION-dev \
clang-$LLVM_VERSION \
libclang-$LLVM_VERSION-dev \
libclang-cpp$LLVM_VERSION-dev \
libelf-dev \
valgrind \
bison \
byacc \
flex \
wayland-protocols \
libwayland-dev \
libwayland-egl-backend-dev \
libxext-dev \
libxfixes-dev \
libxcb-glx0-dev \
libxcb-shm0-dev \
libx11-xcb-dev \
libxcb-dri2-0-dev \
libxcb-dri3-dev \
libxcb-present-dev \
libxshmfence-dev \
libxxf86vm-dev \
libxrandr-dev \
bindgen \
pkg-config
# old deps
# build-essential \
# meson \
# ninja-build \
# libdrm-dev \
# libx11-dev \
# libxxf86vm-dev \
# libxrandr-dev \
# libxshmfence-dev \
# libxdamage-dev \
# libxext-dev \
# libxfixes-dev \
# libwayland-dev \
# libglvnd-dev \
# libelf-dev \
# libunwind-dev \
# libexpat1-dev \
# libllvm-14-ocaml-dev \
# libllvm14 \
# llvm-14 \
# llvm-14-dev \
# llvm-14-runtime \
# libclang-14-dev \
# clang-14 \
# libclang-cpp14-dev \
# libvulkan-dev \
# glslang-tools \
# libzstd-dev \
# libxcb-glx0-dev \
# libxcb-shm0-dev \
# libx11-xcb-dev \
# libxcb-dri2-0-dev \
# libxcb-dri3-dev \
# libxcb-present-dev \
# libxshmfence-dev \
# libxxf86vm-dev \
# libxrandr-dev \
# libwayland-dev \
# wayland-protocols \
# libwayland-egl-backend-dev \
# python3-mako \
# libvdpau-dev

# if [ ! -d "$MESA_DIR" ]; then
# git clone -b $MESA_VERSION_BRANCH --depth 1 --single-branch $MESA_REPO $MESA_DIR
# cd $MESA_DIR
# git apply $DIR/mesa-patches-$MESA_VERSION_BRANCH/*.patch
# fi

# Download and extract Mesa
if [ ! -d "$MESA_DIR" ]; then
curl -L -o "$MESA_TAR" "$MESA_URL"
tar -xf "$MESA_TAR"
mv "mesa-${MESA_VERSION}" "$MESA_DIR"
rm "$MESA_TAR"
cd $MESA_DIR
for patch in $DIR/mesa-patches-$MESA_VERSION/*.patch; do
patch -p1 < "$patch"
done
fi

cd $MESA_DIR

export CFLAGS="$CFLAGS -O2 -g1"
export CXXFLAGS="$CXXFLAGS -O2 -g1"
export CPPFLAGS="$CPPFLAGS -O2 -g1"

# Build Mesa with Freedreno and Rusticl support
# meson setup $BUILD_DIR --prefix=$INSTALL_DIR \
# -Db_ndebug=true \
# -Db_lto=true \
# -Dgallium-drivers=freedreno \
# -Dgallium-opencl=disabled \
# -Dvulkan-drivers=freedreno \
# -Dplatforms=wayland \
# -Dglx=disabled \
# -Dllvm=enabled \
# -Dshared-llvm=enabled \
# -Dgallium-rusticl=true \
# -Drust_std=2021

meson setup $BUILD_DIR --prefix=$INSTALL_DIR \
-Db_ndebug=true \
-Db_lto=false \
-Dgallium-drivers=freedreno \
-Dgallium-opencl=disabled \
-Dvulkan-drivers=freedreno \
-Dplatforms=wayland \
-Dglx=disabled \
-Dllvm=enabled \
-Dshared-llvm=enabled \
-Dgallium-rusticl=true \
-Drust_std=2021 \
-Dgallium-va=disabled \
-Dgallium-vdpau=disabled \
-Dgallium-xa=disabled \
-Dopengl=false \
-Dosmesa=false \
-Dgles1=disabled \
-Dgles2=disabled \
-Degl=disabled \
-Dgallium-extra-hud=false \
-Dgallium-nine=false
# -Dvideo-codecs=disabled

ninja -C $BUILD_DIR

# mkdir -p $INSTALL_DIR/lib
sudo ninja -C $BUILD_DIR install

echo "Mesa $MESA_VERSION has been built and installed successfully to $INSTALL_DIR"
Loading
Loading