Created
December 28, 2019 05:33
-
-
Save cchen140/5ffacdb2477de6a98e90472ab2137f79 to your computer and use it in GitHub Desktop.
Commands for cross-compiling Linux kernel for Raspberry Pi 3, 4
This file contains 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
## Cross-compile Linux kernel for Raspberry Pi 3B | |
## This is for VM with a username “jjs” | |
## Cross-compiler is installed at /home/jjs/rp_tool/ | |
## SD card mount paths are for sdb1 and sdb2 | |
KERNEL=kernel7 | |
make ARCH=arm CROSS_COMPILE=/home/jjs/rp_tool/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- bcm2709_defconfig | |
make ARCH=arm CROSS_COMPILE=/home/jjs/rp_tool/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- zImage modules dtbs -j 6 | |
sudo mount /dev/sdb1 mnt/fat32 | |
sudo mount /dev/sdb2 mnt/ext4 | |
sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img | |
sudo cp arch/arm/boot/zImage mnt/fat32/$KERNEL.img | |
sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/ | |
sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/ | |
sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/ | |
sudo make ARCH=arm CROSS_COMPILE=/home/jjs/rp_tool/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install | |
sudo umount mnt/fat32 | |
sudo umount mnt/ext4 |
This file contains 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
## Cross-compile Linux kernel for Raspberry Pi 4 | |
## This is for VM with a username “jjs” | |
## Cross-compiler is installed at /home/jjs/rp_tool/ | |
## SD card mount paths are for sdb1 and sdb2 | |
KERNEL=kernel7l | |
make ARCH=arm CROSS_COMPILE=/home/jjs/rp_tool/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- bcm2711_defconfig | |
make ARCH=arm CROSS_COMPILE=/home/jjs/rp_tool/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- zImage modules dtbs -j 6 | |
sudo mount /dev/sdb1 mnt/fat32 | |
sudo mount /dev/sdb2 mnt/ext4 | |
sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img | |
sudo cp arch/arm/boot/zImage mnt/fat32/$KERNEL.img | |
sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/ | |
sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/ | |
sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/ | |
sudo make ARCH=arm CROSS_COMPILE=/home/jjs/rp_tool/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install | |
sudo umount mnt/fat32 | |
sudo umount mnt/ext4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference: https://www.raspberrypi.org/documentation/linux/kernel/building.md