@@ -1,161 +1,162 | |||||
1 | #!/bin/bash |
|
1 | #!/bin/bash | |
2 | # |
|
2 | # | |
3 | # Setup RPi2/3 config and cmdline |
|
3 | # Setup RPi2/3 config and cmdline | |
4 | # |
|
4 | # | |
5 |
|
5 | |||
6 | # Load utility functions |
|
6 | # Load utility functions | |
7 | . ./functions.sh |
|
7 | . ./functions.sh | |
8 |
|
8 | |||
9 | if [ "$BUILD_KERNEL" = true ] ; then |
|
9 | if [ "$BUILD_KERNEL" = true ] ; then | |
10 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then |
|
10 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then | |
11 | # Install boot binaries from local directory |
|
11 | # Install boot binaries from local directory | |
12 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin |
|
12 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin | |
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat |
|
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat | |
14 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat |
|
14 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat | |
15 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat |
|
15 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat | |
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf |
|
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf | |
17 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf |
|
17 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf | |
18 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf |
|
18 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf | |
19 | else |
|
19 | else | |
20 | # Create temporary directory for boot binaries |
|
20 | # Create temporary directory for boot binaries | |
21 | temp_dir=$(as_nobody mktemp -d) |
|
21 | temp_dir=$(as_nobody mktemp -d) | |
22 |
|
22 | |||
23 | # Install latest boot binaries from raspberry/firmware github |
|
23 | # Install latest boot binaries from raspberry/firmware github | |
24 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" |
|
24 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" | |
25 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" |
|
25 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" | |
26 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" |
|
26 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" | |
27 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" |
|
27 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" | |
28 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" |
|
28 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" | |
29 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" |
|
29 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" | |
30 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" |
|
30 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" | |
31 |
|
31 | |||
32 | # Move downloaded boot binaries |
|
32 | # Move downloaded boot binaries | |
33 | mv "${temp_dir}/"* "${BOOT_DIR}/" |
|
33 | mv "${temp_dir}/"* "${BOOT_DIR}/" | |
34 |
|
34 | |||
35 | # Remove temporary directory for boot binaries |
|
35 | # Remove temporary directory for boot binaries | |
36 | rm -fr "${temp_dir}" |
|
36 | rm -fr "${temp_dir}" | |
37 |
|
37 | |||
38 | # Set permissions of the boot binaries |
|
38 | # Set permissions of the boot binaries | |
39 | chown -R root:root "${BOOT_DIR}" |
|
39 | chown -R root:root "${BOOT_DIR}" | |
40 | chmod -R 600 "${BOOT_DIR}" |
|
40 | chmod -R 600 "${BOOT_DIR}" | |
41 | fi |
|
41 | fi | |
42 | fi |
|
42 | fi | |
43 |
|
43 | |||
44 | # Setup firmware boot cmdline |
|
44 | # Setup firmware boot cmdline | |
45 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
45 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
46 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
46 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
47 | else |
|
47 | else | |
48 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
48 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
49 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
49 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
50 | else |
|
50 | else | |
51 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
51 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
52 | fi |
|
52 | fi | |
53 | fi |
|
53 | fi | |
54 |
|
54 | |||
55 |
|
55 | |||
56 | # Add encrypted root partition to cmdline.txt |
|
56 | # Add encrypted root partition to cmdline.txt | |
57 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
57 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
58 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
58 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
59 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") |
|
59 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") | |
60 | else |
|
60 | else | |
61 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
61 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
62 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") |
|
62 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") | |
63 | else |
|
63 | else | |
64 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") |
|
64 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") | |
65 | fi |
|
65 | fi | |
66 | fi |
|
66 | fi | |
|
67 | fi | |||
67 |
|
68 | |||
68 | # Add serial console support |
|
69 | # Add serial console support | |
69 | if [ "$ENABLE_CONSOLE" = true ] ; then |
|
70 | if [ "$ENABLE_CONSOLE" = true ] ; then | |
70 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" |
|
71 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" | |
71 | fi |
|
72 | fi | |
72 |
|
73 | |||
73 | # Remove IPv6 networking support |
|
74 | # Remove IPv6 networking support | |
74 | if [ "$ENABLE_IPV6" = false ] ; then |
|
75 | if [ "$ENABLE_IPV6" = false ] ; then | |
75 | CMDLINE="${CMDLINE} ipv6.disable=1" |
|
76 | CMDLINE="${CMDLINE} ipv6.disable=1" | |
76 | fi |
|
77 | fi | |
77 |
|
78 | |||
78 | # Automatically assign predictable network interface names |
|
79 | # Automatically assign predictable network interface names | |
79 | if [ "$ENABLE_IFNAMES" = false ] ; then |
|
80 | if [ "$ENABLE_IFNAMES" = false ] ; then | |
80 | CMDLINE="${CMDLINE} net.ifnames=0" |
|
81 | CMDLINE="${CMDLINE} net.ifnames=0" | |
81 | else |
|
82 | else | |
82 | CMDLINE="${CMDLINE} net.ifnames=1" |
|
83 | CMDLINE="${CMDLINE} net.ifnames=1" | |
83 | fi |
|
84 | fi | |
84 |
|
85 | |||
85 | # Set init to systemd if required by Debian release |
|
86 | # Set init to systemd if required by Debian release | |
86 | if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then |
|
87 | if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then | |
87 | CMDLINE="${CMDLINE} init=/bin/systemd" |
|
88 | CMDLINE="${CMDLINE} init=/bin/systemd" | |
88 | fi |
|
89 | fi | |
89 |
|
90 | |||
90 | # Install firmware boot cmdline |
|
91 | # Install firmware boot cmdline | |
91 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" |
|
92 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" | |
92 |
|
93 | |||
93 | # Install firmware config |
|
94 | # Install firmware config | |
94 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" |
|
95 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" | |
95 |
|
96 | |||
96 | # Setup minimal GPU memory allocation size: 16MB (no X) |
|
97 | # Setup minimal GPU memory allocation size: 16MB (no X) | |
97 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
98 | if [ "$ENABLE_MINGPU" = true ] ; then | |
98 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" |
|
99 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" | |
99 | fi |
|
100 | fi | |
100 |
|
101 | |||
101 | # Setup boot with initramfs |
|
102 | # Setup boot with initramfs | |
102 | if [ "$ENABLE_INITRAMFS" = true ] ; then |
|
103 | if [ "$ENABLE_INITRAMFS" = true ] ; then | |
103 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" |
|
104 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" | |
104 | fi |
|
105 | fi | |
105 |
|
106 | |||
106 | # Disable RPi3 Bluetooth and restore ttyAMA0 serial device |
|
107 | # Disable RPi3 Bluetooth and restore ttyAMA0 serial device | |
107 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then |
|
108 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then | |
108 | if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then |
|
109 | if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then | |
109 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" |
|
110 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" | |
110 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" |
|
111 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" | |
111 | fi |
|
112 | fi | |
112 | fi |
|
113 | fi | |
113 |
|
114 | |||
114 | # Create firmware configuration and cmdline symlinks |
|
115 | # Create firmware configuration and cmdline symlinks | |
115 | ln -sf firmware/config.txt "${R}/boot/config.txt" |
|
116 | ln -sf firmware/config.txt "${R}/boot/config.txt" | |
116 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" |
|
117 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" | |
117 |
|
118 | |||
118 | # Install and setup kernel modules to load at boot |
|
119 | # Install and setup kernel modules to load at boot | |
119 | mkdir -p "${R}/lib/modules-load.d/" |
|
120 | mkdir -p "${R}/lib/modules-load.d/" | |
120 | install_readonly files/modules/rpi2.conf "${R}/lib/modules-load.d/rpi2.conf" |
|
121 | install_readonly files/modules/rpi2.conf "${R}/lib/modules-load.d/rpi2.conf" | |
121 |
|
122 | |||
122 | # Load hardware random module at boot |
|
123 | # Load hardware random module at boot | |
123 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then |
|
124 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then | |
124 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${R}/lib/modules-load.d/rpi2.conf" |
|
125 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${R}/lib/modules-load.d/rpi2.conf" | |
125 | fi |
|
126 | fi | |
126 |
|
127 | |||
127 | # Load sound module at boot |
|
128 | # Load sound module at boot | |
128 | if [ "$ENABLE_SOUND" = true ] ; then |
|
129 | if [ "$ENABLE_SOUND" = true ] ; then | |
129 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${R}/lib/modules-load.d/rpi2.conf" |
|
130 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${R}/lib/modules-load.d/rpi2.conf" | |
130 | else |
|
131 | else | |
131 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" |
|
132 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" | |
132 | fi |
|
133 | fi | |
133 |
|
134 | |||
134 | # Enable I2C interface |
|
135 | # Enable I2C interface | |
135 | if [ "$ENABLE_I2C" = true ] ; then |
|
136 | if [ "$ENABLE_I2C" = true ] ; then | |
136 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" |
|
137 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" | |
137 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${R}/lib/modules-load.d/rpi2.conf" |
|
138 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${R}/lib/modules-load.d/rpi2.conf" | |
138 | sed -i "s/^# i2c-dev/i2c-dev/" "${R}/lib/modules-load.d/rpi2.conf" |
|
139 | sed -i "s/^# i2c-dev/i2c-dev/" "${R}/lib/modules-load.d/rpi2.conf" | |
139 | fi |
|
140 | fi | |
140 |
|
141 | |||
141 | # Enable SPI interface |
|
142 | # Enable SPI interface | |
142 | if [ "$ENABLE_SPI" = true ] ; then |
|
143 | if [ "$ENABLE_SPI" = true ] ; then | |
143 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" |
|
144 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" | |
144 | echo "spi-bcm2708" >> "${R}/lib/modules-load.d/rpi2.conf" |
|
145 | echo "spi-bcm2708" >> "${R}/lib/modules-load.d/rpi2.conf" | |
145 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then |
|
146 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then | |
146 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${R}/lib/modules-load.d/rpi2.conf" |
|
147 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${R}/lib/modules-load.d/rpi2.conf" | |
147 | fi |
|
148 | fi | |
148 | fi |
|
149 | fi | |
149 |
|
150 | |||
150 | # Disable RPi2/3 under-voltage warnings |
|
151 | # Disable RPi2/3 under-voltage warnings | |
151 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then |
|
152 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
152 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" |
|
153 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" | |
153 | fi |
|
154 | fi | |
154 |
|
155 | |||
155 | # Install kernel modules blacklist |
|
156 | # Install kernel modules blacklist | |
156 | mkdir -p "${ETC_DIR}/modprobe.d/" |
|
157 | mkdir -p "${ETC_DIR}/modprobe.d/" | |
157 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" |
|
158 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" | |
158 |
|
159 | |||
159 | # Install sysctl.d configuration files |
|
160 | # Install sysctl.d configuration files | |
160 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
|
161 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" | |
161 |
|
162 |
@@ -1,104 +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 |
|
||||
56 | fi |
|
|||
57 | else # ENABLE_INITRAMFS=false |
|
55 | else # ENABLE_INITRAMFS=false | |
58 | # Remove initramfs from U-Boot mkfile |
|
56 | # Remove initramfs from U-Boot mkfile | |
59 | sed -i '/.*initramfs.*/d' "${BOOT_DIR}/uboot.mkimage" |
|
57 | sed -i '/.*initramfs.*/d' "${BOOT_DIR}/uboot.mkimage" | |
60 |
|
58 | |||
61 | if [ "$BUILD_KERNEL" = false ] ; then |
|
59 | if [ "$BUILD_KERNEL" = false ] ; then | |
62 | # Remove dtbfile from U-Boot mkfile |
|
60 | # Remove dtbfile from U-Boot mkfile | |
63 | sed -i '/.*dtbfile.*/d' "${BOOT_DIR}/uboot.mkimage" |
|
61 | sed -i '/.*dtbfile.*/d' "${BOOT_DIR}/uboot.mkimage" | |
64 | printf "\nbootz \${kernel_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" |
|
62 | printf "\nbootz \${kernel_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" | |
65 | else |
|
63 | else | |
66 | 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" | |
67 | fi |
|
65 | fi | |
68 | fi |
|
66 | fi | |
69 |
|
67 | |||
70 | if [ "$SET_ARCH" = 64 ] ; then |
|
68 | if [ "$SET_ARCH" = 64 ] ; then | |
71 | echo "Setting up config.txt to boot 64bit uboot" |
|
69 | echo "Setting up config.txt to boot 64bit uboot" | |
72 |
|
70 | |||
73 | printf "\n# 64bit-mode" >> "${BOOT_DIR}/config.txt" |
|
71 | printf "\n# 64bit-mode" >> "${BOOT_DIR}/config.txt" | |
74 | 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" | |
75 | printf "\narm_64bit=1" >> "${BOOT_DIR}/config.txt" |
|
73 | printf "\narm_64bit=1" >> "${BOOT_DIR}/config.txt" | |
76 | sed -i "s|bootz|booti|g" "${BOOT_DIR}/uboot.mkimage" |
|
74 | sed -i "s|bootz|booti|g" "${BOOT_DIR}/uboot.mkimage" | |
77 | fi |
|
75 | fi | |
78 |
|
76 | |||
79 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
77 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
80 | sed -i "s|mmc|usb|g" "${BOOT_DIR}/uboot.mkimage" |
|
78 | sed -i "s|mmc|usb|g" "${BOOT_DIR}/uboot.mkimage" | |
81 | fi |
|
79 | fi | |
82 |
|
80 | |||
83 |
|
81 | |||
84 | # Set mkfile to use the correct mach id |
|
82 | # Set mkfile to use the correct mach id | |
85 | if [ "$ENABLE_QEMU" = true ] ; then |
|
83 | if [ "$ENABLE_QEMU" = true ] ; then | |
86 | sed -i "s/^\(setenv machid \).*/\10x000008e0/" "${BOOT_DIR}/uboot.mkimage" |
|
84 | sed -i "s/^\(setenv machid \).*/\10x000008e0/" "${BOOT_DIR}/uboot.mkimage" | |
87 | fi |
|
85 | fi | |
88 |
|
86 | |||
89 | # Set mkfile to use the correct dtb file |
|
87 | # Set mkfile to use the correct dtb file | |
90 | 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" | |
91 |
|
89 | |||
92 | # Set mkfile to use kernel image |
|
90 | # Set mkfile to use kernel image | |
93 | 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" | |
94 |
|
92 | |||
95 | # Remove all leading blank lines |
|
93 | # Remove all leading blank lines | |
96 | sed -i "/./,\$!d" "${BOOT_DIR}/uboot.mkimage" |
|
94 | sed -i "/./,\$!d" "${BOOT_DIR}/uboot.mkimage" | |
97 |
|
95 | |||
98 | # Generate U-Boot bootloader image |
|
96 | # Generate U-Boot bootloader image | |
99 | 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 | |
100 |
|
98 | |||
101 | # Remove U-Boot sources |
|
99 | # Remove U-Boot sources | |
102 | rm -fr "${R}/tmp/u-boot" |
|
100 | rm -fr "${R}/tmp/u-boot" | |
103 | fi |
|
101 | fi | |
104 |
|
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant