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