@@ -1,68 +1,68 | |||
|
1 | 1 | # |
|
2 | 2 | # Build and Setup U-Boot |
|
3 | 3 | # |
|
4 | 4 | |
|
5 | 5 | # Load utility functions |
|
6 | 6 | . ./functions.sh |
|
7 | 7 | |
|
8 | 8 | # Install gcc/c++ build environment inside the chroot |
|
9 | 9 | if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ] ; then |
|
10 | 10 | COMPILER_PACKAGES=$(chroot_exec apt-get -s install ${COMPILER_PACKAGES} | grep "^Inst " | awk -v ORS=" " '{ print $2 }') |
|
11 | 11 | chroot_exec apt-get -q -y --force-yes --no-install-recommends install ${COMPILER_PACKAGES} |
|
12 | 12 | fi |
|
13 | 13 | |
|
14 | 14 | # Fetch and build U-Boot bootloader |
|
15 | 15 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
16 | 16 | # Fetch U-Boot bootloader sources |
|
17 | 17 | git -C "${R}/tmp" clone "${UBOOT_URL}" |
|
18 | 18 | |
|
19 | 19 | # Build and install U-Boot inside chroot |
|
20 | chroot_exec make -C /tmp/u-boot/ ${UBOOT_CONFIG} all | |
|
20 | chroot_exec make -j${KERNEL_THREADS} -C /tmp/u-boot/ ${UBOOT_CONFIG} all | |
|
21 | 21 | |
|
22 | 22 | # Copy compiled bootloader binary and set config.txt to load it |
|
23 | 23 | install_exec "${R}/tmp/u-boot/tools/mkimage" "${R}/usr/sbin/mkimage" |
|
24 | 24 | install_readonly "${R}/tmp/u-boot/u-boot.bin" "${BOOT_DIR}/u-boot.bin" |
|
25 | 25 | printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> "${BOOT_DIR}/config.txt" |
|
26 | 26 | |
|
27 | 27 | # Install and setup U-Boot command file |
|
28 | 28 | install_readonly files/boot/uboot.mkimage "${BOOT_DIR}/uboot.mkimage" |
|
29 | 29 | printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" |
|
30 | 30 | |
|
31 | 31 | if [ "$ENABLE_INITRAMFS" = true ] ; then |
|
32 | 32 | # Convert generated initramfs for U-Boot using mkimage |
|
33 | 33 | chroot_exec /usr/sbin/mkimage -A "${KERNEL_ARCH}" -T ramdisk -C none -n "initramfs-${KERNEL_VERSION}" -d "/boot/firmware/initramfs-${KERNEL_VERSION}" "/boot/firmware/initramfs-${KERNEL_VERSION}.uboot" |
|
34 | 34 | |
|
35 | 35 | # Remove original initramfs file |
|
36 | 36 | rm -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" |
|
37 | 37 | |
|
38 | 38 | # Configure U-Boot to load generated initramfs |
|
39 | 39 | printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" |
|
40 | 40 | printf "\nbootz \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" |
|
41 | 41 | else # ENABLE_INITRAMFS=false |
|
42 | 42 | # Remove initramfs from U-Boot mkfile |
|
43 | 43 | sed -i '/.*initramfs.*/d' "${BOOT_DIR}/uboot.mkimage" |
|
44 | 44 | |
|
45 | 45 | if [ "$BUILD_KERNEL" = false ] ; then |
|
46 | 46 | # Remove dtbfile from U-Boot mkfile |
|
47 | 47 | sed -i '/.*dtbfile.*/d' "${BOOT_DIR}/uboot.mkimage" |
|
48 | 48 | printf "\nbootz \${kernel_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" |
|
49 | 49 | else |
|
50 | 50 | printf "\nbootz \${kernel_addr_r} - \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" |
|
51 | 51 | fi |
|
52 | 52 | fi |
|
53 | 53 | |
|
54 | 54 | # Set mkfile to use the correct dtb file |
|
55 | 55 | sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOT_DIR}/uboot.mkimage" |
|
56 | 56 | |
|
57 | 57 | # Set mkfile to use kernel image |
|
58 | 58 | sed -i "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOT_DIR}/uboot.mkimage" |
|
59 | 59 | |
|
60 | 60 | # Remove all leading blank lines |
|
61 | 61 | sed -i "/./,\$!d" "${BOOT_DIR}/uboot.mkimage" |
|
62 | 62 | |
|
63 | 63 | # Generate U-Boot bootloader image |
|
64 | 64 | chroot_exec /usr/sbin/mkimage -A "${KERNEL_ARCH}" -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n "RPi${RPI_MODEL}" -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr |
|
65 | 65 | |
|
66 | 66 | # Remove U-Boot sources |
|
67 | 67 | rm -fr "${R}/tmp/u-boot" |
|
68 | 68 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant