This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuildkernel-uboot-rpi3-2.sh
executable file
·89 lines (65 loc) · 2.62 KB
/
buildkernel-uboot-rpi3-2.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
80
81
82
83
84
85
86
87
88
#!/bin/sh
cd build
S=$(pwd)
sudo apt-get install gcc-aarch64-linux-gnu dpkg-dev
sudo apt-get install bc bison flex libssl-dev u-boot-tools
CROSS=aarch64-linux-gnu-
LINUX_RPI=4.15.y
git clone --depth 1 --branch v2018.11 git://git.denx.de/u-boot.git v2018.11
cd v2018.11
make CROSS_COMPILE=$CROSS rpi_3_defconfig
make CROSS_COMPILE=$CROSS
sudo cp u-boot.bin $S/boot
cat <<"EOM" > u-boot-script.txt
setenv fdt_addr_r 0x03000000
fdt addr ${fdt_addr_r}
fdt get value bootargs /chosen bootargs
setenv kernel_addr_r 0x01000000
setenv ramdisk_addr_r 0x03100000
fatload mmc 0:1 ${kernel_addr_r} vmlinuz
fatload mmc 0:1 ${ramdisk_addr_r} initrd.img
setenv initrdsize $filesize
booti ${kernel_addr_r} ${ramdisk_addr_r}:${initrdsize} ${fdt_addr_r}
EOM
mkimage -A arm64 -O linux -T script -d u-boot-script.txt boot.scr
sudo cp boot.scr $S/boot
cd ..
git clone --depth=1 -b rpi-$LINUX_RPI https://github.com/raspberrypi/linux.git linux-$LINUX_RPI
cd linux-$LINUX_RPI
make ARCH=arm64 CROSS_COMPILE=$CROSS bcmrpi3_defconfig
make ARCH=arm64 CROSS_COMPILE=$CROSS -j$(nproc)
KERNEL_VERSION=`cat ./include/generated/utsrelease.h | sed -e 's/.*"\(.*\)".*/\1/'`
sudo rm -rf $S/rootfs/lib/modules/*
sudo rm -rf $S/boot/config-*
sudo rm -rf $S/boot/System.map-*
sudo rm -rf $S/boot/vmlinuz-*
make ARCH=arm64 CROSS_COMPILE=$CROSS install INSTALL_PATH=$S/boot
sudo make ARCH=arm64 CROSS_COMPILE=$CROSS modules_install INSTALL_MOD_PATH=$S/rootfs INSTALL_FW_PATH=$S/rootfs/lib/firmware
sudo make ARCH=arm64 CROSS_COMPILE=$CROSS headers_install INSTALL_HDR_PATH=$S/rootfs/usr
cp arch/arm64/boot/Image $S/boot/Image
cp arch/arm64/boot/dts/broadcom/*.dtb $S/boot
mv $S/boot/vmlinuz-$KERNEL_VERSION $S/boot/vmlinuz
sudo rm -rf $S/boot/*dts*
sudo rm -rf $S/boot/*old
sudo rm -rf $S/boot/kernel*img
sudo rm -rf $S/boot/arm*bin
cd ..
sudo chroot rootfs/ mkinitramfs -o /root/initrd.img $KERNEL_VERSION
sudo mv rootfs/root/initrd.img $S/boot
cat <<"EOM" > $S/boot/config.txt
enable_uart=1
kernel=u-boot.bin
device_tree_address=0x03000000
dtparam=i2c_arm=on
dtparam=spi=on
arm_64bit=1
EOM
echo "earlyprintk dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait" > $S/boot/cmdline.txt
cd $S
echo RPI_VER=rpi3b-uboot-2 >> ./.RPi-Target
make -C linux-$LINUX_RPI ARCH=arm64 CROSS_COMPILE=$CROSS -j$(nproc) bindeb-pkg
mkdir deb-pkg
mv linux-*deb deb-pkg
mv linux-*changes linux-*info linux-$LINUX_RPI
echo "Debian packages of linux-image and linux-headers are generated, "
echo "Please note that vmlinuz is gzip-compressed Image(.gz), and it must be gunziped as uncompressed Image for u-boot's aarch64 booti command"