I was trying to install Debian/MIPS on QEMU and found out that I need to build/update the kernel. The existing instructions mostly talk about native build, which is painfully slow on QEMU. I tried once and it took almost 10 hours! There are some references to cross-build debian kernel and none applies straightforwardly. I decided to write a blog on how I did it.
apt install -y build-essential linux-source bc kmod cpio flex cpio libncurses5-dev bison libssl-dev
apt install -y binutils-mips64-linux-gnuabi64 gcc-mips64-linux-gnuabi64
cd download
wget http://security.debian.org/debian-security/pool/updates/main/l/linux/linux-source-4.19_4.19.67-2+deb10u2_all.deb
wget http://security.debian.org/debian-security/pool/updates/main/l/linux/linux-config-4.19_4.19.67-2+deb10u2_mips64el.deb
dpkg -x download/linux-source-4.19_4.19.67-2+deb10u2_all.deb .
tar xf usr/src/linux-source-4.19.tar.xz
dpkg -x download/linux-config-4.19_4.19.67-2+deb10u2_mips64el.deb .
unxz usr/src/linux-config-4.19/config.mips64el_none_5kc-malta.xz
patch -p0 -b < kconfig.patch
cp usr/src/linux-config-4.19/config.mips64el_none_5kc-malta linux-source-4.19/.config
cd linux-source-4.19
make ARCH=mips CROSS_COMPILE=mips64-linux-gnuabi64- oldconfig
make ARCH=mips CROSS_COMPILE=mips64-linux-gnuabi64- KDEB_PKGVERSION=1 -j`nproc` bindeb-pkg
Below the script file and kernel config patch would work together to execute the above steps automatically.