##// END OF EJS Templates
Merge pull request #20 from drtyhlpr/master...
Gérard Vidal -
r278:7c46fd73c758 Fusion
parent child
Show More
@@ -0,0 +1,12
1 [Match]
2 Name=wlan0
3
4 [Network]
5 DHCP=no
6 Address=
7 Gateway=
8 DNS=
9 DNS=
10 Domains=
11 NTP=
12 NTP=
@@ -151,10 +151,10 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
151 151 允许串行控制台接口. 没有连接显示器键盘的树莓派推荐打开, 此时如果网络无法连接至树莓派, 可以使用串行控制台连至系统.
152 152
153 153 ##### `ENABLE_I2C`=false
154 允许树莓派2/3的 I2C 接口. 请对照 [树莓派2/3 引脚示意图](http://elinux.org/RPi_Low-level_peripherals) 正确连接 GPIO 引脚.
154 允许树莓派2/3的 I2C 接口. 请对照 [树莓派2/3 引脚示意图](https://elinux.org/RPi_Low-level_peripherals) 正确连接 GPIO 引脚.
155 155
156 156 ##### `ENABLE_SPI`=false
157 允许树莓派2/3的 SPI 接口. 请对照 [树莓派2/3 引脚示意图](http://elinux.org/RPi_Low-level_peripherals) 正确连接 GPIO 引脚.
157 允许树莓派2/3的 SPI 接口. 请对照 [树莓派2/3 引脚示意图](https://elinux.org/RPi_Low-level_peripherals) 正确连接 GPIO 引脚.
158 158
159 159 ##### `ENABLE_IPV6`=true
160 160 允许 IPv6 . 通过 systemd-networkd 配置管理网络接口.
@@ -199,10 +199,10 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
199 199 卸载包、删除文件以减小体积 详情查看 `REDUCE_*` 参数.
200 200
201 201 ##### `ENABLE_UBOOT`=false
202 使用 [U-Boot 引导器](http://git.denx.de/?p=u-boot.git;a=summary) 替代树莓派2/3 默认的第二阶段引导器(bootcode.bin). U-Boot 可以通过网络使用 BOOTP/TFTP 协议引导镜像文件.
202 使用 [U-Boot 引导器](https://git.denx.de/?p=u-boot.git;a=summary) 替代树莓派2/3 默认的第二阶段引导器(bootcode.bin). U-Boot 可以通过网络使用 BOOTP/TFTP 协议引导镜像文件.
203 203
204 204 ##### `UBOOTSRC_DIR`=""
205 存放已下载 [U-Boot 引导器源文件](http://git.denx.de/?p=u-boot.git;a=summary) 的目录(`u-boot`).
205 存放已下载 [U-Boot 引导器源文件](https://git.denx.de/?p=u-boot.git;a=summary) 的目录(`u-boot`).
206 206
207 207 ##### `ENABLE_FBTURBO`=false
208 208 安装并且允许 [硬件加速的 Xorg 显卡驱动](https://github.com/ssvb/xf86-video-fbturbo) `fbturbo`. 当前仅支持窗口的移动和滚动的硬件加速.
@@ -444,7 +444,7 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-root.img /dev/sdc
444 444 * [Debian 交叉工具链 Wiki](https://wiki.debian.org/CrossToolchains)
445 445 * [Github上的树莓派官方固件](https://github.com/raspberrypi/firmware)
446 446 * [Github上的树莓派官方内核](https://github.com/raspberrypi/linux)
447 * [U-BOOT git 仓库](http://git.denx.de/?p=u-boot.git;a=summary)
447 * [U-BOOT git 仓库](https://git.denx.de/?p=u-boot.git;a=summary)
448 448 * [Xorg DDX fbturbo驱动](https://github.com/ssvb/xf86-video-fbturbo)
449 449 * [树莓派3无线接口固件](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm80211/brcm)
450 450 * [Collabora 树莓派2预编译内核](https://repositories.collabora.co.uk/debian/)
@@ -68,7 +68,14 A comma separated list of additional packages to be installed by apt after boots
68 68
69 69 #### General system settings:
70 70 ##### `RPI_MODEL`=2
71 Specifiy the target Raspberry Pi hardware model. The script at this time supports the Raspberry Pi models `2` and `3`. `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` is used.
71 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
72 `0` = Used for Raspberry Pi 0 and Raspberry Pi 0 W
73 `1` = Used for Pi 1 model A and B
74 `1P` = Used for Pi 1 model B+ and A+
75 `2` = Used for Pi 2 model B
76 `3` = Used for Pi 3 model B
77 `3P` = Used for Pi 3 model B+
78 `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used.
72 79
73 80 ##### `RELEASE`="jessie"
74 81 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "jessie", "stretch" and "buster". `BUILD_KERNEL`=true will automatically be set if the Debian releases `stretch` or `buster` are used.
@@ -94,6 +101,9 Set default system timezone. All available timezones can be found in the `/usr/s
94 101 ##### `EXPANDROOT`=true
95 102 Expand the root partition and filesystem automatically on first boot.
96 103
104 ##### `ENABLE_QEMU`=false
105 Generate kernel (`vexpress_defconfig`), file system image (`qcow2`) and DTB files that can be used for QEMU full system emulation (`vexpress-A15`). The output files are stored in the `$(pwd)/images/qemu` directory. You can find more information about running the generated image in the QEMU section of this readme file.
106
97 107 ---
98 108
99 109 #### Keyboard settings:
@@ -152,10 +162,10 Set the IP address for the second NTP server.
152 162 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.
153 163
154 164 ##### `ENABLE_I2C`=false
155 Enable I2C interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](http://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
165 Enable I2C interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
156 166
157 167 ##### `ENABLE_SPI`=false
158 Enable SPI interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](http://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
168 Enable SPI interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
159 169
160 170 ##### `ENABLE_IPV6`=true
161 171 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
@@ -201,10 +211,10 Use debootstrap script variant `minbase` which only includes essential packages
201 211 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
202 212
203 213 ##### `ENABLE_UBOOT`=false
204 Replace the default RPi2/3 second stage bootloader (bootcode.bin) with [U-Boot bootloader](http://git.denx.de/?p=u-boot.git;a=summary). U-Boot can boot images via the network using the BOOTP/TFTP protocol.
214 Replace the default RPi2/3 second stage bootloader (bootcode.bin) with [U-Boot bootloader](https://git.denx.de/?p=u-boot.git;a=summary). U-Boot can boot images via the network using the BOOTP/TFTP protocol.
205 215
206 216 ##### `UBOOTSRC_DIR`=""
207 Path to a directory (`u-boot`) of [U-Boot bootloader sources](http://git.denx.de/?p=u-boot.git;a=summary) that will be copied, configured, build and installed inside the chroot.
217 Path to a directory (`u-boot`) of [U-Boot bootloader sources](https://git.denx.de/?p=u-boot.git;a=summary) that will be copied, configured, build and installed inside the chroot.
208 218
209 219 ##### `ENABLE_FBTURBO`=false
210 220 Install and enable the [hardware accelerated Xorg video driver](https://github.com/ssvb/xf86-video-fbturbo) `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
@@ -296,6 +306,12 Install kernel headers with built kernel.
296 306 ##### `KERNEL_MENUCONFIG`=false
297 307 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
298 308
309 ##### `KERNEL_OLDDEFCONFIG`=false
310 Run `make olddefconfig` to automatically set all new kernel configuration options to their recommended default values.
311
312 ##### `KERNEL_CCACHE`=false
313 Compile the kernel using ccache. This speeds up kernel recompilation by caching previous compilations and detecting when the same compilation is being done again.
314
299 315 ##### `KERNEL_REMOVESRC`=true
300 316 Remove all kernel sources from the generated OS image after it was built and installed.
301 317
@@ -437,6 +453,28 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, th
437 453 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-frmw.img /dev/mmcblk0
438 454 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-root.img /dev/sdc
439 455 ```
456
457 ## QEMU emulation
458 Start QEMU full system emulation:
459 ```shell
460 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=tty1"
461 ```
462
463 Start QEMU full system emulation and output to console:
464 ```shell
465 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio
466 ```
467
468 Start QEMU full system emulation with SMP and output to console:
469 ```shell
470 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -smp cpus=2,maxcpus=2 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio
471 ```
472
473 Start QEMU full system emulation with cryptfs, initramfs and output to console:
474 ```shell
475 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -initrd "initramfs-${KERNEL_VERSION}" -append "root=/dev/mapper/secure cryptdevice=/dev/mmcblk0p2:secure rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio
476 ```
477
440 478 ## Weekly image builds
441 479 The image files are provided by JRWR'S I/O PORT and are built once a Sunday at midnight UTC!
442 480 * [Debian Stretch Raspberry Pi2/3 Weekly Image Builds](https://jrwr.io/doku.php?id=projects:debianpi)
@@ -447,7 +485,7 The image files are provided by JRWR'S I/O PORT and are built once a Sunday at m
447 485 * [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains)
448 486 * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware)
449 487 * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux)
450 * [U-BOOT git repository](http://git.denx.de/?p=u-boot.git;a=summary)
488 * [U-BOOT git repository](https://git.denx.de/?p=u-boot.git;a=summary)
451 489 * [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo)
452 490 * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm80211/brcm)
453 491 * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/)
@@ -25,9 +25,9 if [ "$BUILD_KERNEL" = true ] ; then
25 25
26 26 # Fetch current RPi2/3 kernel sources
27 27 if [ -z "${KERNEL_BRANCH}" ] ; then
28 as_nobody git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux
28 as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux
29 29 else
30 as_nobody git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux
30 as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux
31 31 fi
32 32
33 33 # Copy downloaded kernel sources
@@ -87,18 +87,59 if [ "$BUILD_KERNEL" = true ] ; then
87 87 # Load default raspberry kernel configuration
88 88 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
89 89
90 # Set kernel configuration parameters to enable qemu emulation
91 if [ "$ENABLE_QEMU" = true ] ; then
92 echo "CONFIG_FHANDLE=y" >> ${KERNEL_DIR}/.config
93 echo "CONFIG_LBDAF=y" >> ${KERNEL_DIR}/.config
94
95 if [ "$ENABLE_CRYPTFS" = true ] ; then
96 echo "CONFIG_EMBEDDED=y" >> ${KERNEL_DIR}/.config
97 echo "CONFIG_EXPERT=y" >> ${KERNEL_DIR}/.config
98 echo "CONFIG_DAX=y" >> ${KERNEL_DIR}/.config
99 echo "CONFIG_MD=y" >> ${KERNEL_DIR}/.config
100 echo "CONFIG_BLK_DEV_MD=y" >> ${KERNEL_DIR}/.config
101 echo "CONFIG_MD_AUTODETECT=y" >> ${KERNEL_DIR}/.config
102 echo "CONFIG_BLK_DEV_DM=y" >> ${KERNEL_DIR}/.config
103 echo "CONFIG_BLK_DEV_DM_BUILTIN=y" >> ${KERNEL_DIR}/.config
104 echo "CONFIG_DM_CRYPT=y" >> ${KERNEL_DIR}/.config
105 echo "CONFIG_CRYPTO_BLKCIPHER=y" >> ${KERNEL_DIR}/.config
106 echo "CONFIG_CRYPTO_CBC=y" >> ${KERNEL_DIR}/.config
107 echo "CONFIG_CRYPTO_XTS=y" >> ${KERNEL_DIR}/.config
108 echo "CONFIG_CRYPTO_SHA512=y" >> ${KERNEL_DIR}/.config
109 echo "CONFIG_CRYPTO_MANAGER=y" >> ${KERNEL_DIR}/.config
110 fi
111 fi
112
113 # Copy custom kernel configuration file
90 114 if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then
91 115 cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config
92 116 fi
93 117
118 # Set kernel configuration parameters to their default values
119 if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then
120 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig
121 fi
122
94 123 # Start menu-driven kernel configuration (interactive)
95 124 if [ "$KERNEL_MENUCONFIG" = true ] ; then
96 125 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
97 126 fi
98 127 fi
99 128
100 # Cross compile kernel and modules
101 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_BIN_IMAGE}" modules dtbs
129 # Use ccache to cross compile the kernel
130 if [ "$KERNEL_CCACHE" = true ] ; then
131 cc="ccache ${CROSS_COMPILE}gcc"
132 else
133 cc="${CROSS_COMPILE}gcc"
134 fi
135
136 # Cross compile kernel and dtbs
137 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
138
139 # Cross compile kernel modules
140 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
141 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
142 fi
102 143 fi
103 144
104 145 # Check if kernel compilation was successful
@@ -110,12 +151,16 if [ "$BUILD_KERNEL" = true ] ; then
110 151
111 152 # Install kernel modules
112 153 if [ "$ENABLE_REDUCE" = true ] ; then
154 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
113 155 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
156 fi
114 157 else
158 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
115 159 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
160 fi
116 161
117 162 # Install kernel firmware
118 if [ $(cat ./Makefile | grep "^firmware_install:") ] ; then
163 if [ $(grep "^firmware_install:" "${KERNEL_DIR}/Makefile") ] ; then
119 164 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
120 165 fi
121 166 fi
@@ -134,18 +179,36 if [ "$BUILD_KERNEL" = true ] ; then
134 179 # Copy kernel configuration file to the boot directory
135 180 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
136 181
137 # Copy dts and dtb device tree sources and binaries
182 # Prepare device tree directory
138 183 mkdir "${BOOT_DIR}/overlays"
139 184
140 185 # Ensure the proper .dtb is located
141 186 if [ "$KERNEL_ARCH" = "arm" ] ; then
142 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOT_DIR}/"
187 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do
188 if [ -f "${dtb}" ] ; then
189 install_readonly "${dtb}" "${BOOT_DIR}/"
190 fi
191 done
143 192 else
144 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb "${BOOT_DIR}/"
193 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do
194 if [ -f "${dtb}" ] ; then
195 install_readonly "${dtb}" "${BOOT_DIR}/"
196 fi
197 done
198 fi
199
200 # Copy compiled dtb device tree files
201 if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then
202 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb ; do
203 if [ -f "${dtb}" ] ; then
204 install_readonly "${dtb}" "${BOOT_DIR}/overlays/"
145 205 fi
206 done
146 207
147 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOT_DIR}/overlays/"
208 if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then
148 209 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
210 fi
211 fi
149 212
150 213 if [ "$ENABLE_UBOOT" = false ] ; then
151 214 # Convert and copy kernel image to the boot directory
@@ -159,12 +222,17 if [ "$BUILD_KERNEL" = true ] ; then
159 222 if [ "$KERNEL_REMOVESRC" = true ] ; then
160 223 rm -fr "${KERNEL_DIR}"
161 224 else
225 # Prepare compiled kernel modules
226 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
227 if [ $(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile") ] ; then
162 228 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
229 fi
163 230
164 231 # Create symlinks for kernel modules
165 232 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
166 233 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
167 234 fi
235 fi
168 236
169 237 else # BUILD_KERNEL=false
170 238 # Kernel installation
@@ -20,7 +20,7 if [ "$ENABLE_CRYPTFS" = true ] ; then
20 20
21 21 # Add encrypted partition to crypttab and fstab
22 22 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
23 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks" >> "${ETC_DIR}/crypttab"
23 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab"
24 24
25 25 if [ "$ENABLE_SPLITFS" = true ] ; then
26 26 # Add usb/sda disk to crypttab
@@ -41,6 +41,9 if [ "$BUILD_KERNEL" = true ] && [ "$ENABLE_INITRAMFS" = true ] ; then
41 41 # Disable SSHD inside initramfs
42 42 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
43 43
44 # Add cryptsetup modules to initramfs
45 printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
46
44 47 # Dummy mapping required by mkinitramfs
45 48 echo "0 1 crypt $(echo ${CRYPTFS_CIPHER} | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
46 49
@@ -30,6 +30,12 install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces"
30 30 # Install configuration for interface eth0
31 31 install_readonly files/network/eth.network "${ETC_DIR}/systemd/network/eth.network"
32 32
33 # Install configuration for interface wl*
34 install_readonly files/network/wlan.network "${ETC_DIR}/systemd/network/wlan.network"
35
36 #always with dhcp since wpa_supplicant integration is missing
37 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan.network"
38
33 39 if [ "$ENABLE_DHCP" = true ] ; then
34 40 # Enable DHCP configuration for interface eth0
35 41 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth.network"
@@ -55,10 +61,15 fi
55 61
56 62 # Remove empty settings from network configuration
57 63 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network"
64 # Remove empty settings from wlan configuration
65 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network"
58 66
59 67 # Move systemd network configuration if required by Debian release
60 68 if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
61 69 mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network"
70 if [ "$ENABLE_WIRELESS" = true ] ; then
71 mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network"
72 fi
62 73 rm -fr "${ETC_DIR}/systemd/network"
63 74 fi
64 75
@@ -91,17 +102,33 if [ "$ENABLE_WIRELESS" = true ] ; then
91 102 # Create temporary directory for firmware binary blob
92 103 temp_dir=$(as_nobody mktemp -d)
93 104
94 # Fetch firmware binary blob
105 # Fetch firmware binary blob for RPI3B+
106 if [ "$RPI_MODEL" = 3P ] ; then
107 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.bin"
108 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.txt"
109 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.clm_blob" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.clm_blob"
110 else
111 # Fetch firmware binary blob for RPI3
95 112 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin"
96 113 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt"
114 fi
97 115
98 116 # Move downloaded firmware binary blob
117 if [ "$RPI_MODEL" = 3P ] ; then
118 mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/"
119 else
99 120 mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/"
121 fi
100 122
101 123 # Remove temporary directory for firmware binary blob
102 124 rm -fr "${temp_dir}"
103 125
104 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 else
105 131 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
106 132 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
107 133 fi
134 fi
@@ -69,6 +69,11 if [ "$ENABLE_UBOOT" = true ] ; then
69 69 # Set mkfile to use the correct dtb file
70 70 sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOT_DIR}/uboot.mkimage"
71 71
72 # Set mkfile to use the correct mach id
73 if [ "$ENABLE_QEMU" = true ] ; then
74 sed -i "s/^\(setenv machid \).*/\10x000008e0/" "${BOOT_DIR}/uboot.mkimage"
75 fi
76
72 77 # Set mkfile to use kernel image
73 78 sed -i "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOT_DIR}/uboot.mkimage"
74 79
@@ -60,14 +60,22 if [ -z "$PART_START" ] ; then
60 60 return 1
61 61 fi
62 62
63 # Get the current last sector of the root partition
64 PART_END=$(parted /dev/${ROOT_DEV} -ms unit s p | grep "^${PART_NUM}" | cut -f 3 -d: | sed 's/[^0-9]//g')
65 if [ -z "$PART_END" ] ; then
66 log_warning_msg "${ROOT_DEV} unable to get last sector of the partition"
67 return 1
68 fi
69
63 70 # Get the possible last sector for the root partition
64 71 PART_LAST=$(fdisk -l /dev/${ROOT_DEV} | grep '^Disk.*sectors' | awk '{ print $7 - 1 }')
65 72 if [ -z "$PART_LAST" ] ; then
66 log_warning_msg "${ROOT_DEV} unable to get last sector of the partition"
73 log_warning_msg "${ROOT_DEV} unable to get last possible sector of the partition"
67 74 return 1
68 75 fi
69 76
70 77 ### Since rc.local is run with "sh -e", let's add "|| true" to prevent premature exit
78 if [ $PART_END != $PART_LAST ] ; then
71 79 fdisk /dev/${ROOT_DEV} 2> /dev/null <<EOF2 || true
72 80 p
73 81 d
@@ -83,3 +91,6 EOF2
83 91
84 92 partprobe
85 93 log_success_msg "Root partition successfully resized."
94 else
95 log_success_msg "Root partition already resized."
96 fi
@@ -42,11 +42,31 set -x
42 42
43 43 # Raspberry Pi model configuration
44 44 RPI_MODEL=${RPI_MODEL:=2}
45
46 #bcm2708-rpi-0-w.dtb (Used for Pi 0 and PI 0W)
47 RPI0_DTB_FILE=${RPI0_DTB_FILE:=bcm2708-rpi-0-w.dtb}
48 RPI0_UBOOT_CONFIG=${RPI0_UBOOT_CONFIG:=rpi_defconfig}
49
50 #bcm2708-rpi-b.dtb (Used for Pi 1 model A and B)
51 RPI1_DTB_FILE=${RPI1_DTB_FILE:=bcm2708-rpi-b.dtb}
52 RPI1_UBOOT_CONFIG=${RPI1_UBOOT_CONFIG:=rpi_defconfig}
53
54 #bcm2708-rpi-b-plus.dtb (Used for Pi 1 model B+ and A+)
55 RPI1P_DTB_FILE=${RPI1P_DTB_FILE:=bcm2708-rpi-b-plus.dtb}
56 RPI1P_UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG:=rpi_defconfig}
57
58 #bcm2709-rpi-2-b.dtb (Used for Pi 2 model B)
45 59 RPI2_DTB_FILE=${RPI2_DTB_FILE:=bcm2709-rpi-2-b.dtb}
46 60 RPI2_UBOOT_CONFIG=${RPI2_UBOOT_CONFIG:=rpi_2_defconfig}
61
62 #bcm2710-rpi-3-b.dtb (Used for Pi 3 model B)
47 63 RPI3_DTB_FILE=${RPI3_DTB_FILE:=bcm2710-rpi-3-b.dtb}
48 64 RPI3_UBOOT_CONFIG=${RPI3_UBOOT_CONFIG:=rpi_3_32b_defconfig}
49 65
66 #bcm2710-rpi-3-b-plus.dtb (Used for Pi 3 model B+)
67 RPI3P_DTB_FILE=${RPI3P_DTB_FILE:=bcm2710-rpi-3-b-plus.dtb}
68 RPI3P_UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG:=rpi_3_32b_defconfig}
69
50 70 # Debian release
51 71 RELEASE=${RELEASE:=jessie}
52 72 KERNEL_ARCH=${KERNEL_ARCH:=arm}
@@ -56,10 +76,19 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
56 76 if [ "$KERNEL_ARCH" = "arm64" ] ; then
57 77 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
58 78 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
79 fi
80
81 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
82 #RASPBERRY PI 1, PI ZERO, PI ZERO W, AND COMPUTE MODULE DEFAULT Kernel BUILD CONFIGURATION
83 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
84 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
59 85 else
86 #RASPBERRY PI 2, PI 3, PI 3+, AND COMPUTE MODULE 3 DEFAULT Kernel BUILD CONFIGURATION
87 #https://www.raspberrypi.org/documentation/linux/kernel/building.md
60 88 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
61 89 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
62 90 fi
91
63 92 if [ "$RELEASE_ARCH" = "arm64" ] ; then
64 93 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
65 94 else
@@ -73,7 +102,7 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/
73 102 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
74 103 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
75 104 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
76 UBOOT_URL=${UBOOT_URL:=git://git.denx.de/u-boot.git}
105 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
77 106
78 107 # Build directories
79 108 BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}}
@@ -146,6 +175,7 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
146 175 ENABLE_USER=${ENABLE_USER:=true}
147 176 USER_NAME=${USER_NAME:="pi"}
148 177 ENABLE_ROOT=${ENABLE_ROOT:=false}
178 ENABLE_QEMU=${ENABLE_QEMU:=false}
149 179
150 180 # SSH settings
151 181 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
@@ -175,6 +205,9 KERNEL_THREADS=${KERNEL_THREADS:=1}
175 205 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
176 206 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
177 207 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
208 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
209 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
210
178 211 if [ "$KERNEL_ARCH" = "arm64" ] ; then
179 212 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
180 213 else
@@ -204,9 +237,6 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
204 237 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
205 238 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
206 239
207 # Stop the Crypto Wars
208 DISABLE_FBI=${DISABLE_FBI:=false}
209
210 240 # Chroot scripts directory
211 241 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
212 242
@@ -224,20 +254,32 COMPILER_PACKAGES=""
224 254 set +x
225 255
226 256 # Set Raspberry Pi model specific configuration
227 if [ "$RPI_MODEL" = 2 ] ; then
257 if [ "$RPI_MODEL" = 0 ] ; then
258 DTB_FILE=${RPI0_DTB_FILE}
259 UBOOT_CONFIG=${RPI0_UBOOT_CONFIG}
260 elif [ "$RPI_MODEL" = 1 ] ; then
261 DTB_FILE=${RPI1_DTB_FILE}
262 UBOOT_CONFIG=${RPI1_UBOOT_CONFIG}
263 elif [ "$RPI_MODEL" = 1P ] ; then
264 DTB_FILE=${RPI1P_DTB_FILE}
265 UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG}
266 elif [ "$RPI_MODEL" = 2 ] ; then
228 267 DTB_FILE=${RPI2_DTB_FILE}
229 268 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
230 269 elif [ "$RPI_MODEL" = 3 ] ; then
231 270 DTB_FILE=${RPI3_DTB_FILE}
232 271 UBOOT_CONFIG=${RPI3_UBOOT_CONFIG}
233 BUILD_KERNEL=true
272 elif [ "$RPI_MODEL" = 3P ] ; then
273 DTB_FILE=${RPI3P_DTB_FILE}
274 UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG}
234 275 else
235 276 echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!"
236 277 exit 1
237 278 fi
238 279
239 280 # Check if the internal wireless interface is supported by the RPi model
240 if [ "$ENABLE_WIRELESS" = true ] && [ "$RPI_MODEL" != 3 ] ; then
281 if [ "$ENABLE_WIRELESS" = true ] && ([ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ]); then
282
241 283 echo "error: The selected Raspberry Pi model has no internal wireless interface"
242 284 exit 1
243 285 fi
@@ -258,26 +300,32 fi
258 300 # Add packages required for kernel cross compilation
259 301 if [ "$BUILD_KERNEL" = true ] ; then
260 302 if [ "$KERNEL_ARCH" = "arm" ] ; then
303 if [ "$RELEASE_ARCH" = "armel" ]; then
304 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
305 fi
306 if [ "$RELEASE_ARCH" = "armhf" ]; then
261 307 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
262 else
308 fi
309 if [ "$RELEASE_ARCH" = "arm64" ]; then
263 310 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
264 311 fi
265 312 fi
313 fi
266 314
267 315 # Add libncurses5 to enable kernel menuconfig
268 316 if [ "$KERNEL_MENUCONFIG" = true ] ; then
269 317 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses5-dev"
270 318 fi
271 319
272 # Stop the Crypto Wars
273 if [ "$DISABLE_FBI" = true ] ; then
274 ENABLE_CRYPTFS=true
320 # Add ccache compiler cache for (faster) kernel cross (re)compilation
321 if [ "$KERNEL_CCACHE" = true ] ; then
322 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
275 323 fi
276 324
277 325 # Add cryptsetup package to enable filesystem encryption
278 326 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
279 327 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
280 APT_INCLUDES="${APT_INCLUDES},cryptsetup"
328 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
281 329
282 330 if [ -z "$CRYPTFS_PASSWORD" ] ; then
283 331 echo "error: no password defined (CRYPTFS_PASSWORD)!"
@@ -293,7 +341,7 fi
293 341
294 342 # Add device-tree-compiler required for building the U-Boot bootloader
295 343 if [ "$ENABLE_UBOOT" = true ] ; then
296 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler"
344 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex"
297 345 fi
298 346
299 347 # Check if root SSH (v2) public key file exists
@@ -480,6 +528,16 if [ "$KERNEL_REDUCE" = true ] ; then
480 528 KERNELSRC_CONFIG=false
481 529 fi
482 530
531 # Configure qemu compatible kernel
532 if [ "$ENABLE_QEMU" = true ] ; then
533 DTB_FILE=vexpress-v2p-ca15_a7.dtb
534 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
535 KERNEL_DEFCONFIG="vexpress_defconfig"
536 if [ "$KERNEL_MENUCONFIG" = false ] ; then
537 KERNEL_OLDDEFCONFIG=true
538 fi
539 fi
540
483 541 # Execute bootstrap scripts
484 542 for SCRIPT in bootstrap.d/*.sh; do
485 543 head -n 3 "$SCRIPT"
@@ -546,6 +604,54 rm -f "${R}/initrd.img"
546 604 rm -f "${R}/vmlinuz"
547 605 rm -f "${R}${QEMU_BINARY}"
548 606
607 if [ "$ENABLE_QEMU" = true ] ; then
608 # Setup QEMU directory
609 mkdir "${BASEDIR}/qemu"
610
611 # Copy kernel image to QEMU directory
612 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
613
614 # Copy kernel config to QEMU directory
615 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
616
617 # Copy kernel dtbs to QEMU directory
618 for dtb in "${BOOT_DIR}/"*.dtb ; do
619 if [ -f "${dtb}" ] ; then
620 install_readonly "${dtb}" "${BASEDIR}/qemu/"
621 fi
622 done
623
624 # Copy kernel overlays to QEMU directory
625 if [ -d "${BOOT_DIR}/overlays" ] ; then
626 # Setup overlays dtbs directory
627 mkdir "${BASEDIR}/qemu/overlays"
628
629 for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do
630 if [ -f "${dtb}" ] ; then
631 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
632 fi
633 done
634 fi
635
636 # Copy u-boot files to QEMU directory
637 if [ "$ENABLE_UBOOT" = true ] ; then
638 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
639 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
640 fi
641 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
642 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
643 fi
644 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
645 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
646 fi
647 fi
648
649 # Copy initramfs to QEMU directory
650 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
651 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
652 fi
653 fi
654
549 655 # Calculate size of the chroot directory in KB
550 656 CHROOT_SIZE=$(expr `du -s "${R}" | awk '{ print $1 }'`)
551 657
@@ -654,4 +760,15 else
654 760
655 761 # Image was successfully created
656 762 echo "$IMAGE_NAME.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
763
764 # Create qemu qcow2 image
765 if [ "$ENABLE_QEMU" = true ] ; then
766 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
767 QEMU_SIZE=16G
768
769 qemu-img convert -f raw -O qcow2 $IMAGE_NAME.img $QEMU_IMAGE.qcow2
770 qemu-img resize $QEMU_IMAGE.qcow2 $QEMU_SIZE
771
772 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
773 fi
657 774 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant