##// END OF EJS Templates
Merge pull request #166 from burnbabyburn/0...
drtyhlpr -
r465:d3336fac57fa Fusion
parent child
Show More
@@ -0,0 +1,33
1 SUBSYSTEM=="input", GROUP="input", MODE="0660"
2 SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"
3 SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"
4 SUBSYSTEM=="bcm2835-gpiomem", GROUP="gpio", MODE="0660"
5
6 SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660"
7 SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
8 chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
9 chown -R root:gpio /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\
10 chown -R root:gpio /sys$devpath && chmod -R 770 /sys$devpath\
11 '"
12
13 KERNEL=="ttyAMA[01]", PROGRAM="/bin/sh -c '\
14 ALIASES=/proc/device-tree/aliases; \
15 if cmp -s $ALIASES/uart0 $ALIASES/serial0; then \
16 echo 0;\
17 elif cmp -s $ALIASES/uart0 $ALIASES/serial1; then \
18 echo 1; \
19 else \
20 exit 1; \
21 fi\
22 '", SYMLINK+="serial%c"
23
24 KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\
25 ALIASES=/proc/device-tree/aliases; \
26 if cmp -s $ALIASES/uart1 $ALIASES/serial0; then \
27 echo 0; \
28 elif cmp -s $ALIASES/uart1 $ALIASES/serial1; then \
29 echo 1; \
30 else \
31 exit 1; \
32 fi \
33 '", SYMLINK+="serial%c"
@@ -0,0 +1,1
1 kernel.printk = 3 4 1 3 No newline at end of file
@@ -61,19 +61,14 A comma separated list of additional packages to be installed by apt after boots
61 61 Set Architecture to default 32bit. If you want to to compile 64bit (RPI3 or RPI3+) set it to `64`. This option will set every needed crosscompiler or boeard specific option for a successful build.
62 62
63 63 ##### `RPI_MODEL`=2
64 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models (`BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used) :
65
66 `0` = Used for Raspberry Pi 0 and Raspberry Pi 0 W
67
68 `1` = Used for Raspberry Pi 1 model A and B
69
70 `1P` = Used for Raspberry Pi 1 model B+ and A+
71
72 `2` = Used for Raspberry Pi 2 model B
73
74 `3` = Used for Raspberry Pi 3 model B
75
76 `3P` = Used for Raspberry Pi 3 model B+
64 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
65 - `0` = Used for Raspberry Pi 0 and Raspberry Pi 0 W
66 - `1` = Used for Pi 1 model A and B
67 - `1P` = Used for Pi 1 model B+ and A+
68 - `2` = Used for Pi 2 model B
69 - `3` = Used for Pi 3 model B
70 - `3P` = Used for Pi 3 model B+
71 - `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used.
77 72
78 73 ##### `RELEASE`="buster"
79 74 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases `stretch` and `buster`.
@@ -157,7 +152,19 Set the IP address for the second NTP server.
157 152
158 153 #### Basic system features:
159 154 ##### `ENABLE_CONSOLE`=true
160 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi 0/1/2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
155 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system. On RPI `0` `3` `3P` the CPU speed is locked at lowest speed.
156
157 ##### `ENABLE_PRINTK`=false
158 Enables printing kernel messages to konsole. printk is `3 4 1 3` as in raspbian.
159
160 ##### `ENABLE_BLUETOOTH`=false
161 Enable onboard Bluetooth interface on the RPi0/3/3P. See: https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/
162
163 ##### `ENABLE_MINIUART_OVERLAY`=false
164 Enable Bluetooth to use this. Adds overlay to swap UART0 with UART1. Enabling (slower) Bluetooth and full speed serial console. - RPI `0` `3` `3P` have a fast `hardware UART0` (ttyAMA0) and a `mini UART1` (ttyS0)! RPI `1` `1P` `2` only have a `hardware UART0`. `UART0` is considered better, because is faster and more stable than `mini UART1`. By default the Bluetooth modem is mapped to the `hardware UART0` and `mini UART` is used for console. The `mini UART` is a problem for the serial console, because its baudrate depends on the cpu frequency, which is changing on runtime. Resulting in a volatile baudrate and thus in an unusable serial console.
165
166 ##### `ENABLE_TURBO`=false
167 Enable Turbo mode. This setting locks cpu at highest frequency. As setting ENABLE_CONSOLE=true locks RPI to lowest CPU speed, this is can be used additionally to lock cpu hat max speed. Need a good power supply and probably cooling for the Raspberry PI.
161 168
162 169 ##### `ENABLE_I2C`=false
163 170 Enable I2C interface on the RPi 0/1/2/3. Please check the [RPi 0/1/2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
@@ -178,8 +185,7 Allow the installation of non-free Debian packages that do not comply with the D
178 185 Download and install the [closed-source firmware binary blob](https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm) that is required to run the internal wireless interface of the Raspberry Pi model `3`. This parameter is ignored if the specified `RPI_MODEL` is not `3`.
179 186
180 187 ##### `ENABLE_RSYSLOG`=true
181 If set to false, disable and uninstall rsyslog (so logs will be available only
182 in journal files)
188 If set to false, disable and uninstall rsyslog (so logs will be available only in journal files)
183 189
184 190 ##### `ENABLE_SOUND`=true
185 191 Enable sound hardware and install Advanced Linux Sound Architecture.
@@ -28,10 +28,10 if [ "$(echo "$APT_INCLUDES" | grep ",locales")" ] ; then
28 28 chroot_exec update-locale LANG="${DEFLOCAL}"
29 29
30 30 # Install and setup default keyboard configuration
31 if [ "$XKB_MODEL" != "pc105" ] ; then
31 if [ "$XKB_MODEL" != "" ] ; then
32 32 sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" "${ETC_DIR}/default/keyboard"
33 33 fi
34 if [ "$XKB_LAYOUT" != "us" ] ; then
34 if [ "$XKB_LAYOUT" != "" ] ; then
35 35 sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" "${ETC_DIR}/default/keyboard"
36 36 fi
37 37 if [ "$XKB_VARIANT" != "" ] ; then
@@ -108,7 +108,7 if [ "$BUILD_KERNEL" = true ] ; then
108 108 echo "CONFIG_CRYPTO_XTS=y"
109 109 echo "CONFIG_CRYPTO_SHA512=y"
110 110 echo "CONFIG_CRYPTO_MANAGER=y"
111 } >> ${KERNEL_DIR}/.config
111 } >> "${KERNEL_DIR}"/.config
112 112 fi
113 113 fi
114 114
@@ -139,7 +139,7 if [ "$BUILD_KERNEL" = true ] ; then
139 139 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
140 140
141 141 # Cross compile kernel modules
142 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
142 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
143 143 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
144 144 fi
145 145 fi
@@ -153,16 +153,16 if [ "$BUILD_KERNEL" = true ] ; then
153 153
154 154 # Install kernel modules
155 155 if [ "$ENABLE_REDUCE" = true ] ; then
156 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
156 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
157 157 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
158 158 fi
159 159 else
160 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
160 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
161 161 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
162 162 fi
163 163
164 164 # Install kernel firmware
165 if [ "$(grep "^firmware_install:" "${KERNEL_DIR}/Makefile")" ] ; then
165 if grep -q "^firmware_install:" "${KERNEL_DIR}/Makefile" ; then
166 166 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
167 167 fi
168 168 fi
@@ -225,8 +225,8 if [ "$BUILD_KERNEL" = true ] ; then
225 225 rm -fr "${KERNEL_DIR}"
226 226 else
227 227 # Prepare compiled kernel modules
228 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
229 if [ "$(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile")" ] ; then
228 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
229 if grep -q "^modules_prepare:" "${KERNEL_DIR}/Makefile" ; then
230 230 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
231 231 fi
232 232
@@ -56,9 +56,100 if [ "$ENABLE_CRYPTFS" = true ] ; then
56 56 fi
57 57 fi
58 58
59 # Add serial console support
59 #locks cpu at max frequency
60 if [ "$ENABLE_TURBO" = true ] ; then
61 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
62 fi
63
64 if [ "$ENABLE_PRINTK" = true ] ; then
65 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
66 fi
67
68 # Install udev rule for serial alias
69 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
70
71 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
72
73 # RPI0,3,3P Use default ttyS0 (mini-UART)as serial interface
74 SET_SERIAL="ttyS0"
75
76 # Bluetooth enabled
77 if [ "$ENABLE_BLUETOOTH" = true ] ; then
78 # Create temporary directory for Bluetooth sources
79 temp_dir=$(as_nobody mktemp -d)
80
81 # Fetch Bluetooth sources
82 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
83
84 # Copy downloaded sources
85 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
86
87 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
88 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
89 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
90
91 # Set permissions
92 chown -R root:root "${R}/tmp/pi-bluetooth"
93
94 # Install tools
95 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
96 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
97
98 # Install bluetooth udev rule
99 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
100
101 # Install Firmware Flash file and apropiate licence
102 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
103 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
104 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
105 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
106 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
107
108 # Remove temporary directory
109 rm -fr "${temp_dir}"
110
111 # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0
112 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
113 SET_SERIAL="ttyAMA0"
114
115 # set overlay to swap ttyAMA0 and ttyS0
116 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
117
118 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
119 if [ "$ENABLE_TURBO" = false ] ; then
120 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
121 fi
122
123 # Activate services
124 chroot_exec systemctl enable pi-bluetooth.hciuart.service
125 #chroot_exec systemctl enable pi-bluetooth.bthelper@.service
126 else
127 chroot_exec systemctl enable pi-bluetooth.hciuart.service
128 #chroot_exec systemctl enable pi-bluetooth.bthelper@.service
129 fi
130
131 else # if ENABLE_BLUETOOTH = false
132 # set overlay to disable bluetooth
133 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
134 fi # ENABLE_BLUETOOTH end
135
136 else
137 # RPI1,1P,2 Use default ttyAMA0 (full UART) as serial interface
138 SET_SERIAL="ttyAMA0"
139 fi
140
141 # may need sudo systemctl disable hciuart
60 142 if [ "$ENABLE_CONSOLE" = true ] ; then
61 CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200"
143 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
144 # add string to cmdline
145 CMDLINE="${CMDLINE} console=serial0,115200"
146
147 # Enable serial console systemd style
148 chroot_exec systemctl enable serial-getty\@"$SET_SERIAL".service
149 else
150 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
151 # disable serial console systemd style
152 chroot_exec systemctl disable serial-getty\@"$SET_SERIAL".service
62 153 fi
63 154
64 155 # Remove IPv6 networking support
@@ -89,42 +180,6 if [ "$ENABLE_INITRAMFS" = true ] ; then
89 180 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
90 181 fi
91 182
92 # Disable RPi3 Bluetooth and restore ttyAMA0 serial device
93 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
94 if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then
95 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
96 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
97 else
98 # Create temporary directory for Bluetooth sources
99 temp_dir=$(as_nobody mktemp -d)
100
101 # Fetch Bluetooth sources
102 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
103
104 # Copy downloaded sources
105 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
106
107 # Set permissions
108 chown -R root:root "${R}/tmp/pi-bluetooth"
109
110 # Install tools
111 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
112 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
113
114 # Install bluetooth udev rule
115 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
116
117 # Install Firmware Flash file and apropiate licence
118 mkdir "${ETC_DIR}/firmware/"
119
120 wget -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
121 wget -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
122
123 # Get /dev/serial back for compability
124 wget -O "${ETC_DIR}/udev/rules.d/99-com.rules" https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules
125 fi
126 fi
127
128 183 # Create firmware configuration and cmdline symlinks
129 184 ln -sf firmware/config.txt "${R}/boot/config.txt"
130 185 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
@@ -107,28 +107,26 if [ "$ENABLE_WIRELESS" = true ] ; then
107 107 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.bin"
108 108 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.txt"
109 109 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.clm_blob" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.clm_blob"
110
111 # Move downloaded firmware binary blob
112 mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/"
113
114 # Set permissions of the firmware binary blob
115 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
116 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
110 117 elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then
111 118 # Fetch firmware binary blob for RPi3
112 119 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin"
113 120 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt"
114 fi
115
116 # Move downloaded firmware binary blob
117 if [ "$RPI_MODEL" = 3P ] ; then
118 mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/"
119 elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then
120 mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/"
121
122 # Move downloaded firmware binary blob
123 mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/"
124
125 # Set permissions of the firmware binary blob
126 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
127 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
121 128 fi
122 129
123 130 # Remove temporary directory for firmware binary blob
124 131 rm -fr "${temp_dir}"
125
126 # Set permissions of the firmware binary blob
127 if [ "$RPI_MODEL" = 3P ] ; then
128 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
129 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
130 elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then
131 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
132 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
133 fi
134 132 fi
@@ -11,8 +11,8 ENCRYPTED_USER_PASSWORD=$(mkpasswd -m sha-512 "${USER_PASSWORD}")
11 11
12 12 # Setup default user
13 13 if [ "$ENABLE_USER" = true ] ; then
14 chroot_exec adduser --gecos $USER_NAME --add_extra_groups --disabled-password $USER_NAME
15 chroot_exec usermod -a -G sudo -p "${ENCRYPTED_USER_PASSWORD}" $USER_NAME
14 chroot_exec adduser --gecos "$USER_NAME" --add_extra_groups --disabled-password "$USER_NAME"
15 chroot_exec usermod -a -G sudo -p "${ENCRYPTED_USER_PASSWORD}" "$USER_NAME"
16 16 fi
17 17
18 18 # Setup root password or not
@@ -41,7 +41,7 if [ "$ENABLE_UBOOT" = true ] ; then
41 41
42 42 # Install and setup U-Boot command file
43 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 46 if [ "$ENABLE_INITRAMFS" = true ] ; then
47 47 # Convert generated initramfs for U-Boot using mkimage
@@ -51,7 +51,7 if [ "$ENABLE_UBOOT" = true ] ; then
51 51 rm -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}"
52 52
53 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 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
@@ -65,19 +65,21 if [ "$ENABLE_UBOOT" = true ] ; then
65 65 printf "\nbootz \${kernel_addr_r} - \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage"
66 66 fi
67 67 fi
68
69 if [ "$KERNEL_ARCH" = "arm64" ] ; 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 68
69 if [ "$SET_ARCH" = 64 ] ; then
70 echo "Setting up config.txt to boot 64bit uboot"
71 {
72 printf "\n# 64bit-mode"
73 printf "\n# arm_control=0x200 is deprecated https://www.raspberrypi.org/documentation/configuration/config-txt/misc.md"
74 printf "\narm_64bit=1"
75 } >> "${BOOT_DIR}/config.txt"
76
77 #in 64bit uboot booti is used instead of bootz [like in KERNEL_BIN_IMAGE=zImage (armv7)|| Image(armv8)]
76 78 sed -i "s|bootz|booti|g" "${BOOT_DIR}/uboot.mkimage"
77 79 fi
78 80
79 81 # Set mkfile to use the correct dtb file
80 sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOT_DIR}/uboot.mkimage"
82 sed -i "s|bcm2709-rpi-2-b.dtb|${DTB_FILE}|" "${BOOT_DIR}/uboot.mkimage"
81 83
82 84 # Set mkfile to use the correct mach id
83 85 if [ "$ENABLE_QEMU" = true ] ; then
@@ -85,7 +87,7 if [ "$ENABLE_UBOOT" = true ] ; then
85 87 fi
86 88
87 89 # Set mkfile to use kernel image
88 sed -i "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOT_DIR}/uboot.mkimage"
90 sed -i "s|kernel7.img|${KERNEL_IMAGE}|" "${BOOT_DIR}/uboot.mkimage"
89 91
90 92 # Remove all leading blank lines
91 93 sed -i "/./,\$!d" "${BOOT_DIR}/uboot.mkimage"
@@ -8,16 +8,16
8 8 if [ "$ENABLE_VIDEOCORE" = true ] ; then
9 9 # Copy existing videocore sources into chroot directory
10 10 if [ -n "$VIDEOCORESRC_DIR" ] && [ -d "$VIDEOCORESRC_DIR" ] ; then
11 # Copy local U-Boot sources
11 # Copy local videocore sources
12 12 cp -r "${VIDEOCORESRC_DIR}" "${R}/tmp/userland"
13 13 else
14 # Create temporary directory for U-Boot sources
14 # Create temporary directory for videocore sources
15 15 temp_dir=$(as_nobody mktemp -d)
16 16
17 # Fetch U-Boot sources
17 # Fetch videocore sources
18 18 as_nobody git -C "${temp_dir}" clone "${VIDEOCORE_URL}"
19 19
20 # Copy downloaded U-Boot sources
20 # Copy downloaded videocore sources
21 21 mv "${temp_dir}/userland" "${R}/tmp/"
22 22
23 23 # Set permissions of the U-Boot sources
@@ -31,7 +31,7 if [ "$ENABLE_VIDEOCORE" = true ] ; then
31 31 mkdir "${R}"/tmp/userland/build
32 32
33 33 # push us to build directory
34 pushd "${R}"/tmp/userland/build
34 cd "${R}"/tmp/userland/build
35 35
36 36 if [ "$RELEASE_ARCH" = "arm64" ] ; then
37 37 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DARM64=ON -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_ASM_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland"
@@ -48,6 +48,6 if [ "$ENABLE_VIDEOCORE" = true ] ; then
48 48 #build userland
49 49 make -j "$(nproc)"
50 50
51 #pop us out of build dir
52 popd
51 #back to root of scriptdir
52 cd "${WORKDIR}"
53 53 fi
@@ -30,22 +30,22 cleanup (){
30 30
31 31 chroot_exec() {
32 32 # Exec command in chroot
33 LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot ${R} $*
33 LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot "${R}" "$@"
34 34 }
35 35
36 36 as_nobody() {
37 37 # Exec command as user nobody
38 sudo -E -u nobody LANG=C LC_ALL=C $*
38 sudo -E -u nobody LANG=C LC_ALL=C "$@"
39 39 }
40 40
41 41 install_readonly() {
42 42 # Install file with user read-only permissions
43 install -o root -g root -m 644 $*
43 install -o root -g root -m 644 "$@"
44 44 }
45 45
46 46 install_exec() {
47 47 # Install file with root exec permissions
48 install -o root -g root -m 744 $*
48 install -o root -g root -m 744 "$@"
49 49 }
50 50
51 51 use_template () {
@@ -64,14 +64,14 chroot_install_cc() {
64 64 if [ -z "${COMPILER_PACKAGES}" ] ; then
65 65 COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }')
66 66 # Install COMPILER_PACKAGES in chroot
67 chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES}
67 chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install "${COMPILER_PACKAGES}"
68 68 fi
69 69 }
70 70
71 71 chroot_remove_cc() {
72 72 # Remove c/c++ build environment from the chroot
73 if [ ! -z "${COMPILER_PACKAGES}" ] ; then
74 chroot_exec apt-get -qq -y --auto-remove purge ${COMPILER_PACKAGES}
73 if [ -n "${COMPILER_PACKAGES}" ] ; then
74 chroot_exec apt-get -qq -y --auto-remove purge "${COMPILER_PACKAGES}"
75 75 COMPILER_PACKAGES=""
76 76 fi
77 77 }
@@ -59,7 +59,8 VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland}
59 59 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
60 60
61 61 # Build directories
62 BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}}
62 WORKDIR=$(pwd)
63 BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}}
63 64 BUILDDIR="${BASEDIR}/build"
64 65
65 66 # Chroot directories
@@ -69,6 +70,7 LIB_DIR="${R}/lib"
69 70 BOOT_DIR="${R}/boot/firmware"
70 71 KERNEL_DIR="${R}/usr/src/linux"
71 72 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
73 BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt"
72 74
73 75 # Firmware directory: Blank if download from github
74 76 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
@@ -105,6 +107,9 APT_PROXY=${APT_PROXY:=""}
105 107 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
106 108
107 109 # Feature settings
110 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
111 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
112 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
108 113 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
109 114 ENABLE_I2C=${ENABLE_I2C:=false}
110 115 ENABLE_SPI=${ENABLE_SPI:=false}
@@ -186,7 +191,7 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
186 191
187 192 # Packages required in the chroot build environment
188 193 APT_INCLUDES=${APT_INCLUDES:=""}
189 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup"
194 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
190 195
191 196 # Packages to exclude from chroot build environment
192 197 APT_EXCLUDES=${APT_EXCLUDES:=""}
@@ -200,6 +205,12 COMPILER_PACKAGES=""
200 205
201 206 set +x
202 207
208 #Check if apt-cacher-ng has port 3142 open and set APT_PROXY
209 APT_CACHER_RUNNING=$(lsof -i :3142 | grep apt-cacher-ng | cut -d ' ' -f3 | uniq)
210 if [ -n "${APT_CACHER_RUNNING}" ] ; then
211 APT_PROXY=http://127.0.0.1:3142/
212 fi
213
203 214 # Setup architecture specific settings
204 215 if [ -n "$SET_ARCH" ] ; then
205 216 # 64-bit configuration
@@ -252,37 +263,51 else
252 263 echo "error: Please set '32' or '64' as value for SET_ARCH"
253 264 exit 1
254 265 fi
255 # Device specific configuration and U-Boot configuration
256 case "$RPI_MODEL" in
257 0)
258 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
259 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
260 ;;
261 1)
262 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
263 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
264 ;;
265 1P)
266 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
267 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
268 ;;
269 2)
270 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
271 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
272 ;;
273 3)
274 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
275 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
276 ;;
277 3P)
278 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
279 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
280 ;;
281 *)
282 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
283 exit 1
284 ;;
285 esac
266 # Device specific configuration and U-Boot configuration
267 case "$RPI_MODEL" in
268 0)
269 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
270 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
271 ;;
272 1)
273 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
274 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
275 ;;
276 1P)
277 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
278 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
279 ;;
280 2)
281 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
282 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
283 ;;
284 3)
285 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
286 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
287 ;;
288 3P)
289 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
290 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
291 ;;
292 *)
293 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
294 exit 1
295 ;;
296 esac
297
298 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
299 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
300 # Include bluetooth packages on supported boards
301 if [ "$ENABLE_BLUETOOTH" = true ] && [ "$ENABLE_CONSOLE" = false ]; then
302 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
303 fi
304 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
305 # Check if the internal wireless interface is not supported by the RPi model
306 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
307 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
308 exit 1
309 fi
310 fi
286 311
287 312 # Prepare date string for default image file name
288 313 DATE="$(date +%Y-%m-%d)"
@@ -292,16 +317,6 else
292 317 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
293 318 fi
294 319
295 # Check if the internal wireless interface is supported by the RPi model
296 if [ "$ENABLE_WIRELESS" = true ] ; then
297 if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then
298 echo "error: The selected Raspberry Pi model has no internal wireless interface"
299 exit 1
300 else
301 echo "Raspberry Pi $RPI_MODEL has WIFI support"
302 fi
303 fi
304
305 320 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
306 321 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
307 322 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
@@ -347,6 +362,14 if [ "$ENABLE_UBOOT" = true ] ; then
347 362 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
348 363 fi
349 364
365 if [ "$ENABLE_BLUETOOTH" = true ] ; then
366 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
367 if [ "$ENABLE_CONSOLE" = false ] ; then
368 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
369 fi
370 fi
371 fi
372
350 373 # Check if root SSH (v2) public key file exists
351 374 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
352 375 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
@@ -365,7 +388,7 fi
365 388
366 389 # Check if all required packages are installed on the build system
367 390 for package in $REQUIRED_PACKAGES ; do
368 if [ "$(dpkg-query -W -f='${Status}' $package)" != "install ok installed" ] ; then
391 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
369 392 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
370 393 fi
371 394 done
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant