Last active
June 9, 2022 17:53
-
-
Save Cnly/1fff0279259122075e96692f3981e38c to your computer and use it in GitHub Desktop.
Automatically fetch and [cross] compile MPTCP for Raspberry Pi, yielding an easy-to-use install script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
RPI_BRANCH=rpi-4.14.y | |
MPTCP_BRANCH=mptcp_v0.94 | |
# For Pi 1, Pi 0, Pi 0 W, or Compute Module: | |
#KERNEL=kernel | |
#DEFCONFIG=bcmrpi_defconfig | |
# Or, for Pi 2, Pi 3, or Compute Module 3: | |
KERNEL=kernel7 | |
DEFCONFIG=bcm2709_defconfig | |
sudo apt update && sudo apt install -y build-essential git bc | |
case $(uname -m) in | |
*arm*) | |
HOST=arm | |
;; | |
*) | |
HOST=$(uname -m) | |
;; | |
esac | |
if [ "$HOST" != "arm" ]; then | |
git clone --depth 1 https://github.com/raspberrypi/tools rpi-tools | |
if [ "$HOST" == "x86_64" ]; then | |
export PATH=$PATH:$(pwd)/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin | |
else | |
export PATH=$PATH:$(pwd)/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin | |
fi | |
fi | |
git clone -b $RPI_BRANCH --single-branch https://github.com/raspberrypi/linux.git | |
cd linux | |
git remote add -t $MPTCP_BRANCH mptcp https://github.com/multipath-tcp/mptcp.git | |
git fetch mptcp $MPTCP_BRANCH | |
git merge mptcp/$MPTCP_BRANCH -m "Merge $RPI_BRANCH and $MPTCP_BRANCH" | |
if [ "$?" -ne 0 ]; then | |
echo "Merge was unsuccessful. Stopping." | |
echo "Please resolve the conflict, commit, and then re-run the script." | |
exit 1 | |
fi | |
if [ "$HOST" != "arm" ]; then | |
ARCH=arm | |
CROSS_COMPILE=arm-linux-gnueabihf- | |
MAKE_ARGS="ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE -j $(nproc)" | |
else | |
MAKE_ARGS="-j $(nproc)" | |
fi | |
make $MAKE_ARGS $DEFCONFIG | |
tee << EOF > .config-mptcp | |
CONFIG_TCP_CONG_LIA=m | |
CONFIG_TCP_CONG_OLIA=m | |
CONFIG_TCP_CONG_WVEGAS=m | |
CONFIG_TCP_CONG_BALIA=m | |
CONFIG_IPV6=y | |
CONFIG_MPTCP=y | |
CONFIG_MPTCP_PM_ADVANCED=y | |
CONFIG_MPTCP_FULLMESH=y | |
CONFIG_MPTCP_NDIFFPORTS=m | |
CONFIG_MPTCP_BINDER=m | |
CONFIG_DEFAULT_FULLMESH=y | |
# CONFIG_DEFAULT_DUMMY is not set | |
CONFIG_DEFAULT_MPTCP_PM="fullmesh" | |
CONFIG_MPTCP_SCHED_ADVANCED=y | |
CONFIG_MPTCP_ROUNDROBIN=m | |
CONFIG_MPTCP_REDUNDANT=m | |
CONFIG_DEFAULT_SCHEDULER=y | |
CONFIG_DEFAULT_MPTCP_SCHED="default" | |
EOF | |
./scripts/kconfig/merge_config.sh -m .config .config-mptcp | |
make $MAKE_ARGS zImage modules dtbs | |
MOD_OUTPUT_DIR=output/ | |
rm -rf $MOD_OUTPUT_DIR | |
mkdir -p $MOD_OUTPUT_DIR | |
make $MAKE_ARGS INSTALL_MOD_PATH=$MOD_OUTPUT_DIR modules_install | |
KERNEL_VERSION=$(ls output/lib/modules/) | |
rm $MOD_OUTPUT_DIR/lib/modules/$KERNEL_VERSION/build $MOD_OUTPUT_DIR/lib/modules/$KERNEL_VERSION/source | |
BOOT_DIR=output/boot | |
rm -rf $BOOT_DIR | |
mkdir -p $BOOT_DIR/overlays | |
cp arch/arm/boot/zImage $BOOT_DIR/$KERNEL.img | |
cp arch/arm/boot/dts/*.dtb $BOOT_DIR/ | |
cp arch/arm/boot/dts/overlays/*.dtb* $BOOT_DIR/overlays/ | |
cp arch/arm/boot/dts/overlays/README $BOOT_DIR/overlays/ | |
tar -cvJf rpi-$KERNEL_VERSION-mptcp.tar.xz -C output/ . | |
tee << EOF > rpi-$KERNEL_VERSION-mptcp.sh | |
#! /usr/bin/env bash | |
if [ -z \$1 ]; then | |
DIR= | |
else | |
DIR=\$1 | |
fi | |
TEMP_DIR=\$(mktemp -d) | |
cp \$DIR/boot/$KERNEL.img \$DIR/boot/$KERNEL-original.img | |
tail -n+16 \$BASH_SOURCE | tar -xvJf - -C \$TEMP_DIR | |
cp -R \$TEMP_DIR/* \$DIR/ | |
rm -rf \$TEMP_DIR | |
exit 0 | |
EOF | |
cat rpi-$KERNEL_VERSION-mptcp.tar.xz >> rpi-$KERNEL_VERSION-mptcp.sh | |
chmod a+x rpi-$KERNEL_VERSION-mptcp.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it working on latest RPI 4, and Rasbian Buster ?