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-devapt install -y binutils-mips64-linux-gnuabi64 gcc-mips64-linux-gnuabi64cd downloadwget http://security.debian.org/debian-security/pool/updates/main/l/linux/linux-source-4.19_4.19.67-2+deb10u2_all.debwget http://security.debian.org/debian-security/pool/updates/main/l/linux/linux-config-4.19_4.19.67-2+deb10u2_mips64el.debdpkg -x download/linux-source-4.19_4.19.67-2+deb10u2_all.deb .tar xf usr/src/linux-source-4.19.tar.xzdpkg -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.xzpatch -p0 -b < kconfig.patchcp usr/src/linux-config-4.19/config.mips64el_none_5kc-malta linux-source-4.19/.configcd linux-source-4.19make ARCH=mips CROSS_COMPILE=mips64-linux-gnuabi64- oldconfigmake ARCH=mips CROSS_COMPILE=mips64-linux-gnuabi64- KDEB_PKGVERSION=1 -j`nproc` bindeb-pkgBelow the script file and kernel config patch would work together to execute the above steps automatically.