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