|
1 | NO CONTENT: modified file |
@@ -1,88 +1,102 | |||
|
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 | # Fetch and build U-Boot bootloader |
|
9 | 9 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
10 | 10 | # Install c/c++ build environment inside the chroot |
|
11 | 11 | chroot_install_cc |
|
12 | 12 | |
|
13 | 13 | # Copy existing U-Boot sources into chroot directory |
|
14 | 14 | if [ -n "$UBOOTSRC_DIR" ] && [ -d "$UBOOTSRC_DIR" ] ; then |
|
15 | 15 | # Copy local U-Boot sources |
|
16 | 16 | cp -r "${UBOOTSRC_DIR}" "${R}/tmp" |
|
17 | 17 | else |
|
18 | 18 | # Create temporary directory for U-Boot sources |
|
19 | 19 | temp_dir=$(as_nobody mktemp -d) |
|
20 | 20 | |
|
21 | 21 | # Fetch U-Boot sources |
|
22 | 22 | as_nobody git -C "${temp_dir}" clone "${UBOOT_URL}" |
|
23 | 23 | |
|
24 | 24 | # Copy downloaded U-Boot sources |
|
25 | 25 | mv "${temp_dir}/u-boot" "${R}/tmp/" |
|
26 | 26 | |
|
27 | 27 | # Set permissions of the U-Boot sources |
|
28 | 28 | chown -R root:root "${R}/tmp/u-boot" |
|
29 | 29 | |
|
30 | 30 | # Remove temporary directory for U-Boot sources |
|
31 | 31 | rm -fr "${temp_dir}" |
|
32 | 32 | fi |
|
33 | 33 | |
|
34 | 34 | # Build and install U-Boot inside chroot |
|
35 | 35 | chroot_exec make -j"${KERNEL_THREADS}" -C /tmp/u-boot/ "${UBOOT_CONFIG}" all |
|
36 | 36 | |
|
37 | 37 | # Copy compiled bootloader binary and set config.txt to load it |
|
38 | 38 | install_exec "${R}/tmp/u-boot/tools/mkimage" "${R}/usr/sbin/mkimage" |
|
39 | 39 | install_readonly "${R}/tmp/u-boot/u-boot.bin" "${BOOT_DIR}/u-boot.bin" |
|
40 | 40 | printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> "${BOOT_DIR}/config.txt" |
|
41 | 41 | |
|
42 | 42 | # Install and setup U-Boot command file |
|
43 | 43 | install_readonly files/boot/uboot.mkimage "${BOOT_DIR}/uboot.mkimage" |
|
44 | 44 | printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" |
|
45 | 45 | |
|
46 | 46 | if [ "$ENABLE_INITRAMFS" = true ] ; then |
|
47 | 47 | # Convert generated initramfs for U-Boot using mkimage |
|
48 | 48 | 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" |
|
49 | 49 | |
|
50 | 50 | # Remove original initramfs file |
|
51 | 51 | rm -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" |
|
52 | 52 | |
|
53 | 53 | # Configure U-Boot to load generated initramfs |
|
54 | 54 | printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" |
|
55 | 55 | printf "\nbootz \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" |
|
56 | 56 | else # ENABLE_INITRAMFS=false |
|
57 | 57 | # Remove initramfs from U-Boot mkfile |
|
58 | 58 | sed -i '/.*initramfs.*/d' "${BOOT_DIR}/uboot.mkimage" |
|
59 | 59 | |
|
60 | 60 | if [ "$BUILD_KERNEL" = false ] ; then |
|
61 | 61 | # Remove dtbfile from U-Boot mkfile |
|
62 | 62 | sed -i '/.*dtbfile.*/d' "${BOOT_DIR}/uboot.mkimage" |
|
63 | 63 | printf "\nbootz \${kernel_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" |
|
64 | 64 | else |
|
65 | 65 | printf "\nbootz \${kernel_addr_r} - \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" |
|
66 | 66 | fi |
|
67 | 67 | fi |
|
68 | 68 | |
|
69 | if [ "$SET_ARCH" = 64 ] ; then | |
|
70 | echo "Setting up config.txt to boot 64bit uboot" | |
|
71 | ||
|
72 | printf "\n# 64bit-mode" >> "${BOOT_DIR}/config.txt" | |
|
73 | printf "\n# arm_control=0x200 is deprecated https://www.raspberrypi.org/documentation/configuration/config-txt/misc.md" >> "${BOOT_DIR}/config.txt" | |
|
74 | printf "\narm_64bit=1" >> "${BOOT_DIR}/config.txt" | |
|
75 | sed -i "s|bootz|booti|g" "${BOOT_DIR}/uboot.mkimage" | |
|
76 | fi | |
|
77 | ||
|
78 | # instead of sd, boot from usb device | |
|
79 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
|
80 | sed -i "s|mmc|usb|g" "${BOOT_DIR}/uboot.mkimage" | |
|
81 | fi | |
|
82 | ||
|
69 | 83 | # Set mkfile to use the correct dtb file |
|
70 | 84 | sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOT_DIR}/uboot.mkimage" |
|
71 | 85 | |
|
72 | 86 | # Set mkfile to use the correct mach id |
|
73 | 87 | if [ "$ENABLE_QEMU" = true ] ; then |
|
74 | 88 | sed -i "s/^\(setenv machid \).*/\10x000008e0/" "${BOOT_DIR}/uboot.mkimage" |
|
75 | 89 | fi |
|
76 | 90 | |
|
77 | 91 | # Set mkfile to use kernel image |
|
78 | 92 | sed -i "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOT_DIR}/uboot.mkimage" |
|
79 | 93 | |
|
80 | 94 | # Remove all leading blank lines |
|
81 | 95 | sed -i "/./,\$!d" "${BOOT_DIR}/uboot.mkimage" |
|
82 | 96 | |
|
83 | 97 | # Generate U-Boot bootloader image |
|
84 | 98 | 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 |
|
85 | 99 | |
|
86 | 100 | # Remove U-Boot sources |
|
87 | 101 | rm -fr "${R}/tmp/u-boot" |
|
88 | 102 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant