forked from Brainchip-Inc/akida_dw_edma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_kernel_w_cma.sh
executable file
·79 lines (59 loc) · 1.91 KB
/
build_kernel_w_cma.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# This scripts builds the kernel with CMA enabled with 64MB by default, adapted
# for usage with AKD1500.
#
# Info on how to build from:
# - https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel
# - https://askubuntu.com/questions/1435591/correct-way-to-build-kernel-with-hardware-support-fix-patches-ubuntu-22-04-lts
POSTFIX=-cma-akd1500
DIRNAME=linux-kernel$POSTFIX
# Check if CMA is already enabled
grep "CONFIG_CMA=y" /boot/config-$(uname -r)
ret=$?
if [ $ret -eq 0 ]; then
echo "CONFIG_CMA=y is present in your current kernel config, no need to"
echo "rebuild a new kernel."
exit 0
fi
set -e
mkdir -p $DIRNAME
cd $DIRNAME
sudo sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list
sudo apt update
# Instead of:
# sudo apt-get build-dep linux linux-image-$(uname -r)
# This seems to work:
sudo apt -y build-dep linux-image-generic
sudo apt-get install libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf llvm
sudo apt-get install git
apt-get source linux-image-unsigned-$(uname -r)
linux_dir=`ls -d */`
cd $linux_dir
chmod a+x debian/rules
chmod a+x debian/scripts/*
chmod a+x debian/scripts/misc/*
cp /boot/config-$(uname -r) ./.config
# Modify configuration to enable CMA
MBYTES_CMA=64
echo "CONFIG_CMA=y" >> ./.config
echo "CONFIG_CMA_SIZE_MBYTES=$MBYTES_CMA" >> ./.config
echo "CONFIG_CMA_SIZE_SEL_MBYTES=y" >> ./.config
# update config for new kernel with default options for other settings
make olddefconfig
echo
echo
echo "👉 Kernel will now be built, this might take a while."
echo
echo
make deb-pkg LOCALVERSION=-cma-akd1500
echo
echo
echo "🎉 Kernel is now built! Availables packages are in $DIRNAME."
echo "You can install those with these commands:"
echo
echo "sudo dpkg -i $DIRNAME/*.deb"
echo "sudo reboot"
echo
echo "Once rebooted, you will need to re-build the akd1500 PCIe module."
echo "To do that, you can run './install.sh'"
echo