##// END OF EJS Templates
Added Raspberry Pi 3 model support
drtyhlpr -
r94:2ce085c56493
parent child
Show More
@@ -1,6 +1,6
1 # rpi2-gen-image
1 # rpi23-gen-image
2 2 ## Introduction
3 `rpi2-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for the Raspberry 2 (RPi2) computer. The script at this time supports the bootstrapping of the Debian releases "jessie" and "stretch".
3 `rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for Raspberry Pi 2 (RPi2) and Raspberry Pi 3 (RPi3) computers. The script at this time supports the bootstrapping of the Debian releases "jessie" and "stretch". Raspberry Pi 3 images are currently generated for 32-bit mode only.
4 4
5 5 ## Build dependencies
6 6 The following list of Debian packages must be installed on the build system because they are essentially required for the bootstrapping process. The script will check if all required packages are installed and missing packages will be installed automatically if confirmed by the user.
@@ -8,21 +8,23 The following list of Debian packages must be installed on the build system beca
8 8 ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git```
9 9
10 10 ## Command-line parameters
11 The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi2-gen-image.sh` script via (simple) shell-variables. Unlike environment shell-variables (simple) shell-variables are defined at the beginning of the command-line call of the `rpi2-gen-image.sh` script.
11 The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi23-gen-image.sh` script via (simple) shell-variables. Unlike environment shell-variables (simple) shell-variables are defined at the beginning of the command-line call of the `rpi23-gen-image.sh` script.
12 12
13 13 #####Command-line examples:
14 14 ```shell
15 ENABLE_UBOOT=true ./rpi2-gen-image.sh
16 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi2-gen-image.sh
17 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi2-gen-image.sh
18 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi2-gen-image.sh
19 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi2-gen-image.sh
20 ENABLE_MINBASE=true ./rpi2-gen-image.sh
21 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi2-gen-image.sh
22 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi2-gen-image.sh
23 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi2-gen-image.sh
24 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi2-gen-image.sh
25 RELEASE=stretch BUILD_KERNEL=true ./rpi2-gen-image.sh
15 ENABLE_UBOOT=true ./rpi23-gen-image.sh
16 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi23-gen-image.sh
17 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi23-gen-image.sh
18 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi23-gen-image.sh
19 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi23-gen-image.sh
20 ENABLE_MINBASE=true ./rpi23-gen-image.sh
21 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi23-gen-image.sh
22 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi23-gen-image.sh
23 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
24 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
25 RELEASE=stretch BUILD_KERNEL=true ./rpi23-gen-image.sh
26 RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
27 RELEASE=stretch RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
26 28 ```
27 29
28 30 #### APT settings:
@@ -36,10 +38,13 Set Proxy server address. Using a local Proxy-Cache like `apt-cacher-ng` will sp
36 38 A comma separated list of additional packages to be installed during bootstrapping.
37 39
38 40 #### General system settings:
41 ##### `RPI_MODEL`=2
42 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.
43
39 44 ##### `RELEASE`="jessie"
40 45 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "jessie" and "stretch". `BUILD_KERNEL`=true will automatically be set if the Debian release `stretch` is used.
41 46
42 ##### `HOSTNAME`="rpi2-jessie"
47 ##### `HOSTNAME`="rpi${RPI_MODEL}-${RELEASE}"
43 48 Set system host name. It's recommended that the host name is unique in the corresponding subnet.
44 49
45 50 ##### `PASSWORD`="raspberry"
@@ -101,7 +106,7 Set the IP address for the second NTP server.
101 106
102 107 #### Basic system features:
103 108 ##### `ENABLE_CONSOLE`=true
104 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
109 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.
105 110
106 111 ##### `ENABLE_IPV6`=true
107 112 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
@@ -112,6 +117,9 Install and enable OpenSSH service. The default configuration of the service doe
112 117 ##### `ENABLE_NONFREE`=false
113 118 Allow the installation of non-free Debian packages that do not comply with the DFSG. This is required to install closed-source firmware binary blobs.
114 119
120 ##### `ENABLE_WIRELESS`=false
121 Download and install the required non-free closed-source firmware binary blob that is required to run the internal wireless interface of the Rasberry Pi model 3. This parameter is ignored if the specified `RPI_MODEL` is not 3.
122
115 123 ##### `ENABLE_RSYSLOG`=true
116 124 If set to false, disable and uninstall rsyslog (so logs will be available only
117 125 in journal files)
@@ -132,7 +140,7 Install and enable D-Bus message bus. Please note that systemd should work witho
132 140 Install Xorg open-source X Window System.
133 141
134 142 ##### `ENABLE_WM`=""
135 Install a user defined window manager for the X Window System. To make sure all X related package dependencies are getting installed `ENABLE_XORG` will automatically get enabled if `ENABLE_WM` is used. The `rpi2-gen-image.sh` script has been tested with the following list of window managers: `blackbox`, `openbox`, `fluxbox`, `jwm`, `dwm`, `xfce4`, `awesome`.
143 Install a user defined window manager for the X Window System. To make sure all X related package dependencies are getting installed `ENABLE_XORG` will automatically get enabled if `ENABLE_WM` is used. The `rpi23-gen-image.sh` script has been tested with the following list of window managers: `blackbox`, `openbox`, `fluxbox`, `jwm`, `dwm`, `xfce4`, `awesome`.
136 144
137 145 #### Advanced system features:
138 146 ##### `ENABLE_MINBASE`=false
@@ -142,7 +150,7 Use debootstrap script variant `minbase` which only includes essential packages
142 150 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
143 151
144 152 ##### `ENABLE_UBOOT`=false
145 Replace default RPi2 second stage bootloader (bootcode.bin) with U-Boot bootloader. U-Boot can boot images via the network using the BOOTP/TFTP protocol.
153 Replace the default RPi2/3 second stage bootloader (bootcode.bin) with U-Boot bootloader. U-Boot can boot images via the network using the BOOTP/TFTP protocol.
146 154
147 155 ##### `ENABLE_FBTURBO`=false
148 156 Install and enable the hardware accelerated Xorg video driver `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
@@ -180,7 +188,7 Enable automatic assignment of predictable, stable network interface names for a
180 188
181 189 #### Kernel compilation:
182 190 ##### `BUILD_KERNEL`=false
183 Build and install the latest RPi2 Linux kernel. Currently only the default RPi2 kernel configuration is used.
191 Build and install the latest RPi2/3 Linux kernel. Currently only the default RPi2/3 kernel configuration is used.
184 192
185 193 ##### `KERNEL_REDUCE`=false
186 194 Reduce the size of the generated kernel by removing unwanted device, network and filesystem drivers (experimental).
@@ -264,7 +272,7 The functions of this script that are required for the different stages of the b
264 272 | `10-bootstrap.sh` | Debootstrap basic system |
265 273 | `11-apt.sh` | Setup APT repositories |
266 274 | `12-locale.sh` | Setup Locales and keyboard settings |
267 | `13-kernel.sh` | Build and install RPi2 Kernel |
275 | `13-kernel.sh` | Build and install RPi2/3 Kernel |
268 276 | `20-networking.sh` | Setup Networking |
269 277 | `21-firewall.sh` | Setup Firewall |
270 278 | `30-security.sh` | Setup Users and Security settings |
@@ -279,7 +287,7 All the required configuration files that will be copied to the generated OS ima
279 287 | Directory | Description |
280 288 | --- | --- |
281 289 | `apt` | APT management configuration files |
282 | `boot` | Boot and RPi2 configuration files |
290 | `boot` | Boot and RPi2/3 configuration files |
283 291 | `dpkg` | Package Manager configuration |
284 292 | `etc` | Configuration files and rc scripts |
285 293 | `firstboot` | Scripts that get executed on first boot |
@@ -297,14 +305,14 Debian custom packages, i.e. those not in the debian repositories, can be instal
297 305 Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created.
298 306
299 307 ## Logging of the bootstrapping process
300 All information related to the bootstrapping process and the commands executed by the `rpi2-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
308 All information related to the bootstrapping process and the commands executed by the `rpi23-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
301 309
302 310 ```shell
303 script -c 'APT_SERVER=ftp.de.debian.org ./rpi2-gen-image.sh' ./build.log
311 script -c 'APT_SERVER=ftp.de.debian.org ./rpi23-gen-image.sh' ./build.log
304 312 ```
305 313
306 314 ## Flashing the image file
307 After the image file was successfully created by the `rpi2-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi2 computer. This can be performed by using the tools `bmaptool` or `dd`. Using `bmaptool` will probably speed-up the copy process because `bmaptool` copies more wisely than `dd`.
315 After the image file was successfully created by the `rpi23-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi2/3 computer. This can be performed by using the tools `bmaptool` or `dd`. Using `bmaptool` will probably speed-up the copy process because `bmaptool` copies more wisely than `dd`.
308 316
309 317 #####Flashing examples:
310 318 ```shell
@@ -316,3 +324,12 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, th
316 324 bmaptool copy ./images/jessie/2015-12-13-debian-jessie-frmw.img /dev/mmcblk0
317 325 bmaptool copy ./images/jessie/2015-12-13-debian-jessie-root.img /dev/sdc
318 326 ```
327
328 ## External links and references
329 * [Debian worldwide mirror sites](https://www.debian.org/mirror/list)
330 * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware)
331 * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux)
332 * [U-BOOT git repository](http://git.denx.de/?p=u-boot.git;a=summary)
333 * [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo)
334 * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm80211/brcm)
335 * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/)
@@ -7,33 +7,33
7 7
8 8 # Install and setup APT proxy configuration
9 9 if [ -z "$APT_PROXY" ] ; then
10 install_readonly files/apt/10proxy "${ETCDIR}/apt/apt.conf.d/10proxy"
11 sed -i "s/\"\"/\"${APT_PROXY}\"/" "${ETCDIR}/apt/apt.conf.d/10proxy"
10 install_readonly files/apt/10proxy "${ETC_DIR}/apt/apt.conf.d/10proxy"
11 sed -i "s/\"\"/\"${APT_PROXY}\"/" "${ETC_DIR}/apt/apt.conf.d/10proxy"
12 12 fi
13 13
14 14 if [ "$BUILD_KERNEL" = false ] ; then
15 15 # Install APT pinning configuration for flash-kernel package
16 install_readonly files/apt/flash-kernel "${ETCDIR}/apt/preferences.d/flash-kernel"
16 install_readonly files/apt/flash-kernel "${ETC_DIR}/apt/preferences.d/flash-kernel"
17 17
18 18 # Install APT sources.list
19 install_readonly files/apt/sources.list "${ETCDIR}/apt/sources.list"
20 echo "deb ${COLLABORA_URL} ${RELEASE} rpi2" >> "${ETCDIR}/apt/sources.list"
19 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
20 echo "deb ${COLLABORA_URL} ${RELEASE} rpi2" >> "${ETC_DIR}/apt/sources.list"
21 21
22 22 # Upgrade collabora package index and install collabora keyring
23 23 chroot_exec apt-get -qq -y update
24 24 chroot_exec apt-get -qq -y --force-yes install collabora-obs-archive-keyring
25 25 else # BUILD_KERNEL=true
26 26 # Install APT sources.list
27 install_readonly files/apt/sources.list "${ETCDIR}/apt/sources.list"
27 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
28 28
29 29 # Use specified APT server and release
30 sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "${ETCDIR}/apt/sources.list"
31 sed -i "s/ jessie/ ${RELEASE}/" "${ETCDIR}/apt/sources.list"
30 sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "${ETC_DIR}/apt/sources.list"
31 sed -i "s/ jessie/ ${RELEASE}/" "${ETC_DIR}/apt/sources.list"
32 32 fi
33 33
34 34 # Allow the installation of non-free Debian packages
35 35 if [ "$ENABLE_NONFREE" = true ] ; then
36 sed -i "s/ contrib/ contrib non-free/" "${ETCDIR}/apt/sources.list"
36 sed -i "s/ contrib/ contrib non-free/" "${ETC_DIR}/apt/sources.list"
37 37 fi
38 38
39 39 # Upgrade package index and update all installed packages and changed dependencies
@@ -6,7 +6,7
6 6 . ./functions.sh
7 7
8 8 # Install and setup timezone
9 echo ${TIMEZONE} > "${ETCDIR}/timezone"
9 echo ${TIMEZONE} > "${ETC_DIR}/timezone"
10 10 chroot_exec dpkg-reconfigure -f noninteractive tzdata
11 11
12 12 # Install and setup default locale and keyboard configuration
@@ -19,40 +19,40 if [ $(echo "$APT_INCLUDES" | grep ",locales") ] ; then
19 19 else
20 20 # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale
21 21 chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections
22 sed -i "/en_US.UTF-8/s/^#//" "${ETCDIR}/locale.gen"
22 sed -i "/en_US.UTF-8/s/^#//" "${ETC_DIR}/locale.gen"
23 23 fi
24 24
25 sed -i "/${DEFLOCAL}/s/^#//" "${ETCDIR}/locale.gen"
25 sed -i "/${DEFLOCAL}/s/^#//" "${ETC_DIR}/locale.gen"
26 26 chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections
27 27 chroot_exec locale-gen
28 28 chroot_exec update-locale LANG="${DEFLOCAL}"
29 29
30 30 # Install and setup default keyboard configuration
31 31 if [ "$XKB_MODEL" != "" ] ; then
32 sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" "${ETCDIR}/default/keyboard"
32 sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" "${ETC_DIR}/default/keyboard"
33 33 fi
34 34 if [ "$XKB_LAYOUT" != "" ] ; then
35 sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" "${ETCDIR}/default/keyboard"
35 sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" "${ETC_DIR}/default/keyboard"
36 36 fi
37 37 if [ "$XKB_VARIANT" != "" ] ; then
38 sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" "${ETCDIR}/default/keyboard"
38 sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" "${ETC_DIR}/default/keyboard"
39 39 fi
40 40 if [ "$XKB_OPTIONS" != "" ] ; then
41 sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" "${ETCDIR}/default/keyboard"
41 sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" "${ETC_DIR}/default/keyboard"
42 42 fi
43 43 chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration
44 44
45 45 # Install and setup font console
46 46 case "${DEFLOCAL}" in
47 47 *UTF-8)
48 sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' "${ETCDIR}/default/console-setup"
48 sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' "${ETC_DIR}/default/console-setup"
49 49 ;;
50 50 *)
51 sed -i 's/^CHARMAP.*/CHARMAP="guess"/' "${ETCDIR}/default/console-setup"
51 sed -i 's/^CHARMAP.*/CHARMAP="guess"/' "${ETC_DIR}/default/console-setup"
52 52 ;;
53 53 esac
54 54 chroot_exec dpkg-reconfigure -f noninteractive console-setup
55 55 else # (no locales were installed)
56 56 # Install POSIX default locale
57 install_readonly files/locales/locale "${ETCDIR}/default/locale"
57 install_readonly files/locales/locale "${ETC_DIR}/default/locale"
58 58 fi
@@ -1,5 +1,5
1 1 #
2 # Build and Setup RPi2 Kernel
2 # Build and Setup RPi2/3 Kernel
3 3 #
4 4
5 5 # Load utility functions
@@ -17,7 +17,7 if [ "$BUILD_KERNEL" = true ] ; then
17 17
18 18 # Clean the kernel sources
19 19 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
20 make -C "${KERNELDIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
20 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
21 21 fi
22 22 else # KERNELSRC_DIR=""
23 23 # Fetch current raspberrypi kernel sources
@@ -33,7 +33,7 if [ "$BUILD_KERNEL" = true ] ; then
33 33 if [ "$KERNELSRC_PREBUILT" = false ] ; then
34 34 # Remove device, network and filesystem drivers from kernel configuration
35 35 if [ "$KERNEL_REDUCE" = true ] ; then
36 make -C "${KERNELDIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
36 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
37 37 sed -i\
38 38 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
39 39 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
@@ -64,25 +64,25 if [ "$BUILD_KERNEL" = true ] ; then
64 64 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
65 65 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
66 66 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
67 "${KERNELDIR}/.config"
67 "${KERNEL_DIR}/.config"
68 68 fi
69 69
70 70 if [ "$KERNELSRC_CONFIG" = true ] ; then
71 71 # Load default raspberry kernel configuration
72 make -C "${KERNELDIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
72 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
73 73
74 74 # Start menu-driven kernel configuration (interactive)
75 75 if [ "$KERNEL_MENUCONFIG" = true ] ; then
76 make -C "${KERNELDIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
76 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
77 77 fi
78 78 fi
79 79
80 80 # Cross compile kernel and modules
81 make -C "${KERNELDIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" zImage modules dtbs
81 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" zImage modules dtbs
82 82 fi
83 83
84 84 # Check if kernel compilation was successful
85 if [ ! -r "${KERNELDIR}/arch/${KERNEL_ARCH}/boot/zImage" ] ; then
85 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" ] ; then
86 86 echo "error: kernel compilation failed! (zImage not found)"
87 87 cleanup
88 88 exit 1
@@ -90,65 +90,65 if [ "$BUILD_KERNEL" = true ] ; then
90 90
91 91 # Install kernel modules
92 92 if [ "$ENABLE_REDUCE" = true ] ; then
93 make -C "${KERNELDIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
93 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
94 94 else
95 make -C "${KERNELDIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
95 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
96 96
97 97 # Install kernel firmware
98 make -C "${KERNELDIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
98 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
99 99 fi
100 100
101 101 # Install kernel headers
102 102 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
103 make -C "${KERNELDIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
103 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
104 104 fi
105 105
106 106 # Prepare boot (firmware) directory
107 mkdir "${BOOTDIR}"
107 mkdir "${BOOT_DIR}"
108 108
109 109 # Get kernel release version
110 KERNEL_VERSION=`cat "${KERNELDIR}/include/config/kernel.release"`
110 KERNEL_VERSION=`cat "${KERNEL_DIR}/include/config/kernel.release"`
111 111
112 112 # Copy kernel configuration file to the boot directory
113 install_readonly "${KERNELDIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
113 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
114 114
115 115 # Copy dts and dtb device tree sources and binaries
116 mkdir "${BOOTDIR}/overlays"
117 install_readonly "${KERNELDIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOTDIR}/"
118 install_readonly "${KERNELDIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOTDIR}/overlays/"
119 install_readonly "${KERNELDIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOTDIR}/overlays/README"
116 mkdir "${BOOT_DIR}/overlays"
117 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOT_DIR}/"
118 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOT_DIR}/overlays/"
119 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
120 120
121 121 if [ "$ENABLE_UBOOT" = false ] ; then
122 122 # Convert and copy zImage kernel to the boot directory
123 "${KERNELDIR}/scripts/mkknlimg" "${KERNELDIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOTDIR}/${KERNEL_IMAGE}"
123 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
124 124 else
125 125 # Copy zImage kernel to the boot directory
126 install_readonly "${KERNELDIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOTDIR}/${KERNEL_IMAGE}"
126 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
127 127 fi
128 128
129 129 # Remove kernel sources
130 130 if [ "$KERNEL_REMOVESRC" = true ] ; then
131 rm -fr "${KERNELDIR}"
131 rm -fr "${KERNEL_DIR}"
132 132 fi
133 133
134 if [ -n "$FIRMWAREDIR" ] && [ -d "$FIRMWAREDIR" ] ; then
134 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
135 135 # Install boot binaries from local directory
136 cp ${FIRMWAREDIR}/boot/bootcode.bin ${BOOTDIR}/bootcode.bin
137 cp ${FIRMWAREDIR}/boot/fixup.dat ${BOOTDIR}/fixup.dat
138 cp ${FIRMWAREDIR}/boot/fixup_cd.dat ${BOOTDIR}/fixup_cd.dat
139 cp ${FIRMWAREDIR}/boot/fixup_x.dat ${BOOTDIR}/fixup_x.dat
140 cp ${FIRMWAREDIR}/boot/start.elf ${BOOTDIR}/start.elf
141 cp ${FIRMWAREDIR}/boot/start_cd.elf ${BOOTDIR}/start_cd.elf
142 cp ${FIRMWAREDIR}/boot/start_x.elf ${BOOTDIR}/start_x.elf
136 cp ${RPI_FIRMWARE_DIR}/boot/bootcode.bin ${BOOT_DIR}/bootcode.bin
137 cp ${RPI_FIRMWARE_DIR}/boot/fixup.dat ${BOOT_DIR}/fixup.dat
138 cp ${RPI_FIRMWARE_DIR}/boot/fixup_cd.dat ${BOOT_DIR}/fixup_cd.dat
139 cp ${RPI_FIRMWARE_DIR}/boot/fixup_x.dat ${BOOT_DIR}/fixup_x.dat
140 cp ${RPI_FIRMWARE_DIR}/boot/start.elf ${BOOT_DIR}/start.elf
141 cp ${RPI_FIRMWARE_DIR}/boot/start_cd.elf ${BOOT_DIR}/start_cd.elf
142 cp ${RPI_FIRMWARE_DIR}/boot/start_x.elf ${BOOT_DIR}/start_x.elf
143 143 else
144 144 # Install latest boot binaries from raspberry/firmware github
145 wget -q -O "${BOOTDIR}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
146 wget -q -O "${BOOTDIR}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
147 wget -q -O "${BOOTDIR}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
148 wget -q -O "${BOOTDIR}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
149 wget -q -O "${BOOTDIR}/start.elf" "${FIRMWARE_URL}/start.elf"
150 wget -q -O "${BOOTDIR}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
151 wget -q -O "${BOOTDIR}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
145 wget -q -O "${BOOT_DIR}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
146 wget -q -O "${BOOT_DIR}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
147 wget -q -O "${BOOT_DIR}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
148 wget -q -O "${BOOT_DIR}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
149 wget -q -O "${BOOT_DIR}/start.elf" "${FIRMWARE_URL}/start.elf"
150 wget -q -O "${BOOT_DIR}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
151 wget -q -O "${BOOT_DIR}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
152 152 fi
153 153
154 154 else # BUILD_KERNEL=false
@@ -166,7 +166,7 else # BUILD_KERNEL=false
166 166 exit 1
167 167 fi
168 168 # Copy vmlinuz kernel to the boot directory
169 install_readonly "${VMLINUZ}" "${BOOTDIR}/${KERNEL_IMAGE}"
169 install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}"
170 170 fi
171 171
172 172 # Setup firmware boot cmdline
@@ -208,19 +208,26 if [ "$RELEASE" = "stretch" ] ; then
208 208 fi
209 209
210 210 # Install firmware boot cmdline
211 echo "${CMDLINE}" > "${BOOTDIR}/cmdline.txt"
211 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
212 212
213 213 # Install firmware config
214 install_readonly files/boot/config.txt "${BOOTDIR}/config.txt"
214 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
215 215
216 216 # Setup minimal GPU memory allocation size: 16MB (no X)
217 217 if [ "$ENABLE_MINGPU" = true ] ; then
218 echo "gpu_mem=16" >> "${BOOTDIR}/config.txt"
218 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
219 219 fi
220 220
221 221 # Setup boot with initramfs
222 222 if [ "$ENABLE_INITRAMFS" = true ] ; then
223 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOTDIR}/config.txt"
223 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
224 fi
225
226 # Disable RPi3 Bluetooth and restore ttyAMA0 serial device
227 if [ "$RPI_MODEL" = 3 ] ; then
228 if [ "$ENABLE_CONSOLE" = true ] ; then
229 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
230 fi
224 231 fi
225 232
226 233 # Create firmware configuration and cmdline symlinks
@@ -242,29 +249,29 if [ "$ENABLE_SOUND" = true ] ; then
242 249 fi
243 250
244 251 # Install kernel modules blacklist
245 mkdir -p "${ETCDIR}/modprobe.d/"
246 install_readonly files/modules/raspi-blacklist.conf "${ETCDIR}/modprobe.d/raspi-blacklist.conf"
252 mkdir -p "${ETC_DIR}/modprobe.d/"
253 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
247 254
248 255 # Install and setup fstab
249 install_readonly files/mount/fstab "${ETCDIR}/fstab"
256 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
250 257
251 258 # Add usb/sda disk root partition to fstab
252 259 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
253 sed -i "s/mmcblk0p2/sda1/" "${ETCDIR}/fstab"
260 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
254 261 fi
255 262
256 263 # Add encrypted root partition to fstab and crypttab
257 264 if [ "$ENABLE_CRYPTFS" = true ] ; then
258 265 # Replace fstab root partition with encrypted partition mapping
259 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETCDIR}/fstab"
266 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
260 267
261 268 # Add encrypted partition to crypttab and fstab
262 install_readonly files/mount/crypttab "${ETCDIR}/crypttab"
263 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks" >> "${ETCDIR}/crypttab"
269 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
270 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks" >> "${ETC_DIR}/crypttab"
264 271
265 272 if [ "$ENABLE_SPLITFS" = true ] ; then
266 273 # Add usb/sda disk to crypttab
267 sed -i "s/mmcblk0p2/sda1/" "${ETCDIR}/crypttab"
274 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
268 275 fi
269 276 fi
270 277
@@ -273,13 +280,13 if [ "$ENABLE_INITRAMFS" = true ] ; then
273 280 if [ "$ENABLE_CRYPTFS" = true ] ; then
274 281 # Include initramfs scripts to auto expand encrypted root partition
275 282 if [ "$EXPANDROOT" = true ] ; then
276 install_exec files/initramfs/expand_encrypted_rootfs "${ETCDIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
277 install_exec files/initramfs/expand-premount "${ETCDIR}/initramfs-tools/scripts/local-premount/expand-premount"
278 install_exec files/initramfs/expand-tools "${ETCDIR}/initramfs-tools/hooks/expand-tools"
283 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
284 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
285 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
279 286 fi
280 287
281 288 # Disable SSHD inside initramfs
282 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETCDIR}/initramfs-tools/initramfs.conf"
289 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
283 290
284 291 # Dummy mapping required by mkinitramfs
285 292 echo "0 1 crypt $(echo ${CRYPTFS_CIPHER} | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
@@ -296,4 +303,4 if [ "$ENABLE_INITRAMFS" = true ] ; then
296 303 fi
297 304
298 305 # Install sysctl.d configuration files
299 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETCDIR}/sysctl.d/81-rpi-vm.conf"
306 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
@@ -6,37 +6,37
6 6 . ./functions.sh
7 7
8 8 # Install and setup hostname
9 install_readonly files/network/hostname "${ETCDIR}/hostname"
10 sed -i "s/^rpi2-jessie/${HOSTNAME}/" "${ETCDIR}/hostname"
9 install_readonly files/network/hostname "${ETC_DIR}/hostname"
10 sed -i "s/^rpi2-jessie/${HOSTNAME}/" "${ETC_DIR}/hostname"
11 11
12 12 # Install and setup hosts
13 install_readonly files/network/hosts "${ETCDIR}/hosts"
14 sed -i "s/rpi2-jessie/${HOSTNAME}/" "${ETCDIR}/hosts"
13 install_readonly files/network/hosts "${ETC_DIR}/hosts"
14 sed -i "s/rpi2-jessie/${HOSTNAME}/" "${ETC_DIR}/hosts"
15 15
16 16 # Setup hostname entry with static IP
17 17 if [ "$NET_ADDRESS" != "" ] ; then
18 18 NET_IP=$(echo "${NET_ADDRESS}" | cut -f 1 -d'/')
19 sed -i "s/^127.0.1.1/${NET_IP}/" "${ETCDIR}/hosts"
19 sed -i "s/^127.0.1.1/${NET_IP}/" "${ETC_DIR}/hosts"
20 20 fi
21 21
22 22 # Remove IPv6 hosts
23 23 if [ "$ENABLE_IPV6" = false ] ; then
24 sed -i -e "/::[1-9]/d" -e "/^$/d" "${ETCDIR}/hosts"
24 sed -i -e "/::[1-9]/d" -e "/^$/d" "${ETC_DIR}/hosts"
25 25 fi
26 26
27 27 # Install hint about network configuration
28 install_readonly files/network/interfaces "${ETCDIR}/network/interfaces"
28 install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces"
29 29
30 30 # Install configuration for interface eth0
31 install_readonly files/network/eth.network "${ETCDIR}/systemd/network/eth.network"
31 install_readonly files/network/eth.network "${ETC_DIR}/systemd/network/eth.network"
32 32
33 33 if [ "$ENABLE_DHCP" = true ] ; then
34 34 # Enable DHCP configuration for interface eth0
35 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETCDIR}/systemd/network/eth.network"
35 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth.network"
36 36
37 37 # Set DHCP configuration to IPv4 only
38 38 if [ "$ENABLE_IPV6" = false ] ; then
39 sed -i "s/DHCP=.*/DHCP=v4/" "${ETCDIR}/systemd/network/eth.network"
39 sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth.network"
40 40 fi
41 41
42 42 else # ENABLE_DHCP=false
@@ -50,34 +50,44 else # ENABLE_DHCP=false
50 50 -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\
51 51 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\
52 52 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\
53 "${ETCDIR}/systemd/network/eth.network"
53 "${ETC_DIR}/systemd/network/eth.network"
54 54 fi
55 55
56 56 # Remove empty settings from network configuration
57 sed -i "/.*=\$/d" "${ETCDIR}/systemd/network/eth.network"
57 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network"
58 58
59 59 # Move systemd network configuration if required by Debian release
60 60 if [ "$RELEASE" = "stretch" ] ; then
61 mv -v "${ETCDIR}/systemd/network/eth.network" "${LIBDIR}/systemd/network/10-eth.network"
62 rm -fr "${ETCDIR}/systemd/network"
61 mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network"
62 rm -fr "${ETC_DIR}/systemd/network"
63 63 fi
64 64
65 65 # Enable systemd-networkd service
66 66 chroot_exec systemctl enable systemd-networkd
67 67
68 68 # Install host.conf resolver configuration
69 install_readonly files/network/host.conf "${ETCDIR}/host.conf"
69 install_readonly files/network/host.conf "${ETC_DIR}/host.conf"
70 70
71 71 # Enable network stack hardening
72 72 if [ "$ENABLE_HARDNET" = true ] ; then
73 73 # Install sysctl.d configuration files
74 install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETCDIR}/sysctl.d/82-rpi-net-hardening.conf"
74 install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETC_DIR}/sysctl.d/82-rpi-net-hardening.conf"
75 75
76 76 # Setup resolver warnings about spoofed addresses
77 sed -i "s/^# spoof warn/spoof warn/" "${ETCDIR}/host.conf"
77 sed -i "s/^# spoof warn/spoof warn/" "${ETC_DIR}/host.conf"
78 78 fi
79 79
80 80 # Enable time sync
81 81 if [ "NET_NTP_1" != "" ] ; then
82 82 chroot_exec systemctl enable systemd-timesyncd.service
83 83 fi
84
85 # Download the firmware binary blob required to use the RPi3 wireless interface
86 if [ "$ENABLE_WIRELESS" = true ] ; then
87 if [ ! -d ${WLAN_FIRMWARE_DIR} ] ; then
88 mkdir -p ${WLAN_FIRMWARE_DIR}
89 fi
90
91 wget -q -O "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin"
92 wget -q -O "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt"
93 fi
@@ -7,16 +7,16
7 7
8 8 if [ "$ENABLE_IPTABLES" = true ] ; then
9 9 # Create iptables configuration directory
10 mkdir -p "${ETCDIR}/iptables"
10 mkdir -p "${ETC_DIR}/iptables"
11 11
12 12 # Install iptables systemd service
13 install_readonly files/iptables/iptables.service "${ETCDIR}/systemd/system/iptables.service"
13 install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service"
14 14
15 15 # Install flush-table script called by iptables service
16 install_exec files/iptables/flush-iptables.sh "${ETCDIR}/iptables/flush-iptables.sh"
16 install_exec files/iptables/flush-iptables.sh "${ETC_DIR}/iptables/flush-iptables.sh"
17 17
18 18 # Install iptables rule file
19 install_readonly files/iptables/iptables.rules "${ETCDIR}/iptables/iptables.rules"
19 install_readonly files/iptables/iptables.rules "${ETC_DIR}/iptables/iptables.rules"
20 20
21 21 # Reload systemd configuration and enable iptables service
22 22 chroot_exec systemctl daemon-reload
@@ -24,12 +24,12 if [ "$ENABLE_IPTABLES" = true ] ; then
24 24
25 25 if [ "$ENABLE_IPV6" = true ] ; then
26 26 # Install ip6tables systemd service
27 install_readonly files/iptables/ip6tables.service "${ETCDIR}/systemd/system/ip6tables.service"
27 install_readonly files/iptables/ip6tables.service "${ETC_DIR}/systemd/system/ip6tables.service"
28 28
29 29 # Install ip6tables file
30 install_exec files/iptables/flush-ip6tables.sh "${ETCDIR}/iptables/flush-ip6tables.sh"
30 install_exec files/iptables/flush-ip6tables.sh "${ETC_DIR}/iptables/flush-ip6tables.sh"
31 31
32 install_readonly files/iptables/ip6tables.rules "${ETCDIR}/iptables/ip6tables.rules"
32 install_readonly files/iptables/ip6tables.rules "${ETC_DIR}/iptables/ip6tables.rules"
33 33
34 34 # Reload systemd configuration and enable iptables service
35 35 chroot_exec systemctl daemon-reload
@@ -39,6 +39,6 fi
39 39
40 40 if [ "$ENABLE_SSHD" = false ] ; then
41 41 # Remove SSHD related iptables rules
42 sed -i "/^#/! {/SSH/ s/^/# /}" "${ETCDIR}/iptables/iptables.rules" 2> /dev/null
43 sed -i "/^#/! {/SSH/ s/^/# /}" "${ETCDIR}/iptables/ip6tables.rules" 2> /dev/null
42 sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/iptables.rules" 2> /dev/null
43 sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/ip6tables.rules" 2> /dev/null
44 44 fi
@@ -20,7 +20,7 if [ "$ENABLE_ROOT" = true ] ; then
20 20 chroot_exec usermod -p "${ENCRYPTED_PASSWORD}" root
21 21
22 22 if [ "$ENABLE_ROOT_SSH" = true ] ; then
23 sed -i "s|[#]*PermitRootLogin.*|PermitRootLogin yes|g" "${ETCDIR}/ssh/sshd_config"
23 sed -i "s|[#]*PermitRootLogin.*|PermitRootLogin yes|g" "${ETC_DIR}/ssh/sshd_config"
24 24 fi
25 25 else
26 26 # Set no root password to disable root login
@@ -7,7 +7,7
7 7
8 8 # Disable rsyslog
9 9 if [ "$ENABLE_RSYSLOG" = false ] ; then
10 sed -i "s|[#]*ForwardToSyslog=yes|ForwardToSyslog=no|g" "${ETCDIR}/systemd/journald.conf"
10 sed -i "s|[#]*ForwardToSyslog=yes|ForwardToSyslog=no|g" "${ETC_DIR}/systemd/journald.conf"
11 11 chroot_exec systemctl disable rsyslog
12 12 chroot_exec apt-get -qq -y --force-yes purge rsyslog
13 13 fi
@@ -21,47 +21,47 if [ "$ENABLE_UBOOT" = true ] ; then
21 21
22 22 # Copy compiled bootloader binary and set config.txt to load it
23 23 install_exec "${R}/tmp/u-boot/tools/mkimage" "${R}/usr/sbin/mkimage"
24 install_readonly "${R}/tmp/u-boot/u-boot.bin" "${BOOTDIR}/u-boot.bin"
25 printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> "${BOOTDIR}/config.txt"
24 install_readonly "${R}/tmp/u-boot/u-boot.bin" "${BOOT_DIR}/u-boot.bin"
25 printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> "${BOOT_DIR}/config.txt"
26 26
27 27 # Install and setup U-Boot command file
28 install_readonly files/boot/uboot.mkimage "${BOOTDIR}/uboot.mkimage"
29 printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat ${BOOTDIR}/uboot.mkimage)" > "${BOOTDIR}/uboot.mkimage"
28 install_readonly files/boot/uboot.mkimage "${BOOT_DIR}/uboot.mkimage"
29 printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage"
30 30
31 31 if [ "$ENABLE_INITRAMFS" = true ] ; then
32 32 # Convert generated initramfs for U-Boot using mkimage
33 33 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"
34 34
35 35 # Remove original initramfs file
36 rm -f "${BOOTDIR}/initramfs-${KERNEL_VERSION}"
36 rm -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}"
37 37
38 38 # Configure U-Boot to load generated initramfs
39 printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat ${BOOTDIR}/uboot.mkimage)" > "${BOOTDIR}/uboot.mkimage"
40 printf "\nbootz \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}" >> "${BOOTDIR}/uboot.mkimage"
39 printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage"
40 printf "\nbootz \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage"
41 41 else # ENABLE_INITRAMFS=false
42 42 # Remove initramfs from U-Boot mkfile
43 sed -i '/.*initramfs.*/d' "${BOOTDIR}/uboot.mkimage"
43 sed -i '/.*initramfs.*/d' "${BOOT_DIR}/uboot.mkimage"
44 44
45 45 if [ "$BUILD_KERNEL" = false ] ; then
46 46 # Remove dtbfile from U-Boot mkfile
47 sed -i '/.*dtbfile.*/d' "${BOOTDIR}/uboot.mkimage"
48 printf "\nbootz \${kernel_addr_r}" >> "${BOOTDIR}/uboot.mkimage"
47 sed -i '/.*dtbfile.*/d' "${BOOT_DIR}/uboot.mkimage"
48 printf "\nbootz \${kernel_addr_r}" >> "${BOOT_DIR}/uboot.mkimage"
49 49 else
50 printf "\nbootz \${kernel_addr_r} - \${fdt_addr_r}" >> "${BOOTDIR}/uboot.mkimage"
50 printf "\nbootz \${kernel_addr_r} - \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage"
51 51 fi
52 52 fi
53 53
54 # Set mkfile to use dtb file
55 sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOTDIR}/uboot.mkimage"
54 # Set mkfile to use the correct dtb file
55 sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOT_DIR}/uboot.mkimage"
56 56
57 57 # Set mkfile to use kernel image
58 sed -i "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOTDIR}/uboot.mkimage"
58 sed -i "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOT_DIR}/uboot.mkimage"
59 59
60 60 # Remove all leading blank lines
61 sed -i "/./,\$!d" "${BOOTDIR}/uboot.mkimage"
61 sed -i "/./,\$!d" "${BOOT_DIR}/uboot.mkimage"
62 62
63 63 # Generate U-Boot bootloader image
64 chroot_exec /usr/sbin/mkimage -A "${KERNEL_ARCH}" -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n RPi2 -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr
64 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
65 65
66 66 # Remove U-Boot sources
67 67 rm -fr "${R}/tmp/u-boot"
@@ -6,44 +6,44
6 6 . ./functions.sh
7 7
8 8 # Prepare rc.firstboot script
9 cat files/firstboot/10-begin.sh > "${ETCDIR}/rc.firstboot"
9 cat files/firstboot/10-begin.sh > "${ETC_DIR}/rc.firstboot"
10 10
11 11 # Ensure openssh server host keys are regenerated on first boot
12 12 if [ "$ENABLE_SSHD" = true ] ; then
13 cat files/firstboot/21-generate-ssh-keys.sh >> "${ETCDIR}/rc.firstboot"
13 cat files/firstboot/21-generate-ssh-keys.sh >> "${ETC_DIR}/rc.firstboot"
14 14 fi
15 15
16 16 # Prepare filesystem auto expand
17 17 if [ "$EXPANDROOT" = true ] ; then
18 18 if [ "$ENABLE_CRYPTFS" = false ] ; then
19 cat files/firstboot/22-expandroot.sh >> "${ETCDIR}/rc.firstboot"
19 cat files/firstboot/22-expandroot.sh >> "${ETC_DIR}/rc.firstboot"
20 20 else
21 21 # Regenerate initramfs to remove encrypted root partition auto expand
22 cat files/firstboot/23-regenerate-initramfs.sh >> "${ETCDIR}/rc.firstboot"
22 cat files/firstboot/23-regenerate-initramfs.sh >> "${ETC_DIR}/rc.firstboot"
23 23 fi
24 24 fi
25 25
26 26 # Ensure that dbus machine-id exists
27 cat files/firstboot/24-generate-machineid.sh >> "${ETCDIR}/rc.firstboot"
27 cat files/firstboot/24-generate-machineid.sh >> "${ETC_DIR}/rc.firstboot"
28 28
29 29 # Create /etc/resolv.conf symlink
30 cat files/firstboot/25-create-resolv-symlink.sh >> "${ETCDIR}/rc.firstboot"
30 cat files/firstboot/25-create-resolv-symlink.sh >> "${ETC_DIR}/rc.firstboot"
31 31
32 32 # Configure automatic network interface names
33 33 if [ "$ENABLE_IFNAMES" = true ] ; then
34 cat files/firstboot/26-config-ifnames.sh >> "${ETCDIR}/rc.firstboot"
34 cat files/firstboot/26-config-ifnames.sh >> "${ETC_DIR}/rc.firstboot"
35 35 fi
36 36
37 37 # Finalize rc.firstboot script
38 cat files/firstboot/99-finish.sh >> "${ETCDIR}/rc.firstboot"
39 chmod +x "${ETCDIR}/rc.firstboot"
38 cat files/firstboot/99-finish.sh >> "${ETC_DIR}/rc.firstboot"
39 chmod +x "${ETC_DIR}/rc.firstboot"
40 40
41 41 # Install default rc.local if it does not exist
42 if [ ! -f "${ETCDIR}/rc.local" ] ; then
43 install_exec files/etc/rc.local "${ETCDIR}/rc.local"
42 if [ ! -f "${ETC_DIR}/rc.local" ] ; then
43 install_exec files/etc/rc.local "${ETC_DIR}/rc.local"
44 44 fi
45 45
46 46 # Add rc.firstboot script to rc.local
47 sed -i '/exit 0/d' "${ETCDIR}/rc.local"
48 echo /etc/rc.firstboot >> "${ETCDIR}/rc.local"
49 echo exit 0 >> "${ETCDIR}/rc.local"
47 sed -i '/exit 0/d' "${ETC_DIR}/rc.local"
48 echo /etc/rc.firstboot >> "${ETC_DIR}/rc.local"
49 echo exit 0 >> "${ETC_DIR}/rc.local"
@@ -10,13 +10,13 if [ "$ENABLE_REDUCE" = true ] ; then
10 10 if [ "$REDUCE_APT" = true ] ; then
11 11 # Install dpkg configuration file
12 12 if [ "$REDUCE_DOC" = true ] || [ "$REDUCE_MAN" = true ] ; then
13 install_readonly files/dpkg/01nodoc "${ETCDIR}/dpkg/dpkg.cfg.d/01nodoc"
13 install_readonly files/dpkg/01nodoc "${ETC_DIR}/dpkg/dpkg.cfg.d/01nodoc"
14 14 fi
15 15
16 16 # Install APT configuration files
17 install_readonly files/apt/02nocache "${ETCDIR}/apt/apt.conf.d/02nocache"
18 install_readonly files/apt/03compress "${ETCDIR}/apt/apt.conf.d/03compress"
19 install_readonly files/apt/04norecommends "${ETCDIR}/apt/apt.conf.d/04norecommends"
17 install_readonly files/apt/02nocache "${ETC_DIR}/apt/apt.conf.d/02nocache"
18 install_readonly files/apt/03compress "${ETC_DIR}/apt/apt.conf.d/03compress"
19 install_readonly files/apt/04norecommends "${ETC_DIR}/apt/apt.conf.d/04norecommends"
20 20
21 21 # Remove APT cache files
22 22 rm -fr "${R}/var/cache/apt/pkgcache.bin"
@@ -62,10 +62,10 if [ "$ENABLE_REDUCE" = true ] ; then
62 62
63 63 # Remove GPU kernels
64 64 if [ "$ENABLE_MINGPU" = true ] ; then
65 rm -f "${BOOTDIR}/start.elf"
66 rm -f "${BOOTDIR}/fixup.dat"
67 rm -f "${BOOTDIR}/start_x.elf"
68 rm -f "${BOOTDIR}/fixup_x.dat"
65 rm -f "${BOOT_DIR}/start.elf"
66 rm -f "${BOOT_DIR}/fixup.dat"
67 rm -f "${BOOT_DIR}/start_x.elf"
68 rm -f "${BOOT_DIR}/fixup_x.dat"
69 69 fi
70 70
71 71 # Remove kernel and initrd from /boot (already in /boot/firmware)
@@ -1,7 +1,7
1 1 # Set device tree fdtfile
2 2 setenv dtbfile bcm2709-rpi-2-b.dtb
3 3
4 # Tell Linux that it is booting on a Raspberry Pi2
4 # Tell Linux that it is booting on a Raspberry Pi2/3
5 5 setenv machid 0x00000c42
6 6
7 7 # Save these changes to u-boot's environment
@@ -1,3 +1,3
1 # File generated by rpi2-gen-image
1 # File generated by rpi23-gen-image
2 2 LANG=C
3 3 LC_ALL=C
@@ -1,4 +1,4
1 # This file contains utility functions used by rpi2-gen-image.sh
1 # This file contains utility functions used by rpi23-gen-image.sh
2 2
3 3 cleanup (){
4 4 set +x
@@ -1,9 +1,9
1 1 #!/bin/sh
2 2
3 3 ########################################################################
4 # rpi2-gen-image.sh 2015-2016
4 # rpi23-gen-image.sh 2015-2016
5 5 #
6 # Advanced Debian "jessie" and "stretch" bootstrap script for RPi2
6 # Advanced Debian "jessie" and "stretch" bootstrap script for RPi2/3
7 7 #
8 8 # This program is free software; you can redistribute it and/or
9 9 # modify it under the terms of the GNU General Public License
@@ -32,9 +32,16 fi
32 32
33 33 # Introduce settings
34 34 set -e
35 echo -n -e "\n#\n# RPi2 Bootstrap Settings\n#\n"
35 echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n"
36 36 set -x
37 37
38 # Raspberry Pi model configuration
39 RPI_MODEL=${RPI_MODEL:=2}
40 RPI2_DTB_FILE=${RPI2_DTB_FILE:=bcm2709-rpi-2-b.dtb}
41 RPI2_UBOOT_CONFIG=${RPI2_UBOOT_CONFIG:=rpi_2_defconfig}
42 RPI3_DTB_FILE=${RPI3_DTB_FILE:=bcm2710-rpi-3-b.dtb}
43 RPI3_UBOOT_CONFIG=${RPI3_UBOOT_CONFIG:=rpi_3_32b_defconfig}
44
38 45 # Debian release
39 46 RELEASE=${RELEASE:=jessie}
40 47 KERNEL_ARCH=${KERNEL_ARCH:=arm}
@@ -43,13 +50,12 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
43 50 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
44 51 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
45 52 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
46 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
47 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
48 53 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
49 54
50 55 # URLs
51 56 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
52 57 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
58 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm}
53 59 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
54 60 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
55 61 UBOOT_URL=${UBOOT_URL:=git://git.denx.de/u-boot.git}
@@ -60,19 +66,17 BUILDDIR="${BASEDIR}/build"
60 66
61 67 # Chroot directories
62 68 R="${BUILDDIR}/chroot"
63 ETCDIR="${R}/etc"
64 LIBDIR="${R}/lib"
65 BOOTDIR="${R}/boot/firmware"
66 KERNELDIR="${R}/usr/src/linux"
69 ETC_DIR="${R}/etc"
70 LIB_DIR="${R}/lib"
71 BOOT_DIR="${R}/boot/firmware"
72 KERNEL_DIR="${R}/usr/src/linux"
73 WLAN_FIRMWARE_DIR="${R}/lib/firmware/brcm"
67 74
68 75 # Firmware directory: Blank if download from github
69 FIRMWAREDIR=${FIRMWAREDIR:=""}
70
71 # Packages for gcc/c++ inside the chroot
72 COMPILER_PACKAGES=${COMPILER_PACKAGES:="linux-compiler-gcc-4.8-arm g++ make bc"}
76 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
73 77
74 78 # General settings
75 HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}}
79 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
76 80 PASSWORD=${PASSWORD:=raspberry}
77 81 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
78 82 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
@@ -105,6 +109,7 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
105 109 ENABLE_IPV6=${ENABLE_IPV6:=true}
106 110 ENABLE_SSHD=${ENABLE_SSHD:=true}
107 111 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
112 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
108 113 ENABLE_SOUND=${ENABLE_SOUND:=true}
109 114 ENABLE_DBUS=${ENABLE_DBUS:=true}
110 115 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
@@ -175,10 +180,34 MISSING_PACKAGES=""
175 180
176 181 set +x
177 182
178 # Build latest RPi2 Linux kernel if required by Debian release
179 if [ "$RELEASE" = "stretch" ] ; then
183 # Set Raspberry Pi model specific configuration
184 if [ "$RPI_MODEL" = 2 ] ; then
185 DTB_FILE=${RPI2_DTB_FILE}
186 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
187 elif [ "$RPI_MODEL" = 3 ] ; then
188 DTB_FILE=${RPI3_DTB_FILE}
189 UBOOT_CONFIG=${RPI3_UBOOT_CONFIG}
180 190 BUILD_KERNEL=true
181 COMPILER_PACKAGES=$(echo $COMPILER_PACKAGES | sed s/-4.8-arm/-5-arm/)
191 else
192 echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!"
193 exit 1
194 fi
195
196 # Check if the internal wireless interface is supported by the RPi model
197 if [ "$ENABLE_WIRELESS" = true ] && [ "$RPI_MODEL" != 3 ] ; then
198 echo "error: The selected Raspberry Pi model has no internal wireless interface"
199 exit 1
200 fi
201
202 # Set compiler packages and build RPi2/3 Linux kernel if required by Debian release
203 if [ "$RELEASE" = "jessie" ] ; then
204 COMPILER_PACKAGES="linux-compiler-gcc-4.8-arm g++ make bc"
205 elif [ "$RELEASE" = "stretch" ] ; then
206 COMPILER_PACKAGES="linux-compiler-gcc-5-arm g++ make bc"
207 BUILD_KERNEL=true
208 else
209 echo "error: Debian release ${RELEASE} is not supported!"
210 exit 1
182 211 fi
183 212
184 213 # Add packages required for kernel cross compilation
@@ -399,7 +428,7 fi
399 428 # Generate required machine-id
400 429 MACHINE_ID=$(dbus-uuidgen)
401 430 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
402 echo -n "${MACHINE_ID}" > "${ETCDIR}/machine-id"
431 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
403 432
404 433 # APT Cleanup
405 434 chroot_exec apt-get -y clean
@@ -415,13 +444,13 rm -rf "${R}/run/*"
415 444 rm -rf "${R}/tmp/*"
416 445
417 446 # Clean up files
418 rm -f "${ETCDIR}/ssh/ssh_host_*"
419 rm -f "${ETCDIR}/dropbear/dropbear_*"
420 rm -f "${ETCDIR}/apt/sources.list.save"
421 rm -f "${ETCDIR}/resolvconf/resolv.conf.d/original"
422 rm -f "${ETCDIR}/*-"
423 rm -f "${ETCDIR}/apt/apt.conf.d/10proxy"
424 rm -f "${ETCDIR}/resolv.conf"
447 rm -f "${ETC_DIR}/ssh/ssh_host_*"
448 rm -f "${ETC_DIR}/dropbear/dropbear_*"
449 rm -f "${ETC_DIR}/apt/sources.list.save"
450 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
451 rm -f "${ETC_DIR}/*-"
452 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
453 rm -f "${ETC_DIR}/resolv.conf"
425 454 rm -f "${R}/root/.bash_history"
426 455 rm -f "${R}/var/lib/urandom/random-seed"
427 456 rm -f "${R}/initrd.img"
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant