##// END OF EJS Templates
Merge branch 'master' of git://github.com/drtyhlpr/rpi23-gen-image into drtyhlpr-master
vidal -
r707:4b0de60ca6dc Fusion
parent child
Show More
@@ -1,580 +1,596
1 # rpi23-gen-image
1 # rpi23-gen-image
2 ## Introduction
2 ## Introduction
3 <<<<<<< HEAD
3
4
4
5
5 `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 (armhf) releases `jessie`, `stretch` and `buster`. Raspberry Pi 3 images are generated for 32-bit mode only. Raspberry Pi 3 64-bit images can be generated using custom configuration parameters (```templates/rpi3-stretch-arm64-4.11.y```).
6 `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 (armhf) releases `jessie`, `stretch` and `buster`. Raspberry Pi 3 images are generated for 32-bit mode only. Raspberry Pi 3 64-bit images can be generated using custom configuration parameters (```templates/rpi3-stretch-arm64-4.11.y```).
6
7
7
8
9 =======
10 `rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for all Raspberry Pi computers. The script at this time supports the bootstrapping of the Debian (armhf/armel) releases `stretch` and `buster`. Raspberry Pi 0/1/2/3/4 images are generated for 32-bit mode only. Raspberry Pi 3 supports 64-bit images that can be generated using custom configuration parameters (```templates/rpi3-stretch-arm64-4.14.y```).
11 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
8
12
9 ## Build dependencies
13 ## Build dependencies
10 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.
14 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.
11
15
12 ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo```
16 ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo```
13
17
18 <<<<<<< HEAD
14 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the Raspberry 3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf/armel) cross-compiler toolchain.
19 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the Raspberry 3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf/armel) cross-compiler toolchain.
20 =======
21 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
15 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the Raspberry 3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf/armel/aarch64) cross-compiler toolchain.
22 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the Raspberry 3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf/armel/aarch64) cross-compiler toolchain.
16
23
17 The script has been tested using the default `crossbuild-essential-armhf` and `crossbuild-essential-armel` toolchain meta packages on Debian Linux `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information.
24 The script has been tested using the default `crossbuild-essential-armhf` and `crossbuild-essential-armel` toolchain meta packages on Debian Linux `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information.
18
25
19 ## Command-line parameters
26 ## Command-line parameters
20 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.
27 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.
21
28
22 ##### Command-line examples:
29 ##### Command-line examples:
23 ```shell
30 ```shell
24 ENABLE_UBOOT=true ./rpi23-gen-image.sh
31 ENABLE_UBOOT=true ./rpi23-gen-image.sh
25 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi23-gen-image.sh
32 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi23-gen-image.sh
26 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi23-gen-image.sh
33 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi23-gen-image.sh
27 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi23-gen-image.sh
34 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi23-gen-image.sh
28 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi23-gen-image.sh
35 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi23-gen-image.sh
29 ENABLE_MINBASE=true ./rpi23-gen-image.sh
36 ENABLE_MINBASE=true ./rpi23-gen-image.sh
30 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi23-gen-image.sh
37 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi23-gen-image.sh
31 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi23-gen-image.sh
38 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi23-gen-image.sh
32 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
39 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
33 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
40 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
34 RELEASE=stretch BUILD_KERNEL=true ./rpi23-gen-image.sh
41 RELEASE=stretch BUILD_KERNEL=true ./rpi23-gen-image.sh
35 RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
42 RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
36 RELEASE=stretch RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
43 RELEASE=stretch RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
37 ```
44 ```
38
45
39 ## Configuration template files
46 ## Configuration template files
40 To avoid long lists of command-line parameters and to help to store the favourite parameter configurations the `rpi23-gen-image.sh` script supports so called configuration template files (`CONFIG_TEMPLATE`=template). These are simple text files located in the `./templates` directory that contain the list of configuration parameters that will be used. New configuration template files can be added to the `./templates` directory.
47 To avoid long lists of command-line parameters and to help to store the favourite parameter configurations the `rpi23-gen-image.sh` script supports so called configuration template files (`CONFIG_TEMPLATE`=template). These are simple text files located in the `./templates` directory that contain the list of configuration parameters that will be used. New configuration template files can be added to the `./templates` directory.
41
48
42 ##### Command-line examples:
49 ##### Command-line examples:
43 ```shell
50 ```shell
44 CONFIG_TEMPLATE=rpi3stretch ./rpi23-gen-image.sh
51 CONFIG_TEMPLATE=rpi3stretch ./rpi23-gen-image.sh
45 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
52 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
46 ```
53 ```
47
54
48 ## Supported parameters and settings
55 ## Supported parameters and settings
49 #### APT settings:
56 #### APT settings:
50 ##### `APT_SERVER`="ftp.debian.org"
57 ##### `APT_SERVER`="ftp.debian.org"
51 Set Debian packages server address. Choose a server from the list of Debian worldwide [mirror sites](https://www.debian.org/mirror/list). Using a nearby server will probably speed-up all required downloads within the bootstrapping process.
58 Set Debian packages server address. Choose a server from the list of Debian worldwide [mirror sites](https://www.debian.org/mirror/list). Using a nearby server will probably speed-up all required downloads within the bootstrapping process.
52
59
53 ##### `APT_PROXY`=""
60 ##### `APT_PROXY`=""
54 Set Proxy server address. Using a local Proxy-Cache like `apt-cacher-ng` will speed-up the bootstrapping process because all required Debian packages will only be downloaded from the Debian mirror site once. If `apt-cacher-ng` is running on default `http://127.0.0.1:3142` it is autodetected and you don't need to set this.
61 Set Proxy server address. Using a local Proxy-Cache like `apt-cacher-ng` will speed-up the bootstrapping process because all required Debian packages will only be downloaded from the Debian mirror site once. If `apt-cacher-ng` is running on default `http://127.0.0.1:3142` it is autodetected and you don't need to set this.
55
62
56 ##### `KEEP_APT_PROXY`=false
63 ##### `KEEP_APT_PROXY`=false
57 Keep the APT_PROXY settings used in the bootsrapping process in the generated image.
64 Keep the APT_PROXY settings used in the bootsrapping process in the generated image.
58
65
59 ##### `APT_INCLUDES`=""
66 ##### `APT_INCLUDES`=""
60 A comma-separated list of additional packages to be installed by debootstrap during bootstrapping.
67 A comma-separated list of additional packages to be installed by debootstrap during bootstrapping.
61
68
62 ##### `APT_INCLUDES_LATE`=""
69 ##### `APT_INCLUDES_LATE`=""
63 A comma-separated list of additional packages to be installed by apt after bootstrapping and after APT sources are set up. This is useful for packages with pre-depends, which debootstrap do not handle well.
70 A comma-separated list of additional packages to be installed by apt after bootstrapping and after APT sources are set up. This is useful for packages with pre-depends, which debootstrap do not handle well.
64
71
65 ---
72 ---
66
73
67 #### General system settings:
74 #### General system settings:
68 ##### `SET_ARCH`=32
75 ##### `SET_ARCH`=32
76 <<<<<<< HEAD
69 Set Architecture to default 32bit. If you want to compile 64-bit (RPI3 or RPI3+) set it to `64`. This option will set every needed cross-compiler or board specific option for a successful build.
77 Set Architecture to default 32bit. If you want to compile 64-bit (RPI3 or RPI3+) set it to `64`. This option will set every needed cross-compiler or board specific option for a successful build.
78 =======
79 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
70 Set Architecture to default 32bit. If you want to compile 64-bit (RPI3/RPI3+/RPI4) set it to `64`. This option will set every needed cross-compiler or board specific option for a successful build.
80 Set Architecture to default 32bit. If you want to compile 64-bit (RPI3/RPI3+/RPI4) set it to `64`. This option will set every needed cross-compiler or board specific option for a successful build.
71
81
72 ##### `RPI_MODEL`=2
82 ##### `RPI_MODEL`=2
73 Specify the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
83 Specify the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
74 - `0` = Raspberry Pi 0 and Raspberry Pi 0 W
84 - `0` = Raspberry Pi 0 and Raspberry Pi 0 W
75 - `1` = Raspberry Pi 1 model A and B
85 - `1` = Raspberry Pi 1 model A and B
76 - `1P` = Raspberry Pi 1 model B+ and A+
86 - `1P` = Raspberry Pi 1 model B+ and A+
77 - `2` = Raspberry Pi 2 model B
87 - `2` = Raspberry Pi 2 model B
78 - `3` = Raspberry Pi 3 model B
88 - `3` = Raspberry Pi 3 model B
79 - `3P` = Raspberry Pi 3 model B+
89 - `3P` = Raspberry Pi 3 model B+
80 - `4` = Raspberry Pi 4 model B
90 - `4` = Raspberry Pi 4 model B
81
91
82 ##### `RELEASE`="buster"
92 ##### `RELEASE`="buster"
83 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases `stretch` and `buster`.
93 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases `stretch` and `buster`.
84
94
85 ##### `RELEASE_ARCH`="armhf"
95 ##### `RELEASE_ARCH`="armhf"
86 Set the desired Debian release architecture.
96 Set the desired Debian release architecture.
87
97
88 ##### `HOSTNAME`="rpi$RPI_MODEL-$RELEASE"
98 ##### `HOSTNAME`="rpi$RPI_MODEL-$RELEASE"
89 Set system hostname. It's recommended that the hostname is unique in the corresponding subnet.
99 Set system hostname. It's recommended that the hostname is unique in the corresponding subnet.
90
100
91 ##### `PASSWORD`="raspberry"
101 ##### `PASSWORD`="raspberry"
92 Set system `root` password. It's **STRONGLY** recommended that you choose a custom password.
102 Set system `root` password. It's **STRONGLY** recommended that you choose a custom password.
93
103
94 ##### `USER_PASSWORD`="raspberry"
104 ##### `USER_PASSWORD`="raspberry"
95 Set password for the created non-root user `USER_NAME`=pi. Ignored if `ENABLE_USER`=false. It's **STRONGLY** recommended that you choose a custom password.
105 Set password for the created non-root user `USER_NAME`=pi. Ignored if `ENABLE_USER`=false. It's **STRONGLY** recommended that you choose a custom password.
96
106
97 ##### `DEFLOCAL`="en_US.UTF-8"
107 ##### `DEFLOCAL`="en_US.UTF-8"
98 Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. Please note that on using this parameter the script will automatically install the required packages `locales`, `keyboard-configuration` and `console-setup`.
108 Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. Please note that on using this parameter the script will automatically install the required packages `locales`, `keyboard-configuration` and `console-setup`.
99
109
100 ##### `TIMEZONE`="Europe/Berlin"
110 ##### `TIMEZONE`="Europe/Berlin"
101 Set default system timezone. All available timezones can be found in the `/usr/share/zoneinfo/` directory. This setting can also be changed inside the running OS using the `dpkg-reconfigure tzdata` command.
111 Set default system timezone. All available timezones can be found in the `/usr/share/zoneinfo/` directory. This setting can also be changed inside the running OS using the `dpkg-reconfigure tzdata` command.
102
112
103 ##### `EXPANDROOT`=true
113 ##### `EXPANDROOT`=true
104 Expand the root partition and filesystem automatically on first boot.
114 Expand the root partition and filesystem automatically on first boot.
105
115
106 ##### `ENABLE_DPHYSSWAP`=true
116 ##### `ENABLE_DPHYSSWAP`=true
107 Enable swap. The size of the swapfile is chosen relative to the size of the root partition. It'll use the `dphys-swapfile` package for that.
117 Enable swap. The size of the swapfile is chosen relative to the size of the root partition. It'll use the `dphys-swapfile` package for that.
108
118
109 ##### `ENABLE_QEMU`=false
119 ##### `ENABLE_QEMU`=false
110 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.
120 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.
111
121
112 ---
122 ---
113
123
114 #### Keyboard settings:
124 #### Keyboard settings:
115 These options are used to configure keyboard layout in `/etc/default/keyboard` for console and Xorg. These settings can also be changed inside the running OS using the `dpkg-reconfigure keyboard-configuration` command.
125 These options are used to configure keyboard layout in `/etc/default/keyboard` for console and Xorg. These settings can also be changed inside the running OS using the `dpkg-reconfigure keyboard-configuration` command.
116
126
117 ##### `XKB_MODEL`=""
127 ##### `XKB_MODEL`=""
118 Set the name of the model of your keyboard type.
128 Set the name of the model of your keyboard type.
119
129
120 ##### `XKB_LAYOUT`=""
130 ##### `XKB_LAYOUT`=""
121 Set the supported keyboard layout(s).
131 Set the supported keyboard layout(s).
122
132
123 ##### `XKB_VARIANT`=""
133 ##### `XKB_VARIANT`=""
124 Set the supported variant(s) of the keyboard layout(s).
134 Set the supported variant(s) of the keyboard layout(s).
125
135
126 ##### `XKB_OPTIONS`=""
136 ##### `XKB_OPTIONS`=""
127 Set extra xkb configuration options.
137 Set extra xkb configuration options.
128
138
129 ---
139 ---
130
140
131 #### Networking settings (DHCP):
141 #### Networking settings (DHCP):
132 This parameter is used to set up networking auto-configuration in `/etc/systemd/network/eth.network`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.`
142 This parameter is used to set up networking auto-configuration in `/etc/systemd/network/eth.network`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.`
133
143
134 ##### `ENABLE_DHCP`=true
144 ##### `ENABLE_DHCP`=true
135 Set the system to use DHCP. This requires an DHCP server.
145 Set the system to use DHCP. This requires an DHCP server.
136
146
137 ---
147 ---
138
148
139 #### Networking settings (static):
149 #### Networking settings (static):
140 These parameters are used to set up a static networking configuration in `/etc/systemd/network/eth.network`. The following static networking parameters are only supported if `ENABLE_DHCP` was set to `false`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.
150 These parameters are used to set up a static networking configuration in `/etc/systemd/network/eth.network`. The following static networking parameters are only supported if `ENABLE_DHCP` was set to `false`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.
141
151
142 ##### `NET_ADDRESS`=""
152 ##### `NET_ADDRESS`=""
143 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
153 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
144
154
145 ##### `NET_GATEWAY`=""
155 ##### `NET_GATEWAY`=""
146 Set the IP address for the default gateway.
156 Set the IP address for the default gateway.
147
157
148 ##### `NET_DNS_1`=""
158 ##### `NET_DNS_1`=""
149 Set the IP address for the first DNS server.
159 Set the IP address for the first DNS server.
150
160
151 ##### `NET_DNS_2`=""
161 ##### `NET_DNS_2`=""
152 Set the IP address for the second DNS server.
162 Set the IP address for the second DNS server.
153
163
154 ##### `NET_DNS_DOMAINS`=""
164 ##### `NET_DNS_DOMAINS`=""
155 Set the default DNS search domains to use for non fully qualified hostnames.
165 Set the default DNS search domains to use for non fully qualified hostnames.
156
166
157 ##### `NET_NTP_1`=""
167 ##### `NET_NTP_1`=""
158 Set the IP address for the first NTP server.
168 Set the IP address for the first NTP server.
159
169
160 ##### `NET_NTP_2`=""
170 ##### `NET_NTP_2`=""
161 Set the IP address for the second NTP server.
171 Set the IP address for the second NTP server.
162
172
163 ---
173 ---
164
174
165 #### Basic system features:
175 #### Basic system features:
166 ##### `ENABLE_CONSOLE`=true
176 ##### `ENABLE_CONSOLE`=true
167 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.
177 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.
168
178
169 ##### `ENABLE_PRINTK`=false
179 ##### `ENABLE_PRINTK`=false
170 Enables printing kernel messages to konsole. printk is `3 4 1 3` as in raspbian.
180 Enables printing kernel messages to konsole. printk is `3 4 1 3` as in raspbian.
171
181
172 ##### `ENABLE_BLUETOOTH`=false
182 ##### `ENABLE_BLUETOOTH`=false
173 Enable onboard Bluetooth interface on the RPi0/3/3P. See: [Configuring the GPIO serial port on Raspbian jessie and stretch](https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/).
183 Enable onboard Bluetooth interface on the RPi0/3/3P. See: [Configuring the GPIO serial port on Raspbian jessie and stretch](https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/).
174
184
175 ##### `ENABLE_MINIUART_OVERLAY`=false
185 ##### `ENABLE_MINIUART_OVERLAY`=false
176 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.
186 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.
177
187
178 ##### `ENABLE_TURBO`=false
188 ##### `ENABLE_TURBO`=false
179 Enable Turbo mode. This setting locks cpu at the 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.
189 Enable Turbo mode. This setting locks cpu at the 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.
180
190
181 ##### `ENABLE_I2C`=false
191 ##### `ENABLE_I2C`=false
182 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.
192 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.
183
193
184 ##### `ENABLE_SPI`=false
194 ##### `ENABLE_SPI`=false
185 Enable SPI 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.
195 Enable SPI 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.
186
196
187 ##### `ENABLE_IPV6`=true
197 ##### `ENABLE_IPV6`=true
188 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
198 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
189
199
190 ##### `ENABLE_SSHD`=true
200 ##### `ENABLE_SSHD`=true
191 Install and enable OpenSSH service. The default configuration of the service doesn't allow `root` to login. Please use the user `pi` instead and `su -` or `sudo` to execute commands as root.
201 Install and enable OpenSSH service. The default configuration of the service doesn't allow `root` to login. Please use the user `pi` instead and `su -` or `sudo` to execute commands as root.
192
202
193 ##### `ENABLE_NONFREE`=false
203 ##### `ENABLE_NONFREE`=false
194 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.
204 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.
195
205
196 ##### `ENABLE_WIRELESS`=false
206 ##### `ENABLE_WIRELESS`=false
197 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`.
207 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`.
198
208
199 ##### `ENABLE_RSYSLOG`=true
209 ##### `ENABLE_RSYSLOG`=true
200 If set to false, disable and uninstall rsyslog (so logs will be available only in journal files)
210 If set to false, disable and uninstall rsyslog (so logs will be available only in journal files)
201
211
202 ##### `ENABLE_SOUND`=true
212 ##### `ENABLE_SOUND`=true
203 Enable sound hardware and install Advanced Linux Sound Architecture.
213 Enable sound hardware and install Advanced Linux Sound Architecture.
204
214
205 ##### `ENABLE_HWRANDOM`=true
215 ##### `ENABLE_HWRANDOM`=true
206 Enable Hardware Random Number Generator. Strong random numbers are important for most network-based communications that use encryption. It's recommended to be enabled.
216 Enable Hardware Random Number Generator. Strong random numbers are important for most network-based communications that use encryption. It's recommended to be enabled.
207
217
208 ##### `ENABLE_MINGPU`=false
218 ##### `ENABLE_MINGPU`=false
209 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
219 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
210
220
211 ##### `ENABLE_DBUS`=true
221 ##### `ENABLE_DBUS`=true
212 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
222 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
213
223
214 ##### `ENABLE_XORG`=false
224 ##### `ENABLE_XORG`=false
215 Install Xorg open-source X Window System.
225 Install Xorg open-source X Window System.
216
226
217 ##### `ENABLE_WM`=""
227 ##### `ENABLE_WM`=""
218 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`.
228 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`.
219
229
220 ##### `ENABLE_SYSVINIT`=false
230 ##### `ENABLE_SYSVINIT`=false
221 Support for halt,init,poweroff,reboot,runlevel,shutdown,telinit commands
231 Support for halt,init,poweroff,reboot,runlevel,shutdown,telinit commands
222
232
223 ---
233 ---
224
234
225 #### Advanced system features:
235 #### Advanced system features:
226 ##### `ENABLE_KEYGEN`=false
236 ##### `ENABLE_KEYGEN`=false
227 Recover your lost codec license
237 Recover your lost codec license
228
238
229 ##### `ENABLE_SYSTEMDSWAP`=false
239 ##### `ENABLE_SYSTEMDSWAP`=false
230 Enables [Systemd-swap service](https://github.com/Nefelim4ag/systemd-swap). Usefull if `KERNEL_ZSWAP` is enabled.
240 Enables [Systemd-swap service](https://github.com/Nefelim4ag/systemd-swap). Usefull if `KERNEL_ZSWAP` is enabled.
231
241
232 ##### `ENABLE_MINBASE`=false
242 ##### `ENABLE_MINBASE`=false
233 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
243 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
234
244
235 ##### `ENABLE_REDUCE`=false
245 ##### `ENABLE_REDUCE`=false
236 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
246 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
237
247
238 ##### `ENABLE_UBOOT`=false
248 ##### `ENABLE_UBOOT`=false
239 Replace the default RPi 0/1/2/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.
249 Replace the default RPi 0/1/2/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.
240 RPI4 needs tbd
250 RPI4 needs tbd
241
251
242 ##### `UBOOTSRC_DIR`=""
252 ##### `UBOOTSRC_DIR`=""
243 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.
253 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.
244
254
245 ##### `ENABLE_FBTURBO`=false
255 ##### `ENABLE_FBTURBO`=false
246 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.
256 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.
247
257
248 ##### `FBTURBOSRC_DIR`=""
258 ##### `FBTURBOSRC_DIR`=""
249 Path to a directory (`xf86-video-fbturbo`) of [hardware accelerated Xorg video driver sources](https://github.com/ssvb/xf86-video-fbturbo) that will be copied, configured, build and installed inside the chroot.
259 Path to a directory (`xf86-video-fbturbo`) of [hardware accelerated Xorg video driver sources](https://github.com/ssvb/xf86-video-fbturbo) that will be copied, configured, build and installed inside the chroot.
250
260
251 ##### `ENABLE_VIDEOCORE`=false
261 ##### `ENABLE_VIDEOCORE`=false
252 Install and enable the [ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) `vcgencmd`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
262 Install and enable the [ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) `vcgencmd`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
253
263
254 ##### `VIDEOCORESRC_DIR`=""
264 ##### `VIDEOCORESRC_DIR`=""
255 Path to a directory (`userland`) of [ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot.
265 Path to a directory (`userland`) of [ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot.
256
266
257 ##### `ENABLE_NEXMON`=false
267 ##### `ENABLE_NEXMON`=false
258 Install and enable the [Source code for a C-based firmware patching framework for Broadcom/Cypress WiFi chips that enables you to write your own firmware patches, for example, to enable monitor mode with radiotap headers and frame injection](https://github.com/seemoo-lab/nexmon.git).
268 Install and enable the [Source code for a C-based firmware patching framework for Broadcom/Cypress WiFi chips that enables you to write your own firmware patches, for example, to enable monitor mode with radiotap headers and frame injection](https://github.com/seemoo-lab/nexmon.git).
259
269
260 ##### `NEXMONSRC_DIR`=""
270 ##### `NEXMONSRC_DIR`=""
261 Path to a directory (`nexmon`) of [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot.
271 Path to a directory (`nexmon`) of [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot.
262
272
263 ##### `ENABLE_IPTABLES`=false
273 ##### `ENABLE_IPTABLES`=false
264 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
274 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
265
275
266 ##### `ENABLE_USER`=true
276 ##### `ENABLE_USER`=true
267 Create non-root user with password `USER_PASSWORD`=raspberry. Unless overridden with `USER_NAME`=user, the username will be `pi`.
277 Create non-root user with password `USER_PASSWORD`=raspberry. Unless overridden with `USER_NAME`=user, the username will be `pi`.
268
278
269 ##### `USER_NAME`=pi
279 ##### `USER_NAME`=pi
270 Non-root user to create. Ignored if `ENABLE_USER`=false
280 Non-root user to create. Ignored if `ENABLE_USER`=false
271
281
272 ##### `ENABLE_ROOT`=false
282 ##### `ENABLE_ROOT`=false
273 Set root user password so root login will be enabled
283 Set root user password so root login will be enabled
274
284
275 ##### `ENABLE_HARDNET`=false
285 ##### `ENABLE_HARDNET`=false
276 Enable IPv4/IPv6 network stack hardening settings.
286 Enable IPv4/IPv6 network stack hardening settings.
277
287
278 ##### `ENABLE_SPLITFS`=false
288 ##### `ENABLE_SPLITFS`=false
279 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
289 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
280
290
281 ##### `CHROOT_SCRIPTS`=""
291 ##### `CHROOT_SCRIPTS`=""
282 Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this directory is run in lexicographical order.
292 Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this directory is run in lexicographical order.
283
293
284 ##### `ENABLE_INITRAMFS`=false
294 ##### `ENABLE_INITRAMFS`=false
285 Create an initramfs that that will be loaded during the Linux startup process. `ENABLE_INITRAMFS` will automatically get enabled if `ENABLE_CRYPTFS`=true. This parameter will be ignored if `BUILD_KERNEL`=false.
295 Create an initramfs that that will be loaded during the Linux startup process. `ENABLE_INITRAMFS` will automatically get enabled if `ENABLE_CRYPTFS`=true. This parameter will be ignored if `BUILD_KERNEL`=false.
286
296
287 ##### `ENABLE_IFNAMES`=true
297 ##### `ENABLE_IFNAMES`=true
288 Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names.
298 Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names.
289
299
290 ##### `ENABLE_SPLASH`=true
300 ##### `ENABLE_SPLASH`=true
291 Enable default Raspberry Pi boot up rainbow splash screen.
301 Enable default Raspberry Pi boot up rainbow splash screen.
292
302
293 ##### `ENABLE_LOGO`=true
303 ##### `ENABLE_LOGO`=true
294 Enable default Raspberry Pi console logo (image of four raspberries in the top left corner).
304 Enable default Raspberry Pi console logo (image of four raspberries in the top left corner).
295
305
296 ##### `ENABLE_SILENT_BOOT`=false
306 ##### `ENABLE_SILENT_BOOT`=false
297 Set the verbosity of console messages shown during boot up to a strict minimum.
307 Set the verbosity of console messages shown during boot up to a strict minimum.
298
308
299 ##### `DISABLE_UNDERVOLT_WARNINGS`=
309 ##### `DISABLE_UNDERVOLT_WARNINGS`=
300 Disable RPi2/3 under-voltage warnings and overlays. Setting the parameter to `1` will disable the warning overlay. Setting it to `2` will additionally allow RPi2/3 turbo mode when low-voltage is present.
310 Disable RPi2/3 under-voltage warnings and overlays. Setting the parameter to `1` will disable the warning overlay. Setting it to `2` will additionally allow RPi2/3 turbo mode when low-voltage is present.
301
311
302 ---
312 ---
303
313
304 #### SSH settings:
314 #### SSH settings:
305 ##### `SSH_ENABLE_ROOT`=false
315 ##### `SSH_ENABLE_ROOT`=false
306 Enable password-based root login via SSH. This may be a security risk with the default password set, use only in trusted environments. `ENABLE_ROOT` must be set to `true`.
316 Enable password-based root login via SSH. This may be a security risk with the default password set, use only in trusted environments. `ENABLE_ROOT` must be set to `true`.
307
317
308 ##### `SSH_DISABLE_PASSWORD_AUTH`=false
318 ##### `SSH_DISABLE_PASSWORD_AUTH`=false
309 Disable password-based SSH authentication. Only public key based SSH (v2) authentication will be supported.
319 Disable password-based SSH authentication. Only public key based SSH (v2) authentication will be supported.
310
320
311 ##### `SSH_LIMIT_USERS`=false
321 ##### `SSH_LIMIT_USERS`=false
312 Limit the users that are allowed to login via SSH. Only allow user `USER_NAME`=pi and root if `SSH_ENABLE_ROOT`=true to login. This parameter will be ignored if `dropbear` SSH is used (`REDUCE_SSHD`=true).
322 Limit the users that are allowed to login via SSH. Only allow user `USER_NAME`=pi and root if `SSH_ENABLE_ROOT`=true to login. This parameter will be ignored if `dropbear` SSH is used (`REDUCE_SSHD`=true).
313
323
314 ##### `SSH_ROOT_PUB_KEY`=""
324 ##### `SSH_ROOT_PUB_KEY`=""
315 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `root`. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported. `ENABLE_ROOT` **and** `SSH_ENABLE_ROOT` must be set to `true`.
325 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `root`. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported. `ENABLE_ROOT` **and** `SSH_ENABLE_ROOT` must be set to `true`.
316
326
317 ##### `SSH_USER_PUB_KEY`=""
327 ##### `SSH_USER_PUB_KEY`=""
318 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `USER_NAME`=pi. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported.
328 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `USER_NAME`=pi. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported.
319
329
320 ---
330 ---
321
331
322 #### Kernel compilation:
332 #### Kernel compilation:
323 ##### `BUILD_KERNEL`=true
333 ##### `BUILD_KERNEL`=true
334 <<<<<<< HEAD
324 Build and install the latest RPi 0/1/2/3 Linux kernel. Currently only the default RPi 0/1/2/3 kernel configuration is used.
335 Build and install the latest RPi 0/1/2/3 Linux kernel. Currently only the default RPi 0/1/2/3 kernel configuration is used.
336 =======
337 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
325 Build and install the latest RPi 0/1/2/3/4 Linux kernel. The default RPi 0/1/2/3/ kernel configuration is used most of the time.
338 Build and install the latest RPi 0/1/2/3/4 Linux kernel. The default RPi 0/1/2/3/ kernel configuration is used most of the time.
326 ENABLE_NEXMON - Changes Kernel Source to [https://github.com/Re4son/](Kali Linux Kernel)
339 ENABLE_NEXMON - Changes Kernel Source to [https://github.com/Re4son/](Kali Linux Kernel)
327 Precompiled 32bit kernel for RPI0/1/2/3 by [https://github.com/hypriot/](hypriot)
340 Precompiled 32bit kernel for RPI0/1/2/3 by [https://github.com/hypriot/](hypriot)
328 Precompiled 64bit kernel for RPI3/4 by [https://github.com/sakaki-/](sakaki)
341 Precompiled 64bit kernel for RPI3/4 by [https://github.com/sakaki-/](sakaki)
329
342
330
343
331 ##### `CROSS_COMPILE`="arm-linux-gnueabihf-"
344 ##### `CROSS_COMPILE`="arm-linux-gnueabihf-"
332 This sets the cross-compile environment for the compiler.
345 This sets the cross-compile environment for the compiler.
333
346
334 ##### `KERNEL_ARCH`="arm"
347 ##### `KERNEL_ARCH`="arm"
335 This sets the kernel architecture for the compiler.
348 This sets the kernel architecture for the compiler.
336
349
337 ##### `KERNEL_IMAGE`="kernel7.img"
350 ##### `KERNEL_IMAGE`="kernel7.img"
338 Name of the image file in the boot partition. If not set, `KERNEL_IMAGE` will be set to "kernel8.img" automatically if building for arm64.
351 Name of the image file in the boot partition. If not set, `KERNEL_IMAGE` will be set to "kernel8.img" automatically if building for arm64.
339
352
340 ##### `KERNEL_BRANCH`=""
353 ##### `KERNEL_BRANCH`=""
341 Name of the requested branch from the GIT location for the RPi Kernel. Default is using the current default branch from the GIT site.
354 Name of the requested branch from the GIT location for the RPi Kernel. Default is using the current default branch from the GIT site.
342
355
343 ##### `QEMU_BINARY`="/usr/bin/qemu-arm-static"
356 ##### `QEMU_BINARY`="/usr/bin/qemu-arm-static"
344 Sets the QEMU enviornment for the Debian archive. If not set, `QEMU_BINARY` will be set to "/usr/bin/qemu-aarch64-static" automatically if building for arm64.
357 Sets the QEMU enviornment for the Debian archive. If not set, `QEMU_BINARY` will be set to "/usr/bin/qemu-aarch64-static" automatically if building for arm64.
345
358
346 ##### `KERNEL_DEFCONFIG`="bcm2709_defconfig"
359 ##### `KERNEL_DEFCONFIG`="bcm2709_defconfig"
347 Sets the default config for kernel compiling. If not set, `KERNEL_DEFCONFIG` will be set to "bcmrpi3\_defconfig" automatically if building for arm64.
360 Sets the default config for kernel compiling. If not set, `KERNEL_DEFCONFIG` will be set to "bcmrpi3\_defconfig" automatically if building for arm64.
348
361
349 ##### `KERNEL_REDUCE`=false
362 ##### `KERNEL_REDUCE`=false
350 Reduce the size of the generated kernel by removing unwanted devices, network and filesystem drivers (experimental).
363 Reduce the size of the generated kernel by removing unwanted devices, network and filesystem drivers (experimental).
351
364
352 ##### `KERNEL_THREADS`=1
365 ##### `KERNEL_THREADS`=1
353 Number of parallel kernel building threads. If the parameter is left untouched the script will automatically determine the number of CPU cores to set the number of parallel threads to speed the kernel compilation.
366 Number of parallel kernel building threads. If the parameter is left untouched the script will automatically determine the number of CPU cores to set the number of parallel threads to speed the kernel compilation.
354
367
355 ##### `KERNEL_HEADERS`=true
368 ##### `KERNEL_HEADERS`=true
356 Install kernel headers with the built kernel.
369 Install kernel headers with the built kernel.
357
370
358 ##### `KERNEL_MENUCONFIG`=false
371 ##### `KERNEL_MENUCONFIG`=false
359 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
372 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
360
373
361 ##### `KERNEL_OLDDEFCONFIG`=false
374 ##### `KERNEL_OLDDEFCONFIG`=false
362 Run `make olddefconfig` to automatically set all new kernel configuration options to their recommended default values.
375 Run `make olddefconfig` to automatically set all new kernel configuration options to their recommended default values.
363
376
364 ##### `KERNEL_CCACHE`=false
377 ##### `KERNEL_CCACHE`=false
365 Compile the kernel using ccache. This speeds up kernel recompilation by caching previous compilations and detecting when the same compilation is being done again.
378 Compile the kernel using ccache. This speeds up kernel recompilation by caching previous compilations and detecting when the same compilation is being done again.
366
379
367 ##### `KERNEL_REMOVESRC`=true
380 ##### `KERNEL_REMOVESRC`=true
368 Remove all kernel sources from the generated OS image after it was built and installed.
381 Remove all kernel sources from the generated OS image after it was built and installed.
369
382
370 ##### `KERNELSRC_DIR`=""
383 ##### `KERNELSRC_DIR`=""
371 Path to a directory (`linux`) of [RaspberryPi Linux kernel sources](https://github.com/raspberrypi/linux) that will be copied, configured, build and installed inside the chroot.
384 Path to a directory (`linux`) of [RaspberryPi Linux kernel sources](https://github.com/raspberrypi/linux) that will be copied, configured, build and installed inside the chroot.
372
385
373 ##### `KERNELSRC_CLEAN`=false
386 ##### `KERNELSRC_CLEAN`=false
374 Clean the existing kernel sources directory `KERNELSRC_DIR` (using `make mrproper`) after it was copied to the chroot and before the compilation of the kernel has started. This parameter will be ignored if no `KERNELSRC_DIR` was specified or if `KERNELSRC_PREBUILT`=true.
387 Clean the existing kernel sources directory `KERNELSRC_DIR` (using `make mrproper`) after it was copied to the chroot and before the compilation of the kernel has started. This parameter will be ignored if no `KERNELSRC_DIR` was specified or if `KERNELSRC_PREBUILT`=true.
375
388
376 ##### `KERNELSRC_CONFIG`=true
389 ##### `KERNELSRC_CONFIG`=true
377 Run `make bcm2709_defconfig` (and optional `make menuconfig`) to configure the kernel sources before building. This parameter is automatically set to `true` if no existing kernel sources directory was specified using `KERNELSRC_DIR`. This parameter is ignored if `KERNELSRC_PREBUILT`=true.
390 Run `make bcm2709_defconfig` (and optional `make menuconfig`) to configure the kernel sources before building. This parameter is automatically set to `true` if no existing kernel sources directory was specified using `KERNELSRC_DIR`. This parameter is ignored if `KERNELSRC_PREBUILT`=true.
378
391
379 ##### `KERNELSRC_USRCONFIG`=""
392 ##### `KERNELSRC_USRCONFIG`=""
380 Copy own config file to kernel `.config`. If `KERNEL_MENUCONFIG`=true then running after copy.
393 Copy own config file to kernel `.config`. If `KERNEL_MENUCONFIG`=true then running after copy.
381
394
382 ##### `KERNELSRC_PREBUILT`=false
395 ##### `KERNELSRC_PREBUILT`=false
383 With this parameter set to true the script expects the existing kernel sources directory to be already successfully cross-compiled. The parameters `KERNELSRC_CLEAN`, `KERNELSRC_CONFIG`, `KERNELSRC_USRCONFIG` and `KERNEL_MENUCONFIG` are ignored and no kernel compilation tasks are performed.
396 With this parameter set to true the script expects the existing kernel sources directory to be already successfully cross-compiled. The parameters `KERNELSRC_CLEAN`, `KERNELSRC_CONFIG`, `KERNELSRC_USRCONFIG` and `KERNEL_MENUCONFIG` are ignored and no kernel compilation tasks are performed.
384
397
385 ##### `RPI_FIRMWARE_DIR`=""
398 ##### `RPI_FIRMWARE_DIR`=""
386 The directory (`firmware`) containing a local copy of the firmware from the [RaspberryPi firmware project](https://github.com/raspberrypi/firmware). Default is to download the latest firmware directly from the project.
399 The directory (`firmware`) containing a local copy of the firmware from the [RaspberryPi firmware project](https://github.com/raspberrypi/firmware). Default is to download the latest firmware directly from the project.
387
400
388 ##### `KERNEL_DEFAULT_GOV`="ONDEMAND"
401 ##### `KERNEL_DEFAULT_GOV`="ONDEMAND"
389 Set the default cpu governor at kernel compilation. Supported values are: PERFORMANCE POWERSAVE USERSPACE ONDEMAND CONSERVATIVE SCHEDUTIL
402 Set the default cpu governor at kernel compilation. Supported values are: PERFORMANCE POWERSAVE USERSPACE ONDEMAND CONSERVATIVE SCHEDUTIL
390
403
391 ##### `KERNEL_NF`=false
404 ##### `KERNEL_NF`=false
392 Enable Netfilter modules as kernel modules
405 Enable Netfilter modules as kernel modules
393
406
394 ##### `KERNEL_VIRT`=false
407 ##### `KERNEL_VIRT`=false
395 Enable Kernel KVM support (/dev/kvm)
408 Enable Kernel KVM support (/dev/kvm)
396
409
397 ##### `KERNEL_ZSWAP`=false
410 ##### `KERNEL_ZSWAP`=false
398 Enable Kernel Zswap support. Best use on high RAM load and mediocre CPU load usecases
411 Enable Kernel Zswap support. Best use on high RAM load and mediocre CPU load usecases
399
412
400 ##### `KERNEL_BPF`=true
413 ##### `KERNEL_BPF`=true
401 Allow attaching eBPF programs to a cgroup using the bpf syscall (CONFIG_BPF_SYSCALL CONFIG_CGROUP_BPF) [systemd compilations about it - File /lib/systemd/system/systemd-journald.server:36 configures an IP firewall (IPAddressDeny=all), but the local system does not support BPF/cgroup based firewalls]
414 Allow attaching eBPF programs to a cgroup using the bpf syscall (CONFIG_BPF_SYSCALL CONFIG_CGROUP_BPF) [systemd compilations about it - File /lib/systemd/system/systemd-journald.server:36 configures an IP firewall (IPAddressDeny=all), but the local system does not support BPF/cgroup based firewalls]
402
415
403 ##### `KERNEL_SECURITY`=false
416 ##### `KERNEL_SECURITY`=false
404 Enables Apparmor, integrity subsystem, auditing.
417 Enables Apparmor, integrity subsystem, auditing.
405
418
406 ##### `KERNEL_BTRFS`="false"
419 ##### `KERNEL_BTRFS`="false"
407 enable btrfs kernel support
420 enable btrfs kernel support
408
421
409 ##### `KERNEL_POEHAT`="false"
422 ##### `KERNEL_POEHAT`="false"
410 enable Enable RPI POE HAT fan kernel support
423 enable Enable RPI POE HAT fan kernel support
411
424
412 ##### `KERNEL_NSPAWN`="false"
425 ##### `KERNEL_NSPAWN`="false"
413 Enable per-interface network priority control - for systemd-nspawn
426 Enable per-interface network priority control - for systemd-nspawn
414
427
415 ##### `KERNEL_DHKEY`="true"
428 ##### `KERNEL_DHKEY`="true"
416 Diffie-Hellman operations on retained keys - required for >keyutils-1.6
429 Diffie-Hellman operations on retained keys - required for >keyutils-1.6
417
430
418 ---
431 ---
419
432
420 #### Reduce disk usage:
433 #### Reduce disk usage:
421 The following list of parameters is ignored if `ENABLE_REDUCE`=false.
434 The following list of parameters is ignored if `ENABLE_REDUCE`=false.
422
435
423 ##### `REDUCE_APT`=true
436 ##### `REDUCE_APT`=true
424 Configure APT to use compressed package repository lists and no package caching files.
437 Configure APT to use compressed package repository lists and no package caching files.
425
438
426 ##### `REDUCE_DOC`=true
439 ##### `REDUCE_DOC`=true
427 Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations.
440 Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations.
428
441
429 ##### `REDUCE_MAN`=true
442 ##### `REDUCE_MAN`=true
430 Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations.
443 Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations.
431
444
432 ##### `REDUCE_VIM`=false
445 ##### `REDUCE_VIM`=false
433 Replace `vim-tiny` package by `levee` a tiny vim clone.
446 Replace `vim-tiny` package by `levee` a tiny vim clone.
434
447
435 ##### `REDUCE_BASH`=false
448 ##### `REDUCE_BASH`=false
436 Remove `bash` package and switch to `dash` shell (experimental).
449 Remove `bash` package and switch to `dash` shell (experimental).
437
450
438 ##### `REDUCE_HWDB`=true
451 ##### `REDUCE_HWDB`=true
439 Remove PCI related hwdb files (experimental).
452 Remove PCI related hwdb files (experimental).
440
453
441 ##### `REDUCE_SSHD`=true
454 ##### `REDUCE_SSHD`=true
442 Replace `openssh-server` with `dropbear`.
455 Replace `openssh-server` with `dropbear`.
443
456
444 ##### `REDUCE_LOCALE`=true
457 ##### `REDUCE_LOCALE`=true
445 Remove all `locale` translation files.
458 Remove all `locale` translation files.
446
459
447 ---
460 ---
448
461
449 #### Encrypted root partition:
462 #### Encrypted root partition:
450 ##### `ENABLE_CRYPTFS`=false
463 ##### `ENABLE_CRYPTFS`=false
451 Enable full system encryption with dm-crypt. Setup a fully LUKS encrypted root partition (aes-xts-plain64:sha512) and generate required initramfs. The /boot directory will not be encrypted. This parameter will be ignored if `BUILD_KERNEL`=false. `ENABLE_CRYPTFS` is experimental. SSH-to-initramfs is currently not supported but will be soon - feel free to help.
464 Enable full system encryption with dm-crypt. Setup a fully LUKS encrypted root partition (aes-xts-plain64:sha512) and generate required initramfs. The /boot directory will not be encrypted. This parameter will be ignored if `BUILD_KERNEL`=false. `ENABLE_CRYPTFS` is experimental. SSH-to-initramfs is currently not supported but will be soon - feel free to help.
452
465
453 ##### `CRYPTFS_PASSWORD`=""
466 ##### `CRYPTFS_PASSWORD`=""
454 Set password of the encrypted root partition. This parameter is mandatory if `ENABLE_CRYPTFS`=true.
467 Set password of the encrypted root partition. This parameter is mandatory if `ENABLE_CRYPTFS`=true.
455
468
456 ##### `CRYPTFS_MAPPING`="secure"
469 ##### `CRYPTFS_MAPPING`="secure"
457 Set name of dm-crypt managed device-mapper mapping.
470 Set name of dm-crypt managed device-mapper mapping.
458
471
472 <<<<<<< HEAD
459 ##### `CRYPTFS_CIPHER`="aes-xts-plain64:sha512"
473 ##### `CRYPTFS_CIPHER`="aes-xts-plain64:sha512"
474 =======
475 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
460 ##### `CRYPTFS_CIPHER`="aes-xts-plain64"
476 ##### `CRYPTFS_CIPHER`="aes-xts-plain64"
461 Set cipher specification string. `aes-xts*` ciphers are strongly recommended.
477 Set cipher specification string. `aes-xts*` ciphers are strongly recommended.
462
478
463 ##### `CRYPTFS_HASH`=sha512
479 ##### `CRYPTFS_HASH`=sha512
464 Hash function and size to be used
480 Hash function and size to be used
465
481
466 ##### `CRYPTFS_XTSKEYSIZE`=512
482 ##### `CRYPTFS_XTSKEYSIZE`=512
467 Sets key size in bits. The argument has to be a multiple of 8.
483 Sets key size in bits. The argument has to be a multiple of 8.
468
484
469 ##### `CRYPTFS_DROPBEAR`=false
485 ##### `CRYPTFS_DROPBEAR`=false
470 Enable Dropbear Initramfs support
486 Enable Dropbear Initramfs support
471
487
472 ##### `CRYPTFS_DROPBEAR_PUBKEY`=""
488 ##### `CRYPTFS_DROPBEAR_PUBKEY`=""
473 Provide path to dropbear Public RSA-OpenSSH Key
489 Provide path to dropbear Public RSA-OpenSSH Key
474
490
475 ---
491 ---
476
492
477 #### Build settings:
493 #### Build settings:
478 ##### `BASEDIR`=$(pwd)/images/${RELEASE}
494 ##### `BASEDIR`=$(pwd)/images/${RELEASE}
479 Set a path to a working directory used by the script to generate an image.
495 Set a path to a working directory used by the script to generate an image.
480
496
481 ##### `IMAGE_NAME`=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}
497 ##### `IMAGE_NAME`=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}
482 Set a filename for the output file(s). Note: the script will create $IMAGE_NAME.img if `ENABLE_SPLITFS`=false or $IMAGE_NAME-frmw.img and $IMAGE_NAME-root.img if `ENABLE_SPLITFS`=true. Note 2: If the KERNEL_BRANCH is not set, the word "CURRENT" is used.
498 Set a filename for the output file(s). Note: the script will create $IMAGE_NAME.img if `ENABLE_SPLITFS`=false or $IMAGE_NAME-frmw.img and $IMAGE_NAME-root.img if `ENABLE_SPLITFS`=true. Note 2: If the KERNEL_BRANCH is not set, the word "CURRENT" is used.
483
499
484 ## Understanding the script
500 ## Understanding the script
485 The functions of this script that are required for the different stages of the bootstrapping are split up into single files located inside the `bootstrap.d` directory. During the bootstrapping every script in this directory gets executed in lexicographical order:
501 The functions of this script that are required for the different stages of the bootstrapping are split up into single files located inside the `bootstrap.d` directory. During the bootstrapping every script in this directory gets executed in lexicographical order:
486
502
487 | Script | Description |
503 | Script | Description |
488 | --- | --- |
504 | --- | --- |
489 | `10-bootstrap.sh` | Debootstrap basic system |
505 | `10-bootstrap.sh` | Debootstrap basic system |
490 | `11-apt.sh` | Setup APT repositories |
506 | `11-apt.sh` | Setup APT repositories |
491 | `12-locale.sh` | Setup Locales and keyboard settings |
507 | `12-locale.sh` | Setup Locales and keyboard settings |
492 | `13-kernel.sh` | Build and install RPi 0/1/2/3 Kernel |
508 | `13-kernel.sh` | Build and install RPi 0/1/2/3 Kernel |
493 | `14-fstab.sh` | Setup fstab and initramfs |
509 | `14-fstab.sh` | Setup fstab and initramfs |
494 | `15-rpi-config.sh` | Setup RPi 0/1/2/3 config and cmdline |
510 | `15-rpi-config.sh` | Setup RPi 0/1/2/3 config and cmdline |
495 | `20-networking.sh` | Setup Networking |
511 | `20-networking.sh` | Setup Networking |
496 | `21-firewall.sh` | Setup Firewall |
512 | `21-firewall.sh` | Setup Firewall |
497 | `30-security.sh` | Setup Users and Security settings |
513 | `30-security.sh` | Setup Users and Security settings |
498 | `31-logging.sh` | Setup Logging |
514 | `31-logging.sh` | Setup Logging |
499 | `32-sshd.sh` | Setup SSH and public keys |
515 | `32-sshd.sh` | Setup SSH and public keys |
500 | `41-uboot.sh` | Build and Setup U-Boot |
516 | `41-uboot.sh` | Build and Setup U-Boot |
501 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
517 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
502 | `43-videocore.sh` | Build and Setup videocore libraries |
518 | `43-videocore.sh` | Build and Setup videocore libraries |
503 | `50-firstboot.sh` | First boot actions |
519 | `50-firstboot.sh` | First boot actions |
504 | `99-reduce.sh` | Reduce the disk space usage |
520 | `99-reduce.sh` | Reduce the disk space usage |
505
521
506 All the required configuration files that will be copied to the generated OS image are located inside the `files` directory. It is not recommended to modify these configuration files manually.
522 All the required configuration files that will be copied to the generated OS image are located inside the `files` directory. It is not recommended to modify these configuration files manually.
507
523
508 | Directory | Description |
524 | Directory | Description |
509 | --- | --- |
525 | --- | --- |
510 | `apt` | APT management configuration files |
526 | `apt` | APT management configuration files |
511 | `boot` | Boot and RPi 0/1/2/3 configuration files |
527 | `boot` | Boot and RPi 0/1/2/3 configuration files |
512 | `dpkg` | Package Manager configuration |
528 | `dpkg` | Package Manager configuration |
513 | `etc` | Configuration files and rc scripts |
529 | `etc` | Configuration files and rc scripts |
514 | `firstboot` | Scripts that get executed on first boot |
530 | `firstboot` | Scripts that get executed on first boot |
515 | `initramfs` | Initramfs scripts |
531 | `initramfs` | Initramfs scripts |
516 | `iptables` | Firewall configuration files |
532 | `iptables` | Firewall configuration files |
517 | `locales` | Locales configuration |
533 | `locales` | Locales configuration |
518 | `modules` | Kernel Modules configuration |
534 | `modules` | Kernel Modules configuration |
519 | `mount` | Fstab configuration |
535 | `mount` | Fstab configuration |
520 | `network` | Networking configuration files |
536 | `network` | Networking configuration files |
521 | `sysctl.d` | Swapping and Network Hardening configuration |
537 | `sysctl.d` | Swapping and Network Hardening configuration |
522 | `xorg` | fbturbo Xorg driver configuration |
538 | `xorg` | fbturbo Xorg driver configuration |
523
539
524 ## Custom packages and scripts
540 ## Custom packages and scripts
525 Debian custom packages, i.e. those not in the debian repositories, can be installed by placing them in the `packages` directory. They are installed immediately after packages from the repositories are installed. Any dependencies listed in the custom packages will be downloaded automatically from the repositories. Do not list these custom packages in `APT_INCLUDES`.
541 Debian custom packages, i.e. those not in the debian repositories, can be installed by placing them in the `packages` directory. They are installed immediately after packages from the repositories are installed. Any dependencies listed in the custom packages will be downloaded automatically from the repositories. Do not list these custom packages in `APT_INCLUDES`.
526
542
527 Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created.
543 Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created.
528
544
529 ## Logging of the bootstrapping process
545 ## Logging of the bootstrapping process
530 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:
546 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:
531
547
532 ```shell
548 ```shell
533 script -c 'APT_SERVER=ftp.de.debian.org ./rpi23-gen-image.sh' ./build.log
549 script -c 'APT_SERVER=ftp.de.debian.org ./rpi23-gen-image.sh' ./build.log
534 ```
550 ```
535
551
536 ## Flashing the image file
552 ## Flashing the image file
537 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 RPi 0/1/2/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`.
553 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 RPi 0/1/2/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`.
538
554
539 ##### Flashing examples:
555 ##### Flashing examples:
540 ```shell
556 ```shell
541 bmaptool copy ./images/buster/2017-01-23-rpi3-buster.img /dev/mmcblk0
557 bmaptool copy ./images/buster/2017-01-23-rpi3-buster.img /dev/mmcblk0
542 dd bs=4M if=./images/buster/2017-01-23-rpi3-buster.img of=/dev/mmcblk0
558 dd bs=4M if=./images/buster/2017-01-23-rpi3-buster.img of=/dev/mmcblk0
543 ```
559 ```
544 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
560 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
545 ```shell
561 ```shell
546 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-frmw.img /dev/mmcblk0
562 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-frmw.img /dev/mmcblk0
547 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-root.img /dev/sdc
563 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-root.img /dev/sdc
548 ```
564 ```
549
565
550 ## QEMU emulation
566 ## QEMU emulation
551 Start QEMU full system emulation:
567 Start QEMU full system emulation:
552 ```shell
568 ```shell
553 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"
569 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"
554 ```
570 ```
555
571
556 Start QEMU full system emulation and output to console:
572 Start QEMU full system emulation and output to console:
557 ```shell
573 ```shell
558 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
574 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
559 ```
575 ```
560
576
561 Start QEMU full system emulation with SMP and output to console:
577 Start QEMU full system emulation with SMP and output to console:
562 ```shell
578 ```shell
563 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
579 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
564 ```
580 ```
565
581
566 Start QEMU full system emulation with cryptfs, initramfs and output to console:
582 Start QEMU full system emulation with cryptfs, initramfs and output to console:
567 ```shell
583 ```shell
568 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
584 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
569 ```
585 ```
570
586
571 ## External links and references
587 ## External links and references
572 * [Debian worldwide mirror sites](https://www.debian.org/mirror/list)
588 * [Debian worldwide mirror sites](https://www.debian.org/mirror/list)
573 * [Debian Raspberry Pi 2 Wiki](https://wiki.debian.org/RaspberryPi2)
589 * [Debian Raspberry Pi 2 Wiki](https://wiki.debian.org/RaspberryPi2)
574 * [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains)
590 * [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains)
575 * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware)
591 * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware)
576 * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux)
592 * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux)
577 * [U-BOOT git repository](https://git.denx.de/?p=u-boot.git;a=summary)
593 * [U-BOOT git repository](https://git.denx.de/?p=u-boot.git;a=summary)
578 * [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo)
594 * [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo)
579 * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm)
595 * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm)
580 * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/)
596 * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/)
@@ -1,615 +1,889
1 #
1 #
2 # Build and Setup RPi2/3 Kernel
2 # Build and Setup RPi2/3 Kernel
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Need to use kali kernel src if nexmon is enabled
8 # Need to use kali kernel src if nexmon is enabled
9 if [ "$ENABLE_NEXMON" = true ] ; then
9 if [ "$ENABLE_NEXMON" = true ] ; then
10 KERNEL_URL="${KALI_KERNEL_URL}"
10 KERNEL_URL="${KALI_KERNEL_URL}"
11 # Clear Branch and KernelSRC_DIR if using nexmon. Everyone will forget to clone kali kernel instead of nomrla kernel
11 # Clear Branch and KernelSRC_DIR if using nexmon. Everyone will forget to clone kali kernel instead of nomrla kernel
12 KERNEL_BRANCH=""
12 KERNEL_BRANCH=""
13 KERNELSRC_DIR=""
13 KERNELSRC_DIR=""
14 fi
14 fi
15
15
16 # Fetch and build latest raspberry kernel
16 # Fetch and build latest raspberry kernel
17 if [ "$BUILD_KERNEL" = true ] ; then
17 if [ "$BUILD_KERNEL" = true ] ; then
18 # Setup source directory
18 # Setup source directory
19 mkdir -p "${KERNEL_DIR}"
19 mkdir -p "${KERNEL_DIR}"
20
20
21 # Copy existing kernel sources into chroot directory
21 # Copy existing kernel sources into chroot directory
22 if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then
22 if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then
23 # Copy kernel sources and include hidden files
23 # Copy kernel sources and include hidden files
24 cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}"
24 cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}"
25
25
26 # Clean the kernel sources
26 # Clean the kernel sources
27 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
27 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
28 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
28 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
29 fi
29 fi
30 else # KERNELSRC_DIR=""
30 else # KERNELSRC_DIR=""
31 # Create temporary directory for kernel sources
31 # Create temporary directory for kernel sources
32 temp_dir=$(as_nobody mktemp -d)
32 temp_dir=$(as_nobody mktemp -d)
33
33
34 # Fetch current RPi2/3 kernel sources
34 # Fetch current RPi2/3 kernel sources
35 if [ -z "${KERNEL_BRANCH}" ] ; then
35 if [ -z "${KERNEL_BRANCH}" ] ; then
36 as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux
36 as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux
37 else
37 else
38 as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux
38 as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux
39 fi
39 fi
40
40
41 # Copy downloaded kernel sources
41 # Copy downloaded kernel sources
42 cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}"
42 cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}"
43
43
44 # Remove temporary directory for kernel sources
44 # Remove temporary directory for kernel sources
45 rm -fr "${temp_dir}"
45 rm -fr "${temp_dir}"
46
46
47 # Set permissions of the kernel sources
47 # Set permissions of the kernel sources
48 chown -R root:root "${R}/usr/src"
48 chown -R root:root "${R}/usr/src"
49 fi
49 fi
50
50
51 # Calculate optimal number of kernel building threads
51 # Calculate optimal number of kernel building threads
52 if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then
52 if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then
53 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
53 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
54 fi
54 fi
55
56 #Copy 32bit config to 64bit
57 if [ "$ENABLE_QEMU" = true ] && [ "$KERNEL_ARCH" = arm64 ]; then
58 cp "${KERNEL_DIR}"/arch/arm/configs/vexpress_defconfig "${KERNEL_DIR}"/arch/arm64/configs/
59 fi
55
60
56 # Configure and build kernel
61 # Configure and build kernel
57 if [ "$KERNELSRC_PREBUILT" = false ] ; then
62 if [ "$KERNELSRC_PREBUILT" = false ] ; then
58 # Remove device, network and filesystem drivers from kernel configuration
63 # Remove device, network and filesystem drivers from kernel configuration
59 if [ "$KERNEL_REDUCE" = true ] ; then
64 if [ "$KERNEL_REDUCE" = true ] ; then
60 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
65 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
61 sed -i\
66 sed -i\
62 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
67 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
63 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
68 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
64 -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
69 -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
65 -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
70 -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
66 -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
71 -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
67 -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
72 -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
68 -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
73 -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
69 -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
74 -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
70 -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
75 -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
71 -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
76 -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
72 -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
77 -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
73 -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
78 -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
74 -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
79 -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
75 -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
80 -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
76 -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
81 -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
77 -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
82 -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
78 -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
83 -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
79 -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
84 -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
80 -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
85 -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
81 -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
86 -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
82 -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
87 -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
83 -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
88 -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
84 -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
89 -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
85 -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
90 -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
86 -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
91 -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
87 -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
92 -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
88 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
93 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
89 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
94 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
90 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
95 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
91 "${KERNEL_DIR}/.config"
96 "${KERNEL_DIR}/.config"
92 fi
97 fi
93
98
94 if [ "$KERNELSRC_CONFIG" = true ] ; then
99 if [ "$KERNELSRC_CONFIG" = true ] ; then
95 # Load default raspberry kernel configuration
100 # Load default raspberry kernel configuration
96 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
101 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
97
102
98 #Switch to KERNELSRC_DIR so we can use set_kernel_config
103 #Switch to KERNELSRC_DIR so we can use set_kernel_config
99 cd "${KERNEL_DIR}" || exit
104 cd "${KERNEL_DIR}" || exit
100
105
101 if [ "$KERNEL_ARCH" = arm64 ] ; then
106 # Enable RPI POE HAT fan
107 if [ "$KERNEL_POEHAT" = true ]; then
108 set_kernel_config CONFIG_SENSORS_RPI_POE_FAN m
109 fi
110
111 # Enable per-interface network priority control
112 # (for systemd-nspawn)
113 if [ "$KERNEL_NSPAN" = true ]; then
114 set_kernel_config CONFIG_CGROUP_NET_PRIO y
115 fi
116
117 # Compile in BTRFS
118 if [ "$KERNEL_BTRFS" = true ]; then
119 set_kernel_config CONFIG_BTRFS_FS y
120 set_kernel_config CONFIG_BTRFS_FS_POSIX_ACL y
121 set_kernel_config CONFIG_BTRFS_FS_REF_VERIFY y
122 fi
123
124 # Diffie-Hellman operations on retained keys
125 # (required for >keyutils-1.6)
126 if [ "$KERNEL_DHKEY" = true ]; then
127 set_kernel_config CONFIG_KEY_DH_OPERATIONS y
128 fi
129
130 if [ "$KERNEL_ARCH" = arm64 ] && [ "$ENABLE_QEMU" = false ]; then
131 # Mask this temporarily during switch to rpi-4.19.y
102 #Fix SD_DRIVER upstream and downstream mess in 64bit RPIdeb_config
132 #Fix SD_DRIVER upstream and downstream mess in 64bit RPIdeb_config
103 # use correct driver MMC_BCM2835_MMC instead of MMC_BCM2835_SDHOST - see https://www.raspberrypi.org/forums/viewtopic.php?t=210225
133 # use correct driver MMC_BCM2835_MMC instead of MMC_BCM2835_SDHOST - see https://www.raspberrypi.org/forums/viewtopic.php?t=210225
104 set_kernel_config CONFIG_MMC_BCM2835 n
134 #set_kernel_config CONFIG_MMC_BCM2835 n
105 set_kernel_config CONFIG_MMC_SDHCI_IPROC n
135 #set_kernel_config CONFIG_MMC_SDHCI_IPROC n
106 set_kernel_config CONFIG_USB_DWC2 n
136 #set_kernel_config CONFIG_USB_DWC2 n
107 sed -i "s|depends on MMC_BCM2835_MMC && MMC_BCM2835_DMA|depends on MMC_BCM2835_MMC|" "${KERNEL_DIR}"/drivers/mmc/host/Kconfig
137 #sed -i "s|depends on MMC_BCM2835_MMC && MMC_BCM2835_DMA|depends on MMC_BCM2835_MMC|" "${KERNEL_DIR}"/drivers/mmc/host/Kconfig
108
138
109 #VLAN got disabled without reason in arm64bit
139 #VLAN got disabled without reason in arm64bit
110 set_kernel_config CONFIG_IPVLAN m
140 set_kernel_config CONFIG_IPVLAN m
111 fi
141 fi
112
142
113 # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap
143 # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap
114 if [ "$KERNEL_ZSWAP" = true ] ; then
144 if [ "$KERNEL_ZSWAP" = true ] ; then
115 set_kernel_config CONFIG_ZPOOL y
145 set_kernel_config CONFIG_ZPOOL y
116 set_kernel_config CONFIG_ZSWAP y
146 set_kernel_config CONFIG_ZSWAP y
117 set_kernel_config CONFIG_ZBUD y
147 set_kernel_config CONFIG_ZBUD y
118 set_kernel_config CONFIG_Z3FOLD y
148 set_kernel_config CONFIG_Z3FOLD y
119 set_kernel_config CONFIG_ZSMALLOC y
149 set_kernel_config CONFIG_ZSMALLOC y
120 set_kernel_config CONFIG_PGTABLE_MAPPING y
150 set_kernel_config CONFIG_PGTABLE_MAPPING y
121 set_kernel_config CONFIG_LZO_COMPRESS y
151 set_kernel_config CONFIG_LZO_COMPRESS y
122
152 fi
153
154 if [ "$RPI_MODEL" = 4 ] ; then
155 # Following are set in current 32-bit LPAE kernel
156 set_kernel_config CONFIG_CGROUP_PIDS y
157 set_kernel_config CONFIG_NET_IPVTI m
158 set_kernel_config CONFIG_NF_TABLES_SET m
159 set_kernel_config CONFIG_NF_TABLES_INET y
160 set_kernel_config CONFIG_NF_TABLES_NETDEV y
161 set_kernel_config CONFIG_NF_FLOW_TABLE m
162 set_kernel_config CONFIG_NFT_FLOW_OFFLOAD m
163 set_kernel_config CONFIG_NFT_CONNLIMIT m
164 set_kernel_config CONFIG_NFT_TUNNEL m
165 set_kernel_config CONFIG_NFT_OBJREF m
166 set_kernel_config CONFIG_NFT_FIB_IPV4 m
167 set_kernel_config CONFIG_NFT_FIB_IPV6 m
168 set_kernel_config CONFIG_NFT_FIB_INET m
169 set_kernel_config CONFIG_NFT_SOCKET m
170 set_kernel_config CONFIG_NFT_OSF m
171 set_kernel_config CONFIG_NFT_TPROXY m
172 set_kernel_config CONFIG_NF_DUP_NETDEV m
173 set_kernel_config CONFIG_NFT_DUP_NETDEV m
174 set_kernel_config CONFIG_NFT_FWD_NETDEV m
175 set_kernel_config CONFIG_NFT_FIB_NETDEV m
176 set_kernel_config CONFIG_NF_FLOW_TABLE_INET m
177 set_kernel_config CONFIG_NF_FLOW_TABLE m
178 set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m
179 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m
180 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m
181 set_kernel_config CONFIG_NFT_MASQ_IPV6 m
182 set_kernel_config CONFIG_NFT_REDIR_IPV6 m
183 set_kernel_config CONFIG_NFT_REJECT_IPV6 m
184 set_kernel_config CONFIG_NFT_DUP_IPV6 m
185 set_kernel_config CONFIG_NFT_FIB_IPV6 m
186 set_kernel_config CONFIG_NF_FLOW_TABLE_IPV6 m
187 set_kernel_config CONFIG_NF_TABLES_BRIDGE m
188 set_kernel_config CONFIG_NFT_BRIDGE_REJECT m
189 set_kernel_config CONFIG_NF_LOG_BRIDGE m
190 set_kernel_config CONFIG_MT76_CORE m
191 set_kernel_config CONFIG_MT76_LEDS m
192 set_kernel_config CONFIG_MT76_USB m
193 set_kernel_config CONFIG_MT76x2_COMMON m
194 set_kernel_config CONFIG_MT76x0U m
195 set_kernel_config CONFIG_MT76x2U m
196 set_kernel_config CONFIG_TOUCHSCREEN_ILI210X m
197 set_kernel_config CONFIG_BCM_VC_SM m
198 set_kernel_config CONFIG_BCM2835_SMI_DEV m
199 set_kernel_config CONFIG_RPIVID_MEM m
200 set_kernel_config CONFIG_HW_RANDOM_BCM2835 y
201 set_kernel_config CONFIG_TCG_TPM m
202 set_kernel_config CONFIG_HW_RANDOM_TPM y
203 set_kernel_config CONFIG_TCG_TIS m
204 set_kernel_config CONFIG_TCG_TIS_SPI m
205 set_kernel_config CONFIG_I2C_MUX m
206 set_kernel_config CONFIG_I2C_MUX_GPMUX m
207 set_kernel_config CONFIG_I2C_MUX_PCA954x m
208 set_kernel_config CONFIG_SPI_GPIO m
209 set_kernel_config CONFIG_BATTERY_MAX17040 m
210 set_kernel_config CONFIG_SENSORS_GPIO_FAN m
211 set_kernel_config CONFIG_SENSORS_RASPBERRYPI_HWMON m
212 set_kernel_config CONFIG_BCM2835_THERMAL y
213 set_kernel_config CONFIG_RC_CORE y
214 set_kernel_config CONFIG_RC_MAP y
215 set_kernel_config CONFIG_LIRC y
216 set_kernel_config CONFIG_RC_DECODERS y
217 set_kernel_config CONFIG_IR_NEC_DECODER m
218 set_kernel_config CONFIG_IR_RC5_DECODER m
219 set_kernel_config CONFIG_IR_RC6_DECODER m
220 set_kernel_config CONFIG_IR_JVC_DECODER m
221 set_kernel_config CONFIG_IR_SONY_DECODER m
222 set_kernel_config CONFIG_IR_SANYO_DECODER m
223 set_kernel_config CONFIG_IR_SHARP_DECODER m
224 set_kernel_config CONFIG_IR_MCE_KBD_DECODER m
225 set_kernel_config CONFIG_IR_XMP_DECODER m
226 set_kernel_config CONFIG_IR_IMON_DECODER m
227 set_kernel_config CONFIG_RC_DEVICES y
228 set_kernel_config CONFIG_RC_ATI_REMOTE m
229 set_kernel_config CONFIG_IR_IMON m
230 set_kernel_config CONFIG_IR_MCEUSB m
231 set_kernel_config CONFIG_IR_REDRAT3 m
232 set_kernel_config CONFIG_IR_STREAMZAP m
233 set_kernel_config CONFIG_IR_IGUANA m
234 set_kernel_config CONFIG_IR_TTUSBIR m
235 set_kernel_config CONFIG_RC_LOOPBACK m
236 set_kernel_config CONFIG_IR_GPIO_CIR m
237 set_kernel_config CONFIG_IR_GPIO_TX m
238 set_kernel_config CONFIG_IR_PWM_TX m
239 set_kernel_config CONFIG_VIDEO_V4L2_SUBDEV_API y
240 set_kernel_config CONFIG_VIDEO_AU0828_RC y
241 set_kernel_config CONFIG_VIDEO_CX231XX m
242 set_kernel_config CONFIG_VIDEO_CX231XX_RC y
243 set_kernel_config CONFIG_VIDEO_CX231XX_ALSA m
244 set_kernel_config CONFIG_VIDEO_CX231XX_DVB m
245 set_kernel_config CONFIG_VIDEO_TM6000 m
246 set_kernel_config CONFIG_VIDEO_TM6000_ALSA m
247 set_kernel_config CONFIG_VIDEO_TM6000_DVB m
248 set_kernel_config CONFIG_DVB_USB m
249 set_kernel_config CONFIG_DVB_USB_DIB3000MC m
250 set_kernel_config CONFIG_DVB_USB_A800 m
251 set_kernel_config CONFIG_DVB_USB_DIBUSB_MB m
252 set_kernel_config CONFIG_DVB_USB_DIBUSB_MB_FAULTY y
253 set_kernel_config CONFIG_DVB_USB_DIBUSB_MC m
254 set_kernel_config CONFIG_DVB_USB_DIB0700 m
255 set_kernel_config CONFIG_DVB_USB_UMT_010 m
256 set_kernel_config CONFIG_DVB_USB_CXUSB m
257 set_kernel_config CONFIG_DVB_USB_M920X m
258 set_kernel_config CONFIG_DVB_USB_DIGITV m
259 set_kernel_config CONFIG_DVB_USB_VP7045 m
260 set_kernel_config CONFIG_DVB_USB_VP702X m
261 set_kernel_config CONFIG_DVB_USB_GP8PSK m
262 set_kernel_config CONFIG_DVB_USB_NOVA_T_USB2 m
263 set_kernel_config CONFIG_DVB_USB_TTUSB2 m
264 set_kernel_config CONFIG_DVB_USB_DTT200U m
265 set_kernel_config CONFIG_DVB_USB_OPERA1 m
266 set_kernel_config CONFIG_DVB_USB_AF9005 m
267 set_kernel_config CONFIG_DVB_USB_AF9005_REMOTE m
268 set_kernel_config CONFIG_DVB_USB_PCTV452E m
269 set_kernel_config CONFIG_DVB_USB_DW2102 m
270 set_kernel_config CONFIG_DVB_USB_CINERGY_T2 m
271 set_kernel_config CONFIG_DVB_USB_DTV5100 m
272 set_kernel_config CONFIG_DVB_USB_AZ6027 m
273 set_kernel_config CONFIG_DVB_USB_TECHNISAT_USB2 m
274 set_kernel_config CONFIG_DVB_USB_AF9015 m
275 set_kernel_config CONFIG_DVB_USB_LME2510 m
276 set_kernel_config CONFIG_DVB_USB_RTL28XXU m
277 set_kernel_config CONFIG_VIDEO_EM28XX_RC m
278 set_kernel_config CONFIG_SMS_SIANO_RC m
279 set_kernel_config CONFIG_VIDEO_IR_I2C m
280 set_kernel_config CONFIG_VIDEO_ADV7180 m
281 set_kernel_config CONFIG_VIDEO_TC358743 m
282 set_kernel_config CONFIG_VIDEO_OV5647 m
283 set_kernel_config CONFIG_DVB_M88DS3103 m
284 set_kernel_config CONFIG_DVB_AF9013 m
285 set_kernel_config CONFIG_DVB_RTL2830 m
286 set_kernel_config CONFIG_DVB_RTL2832 m
287 set_kernel_config CONFIG_DVB_SI2168 m
288 set_kernel_config CONFIG_DVB_GP8PSK_FE m
289 set_kernel_config CONFIG_DVB_USB m
290 set_kernel_config CONFIG_DVB_LGDT3306A m
291 set_kernel_config CONFIG_FB_SIMPLE y
292 set_kernel_config CONFIG_SND_BCM2708_SOC_IQAUDIO_CODEC m
293 set_kernel_config CONFIG_SND_BCM2708_SOC_I_SABRE_Q2M m
294 set_kernel_config CONFIG_SND_AUDIOSENSE_PI m
295 set_kernel_config CONFIG_SND_SOC_AD193X m
296 set_kernel_config CONFIG_SND_SOC_AD193X_SPI m
297 set_kernel_config CONFIG_SND_SOC_AD193X_I2C m
298 set_kernel_config CONFIG_SND_SOC_CS4265 m
299 set_kernel_config CONFIG_SND_SOC_DA7213 m
300 set_kernel_config CONFIG_SND_SOC_ICS43432 m
301 set_kernel_config CONFIG_SND_SOC_TLV320AIC32X4 m
302 set_kernel_config CONFIG_SND_SOC_TLV320AIC32X4_I2C m
303 set_kernel_config CONFIG_SND_SOC_I_SABRE_CODEC m
304 set_kernel_config CONFIG_HID_BIGBEN_FF m
305 #set_kernel_config CONFIG_USB_XHCI_PLATFORM y
306 set_kernel_config CONFIG_USB_TMC m
307 set_kernel_config CONFIG_USB_UAS y
308 set_kernel_config CONFIG_USBIP_VUDC m
309 set_kernel_config CONFIG_USB_CONFIGFS m
310 set_kernel_config CONFIG_USB_CONFIGFS_SERIAL y
311 set_kernel_config CONFIG_USB_CONFIGFS_ACM y
312 set_kernel_config CONFIG_USB_CONFIGFS_OBEX y
313 set_kernel_config CONFIG_USB_CONFIGFS_NCM y
314 set_kernel_config CONFIG_USB_CONFIGFS_ECM y
315 set_kernel_config CONFIG_USB_CONFIGFS_ECM_SUBSET y
316 set_kernel_config CONFIG_USB_CONFIGFS_RNDIS y
317 set_kernel_config CONFIG_USB_CONFIGFS_EEM y
318 set_kernel_config CONFIG_USB_CONFIGFS_MASS_STORAGE y
319 set_kernel_config CONFIG_USB_CONFIGFS_F_LB_SS y
320 set_kernel_config CONFIG_USB_CONFIGFS_F_FS y
321 set_kernel_config CONFIG_USB_CONFIGFS_F_UAC1 y
322 set_kernel_config CONFIG_USB_CONFIGFS_F_UAC2 y
323 set_kernel_config CONFIG_USB_CONFIGFS_F_MIDI y
324 set_kernel_config CONFIG_USB_CONFIGFS_F_HID y
325 set_kernel_config CONFIG_USB_CONFIGFS_F_UVC y
326 set_kernel_config CONFIG_USB_CONFIGFS_F_PRINTER y
327 set_kernel_config CONFIG_LEDS_PCA963X m
328 set_kernel_config CONFIG_LEDS_IS31FL32XX m
329 set_kernel_config CONFIG_LEDS_TRIGGER_NETDEV m
330 set_kernel_config CONFIG_RTC_DRV_RV3028 m
331 set_kernel_config CONFIG_AUXDISPLAY y
332 set_kernel_config CONFIG_HD44780 m
333 set_kernel_config CONFIG_FB_TFT_SH1106 m
334 set_kernel_config CONFIG_VIDEO_CODEC_BCM2835 m
335 set_kernel_config CONFIG_BCM2835_POWER y
336 set_kernel_config CONFIG_INV_MPU6050_IIO m
337 set_kernel_config CONFIG_INV_MPU6050_I2C m
338 set_kernel_config CONFIG_SECURITYFS y
339
340 # Safer to build this in
341 set_kernel_config CONFIG_BINFMT_MISC y
342
343 # pulseaudio wants a buffer of at least this size
344 set_kernel_config CONFIG_SND_HDA_PREALLOC_SIZE 2048
345
346 # PR#3063: enable 3D acceleration with 64-bit kernel on RPi4
347 # set the appropriate kernel configs unlocked by this PR
348 set_kernel_config CONFIG_ARCH_BCM y
349 set_kernel_config CONFIG_ARCH_BCM2835 y
350 set_kernel_config CONFIG_DRM_V3D m
351 set_kernel_config CONFIG_DRM_VC4 m
352 set_kernel_config CONFIG_DRM_VC4_HDMI_CEC y
353
354 # PR#3144: add arm64 pcie bounce buffers; enables 4GiB on RPi4
355 # required by PR#3144; should already be applied, but just to be safe
356 set_kernel_config CONFIG_PCIE_BRCMSTB y
357 set_kernel_config CONFIG_BCM2835_MMC y
358
359 # Snap needs squashfs. The ubuntu eoan-preinstalled-server image at
360 # http://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/ uses snap
361 # during cloud-init setup at first boot. Without this the login accounts are not
362 # created and the user can not login.
363 set_kernel_config CONFIG_SQUASHFS y
364
365 # Ceph support for Block Device (RBD) and Filesystem (FS)
366 # https://docs.ceph.com/docs/master/
367 set_kernel_config CONFIG_CEPH_LIB m
368 set_kernel_config CONFIG_CEPH_LIB_USE_DNS_RESOLVER y
369 set_kernel_config CONFIG_CEPH_FS m
370 set_kernel_config CONFIG_CEPH_FSCACHE y
371 set_kernel_config CONFIG_CEPH_FS_POSIX_ACL y
372 set_kernel_config CONFIG_BLK_DEV_RBD m
123 fi
373 fi
124
374
125 # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453
375 # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453
126 if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
376 if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; } ; then
377 set_kernel_config CONFIG_HAVE_KVM y
378 set_kernel_config CONFIG_HIGH_RES_TIMERS y
127 set_kernel_config CONFIG_HAVE_KVM_IRQCHIP y
379 set_kernel_config CONFIG_HAVE_KVM_IRQCHIP y
128 set_kernel_config CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL y
380 set_kernel_config CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL y
129 set_kernel_config CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT y
381 set_kernel_config CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT y
130 set_kernel_config CONFIG_HAVE_KVM_EVENTFD y
382 set_kernel_config CONFIG_HAVE_KVM_EVENTFD y
131 set_kernel_config CONFIG_HAVE_KVM_IRQFD y
383 set_kernel_config CONFIG_HAVE_KVM_IRQFD y
132 set_kernel_config CONFIG_HAVE_KVM_IRQ_ROUTING y
384 set_kernel_config CONFIG_HAVE_KVM_IRQ_ROUTING y
133 set_kernel_config CONFIG_HAVE_KVM_MSI y
385 set_kernel_config CONFIG_HAVE_KVM_MSI y
134 set_kernel_config CONFIG_KVM y
386 set_kernel_config CONFIG_KVM y
135 set_kernel_config CONFIG_KVM_ARM_HOST y
387 set_kernel_config CONFIG_KVM_ARM_HOST y
136 set_kernel_config CONFIG_KVM_ARM_PMU y
388 set_kernel_config CONFIG_KVM_ARM_PMU y
137 set_kernel_config CONFIG_KVM_COMPAT y
389 set_kernel_config CONFIG_KVM_COMPAT y
138 set_kernel_config CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT y
390 set_kernel_config CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT y
139 set_kernel_config CONFIG_KVM_MMIO y
391 set_kernel_config CONFIG_KVM_MMIO y
140 set_kernel_config CONFIG_KVM_VFIO y
392 set_kernel_config CONFIG_KVM_VFIO y
393 set_kernel_config CONFIG_KVM_MMU_AUDIT y
141 set_kernel_config CONFIG_VHOST m
394 set_kernel_config CONFIG_VHOST m
142 set_kernel_config CONFIG_VHOST_CROSS_ENDIAN_LEGACY y
395 set_kernel_config CONFIG_VHOST_CROSS_ENDIAN_LEGACY y
143 set_kernel_config CONFIG_VHOST_NET m
396 set_kernel_config CONFIG_VHOST_NET m
144 set_kernel_config CONFIG_VIRTUALIZATION y
397 set_kernel_config CONFIG_VIRTUALIZATION y
145
398 set_kernel_config CONFIG_SLAB_FREELIST_RANDOM=y
399 set_kernel_config CONFIG_SLAB_FREELIST_HARDENED=y
146 set_kernel_config CONFIG_MMU_NOTIFIER y
400 set_kernel_config CONFIG_MMU_NOTIFIER y
147
401
148 # erratum
402 # erratum
149 set_kernel_config ARM64_ERRATUM_834220 y
403 set_kernel_config ARM64_ERRATUM_834220 y
150
404
151 # https://sourceforge.net/p/kvm/mailman/message/18440797/
405 # https://sourceforge.net/p/kvm/mailman/message/18440797/
152 set_kernel_config CONFIG_PREEMPT_NOTIFIERS y
406 set_kernel_config CONFIG_PREEMPT_NOTIFIERS y
153 fi
407 fi
154
408
155 # enable apparmor,integrity audit,
409 # enable apparmor,integrity audit,
156 if [ "$KERNEL_SECURITY" = true ] ; then
410 if [ "$KERNEL_SECURITY" = true ] ; then
157
411
158 # security filesystem, security models and audit
412 # security filesystem, security models and audit
159 set_kernel_config CONFIG_SECURITYFS y
413 set_kernel_config CONFIG_SECURITYFS y
160 set_kernel_config CONFIG_SECURITY y
414 set_kernel_config CONFIG_SECURITY y
161 set_kernel_config CONFIG_AUDIT y
415 set_kernel_config CONFIG_AUDIT y
162
416
163 # harden strcpy and memcpy
417 # harden strcpy and memcpy
164 set_kernel_config CONFIG_HARDENED_USERCOPY y
418 set_kernel_config CONFIG_HARDENED_USERCOPY y
165 set_kernel_config CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR y
419 set_kernel_config CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR y
166 set_kernel_config CONFIG_FORTIFY_SOURCE y
420 set_kernel_config CONFIG_FORTIFY_SOURCE y
167
421
168 # integrity sub-system
422 # integrity sub-system
169 set_kernel_config CONFIG_INTEGRITY y
423 set_kernel_config CONFIG_INTEGRITY y
170 set_kernel_config CONFIG_INTEGRITY_ASYMMETRIC_KEYS y
424 set_kernel_config CONFIG_INTEGRITY_ASYMMETRIC_KEYS y
171 set_kernel_config CONFIG_INTEGRITY_AUDIT y
425 set_kernel_config CONFIG_INTEGRITY_AUDIT y
172 set_kernel_config CONFIG_INTEGRITY_SIGNATURE y
426 set_kernel_config CONFIG_INTEGRITY_SIGNATURE y
173 set_kernel_config CONFIG_INTEGRITY_TRUSTED_KEYRING y
427 set_kernel_config CONFIG_INTEGRITY_TRUSTED_KEYRING y
174
428
175 # This option provides support for retaining authentication tokens and access keys in the kernel.
429 # This option provides support for retaining authentication tokens and access keys in the kernel.
176 set_kernel_config CONFIG_KEYS y
430 set_kernel_config CONFIG_KEYS y
177 set_kernel_config CONFIG_KEYS_COMPAT y
431 set_kernel_config CONFIG_KEYS_COMPAT y
178
432
179 # Apparmor
433 # Apparmor
180 set_kernel_config CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE 0
434 set_kernel_config CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE 0
181 set_kernel_config CONFIG_SECURITY_APPARMOR_HASH_DEFAULT y
435 set_kernel_config CONFIG_SECURITY_APPARMOR_HASH_DEFAULT y
182 set_kernel_config CONFIG_DEFAULT_SECURITY_APPARMOR y
436 set_kernel_config CONFIG_DEFAULT_SECURITY_APPARMOR y
183 set_kernel_config CONFIG_SECURITY_APPARMOR y
437 set_kernel_config CONFIG_SECURITY_APPARMOR y
184 set_kernel_config CONFIG_SECURITY_APPARMOR_HASH y
438 set_kernel_config CONFIG_SECURITY_APPARMOR_HASH y
185 set_kernel_config CONFIG_DEFAULT_SECURITY "apparmor"
439 set_kernel_config CONFIG_DEFAULT_SECURITY "apparmor"
186
440
187 # restrictions on unprivileged users reading the kernel
441 # restrictions on unprivileged users reading the kernel
188 set_kernel_config CONFIG_SECURITY_DMESG_RESTRICT y
442 set_kernel_config CONFIG_SECURITY_DMESG_RESTRICT y
189
443
190 # network security hooks
444 # network security hooks
191 set_kernel_config CONFIG_SECURITY_NETWORK y
445 set_kernel_config CONFIG_SECURITY_NETWORK y
192 set_kernel_config CONFIG_SECURITY_NETWORK_XFRM y
446 set_kernel_config CONFIG_SECURITY_NETWORK_XFRM y
193 set_kernel_config CONFIG_SECURITY_PATH y
447 set_kernel_config CONFIG_SECURITY_PATH y
194 set_kernel_config CONFIG_SECURITY_YAMA n
448 set_kernel_config CONFIG_SECURITY_YAMA n
195
449
196 # New Options
197 if [ "$KERNEL_NF" = true ] ; then
198 set_kernel_config CONFIG_IP_NF_SECURITY m
199 set_kernel_config CONFIG_NETLABEL y
200 set_kernel_config CONFIG_IP6_NF_SECURITY m
201 fi
202 set_kernel_config CONFIG_SECURITY_SELINUX n
450 set_kernel_config CONFIG_SECURITY_SELINUX n
203 set_kernel_config CONFIG_SECURITY_SMACK n
451 set_kernel_config CONFIG_SECURITY_SMACK n
204 set_kernel_config CONFIG_SECURITY_TOMOYO n
452 set_kernel_config CONFIG_SECURITY_TOMOYO n
205 set_kernel_config CONFIG_SECURITY_APPARMOR_DEBUG n
453 set_kernel_config CONFIG_SECURITY_APPARMOR_DEBUG n
206 set_kernel_config CONFIG_SECURITY_LOADPIN n
454 set_kernel_config CONFIG_SECURITY_LOADPIN n
207 set_kernel_config CONFIG_HARDENED_USERCOPY_PAGESPAN n
455 set_kernel_config CONFIG_HARDENED_USERCOPY_PAGESPAN n
208 set_kernel_config CONFIG_IMA n
456 set_kernel_config CONFIG_IMA n
209 set_kernel_config CONFIG_EVM n
457 set_kernel_config CONFIG_EVM n
210 set_kernel_config CONFIG_FANOTIFY_ACCESS_PERMISSIONS y
458 set_kernel_config CONFIG_FANOTIFY_ACCESS_PERMISSIONS y
211 set_kernel_config CONFIG_NFSD_V4_SECURITY_LABEL y
459 set_kernel_config CONFIG_NFSD_V4_SECURITY_LABEL y
212 set_kernel_config CONFIG_PKCS7_MESSAGE_PARSER y
460 set_kernel_config CONFIG_PKCS7_MESSAGE_PARSER y
213 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYRING y
461 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYRING y
214 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS y
215 set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE y
462 set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE y
216 set_kernel_config CONFIG_SECONDARY_TRUSTED_KEYRING y
463 set_kernel_config CONFIG_SECONDARY_TRUSTED_KEYRING y
217 set_kernel_config CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY n
464 set_kernel_config CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY n
218 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS m
465 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS m
219 set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE 4096
466 set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE 4096
220
467
221 set_kernel_config CONFIG_ARM64_CRYPTO y
468 set_kernel_config CONFIG_ARM64_CRYPTO y
222 set_kernel_config CONFIG_CRYPTO_SHA256_ARM64 m
469 set_kernel_config CONFIG_CRYPTO_SHA256_ARM64 m
223 set_kernel_config CONFIG_CRYPTO_SHA512_ARM64 m
470 set_kernel_config CONFIG_CRYPTO_SHA512_ARM64 m
224 set_kernel_config CONFIG_CRYPTO_SHA1_ARM64_CE m
471 set_kernel_config CONFIG_CRYPTO_SHA1_ARM64_CE m
225 set_kernel_config CRYPTO_GHASH_ARM64_CE m
472 set_kernel_config CRYPTO_GHASH_ARM64_CE m
226 set_kernel_config CRYPTO_SHA2_ARM64_CE m
473 set_kernel_config CRYPTO_SHA2_ARM64_CE m
227 set_kernel_config CONFIG_CRYPTO_CRCT10DIF_ARM64_CE m
474 set_kernel_config CONFIG_CRYPTO_CRCT10DIF_ARM64_CE m
228 set_kernel_config CONFIG_CRYPTO_CRC32_ARM64_CE m
475 set_kernel_config CONFIG_CRYPTO_CRC32_ARM64_CE m
229 set_kernel_config CONFIG_CRYPTO_AES_ARM64 m
476 set_kernel_config CONFIG_CRYPTO_AES_ARM64 m
230 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE m
477 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE m
231 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_CCM y
478 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_CCM y
232 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_BLK y
479 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_BLK y
233 set_kernel_config CONFIG_CRYPTO_AES_ARM64_NEON_BLK m
480 set_kernel_config CONFIG_CRYPTO_AES_ARM64_NEON_BLK m
234 set_kernel_config CONFIG_CRYPTO_CHACHA20_NEON m
481 set_kernel_config CONFIG_CRYPTO_CHACHA20_NEON m
235 set_kernel_config CONFIG_CRYPTO_AES_ARM64_BS m
482 set_kernel_config CONFIG_CRYPTO_AES_ARM64_BS m
236 set_kernel_config SYSTEM_TRUSTED_KEYS
237 fi
483 fi
238
484
239 # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406
485 # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406
240 if [ "$KERNEL_NF" = true ] ; then
486 if [ "$KERNEL_NF" = true ] ; then
487 set_kernel_config CONFIG_IP_NF_SECURITY m
488 set_kernel_config CONFIG_NETLABEL y
489 set_kernel_config CONFIG_IP6_NF_SECURITY m
241 set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m
490 set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m
242 set_kernel_config CONFIG_NETFILTER_XT_TARGET_AUDIT m
491 set_kernel_config CONFIG_NETFILTER_XT_TARGET_AUDIT m
243 set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m
492 set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m
244 set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m
493 set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m
245 set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m
494 set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m
246 set_kernel_config CONFIG_NFT_FIB_INET m
495 set_kernel_config CONFIG_NFT_FIB_INET m
247 set_kernel_config CONFIG_NFT_FIB_IPV4 m
496 set_kernel_config CONFIG_NFT_FIB_IPV4 m
248 set_kernel_config CONFIG_NFT_FIB_IPV6 m
497 set_kernel_config CONFIG_NFT_FIB_IPV6 m
249 set_kernel_config CONFIG_NFT_FIB_NETDEV m
498 set_kernel_config CONFIG_NFT_FIB_NETDEV m
250 set_kernel_config CONFIG_NFT_OBJREF m
499 set_kernel_config CONFIG_NFT_OBJREF m
251 set_kernel_config CONFIG_NFT_RT m
500 set_kernel_config CONFIG_NFT_RT m
252 set_kernel_config CONFIG_NFT_SET_BITMAP m
501 set_kernel_config CONFIG_NFT_SET_BITMAP m
253 set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y
502 set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y
254 set_kernel_config CONFIG_NF_LOG_ARP m
503 set_kernel_config CONFIG_NF_LOG_ARP m
255 set_kernel_config CONFIG_NF_SOCKET_IPV4 m
504 set_kernel_config CONFIG_NF_SOCKET_IPV4 m
256 set_kernel_config CONFIG_NF_SOCKET_IPV6 m
505 set_kernel_config CONFIG_NF_SOCKET_IPV6 m
257 set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m
506 set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m
258 set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m
507 set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m
259 set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m
508 set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m
260 set_kernel_config CONFIG_IP6_NF_IPTABLES m
509 set_kernel_config CONFIG_IP6_NF_IPTABLES m
261 set_kernel_config CONFIG_IP6_NF_MATCH_AH m
510 set_kernel_config CONFIG_IP6_NF_MATCH_AH m
262 set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m
511 set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m
263 set_kernel_config CONFIG_IP6_NF_NAT m
512 set_kernel_config CONFIG_IP6_NF_NAT m
264 set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m
513 set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m
265 set_kernel_config CONFIG_IP6_NF_TARGET_NPT m
514 set_kernel_config CONFIG_IP6_NF_TARGET_NPT m
266 set_kernel_config CONFIG_IP_NF_SECURITY m
267 set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m
515 set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m
268 set_kernel_config CONFIG_IP_SET_BITMAP_PORT m
516 set_kernel_config CONFIG_IP_SET_BITMAP_PORT m
269 set_kernel_config CONFIG_IP_SET_HASH_IP m
517 set_kernel_config CONFIG_IP_SET_HASH_IP m
270 set_kernel_config CONFIG_IP_SET_HASH_IPMARK m
518 set_kernel_config CONFIG_IP_SET_HASH_IPMARK m
271 set_kernel_config CONFIG_IP_SET_HASH_IPPORT m
519 set_kernel_config CONFIG_IP_SET_HASH_IPPORT m
272 set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m
520 set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m
273 set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m
521 set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m
274 set_kernel_config CONFIG_IP_SET_HASH_MAC m
522 set_kernel_config CONFIG_IP_SET_HASH_MAC m
275 set_kernel_config CONFIG_IP_SET_HASH_NET m
523 set_kernel_config CONFIG_IP_SET_HASH_NET m
276 set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m
524 set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m
277 set_kernel_config CONFIG_IP_SET_HASH_NETNET m
525 set_kernel_config CONFIG_IP_SET_HASH_NETNET m
278 set_kernel_config CONFIG_IP_SET_HASH_NETPORT m
526 set_kernel_config CONFIG_IP_SET_HASH_NETPORT m
279 set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m
527 set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m
280 set_kernel_config CONFIG_IP_SET_LIST_SET m
528 set_kernel_config CONFIG_IP_SET_LIST_SET m
281 set_kernel_config CONFIG_NETFILTER_XTABLES m
529 set_kernel_config CONFIG_NETFILTER_XTABLES m
282 set_kernel_config CONFIG_NETFILTER_XTABLES m
530 set_kernel_config CONFIG_NETFILTER_XTABLES m
283 set_kernel_config CONFIG_NFT_BRIDGE_META m
531 set_kernel_config CONFIG_NFT_BRIDGE_META m
284 set_kernel_config CONFIG_NFT_BRIDGE_REJECT m
532 set_kernel_config CONFIG_NFT_BRIDGE_REJECT m
285 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m
533 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m
286 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m
534 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m
287 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m
535 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m
288 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m
536 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m
289 set_kernel_config CONFIG_NFT_COMPAT m
537 set_kernel_config CONFIG_NFT_COMPAT m
290 set_kernel_config CONFIG_NFT_COUNTER m
538 set_kernel_config CONFIG_NFT_COUNTER m
291 set_kernel_config CONFIG_NFT_CT m
539 set_kernel_config CONFIG_NFT_CT m
292 set_kernel_config CONFIG_NFT_DUP_IPV4 m
540 set_kernel_config CONFIG_NFT_DUP_IPV4 m
293 set_kernel_config CONFIG_NFT_DUP_IPV6 m
541 set_kernel_config CONFIG_NFT_DUP_IPV6 m
294 set_kernel_config CONFIG_NFT_DUP_NETDEV m
542 set_kernel_config CONFIG_NFT_DUP_NETDEV m
295 set_kernel_config CONFIG_NFT_EXTHDR m
543 set_kernel_config CONFIG_NFT_EXTHDR m
296 set_kernel_config CONFIG_NFT_FWD_NETDEV m
544 set_kernel_config CONFIG_NFT_FWD_NETDEV m
297 set_kernel_config CONFIG_NFT_HASH m
545 set_kernel_config CONFIG_NFT_HASH m
298 set_kernel_config CONFIG_NFT_LIMIT m
546 set_kernel_config CONFIG_NFT_LIMIT m
299 set_kernel_config CONFIG_NFT_LOG m
547 set_kernel_config CONFIG_NFT_LOG m
300 set_kernel_config CONFIG_NFT_MASQ m
548 set_kernel_config CONFIG_NFT_MASQ m
301 set_kernel_config CONFIG_NFT_MASQ_IPV4 m
549 set_kernel_config CONFIG_NFT_MASQ_IPV4 m
302 set_kernel_config CONFIG_NFT_MASQ_IPV6 m
550 set_kernel_config CONFIG_NFT_MASQ_IPV6 m
303 set_kernel_config CONFIG_NFT_META m
551 set_kernel_config CONFIG_NFT_META m
304 set_kernel_config CONFIG_NFT_NAT m
552 set_kernel_config CONFIG_NFT_NAT m
305 set_kernel_config CONFIG_NFT_NUMGEN m
553 set_kernel_config CONFIG_NFT_NUMGEN m
306 set_kernel_config CONFIG_NFT_QUEUE m
554 set_kernel_config CONFIG_NFT_QUEUE m
307 set_kernel_config CONFIG_NFT_QUOTA m
555 set_kernel_config CONFIG_NFT_QUOTA m
308 set_kernel_config CONFIG_NFT_REDIR m
556 set_kernel_config CONFIG_NFT_REDIR m
309 set_kernel_config CONFIG_NFT_REDIR_IPV4 m
557 set_kernel_config CONFIG_NFT_REDIR_IPV4 m
310 set_kernel_config CONFIG_NFT_REDIR_IPV6 m
558 set_kernel_config CONFIG_NFT_REDIR_IPV6 m
311 set_kernel_config CONFIG_NFT_REJECT m
559 set_kernel_config CONFIG_NFT_REJECT m
312 set_kernel_config CONFIG_NFT_REJECT_INET m
560 set_kernel_config CONFIG_NFT_REJECT_INET m
313 set_kernel_config CONFIG_NFT_REJECT_IPV4 m
561 set_kernel_config CONFIG_NFT_REJECT_IPV4 m
314 set_kernel_config CONFIG_NFT_REJECT_IPV6 m
562 set_kernel_config CONFIG_NFT_REJECT_IPV6 m
315 set_kernel_config CONFIG_NFT_SET_HASH m
563 set_kernel_config CONFIG_NFT_SET_HASH m
316 set_kernel_config CONFIG_NFT_SET_RBTREE m
564 set_kernel_config CONFIG_NFT_SET_RBTREE m
317 set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m
565 set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m
318 set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m
566 set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m
319 set_kernel_config CONFIG_NF_DEFRAG_IPV4 m
567 set_kernel_config CONFIG_NF_DEFRAG_IPV4 m
320 set_kernel_config CONFIG_NF_DEFRAG_IPV6 m
568 set_kernel_config CONFIG_NF_DEFRAG_IPV6 m
321 set_kernel_config CONFIG_NF_DUP_IPV4 m
569 set_kernel_config CONFIG_NF_DUP_IPV4 m
322 set_kernel_config CONFIG_NF_DUP_IPV6 m
570 set_kernel_config CONFIG_NF_DUP_IPV6 m
323 set_kernel_config CONFIG_NF_DUP_NETDEV m
571 set_kernel_config CONFIG_NF_DUP_NETDEV m
324 set_kernel_config CONFIG_NF_LOG_BRIDGE m
572 set_kernel_config CONFIG_NF_LOG_BRIDGE m
325 set_kernel_config CONFIG_NF_LOG_IPV4 m
573 set_kernel_config CONFIG_NF_LOG_IPV4 m
326 set_kernel_config CONFIG_NF_LOG_IPV6 m
574 set_kernel_config CONFIG_NF_LOG_IPV6 m
327 set_kernel_config CONFIG_NF_NAT_IPV4 m
575 set_kernel_config CONFIG_NF_NAT_IPV4 m
328 set_kernel_config CONFIG_NF_NAT_IPV6 m
576 set_kernel_config CONFIG_NF_NAT_IPV6 m
329 set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 m
577 set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 y
330 set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 m
578 set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 y
331 set_kernel_config CONFIG_NF_NAT_PPTP m
579 set_kernel_config CONFIG_NF_NAT_PPTP m
332 set_kernel_config CONFIG_NF_NAT_PROTO_GRE m
580 set_kernel_config CONFIG_NF_NAT_PROTO_GRE m
333 set_kernel_config CONFIG_NF_NAT_REDIRECT m
581 set_kernel_config CONFIG_NF_NAT_REDIRECT y
334 set_kernel_config CONFIG_NF_NAT_SIP m
582 set_kernel_config CONFIG_NF_NAT_SIP m
335 set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m
583 set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m
336 set_kernel_config CONFIG_NF_NAT_TFTP m
584 set_kernel_config CONFIG_NF_NAT_TFTP m
337 set_kernel_config CONFIG_NF_REJECT_IPV4 m
585 set_kernel_config CONFIG_NF_REJECT_IPV4 m
338 set_kernel_config CONFIG_NF_REJECT_IPV6 m
586 set_kernel_config CONFIG_NF_REJECT_IPV6 m
339 set_kernel_config CONFIG_NF_TABLES m
587 set_kernel_config CONFIG_NF_TABLES m
340 set_kernel_config CONFIG_NF_TABLES_ARP m
588 set_kernel_config CONFIG_NF_TABLES_ARP m
341 set_kernel_config CONFIG_NF_TABLES_BRIDGE m
589 set_kernel_config CONFIG_NF_TABLES_BRIDGE m
342 set_kernel_config CONFIG_NF_TABLES_INET m
590 set_kernel_config CONFIG_NF_TABLES_INET m
343 set_kernel_config CONFIG_NF_TABLES_IPV4 m
591 set_kernel_config CONFIG_NF_TABLES_IPV4 y
344 set_kernel_config CONFIG_NF_TABLES_IPV6 m
592 set_kernel_config CONFIG_NF_TABLES_IPV6 y
345 set_kernel_config CONFIG_NF_TABLES_NETDEV m
593 set_kernel_config CONFIG_NF_TABLES_NETDEV m
594 set_kernel_config CONFIG_NF_TABLES_SET m
595 set_kernel_config CONFIG_NF_TABLES_INET y
596 set_kernel_config CONFIG_NF_TABLES_NETDEV y
597 set_kernel_config CONFIG_NFT_CONNLIMIT m
598 set_kernel_config CONFIG_NFT_TUNNEL m
599 set_kernel_config CONFIG_NFT_SOCKET m
600 set_kernel_config CONFIG_NFT_TPROXY m
601 set_kernel_config CONFIG_NF_FLOW_TABLE m
602 set_kernel_config CONFIG_NFT_FLOW_OFFLOAD m
603 set_kernel_config CONFIG_NF_FLOW_TABLE_INET m
604 set_kernel_config CONFIG_NF_TABLES_ARP y
605 set_kernel_config CONFIG_NF_FLOW_TABLE_IPV4 y
606 set_kernel_config CONFIG_NF_FLOW_TABLE_IPV6 y
607 set_kernel_config CONFIG_NF_TABLES_BRIDGE y
608 set_kernel_config CONFIG_NF_CT_NETLINK_TIMEOUT m
609 set_kernel_config CONFIG_NFT_OSF m
610
346 fi
611 fi
347
612
348 # Enables BPF syscall for systemd-journald see https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 or https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA
613 # Enables BPF syscall for systemd-journald see https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 or https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA
349 if [ "$KERNEL_BPF" = true ] ; then
614 if [ "$KERNEL_BPF" = true ] ; then
350 set_kernel_config CONFIG_BPF_SYSCALL y
615 set_kernel_config CONFIG_BPF_SYSCALL y
351 set_kernel_config CONFIG_BPF_EVENTS y
616 set_kernel_config CONFIG_BPF_EVENTS y
352 set_kernel_config CONFIG_BPF_STREAM_PARSER y
617 set_kernel_config CONFIG_BPF_STREAM_PARSER y
353 set_kernel_config CONFIG_CGROUP_BPF y
618 set_kernel_config CONFIG_CGROUP_BPF y
619 set_kernel_config CONFIG_XDP_SOCKETS y
354 fi
620 fi
355
621
356 # KERNEL_DEFAULT_GOV was set by user
622 # KERNEL_DEFAULT_GOV was set by user
357 if [ "$KERNEL_DEFAULT_GOV" != powersave ] && [ -n "$KERNEL_DEFAULT_GOV" ] ; then
623 if [ "$KERNEL_DEFAULT_GOV" != powersave ] && [ -n "$KERNEL_DEFAULT_GOV" ] ; then
358
624
359 case "$KERNEL_DEFAULT_GOV" in
625 case "$KERNEL_DEFAULT_GOV" in
360 performance)
626 performance)
361 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y
627 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y
362 ;;
628 ;;
363 userspace)
629 userspace)
364 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE y
630 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE y
365 ;;
631 ;;
366 ondemand)
632 ondemand)
367 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND y
633 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND y
368 ;;
634 ;;
369 conservative)
635 conservative)
370 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE y
636 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE y
371 ;;
637 ;;
372 shedutil)
638 shedutil)
373 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL y
639 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL y
374 ;;
640 ;;
375 *)
641 *)
376 echo "error: unsupported default cpu governor"
642 echo "error: unsupported default cpu governor"
377 exit 1
643 exit 1
378 ;;
644 ;;
379 esac
645 esac
380
646
381 # unset previous default governor
647 # unset previous default governor
382 unset_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE
648 unset_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE
383 fi
649 fi
384
650
385 #Revert to previous directory
651 #Revert to previous directory
386 cd "${WORKDIR}" || exit
652 cd "${WORKDIR}" || exit
387
653
388 # Set kernel configuration parameters to enable qemu emulation
654 # Set kernel configuration parameters to enable qemu emulation
389 if [ "$ENABLE_QEMU" = true ] ; then
655 if [ "$ENABLE_QEMU" = true ] ; then
390 echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config
656 echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config
391 echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config
657 echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config
392
658
393 if [ "$ENABLE_CRYPTFS" = true ] ; then
659 if [ "$ENABLE_CRYPTFS" = true ] ; then
394 {
660 {
395 echo "CONFIG_EMBEDDED=y"
661 echo "CONFIG_EMBEDDED=y"
396 echo "CONFIG_EXPERT=y"
662 echo "CONFIG_EXPERT=y"
397 echo "CONFIG_DAX=y"
663 echo "CONFIG_DAX=y"
398 echo "CONFIG_MD=y"
664 echo "CONFIG_MD=y"
399 echo "CONFIG_BLK_DEV_MD=y"
665 echo "CONFIG_BLK_DEV_MD=y"
400 echo "CONFIG_MD_AUTODETECT=y"
666 echo "CONFIG_MD_AUTODETECT=y"
401 echo "CONFIG_BLK_DEV_DM=y"
667 echo "CONFIG_BLK_DEV_DM=y"
402 echo "CONFIG_BLK_DEV_DM_BUILTIN=y"
668 echo "CONFIG_BLK_DEV_DM_BUILTIN=y"
403 echo "CONFIG_DM_CRYPT=y"
669 echo "CONFIG_DM_CRYPT=y"
404 echo "CONFIG_CRYPTO_BLKCIPHER=y"
670 echo "CONFIG_CRYPTO_BLKCIPHER=y"
405 echo "CONFIG_CRYPTO_CBC=y"
671 echo "CONFIG_CRYPTO_CBC=y"
406 echo "CONFIG_CRYPTO_XTS=y"
672 echo "CONFIG_CRYPTO_XTS=y"
407 echo "CONFIG_CRYPTO_SHA512=y"
673 echo "CONFIG_CRYPTO_SHA512=y"
408 echo "CONFIG_CRYPTO_MANAGER=y"
674 echo "CONFIG_CRYPTO_MANAGER=y"
409 } >> "${KERNEL_DIR}"/.config
675 } >> "${KERNEL_DIR}"/.config
410 fi
676 fi
411 fi
677 fi
412
678
413 # Copy custom kernel configuration file
679 # Copy custom kernel configuration file
414 if [ -n "$KERNELSRC_USRCONFIG" ] ; then
680 if [ -n "$KERNELSRC_USRCONFIG" ] ; then
415 cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config
681 cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config
416 fi
682 fi
417
683
418 # Set kernel configuration parameters to their default values
684 # Set kernel configuration parameters to their default values
419 if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then
685 if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then
420 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig
686 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig
421 fi
687 fi
422
688
423 # Start menu-driven kernel configuration (interactive)
689 # Start menu-driven kernel configuration (interactive)
424 if [ "$KERNEL_MENUCONFIG" = true ] ; then
690 if [ "$KERNEL_MENUCONFIG" = true ] ; then
425 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
691 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
426 fi
692 fi
427 # end if "$KERNELSRC_CONFIG" = true
693 # end if "$KERNELSRC_CONFIG" = true
428 fi
694 fi
429
695
430 # Use ccache to cross compile the kernel
696 # Use ccache to cross compile the kernel
431 if [ "$KERNEL_CCACHE" = true ] ; then
697 if [ "$KERNEL_CCACHE" = true ] ; then
432 cc="ccache ${CROSS_COMPILE}gcc"
698 cc="ccache ${CROSS_COMPILE}gcc"
433 else
699 else
434 cc="${CROSS_COMPILE}gcc"
700 cc="${CROSS_COMPILE}gcc"
435 fi
701 fi
436
702
437 # Cross compile kernel and dtbs
703 # Cross compile kernel and dtbs
438 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
704 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
439
705
440 # Cross compile kernel modules
706 # Cross compile kernel modules
441 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
707 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
442 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
708 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
443 fi
709 fi
444 # end if "$KERNELSRC_PREBUILT" = false
710 # end if "$KERNELSRC_PREBUILT" = false
445 fi
711 fi
446
712
447 # Check if kernel compilation was successful
713 # Check if kernel compilation was successful
448 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then
714 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then
449 echo "error: kernel compilation failed! (kernel image not found)"
715 echo "error: kernel compilation failed! (kernel image not found)"
450 cleanup
716 cleanup
451 exit 1
717 exit 1
452 fi
718 fi
453
719
454 # Install kernel modules
720 # Install kernel modules
455 if [ "$ENABLE_REDUCE" = true ] ; then
721 if [ "$ENABLE_REDUCE" = true ] ; then
456 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
722 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
457 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
723 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
458 fi
724 fi
459 else
725 else
460 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
726 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
461 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
727 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
462 fi
728 fi
463
729
464 # Install kernel firmware
730 # Install kernel firmware
465 if grep -q "^firmware_install:" "${KERNEL_DIR}/Makefile" ; then
731 if grep -q "^firmware_install:" "${KERNEL_DIR}/Makefile" ; then
466 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
732 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
467 fi
733 fi
468 fi
734 fi
469
735
470 # Install kernel headers
736 # Install kernel headers
471 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
737 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
472 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
738 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
473 fi
739 fi
474
740
475 # Prepare boot (firmware) directory
741 # Prepare boot (firmware) directory
476 mkdir "${BOOT_DIR}"
742 mkdir "${BOOT_DIR}"
477
743
478 # Get kernel release version
744 # Get kernel release version
479 KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release")
745 KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release")
480
746
481 # Copy kernel configuration file to the boot directory
747 # Copy kernel configuration file to the boot directory
482 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
748 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
483
749
484 # Prepare device tree directory
750 # Prepare device tree directory
485 mkdir "${BOOT_DIR}/overlays"
751 mkdir "${BOOT_DIR}/overlays"
486
752
487 # Ensure the proper .dtb is located
753 # Ensure the proper .dtb is located
488 if [ "$KERNEL_ARCH" = "arm" ] ; then
754 if [ "$KERNEL_ARCH" = "arm" ] ; then
489 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do
755 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do
490 if [ -f "${dtb}" ] ; then
756 if [ -f "${dtb}" ] ; then
491 install_readonly "${dtb}" "${BOOT_DIR}/"
757 install_readonly "${dtb}" "${BOOT_DIR}/"
492 fi
758 fi
493 done
759 done
494 else
760 else
495 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do
761 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do
496 if [ -f "${dtb}" ] ; then
762 if [ -f "${dtb}" ] ; then
497 install_readonly "${dtb}" "${BOOT_DIR}/"
763 install_readonly "${dtb}" "${BOOT_DIR}/"
498 fi
764 fi
499 done
765 done
500 fi
766 fi
501
767
502 # Copy compiled dtb device tree files
768 # Copy compiled dtb device tree files
503 if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then
769 if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then
504 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtbo ; do
770 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtbo ; do
505 if [ -f "${dtb}" ] ; then
771 if [ -f "${dtb}" ] ; then
506 install_readonly "${dtb}" "${BOOT_DIR}/overlays/"
772 install_readonly "${dtb}" "${BOOT_DIR}/overlays/"
507 fi
773 fi
508 done
774 done
509
775
510 if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then
776 if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then
511 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
777 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
512 fi
778 fi
513 fi
779 fi
514
780
515 if [ "$ENABLE_UBOOT" = false ] ; then
781 if [ "$ENABLE_UBOOT" = false ] ; then
516 # Convert and copy kernel image to the boot directory
782 # Convert and copy kernel image to the boot directory
517 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
783 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
518 else
784 else
519 # Copy kernel image to the boot directory
785 # Copy kernel image to the boot directory
520 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
786 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
521 fi
787 fi
522
788
523 # Remove kernel sources
789 # Remove kernel sources
524 if [ "$KERNEL_REMOVESRC" = true ] ; then
790 if [ "$KERNEL_REMOVESRC" = true ] ; then
525 rm -fr "${KERNEL_DIR}"
791 rm -fr "${KERNEL_DIR}"
526 else
792 else
527 # Prepare compiled kernel modules
793 # Prepare compiled kernel modules
528 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
794 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
529 if grep -q "^modules_prepare:" "${KERNEL_DIR}/Makefile" ; then
795 if grep -q "^modules_prepare:" "${KERNEL_DIR}/Makefile" ; then
530 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
796 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
531 fi
797 fi
532
798
533 # Create symlinks for kernel modules
799 # Create symlinks for kernel modules
534 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
800 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
535 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
801 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
536 fi
802 fi
537 fi
803 fi
538
804
539 else # BUILD_KERNEL=false
805 else # BUILD_KERNEL=false
540 if [ "$SET_ARCH" = 64 ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
806 if [ "$SET_ARCH" = 64 ] ; then
541
807 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
542 # Use Sakakis modified kernel if ZSWAP is active
808 # Use Sakakis modified kernel if ZSWAP is active
543 if [ "$KERNEL_ZSWAP" = true ] || [ "$KERNEL_VIRT" = true ] || [ "$KERNEL_NF" = true ] || [ "$KERNEL_BPF" = true ] ; then
809 if [ "$KERNEL_ZSWAP" = true ] || [ "$KERNEL_VIRT" = true ] || [ "$KERNEL_NF" = true ] || [ "$KERNEL_BPF" = true ] ; then
544 RPI3_64_KERNEL_URL="${RPI3_64_BIS_KERNEL_URL}"
810 RPI3_64_KERNEL_URL="${RPI3_64_BIS_KERNEL_URL}"
545 fi
811 fi
546
812
547 # Create temporary directory for dl
813 # Create temporary directory for dl
548 temp_dir=$(as_nobody mktemp -d)
814 temp_dir=$(as_nobody mktemp -d)
549
815
550 # Fetch kernel dl
816 # Fetch kernel dl
551 as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL"
817 as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL"
818 fi
819 if [ "$SET_ARCH" = 64 ] && [ "$RPI_MODEL" = 4 ] ; then
820 # Create temporary directory for dl
821 temp_dir=$(as_nobody mktemp -d)
552
822
553 #extract download
823 # Fetch kernel dl
824 as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI4_64_KERNEL_URL"
825 fi
826
827 #extract download
554 tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}"
828 tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}"
555
829
556 #move extracted kernel to /boot/firmware
830 #move extracted kernel to /boot/firmware
557 mkdir "${R}/boot/firmware"
831 mkdir "${R}/boot/firmware"
558 cp "${temp_dir}"/boot/* "${R}"/boot/firmware/
832 cp "${temp_dir}"/boot/* "${R}"/boot/firmware/
559 cp -r "${temp_dir}"/lib/* "${R}"/lib/
833 cp -r "${temp_dir}"/lib/* "${R}"/lib/
560
834
561 # Remove temporary directory for kernel sources
835 # Remove temporary directory for kernel sources
562 rm -fr "${temp_dir}"
836 rm -fr "${temp_dir}"
563
837
564 # Set permissions of the kernel sources
838 # Set permissions of the kernel sources
565 chown -R root:root "${R}/boot/firmware"
839 chown -R root:root "${R}/boot/firmware"
566 chown -R root:root "${R}/lib/modules"
840 chown -R root:root "${R}/lib/modules"
567 fi
841 fi
568
842
569 # Install Kernel from hypriot comptabile with all Raspberry PI
843 # Install Kernel from hypriot comptabile with all Raspberry PI (dunno if its compatible with RPI4 - better compile your own kernel)
570 if [ "$SET_ARCH" = 32 ] ; then
844 if [ "$SET_ARCH" = 32 ] && [ "$RPI_MODEL" != 4 ] ; then
571 # Create temporary directory for dl
845 # Create temporary directory for dl
572 temp_dir=$(as_nobody mktemp -d)
846 temp_dir=$(as_nobody mktemp -d)
573
847
574 # Fetch kernel
848 # Fetch kernel
575 as_nobody wget -O "${temp_dir}"/kernel.deb -c "$RPI_32_KERNEL_URL"
849 as_nobody wget -O "${temp_dir}"/kernel.deb -c "$RPI_32_KERNEL_URL"
576
850
577 # Copy downloaded U-Boot sources
851 # Copy downloaded kernel package
578 mv "${temp_dir}"/kernel.deb "${R}"/tmp/kernel.deb
852 mv "${temp_dir}"/kernel.deb "${R}"/tmp/kernel.deb
579
853
580 # Set permissions
854 # Set permissions
581 chown -R root:root "${R}"/tmp/kernel.deb
855 chown -R root:root "${R}"/tmp/kernel.deb
582
856
583 # Install kernel
857 # Install kernel
584 chroot_exec dpkg -i /tmp/kernel.deb
858 chroot_exec dpkg -i /tmp/kernel.deb
585
859
586 # move /boot to /boot/firmware to fit script env.
860 # move /boot to /boot/firmware to fit script env.
587 #mkdir "${BOOT_DIR}"
861 #mkdir "${BOOT_DIR}"
588 mkdir "${temp_dir}"/firmware
862 mkdir "${temp_dir}"/firmware
589 mv "${R}"/boot/* "${temp_dir}"/firmware/
863 mv "${R}"/boot/* "${temp_dir}"/firmware/
590 mv "${temp_dir}"/firmware "${R}"/boot/
864 mv "${temp_dir}"/firmware "${R}"/boot/
591
865
592 #same for kernel headers
866 #same for kernel headers
593 if [ "$KERNEL_HEADERS" = true ] ; then
867 if [ "$KERNEL_HEADERS" = true ] ; then
594 # Fetch kernel header
868 # Fetch kernel header
595 as_nobody wget -O "${temp_dir}"/kernel-header.deb -c "$RPI_32_KERNELHEADER_URL"
869 as_nobody wget -O "${temp_dir}"/kernel-header.deb -c "$RPI_32_KERNELHEADER_URL"
596 mv "${temp_dir}"/kernel-header.deb "${R}"/tmp/kernel-header.deb
870 mv "${temp_dir}"/kernel-header.deb "${R}"/tmp/kernel-header.deb
597 chown -R root:root "${R}"/tmp/kernel-header.deb
871 chown -R root:root "${R}"/tmp/kernel-header.deb
598 # Install kernel header
872 # Install kernel header
599 chroot_exec dpkg -i /tmp/kernel-header.deb
873 chroot_exec dpkg -i /tmp/kernel-header.deb
600 rm -f "${R}"/tmp/kernel-header.deb
874 rm -f "${R}"/tmp/kernel-header.deb
601 fi
875 fi
602
876
603 # Remove temporary directory and files
877 # Remove temporary directory and files
604 rm -fr "${temp_dir}"
878 rm -fr "${temp_dir}"
605 rm -f "${R}"/tmp/kernel.deb
879 rm -f "${R}"/tmp/kernel.deb
606 fi
880 fi
607
881
608 # Check if kernel installation was successful
882 # Check if kernel installation was successful
609 KERNEL="$(ls -1 "${R}"/boot/firmware/kernel* | sort | tail -n 1)"
883 KERNEL="$(ls -1 "${R}"/boot/firmware/kernel* | sort | tail -n 1)"
610 if [ -z "$KERNEL" ] ; then
884 if [ -z "$KERNEL" ] ; then
611 echo "error: kernel installation failed! (/boot/kernel* not found)"
885 echo "error: kernel installation failed! (/boot/kernel* not found)"
612 cleanup
886 cleanup
613 exit 1
887 exit 1
614 fi
888 fi
615 fi
889 fi
@@ -1,122 +1,128
1 #
1 #
2 # Setup fstab and initramfs
2 # Setup fstab and initramfs
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Install and setup fstab
8 # Install and setup fstab
9 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
9 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
10
10
11 # Generate initramfs file
11 # Generate initramfs file
12 if [ "$ENABLE_INITRAMFS" = true ] ; then
12 if [ "$ENABLE_INITRAMFS" = true ] ; then
13 if [ "$ENABLE_CRYPTFS" = true ] ; then
13 if [ "$ENABLE_CRYPTFS" = true ] ; then
14
14
15 # Include initramfs scripts to auto expand encrypted root partition
15 # Include initramfs scripts to auto expand encrypted root partition
16 if [ "$EXPANDROOT" = true ] ; then
16 if [ "$EXPANDROOT" = true ] ; then
17 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
17 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
18 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
18 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
19 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
19 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
20 fi
20 fi
21
21
22 # Replace fstab root partition with encrypted partition mapping
22 # Replace fstab root partition with encrypted partition mapping
23 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
23 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
24
24
25 # Add encrypted partition to crypttab and fstab
25 # Add encrypted partition to crypttab and fstab
26 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
26 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
27 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab"
27 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab"
28
28
29 if [ "$ENABLE_USBBOOT" = true ] && [ "$ENABLE_SPLITFS" = false ]; then
29 if [ "$ENABLE_USBBOOT" = true ] && [ "$ENABLE_SPLITFS" = false ]; then
30 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
30 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
31 # Add usb/sda2 disk to crypttab
31 # Add usb/sda2 disk to crypttab
32 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/crypttab"
32 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/crypttab"
33 fi
33 fi
34
34
35 # Add encrypted root partition to fstab and crypttab
35 # Add encrypted root partition to fstab and crypttab
36 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_USBBOOT" = false ]; then
36 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_USBBOOT" = false ]; then
37 # Add usb/sda1 disk to crypttab
37 # Add usb/sda1 disk to crypttab
38 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
38 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
39 fi
39 fi
40
40
41 if [ "$CRYPTFS_DROPBEAR" = true ]; then
41 if [ "$CRYPTFS_DROPBEAR" = true ]; then
42 if [ "$ENABLE_DHCP" = false ] ; then
42 if [ "$ENABLE_DHCP" = false ] ; then
43 # Get cdir from NET_ADDRESS e.g. 24
43 # Get cdir from NET_ADDRESS e.g. 24
44 cdir=$(printf "%s" "${NET_ADDRESS}" | cut -d '/' -f2)
44 cdir=$(printf "%s" "${NET_ADDRESS}" | cut -d '/' -f2)
45
45
46 # Convert cdir ro netmask e.g. 24 to 255.255.255.0
46 # Convert cdir ro netmask e.g. 24 to 255.255.255.0
47 NET_MASK=$(cdr2mask "$cdir")
47 NET_MASK=$(cdr2mask "$cdir")
48
48
49 # Write static ip settings to "${ETC_DIR}"/initramfs-tools/initramfs.conf
49 # Write static ip settings to "${ETC_DIR}"/initramfs-tools/initramfs.conf
50 # ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
50 # ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
51 sed -i "\$a\nIP=${NET_ADDRESS}::${NET_GATEWAY}:${NET_MASK}:${HOSTNAME}:" "${ETC_DIR}"/initramfs-tools/initramfs.conf
51 sed -i "\$a\nIP=${NET_ADDRESS}::${NET_GATEWAY}:${NET_MASK}:${HOSTNAME}:" "${ETC_DIR}"/initramfs-tools/initramfs.conf
52 else
52 else
53 sed -i "\$a\nIP=::::${HOSTNAME}::dhcp" "${ETC_DIR}"/initramfs-tools/initramfs.conf
53 sed -i "\$a\nIP=::::${HOSTNAME}::dhcp" "${ETC_DIR}"/initramfs-tools/initramfs.conf
54 fi
54 fi
55
55
56 if [ -n "$CRYPTFS_DROPBEAR_PUBKEY" ] && [ -f "$CRYPTFS_DROPBEAR_PUBKEY" ] ; then
56 if [ -n "$CRYPTFS_DROPBEAR_PUBKEY" ] && [ -f "$CRYPTFS_DROPBEAR_PUBKEY" ] ; then
57 install_readonly "${CRYPTFS_DROPBEAR_PUBKEY}" "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
57 install_readonly "${CRYPTFS_DROPBEAR_PUBKEY}" "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
58 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub >> "${ETC_DIR}"/dropbear-initramfs/authorized_keys
58 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub >> "${ETC_DIR}"/dropbear-initramfs/authorized_keys
59 else
59 else
60 # Create key
60 # Create key
61 chroot_exec /usr/bin/dropbearkey -t rsa -f /etc/dropbear-initramfs/id_rsa.dropbear
61 chroot_exec /usr/bin/dropbearkey -t rsa -f /etc/dropbear-initramfs/id_rsa.dropbear
62
62
63 # Convert dropbear key to openssh key
63 # Convert dropbear key to openssh key
64 chroot_exec /usr/lib/dropbear/dropbearconvert dropbear openssh /etc/dropbear-initramfs/id_rsa.dropbear /etc/dropbear-initramfs/id_rsa
64 chroot_exec /usr/lib/dropbear/dropbearconvert dropbear openssh /etc/dropbear-initramfs/id_rsa.dropbear /etc/dropbear-initramfs/id_rsa
65
65
66 # Get Public Key Part
66 # Get Public Key Part
67 chroot_exec /usr/bin/dropbearkey -y -f /etc/dropbear-initramfs/id_rsa.dropbear | chroot_exec tee /etc/dropbear-initramfs/id_rsa.pub
67 chroot_exec /usr/bin/dropbearkey -y -f /etc/dropbear-initramfs/id_rsa.dropbear | chroot_exec tee /etc/dropbear-initramfs/id_rsa.pub
68
68
69 # Delete unwanted lines
69 # Delete unwanted lines
70 sed -i '/Public/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
70 sed -i '/Public/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
71 sed -i '/Fingerprint/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
71 sed -i '/Fingerprint/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
72
72
73 # Trust the new key
73 # Trust the new key
74 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub > "${ETC_DIR}"/dropbear-initramfs/authorized_keys
74 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub > "${ETC_DIR}"/dropbear-initramfs/authorized_keys
75
75
76 # Save Keys - convert with putty from rsa/openssh to puttkey
76 # Save Keys - convert with putty from rsa/openssh to puttkey
77 cp -f "${ETC_DIR}"/dropbear-initramfs/id_rsa "${BASEDIR}"/dropbear_initramfs_key.rsa
77 cp -f "${ETC_DIR}"/dropbear-initramfs/id_rsa "${BASEDIR}"/dropbear_initramfs_key.rsa
78
78
79 # Get unlock script
79 # Get unlock script
80 install_exec files/initramfs/crypt_unlock.sh "${ETC_DIR}"/initramfs-tools/hooks/crypt_unlock.sh
80 install_exec files/initramfs/crypt_unlock.sh "${ETC_DIR}"/initramfs-tools/hooks/crypt_unlock.sh
81
81
82 # Enable Dropbear inside initramfs
82 # Enable Dropbear inside initramfs
83 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=y\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
83 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=y\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
84
84
85 # Enable Dropbear inside initramfs
85 # Enable Dropbear inside initramfs
86 sed -i "54 i sleep 5" "${R}"/usr/share/initramfs-tools/scripts/init-premount/dropbear
86 sed -i "54 i sleep 5" "${R}"/usr/share/initramfs-tools/scripts/init-premount/dropbear
87 fi
87 fi
88 # CRYPTFSDROPBEAR=false
88 # CRYPTFSDROPBEAR=false
89 else
89 else
90 # Disable SSHD inside initramfs
90 # Disable SSHD inside initramfs
91 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
91 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
92 fi
92 fi
93
93
94 # Add cryptsetup modules to initramfs
94 # Add cryptsetup modules to initramfs
95 <<<<<<< HEAD
95 printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
96 printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
96 #printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
97 #printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
97
98
98 # Dummy mapping required by mkinitramfs
99 # Dummy mapping required by mkinitramfs
99 echo "0 1 crypt $(echo "${CRYPTFS_CIPHER}" | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
100 echo "0 1 crypt $(echo "${CRYPTFS_CIPHER}" | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
101 =======
102 #printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
103
104 # Dummy mapping required by mkinitramfs
105 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
100 echo "0 1 crypt "${CRYPTFS_CIPHER}" ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
106 echo "0 1 crypt "${CRYPTFS_CIPHER}" ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
101
107
102 # Generate initramfs with encrypted root partition support
108 # Generate initramfs with encrypted root partition support
103 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
109 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
104
110
105 # Remove dummy mapping
111 # Remove dummy mapping
106 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
112 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
107 # CRYPTFS=false
113 # CRYPTFS=false
108 else
114 else
109 #USB BOOT /boot on sda1 / on sda2
115 #USB BOOT /boot on sda1 / on sda2
110 if [ "$ENABLE_USBBOOT" = true ] ; then
116 if [ "$ENABLE_USBBOOT" = true ] ; then
111 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
117 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
112 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab"
118 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab"
113 fi
119 fi
114
120
115 # Add usb/sda disk root partition to fstab
121 # Add usb/sda disk root partition to fstab
116 if [ "$ENABLE_SPLITFS" = true ] ; then
122 if [ "$ENABLE_SPLITFS" = true ] ; then
117 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
123 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
118 fi
124 fi
119 # Generate initramfs without encrypted root partition support
125 # Generate initramfs without encrypted root partition support
120 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
126 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
121 fi
127 fi
122 fi
128 fi
@@ -1,311 +1,316
1 #
1 #
2 # Setup RPi2/3 config and cmdline
2 # Setup RPi2/3 config and cmdline
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
8 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
9 # Install boot binaries from local directory
9 # Install boot binaries from local directory
10 cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin
10 cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin
11 cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat
11 cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat
12 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat
12 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat
13 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat
13 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat
14 cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf
14 cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf
15 cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf
15 cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf
16 cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf
16 cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf
17 else
17 else
18 # Create temporary directory for boot binaries
18 # Create temporary directory for boot binaries
19 temp_dir=$(as_nobody mktemp -d)
19 temp_dir=$(as_nobody mktemp -d)
20
20
21 # Install latest boot binaries from raspberry/firmware github
21 # Install latest boot binaries from raspberry/firmware github
22 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
22 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
23 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
23 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
24 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
24 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
26 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
26 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
27 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
27 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
28 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
28 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
29
29
30 # Move downloaded boot binaries
30 # Move downloaded boot binaries
31 mv "${temp_dir}/"* "${BOOT_DIR}/"
31 mv "${temp_dir}/"* "${BOOT_DIR}/"
32
32
33 # Remove temporary directory for boot binaries
33 # Remove temporary directory for boot binaries
34 rm -fr "${temp_dir}"
34 rm -fr "${temp_dir}"
35
35
36 # Set permissions of the boot binaries
36 # Set permissions of the boot binaries
37 chown -R root:root "${BOOT_DIR}"
37 chown -R root:root "${BOOT_DIR}"
38 chmod -R 600 "${BOOT_DIR}"
38 chmod -R 600 "${BOOT_DIR}"
39 fi
39 fi
40
40
41 # Setup firmware boot cmdline
41 # Setup firmware boot cmdline
42 if [ "$ENABLE_USBBOOT" = true ] ; then
42 if [ "$ENABLE_USBBOOT" = true ] ; then
43 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
43 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
44 else
44 else
45 if [ "$ENABLE_SPLITFS" = true ] ; then
45 if [ "$ENABLE_SPLITFS" = true ] ; then
46 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
46 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
47 else
47 else
48 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
48 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
49 fi
49 fi
50 fi
50 fi
51
51
52 # Add encrypted root partition to cmdline.txt
52 # Add encrypted root partition to cmdline.txt
53 if [ "$ENABLE_CRYPTFS" = true ] ; then
53 if [ "$ENABLE_CRYPTFS" = true ] ; then
54 if [ "$ENABLE_SPLITFS" = true ] ; then
54 if [ "$ENABLE_SPLITFS" = true ] ; then
55 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
55 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
56 else
56 else
57 if [ "$ENABLE_USBBOOT" = true ] ; then
57 if [ "$ENABLE_USBBOOT" = true ] ; then
58 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/")
58 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/")
59 else
59 else
60 CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
60 CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
61 fi
61 fi
62 fi
62 fi
63 fi
63 fi
64
64
65 # Enable Kernel messages on standard output
65 # Enable Kernel messages on standard output
66 if [ "$ENABLE_PRINTK" = true ] ; then
66 if [ "$ENABLE_PRINTK" = true ] ; then
67 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
67 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
68 fi
68 fi
69
69
70 # Enable Kernel messages on standard output
70 # Enable Kernel messages on standard output
71 if [ "$KERNEL_SECURITY" = true ] ; then
71 if [ "$KERNEL_SECURITY" = true ] ; then
72 install_readonly files/sysctl.d/84-rpi-ASLR.conf "${ETC_DIR}/sysctl.d/84-rpi-ASLR.conf"
72 install_readonly files/sysctl.d/84-rpi-ASLR.conf "${ETC_DIR}/sysctl.d/84-rpi-ASLR.conf"
73 fi
73 fi
74
74
75 # Install udev rule for serial alias - serial0 = console serial1=bluetooth
75 # Install udev rule for serial alias - serial0 = console serial1=bluetooth
76 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
76 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
77
77
78 # Remove IPv6 networking support
78 # Remove IPv6 networking support
79 if [ "$ENABLE_IPV6" = false ] ; then
79 if [ "$ENABLE_IPV6" = false ] ; then
80 CMDLINE="${CMDLINE} ipv6.disable=1"
80 CMDLINE="${CMDLINE} ipv6.disable=1"
81 fi
81 fi
82
82
83 # Automatically assign predictable network interface names
83 # Automatically assign predictable network interface names
84 if [ "$ENABLE_IFNAMES" = false ] ; then
84 if [ "$ENABLE_IFNAMES" = false ] ; then
85 CMDLINE="${CMDLINE} net.ifnames=0"
85 CMDLINE="${CMDLINE} net.ifnames=0"
86 else
86 else
87 CMDLINE="${CMDLINE} net.ifnames=1"
87 CMDLINE="${CMDLINE} net.ifnames=1"
88 fi
88 fi
89
89
90 # Disable Raspberry Pi console logo
90 # Disable Raspberry Pi console logo
91 if [ "$ENABLE_LOGO" = false ] ; then
91 if [ "$ENABLE_LOGO" = false ] ; then
92 CMDLINE="${CMDLINE} logo.nologo"
92 CMDLINE="${CMDLINE} logo.nologo"
93 fi
93 fi
94
94
95 # Strictly limit verbosity of boot up console messages
95 # Strictly limit verbosity of boot up console messages
96 if [ "$ENABLE_SILENT_BOOT" = true ] ; then
96 if [ "$ENABLE_SILENT_BOOT" = true ] ; then
97 CMDLINE="${CMDLINE} quiet loglevel=0 rd.systemd.show_status=auto rd.udev.log_priority=0"
97 CMDLINE="${CMDLINE} quiet loglevel=0 rd.systemd.show_status=auto rd.udev.log_priority=0"
98 fi
98 fi
99
99
100 # Install firmware config
100 # Install firmware config
101 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
101 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
102
102
103 # Disable Raspberry Pi console logo
103 # Disable Raspberry Pi console logo
104 if [ "$ENABLE_SLASH" = false ] ; then
104 if [ "$ENABLE_SLASH" = false ] ; then
105 echo "disable_splash=1" >> "${BOOT_DIR}/config.txt"
105 echo "disable_splash=1" >> "${BOOT_DIR}/config.txt"
106 fi
106 fi
107
107
108 # Locks CPU frequency at maximum
108 # Locks CPU frequency at maximum
109 if [ "$ENABLE_TURBO" = true ] ; then
109 if [ "$ENABLE_TURBO" = true ] ; then
110 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
110 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
111 # helps to avoid sdcard corruption when force_turbo is enabled.
111 # helps to avoid sdcard corruption when force_turbo is enabled.
112 echo "boot_delay=1" >> "${BOOT_DIR}/config.txt"
112 echo "boot_delay=1" >> "${BOOT_DIR}/config.txt"
113 fi
113 fi
114
114
115 <<<<<<< HEAD
115 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
116 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
117 =======
118 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
116 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; then
119 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; then
117
120
118 # Bluetooth enabled
121 # Bluetooth enabled
119 if [ "$ENABLE_BLUETOOTH" = true ] ; then
122 if [ "$ENABLE_BLUETOOTH" = true ] ; then
120 # Create temporary directory for Bluetooth sources
123 # Create temporary directory for Bluetooth sources
121 temp_dir=$(as_nobody mktemp -d)
124 temp_dir=$(as_nobody mktemp -d)
122
125
123 # Fetch Bluetooth sources
126 # Fetch Bluetooth sources
124 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
127 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
125
128
126 # Copy downloaded sources
129 # Copy downloaded sources
127 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
130 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
128
131
129 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
130 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
131 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd
132
133 # Set permissions
132 # Set permissions
134 chown -R root:root "${R}/tmp/pi-bluetooth"
133 chown -R root:root "${R}/tmp/pi-bluetooth"
135
134
136 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
135 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
137 wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
136 wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
138 wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd
137 wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd
139
138
140 # Install tools
139 # Install tools
141 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
140 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
142 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
141 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
143
142
144 # make scripts executable
143 # make scripts executable
145 chmod +x "${R}/usr/bin/bthelper"
144 chmod +x "${R}/usr/bin/bthelper"
146 chmod +x "${R}/usr/bin/btuart"
145 chmod +x "${R}/usr/bin/btuart"
147
146
148 # Install bluetooth udev rule
147 # Install bluetooth udev rule
149 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
148 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
150
149
151 # Install Firmware Flash file and apropiate licence
150 # Install Firmware Flash file and apropiate licence
152 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
151 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
153 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
152 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
154 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/BCM43430A1.hcd"
153 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/BCM43430A1.hcd"
155 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
154 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
156 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
155 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
157
156
158 # Remove temporary directories
157 # Remove temporary directories
159 rm -fr "${temp_dir}"
158 rm -fr "${temp_dir}"
160 rm -fr "${R}"/tmp/pi-bluetooth
159 rm -fr "${R}"/tmp/pi-bluetooth
161
160
162 # 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
161 # 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
163 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
162 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
164 # set overlay to swap ttyAMA0 and ttyS0
163 # set overlay to swap ttyAMA0 and ttyS0
165 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
164 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
166
165
167 if [ "$ENABLE_TURBO" = false ] ; then
166 if [ "$ENABLE_TURBO" = false ] ; then
168 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
167 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
169 fi
168 fi
170
169
171 fi
170 fi
172
171
173 # Activate services
172 # Activate services
174 chroot_exec systemctl enable pi-bluetooth.hciuart.service
173 chroot_exec systemctl enable pi-bluetooth.hciuart.service
175
174
176 else # if ENABLE_BLUETOOTH = false
175 else # if ENABLE_BLUETOOTH = false
177 # set overlay to disable bluetooth
176 # set overlay to disable bluetooth
178 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
177 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
179 fi # ENABLE_BLUETOOTH end
178 fi # ENABLE_BLUETOOTH end
180 fi
179 fi
181
180
182 # may need sudo systemctl disable hciuart
181 # may need sudo systemctl disable hciuart
183 if [ "$ENABLE_CONSOLE" = true ] ; then
182 if [ "$ENABLE_CONSOLE" = true ] ; then
184 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
183 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
185 # add string to cmdline
184 # add string to cmdline
186 CMDLINE="${CMDLINE} console=serial0,115200"
185 CMDLINE="${CMDLINE} console=serial0,115200"
187
186
188 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]|| [ "$RPI_MODEL" = 0 ]; then
187 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]|| [ "$RPI_MODEL" = 0 ]; then
189 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
188 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
190 if [ "$ENABLE_TURBO" = false ] ; then
189 if [ "$ENABLE_TURBO" = false ] ; then
191 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
190 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
192 fi
191 fi
193 fi
192 fi
194
193
195 # Enable serial console systemd style
194 # Enable serial console systemd style
196 chroot_exec systemctl enable serial-getty@serial0.service
195 chroot_exec systemctl enable serial-getty@serial0.service
197 else
196 else
198 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
197 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
199 fi
198 fi
200
199
201 # Disable dphys-swapfile service. Will get enabled on first boot
200 # Disable dphys-swapfile service. Will get enabled on first boot
202 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
201 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
203 chroot_exec systemctl disable dphys-swapfile
202 chroot_exec systemctl disable dphys-swapfile
204 fi
203 fi
205
204
206 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
205 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
207 # Create temporary directory for systemd-swap sources
206 # Create temporary directory for systemd-swap sources
208 temp_dir=$(as_nobody mktemp -d)
207 temp_dir=$(as_nobody mktemp -d)
209
208
210 # Fetch systemd-swap sources
209 # Fetch systemd-swap sources
211 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
210 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
212
211
213 # Copy downloaded systemd-swap sources
212 # Copy downloaded systemd-swap sources
214 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
213 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
215
214
216 # Change into downloaded src dir
215 # Change into downloaded src dir
217 cd "${R}/tmp/systemd-swap" || exit
216 cd "${R}/tmp/systemd-swap" || exit
217 <<<<<<< HEAD
218
218
219 =======
220 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
219
221
220 # Get Verion
222 # Get Verion
221 VERSION=$(git tag | tail -n 1)
223 VERSION=$(git tag | tail -n 1)
222 #sed -i "s/DEB_NAME=.*/DEB_NAME=systemd-swap_all/g" "${R}/tmp/systemd-swap/package.sh"
224 #sed -i "s/DEB_NAME=.*/DEB_NAME=systemd-swap_all/g" "${R}/tmp/systemd-swap/package.sh"
223
225
224 # Build package
226 # Build package
225 bash ./package.sh debian
227 bash ./package.sh debian
226
228
227 # Change back into script root dir
229 # Change back into script root dir
228 cd "${WORKDIR}" || exit
230 cd "${WORKDIR}" || exit
229
231
230 # Set permissions of the systemd-swap sources
232 # Set permissions of the systemd-swap sources
231 chown -R root:root "${R}/tmp/systemd-swap"
233 chown -R root:root "${R}/tmp/systemd-swap"
232
234
233 # Install package - IMPROVE AND MAKE IT POSSIBLE WITHOUT VERSION NR.
235 # Install package - IMPROVE AND MAKE IT POSSIBLE WITHOUT VERSION NR.
236 <<<<<<< HEAD
234 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_4.0.1_any.deb
237 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_4.0.1_any.deb
238 =======
239 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
235 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_"$VERSION"_all.deb
240 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_"$VERSION"_all.deb
236
241
237 # Enable service
242 # Enable service
238 chroot_exec systemctl enable systemd-swap
243 chroot_exec systemctl enable systemd-swap
239
244
240 # Remove temporary directory for systemd-swap sources
245 # Remove temporary directory for systemd-swap sources
241 rm -fr "${temp_dir}"
246 rm -fr "${temp_dir}"
242 else
247 else
243 # Enable ZSWAP in cmdline if systemd-swap is not used
248 # Enable ZSWAP in cmdline if systemd-swap is not used
244 if [ "$KERNEL_ZSWAP" = true ] ; then
249 if [ "$KERNEL_ZSWAP" = true ] ; then
245 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
250 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
246 fi
251 fi
247 fi
252 fi
248 if [ "$KERNEL_SECURITY" = true ] ; then
253 if [ "$KERNEL_SECURITY" = true ] ; then
249 CMDLINE="${CMDLINE} apparmor=1 security=apparmor"
254 CMDLINE="${CMDLINE} apparmor=1 security=apparmor"
250 fi
255 fi
251
256
252 # Install firmware boot cmdline
257 # Install firmware boot cmdline
253 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
258 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
254
259
255 # Setup minimal GPU memory allocation size: 16MB (no X)
260 # Setup minimal GPU memory allocation size: 16MB (no X)
256 if [ "$ENABLE_MINGPU" = true ] ; then
261 if [ "$ENABLE_MINGPU" = true ] ; then
257 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
262 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
258 fi
263 fi
259
264
260 # Setup boot with initramfs
265 # Setup boot with initramfs
261 if [ "$ENABLE_INITRAMFS" = true ] ; then
266 if [ "$ENABLE_INITRAMFS" = true ] ; then
262 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
267 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
263 fi
268 fi
264
269
265 # Create firmware configuration and cmdline symlinks
270 # Create firmware configuration and cmdline symlinks
266 ln -sf firmware/config.txt "${R}/boot/config.txt"
271 ln -sf firmware/config.txt "${R}/boot/config.txt"
267 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
272 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
268
273
269 # Install and setup kernel modules to load at boot
274 # Install and setup kernel modules to load at boot
270 mkdir -p "${LIB_DIR}/modules-load.d/"
275 mkdir -p "${LIB_DIR}/modules-load.d/"
271 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
276 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
272
277
273 # Load hardware random module at boot
278 # Load hardware random module at boot
274 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
279 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
275 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
280 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
276 fi
281 fi
277
282
278 # Load sound module at boot
283 # Load sound module at boot
279 if [ "$ENABLE_SOUND" = true ] ; then
284 if [ "$ENABLE_SOUND" = true ] ; then
280 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
285 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
281 else
286 else
282 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
287 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
283 fi
288 fi
284
289
285 # Enable I2C interface
290 # Enable I2C interface
286 if [ "$ENABLE_I2C" = true ] ; then
291 if [ "$ENABLE_I2C" = true ] ; then
287 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
292 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
288 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
293 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
289 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
294 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
290 fi
295 fi
291
296
292 # Enable SPI interface
297 # Enable SPI interface
293 if [ "$ENABLE_SPI" = true ] ; then
298 if [ "$ENABLE_SPI" = true ] ; then
294 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
299 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
295 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
300 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
296 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
301 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
297 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
302 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
298 fi
303 fi
299 fi
304 fi
300
305
301 # Disable RPi2/3 under-voltage warnings
306 # Disable RPi2/3 under-voltage warnings
302 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
307 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
303 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
308 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
304 fi
309 fi
305
310
306 # Install kernel modules blacklist
311 # Install kernel modules blacklist
307 mkdir -p "${ETC_DIR}/modprobe.d/"
312 mkdir -p "${ETC_DIR}/modprobe.d/"
308 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
313 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
309
314
310 # Install sysctl.d configuration files
315 # Install sysctl.d configuration files
311 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
316 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
@@ -1,137 +1,140
1 #
1 #
2 # Setup Networking
2 # Setup Networking
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Install and setup hostname
8 # Install and setup hostname
9 install_readonly files/network/hostname "${ETC_DIR}/hostname"
9 install_readonly files/network/hostname "${ETC_DIR}/hostname"
10 sed -i "s/^RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hostname"
10 sed -i "s/^RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hostname"
11
11
12 # Install and setup hosts
12 # Install and setup hosts
13 install_readonly files/network/hosts "${ETC_DIR}/hosts"
13 install_readonly files/network/hosts "${ETC_DIR}/hosts"
14 sed -i "s/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts"
14 sed -i "s/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts"
15
15
16 # Setup hostname entry with static IP
16 # Setup hostname entry with static IP
17 if [ "$NET_ADDRESS" != "" ] ; then
17 if [ "$NET_ADDRESS" != "" ] ; then
18 NET_IP=$(echo "${NET_ADDRESS}" | cut -f 1 -d'/')
18 NET_IP=$(echo "${NET_ADDRESS}" | cut -f 1 -d'/')
19 sed -i "s/^127.0.1.1/${NET_IP}/" "${ETC_DIR}/hosts"
19 sed -i "s/^127.0.1.1/${NET_IP}/" "${ETC_DIR}/hosts"
20 fi
20 fi
21
21
22 # Remove IPv6 hosts
22 # Remove IPv6 hosts
23 if [ "$ENABLE_IPV6" = false ] ; then
23 if [ "$ENABLE_IPV6" = false ] ; then
24 sed -i -e "/::[1-9]/d" -e "/^$/d" "${ETC_DIR}/hosts"
24 sed -i -e "/::[1-9]/d" -e "/^$/d" "${ETC_DIR}/hosts"
25 fi
25 fi
26
26
27 # Install hint about network configuration
27 # Install hint about network configuration
28 install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces"
28 install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces"
29
29
30 # Install configuration for interface eth0
30 # Install configuration for interface eth0
31 install_readonly files/network/eth.network "${ETC_DIR}/systemd/network/eth.network"
31 install_readonly files/network/eth.network "${ETC_DIR}/systemd/network/eth.network"
32
32
33 if [ "$RPI_MODEL" = 3P ] ; then
33 if [ "$RPI_MODEL" = 3P ] ; then
34 printf "\n[Link]\nGenericReceiveOffload=off\nTCPSegmentationOffload=off\nGenericSegmentationOffload=off" >> "${ETC_DIR}/systemd/network/eth.network"
34 printf "\n[Link]\nGenericReceiveOffload=off\nTCPSegmentationOffload=off\nGenericSegmentationOffload=off" >> "${ETC_DIR}/systemd/network/eth.network"
35 fi
35 fi
36
36
37 # Install configuration for interface wl*
37 # Install configuration for interface wl*
38 install_readonly files/network/wlan.network "${ETC_DIR}/systemd/network/wlan.network"
38 install_readonly files/network/wlan.network "${ETC_DIR}/systemd/network/wlan.network"
39
39
40 #always with dhcp since wpa_supplicant integration is missing
40 #always with dhcp since wpa_supplicant integration is missing
41 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan.network"
41 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan.network"
42
42
43 if [ "$ENABLE_DHCP" = true ] ; then
43 if [ "$ENABLE_DHCP" = true ] ; then
44 # Enable DHCP configuration for interface eth0
44 # Enable DHCP configuration for interface eth0
45 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth.network"
45 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth.network"
46
46
47 # Set DHCP configuration to IPv4 only
47 # Set DHCP configuration to IPv4 only
48 if [ "$ENABLE_IPV6" = false ] ; then
48 if [ "$ENABLE_IPV6" = false ] ; then
49 sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth.network"
49 sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth.network"
50 fi
50 fi
51
51
52 else # ENABLE_DHCP=false
52 else # ENABLE_DHCP=false
53 # Set static network configuration for interface eth0
53 # Set static network configuration for interface eth0
54 sed -i\
54 sed -i\
55 -e "s|DHCP=.*|DHCP=no|"\
55 -e "s|DHCP=.*|DHCP=no|"\
56 -e "s|Address=\$|Address=${NET_ADDRESS}|"\
56 -e "s|Address=\$|Address=${NET_ADDRESS}|"\
57 -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\
57 -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\
58 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\
58 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\
59 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\
59 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\
60 -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\
60 -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\
61 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\
61 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\
62 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\
62 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\
63 "${ETC_DIR}/systemd/network/eth.network"
63 "${ETC_DIR}/systemd/network/eth.network"
64 fi
64 fi
65
65
66 # Remove empty settings from network configuration
66 # Remove empty settings from network configuration
67 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network"
67 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network"
68 # Remove empty settings from wlan configuration
68 # Remove empty settings from wlan configuration
69 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network"
69 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network"
70
70
71 # Move systemd network configuration if required by Debian release
71 # Move systemd network configuration if required by Debian release
72 mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network"
72 mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network"
73 # If WLAN is enabled copy wlan configuration too
73 # If WLAN is enabled copy wlan configuration too
74 if [ "$ENABLE_WIRELESS" = true ] ; then
74 if [ "$ENABLE_WIRELESS" = true ] ; then
75 mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network"
75 mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network"
76 fi
76 fi
77 rm -fr "${ETC_DIR}/systemd/network"
77 rm -fr "${ETC_DIR}/systemd/network"
78
78
79 # Enable systemd-networkd service
79 # Enable systemd-networkd service
80 chroot_exec systemctl enable systemd-networkd
80 chroot_exec systemctl enable systemd-networkd
81
81
82 # Install host.conf resolver configuration
82 # Install host.conf resolver configuration
83 install_readonly files/network/host.conf "${ETC_DIR}/host.conf"
83 install_readonly files/network/host.conf "${ETC_DIR}/host.conf"
84
84
85 # Enable network stack hardening
85 # Enable network stack hardening
86 if [ "$ENABLE_HARDNET" = true ] ; then
86 if [ "$ENABLE_HARDNET" = true ] ; then
87 # Install sysctl.d configuration files
87 # Install sysctl.d configuration files
88 install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETC_DIR}/sysctl.d/82-rpi-net-hardening.conf"
88 install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETC_DIR}/sysctl.d/82-rpi-net-hardening.conf"
89
89
90 # Setup resolver warnings about spoofed addresses
90 # Setup resolver warnings about spoofed addresses
91 sed -i "s/^# spoof warn/spoof warn/" "${ETC_DIR}/host.conf"
91 sed -i "s/^# spoof warn/spoof warn/" "${ETC_DIR}/host.conf"
92 fi
92 fi
93
93
94 # Enable time sync
94 # Enable time sync
95 if [ "$NET_NTP_1" != "" ] ; then
95 if [ "$NET_NTP_1" != "" ] ; then
96 chroot_exec systemctl enable systemd-timesyncd.service
96 chroot_exec systemctl enable systemd-timesyncd.service
97 fi
97 fi
98
98
99 # Download the firmware binary blob required to use the RPi3 wireless interface
99 # Download the firmware binary blob required to use the RPi3 wireless interface
100 if [ "$ENABLE_WIRELESS" = true ] ; then
100 if [ "$ENABLE_WIRELESS" = true ] ; then
101 if [ ! -d "${WLAN_FIRMWARE_DIR}" ] ; then
101 if [ ! -d "${WLAN_FIRMWARE_DIR}" ] ; then
102 mkdir -p "${WLAN_FIRMWARE_DIR}"
102 mkdir -p "${WLAN_FIRMWARE_DIR}"
103 fi
103 fi
104
104
105 # Create temporary directory for firmware binary blob
105 # Create temporary directory for firmware binary blob
106 temp_dir=$(as_nobody mktemp -d)
106 temp_dir=$(as_nobody mktemp -d)
107
107
108 # Fetch firmware binary blob for RPI3B+
108 # Fetch firmware binary blob for RPI3B+
109 <<<<<<< HEAD
109 if [ "$RPI_MODEL" = 3P ] ; then
110 if [ "$RPI_MODEL" = 3P ] ; then
111 =======
112 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
110 if [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
113 if [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
111 # Fetch firmware binary blob for RPi3P
114 # Fetch firmware binary blob for RPi3P
112 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.bin"
115 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.bin"
113 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.txt"
116 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.txt"
114 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.clm_blob" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.clm_blob"
117 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.clm_blob" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.clm_blob"
115
118
116 # Move downloaded firmware binary blob
119 # Move downloaded firmware binary blob
117 mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/"
120 mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/"
118
121
119 # Set permissions of the firmware binary blob
122 # Set permissions of the firmware binary blob
120 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
123 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
121 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
124 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
122 elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then
125 elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then
123 # Fetch firmware binary blob for RPi3
126 # Fetch firmware binary blob for RPi3
124 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin"
127 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin"
125 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt"
128 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt"
126
129
127 # Move downloaded firmware binary blob
130 # Move downloaded firmware binary blob
128 mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/"
131 mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/"
129
132
130 # Set permissions of the firmware binary blob
133 # Set permissions of the firmware binary blob
131 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
134 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
132 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
135 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
133 fi
136 fi
134
137
135 # Remove temporary directory for firmware binary blob
138 # Remove temporary directory for firmware binary blob
136 rm -fr "${temp_dir}"
139 rm -fr "${temp_dir}"
137 fi
140 fi
@@ -1,58 +1,64
1 #
1 #
2 # Setup videocore - Raspberry Userland
2 # Setup videocore - Raspberry Userland
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 if [ "$ENABLE_VIDEOCORE" = true ] ; then
8 if [ "$ENABLE_VIDEOCORE" = true ] ; then
9 # Copy existing videocore sources into chroot directory
9 # Copy existing videocore sources into chroot directory
10 if [ -n "$VIDEOCORESRC_DIR" ] && [ -d "$VIDEOCORESRC_DIR" ] ; then
10 if [ -n "$VIDEOCORESRC_DIR" ] && [ -d "$VIDEOCORESRC_DIR" ] ; then
11 # Copy local videocore sources
11 # Copy local videocore sources
12 cp -r "${VIDEOCORESRC_DIR}" "${R}/tmp/userland"
12 cp -r "${VIDEOCORESRC_DIR}" "${R}/tmp/userland"
13 else
13 else
14 # Create temporary directory for videocore sources
14 # Create temporary directory for videocore sources
15 temp_dir=$(as_nobody mktemp -d)
15 temp_dir=$(as_nobody mktemp -d)
16
16
17 # Fetch videocore sources
17 # Fetch videocore sources
18 as_nobody git -C "${temp_dir}" clone "${VIDEOCORE_URL}"
18 as_nobody git -C "${temp_dir}" clone "${VIDEOCORE_URL}"
19
19
20 # Copy downloaded videocore sources
20 # Copy downloaded videocore sources
21 mv "${temp_dir}/userland" "${R}/tmp/"
21 mv "${temp_dir}/userland" "${R}/tmp/"
22
22
23 # Set permissions of the U-Boot sources
23 # Set permissions of the U-Boot sources
24 chown -R root:root "${R}/tmp/userland"
24 chown -R root:root "${R}/tmp/userland"
25
25
26 # Remove temporary directory for U-Boot sources
26 # Remove temporary directory for U-Boot sources
27 rm -fr "${temp_dir}"
27 rm -fr "${temp_dir}"
28 fi
28 fi
29
29
30 # Create build dir
30 # Create build dir
31 mkdir "${R}"/tmp/userland/build
31 mkdir "${R}"/tmp/userland/build
32
32
33 # push us to build directory
33 # push us to build directory
34 cd "${R}"/tmp/userland/build
34 cd "${R}"/tmp/userland/build
35
35
36 if [ "$RELEASE_ARCH" = "arm64" ] ; then
36 if [ "$RELEASE_ARCH" = "arm64" ] ; then
37 <<<<<<< HEAD
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"
38 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"
39 =======
40 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
38 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/aarch64-linux-gnu.cmake -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"
41 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/aarch64-linux-gnu.cmake -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"
39 fi
42 fi
40
43
41 if [ "$RELEASE_ARCH" = "armel" ] ; then
44 if [ "$RELEASE_ARCH" = "armel" ] ; then
45 <<<<<<< HEAD
42 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++ -DCMAKE_ASM_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DCMAKE_SYSTEM_PROCESSOR="arm" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland"
46 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++ -DCMAKE_ASM_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DCMAKE_SYSTEM_PROCESSOR="arm" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland"
47 =======
48 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
43 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++ -DCMAKE_ASM_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DCMAKE_SYSTEM_PROCESSOR="arm" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland"
49 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++ -DCMAKE_ASM_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DCMAKE_SYSTEM_PROCESSOR="arm" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland"
44 fi
50 fi
45
51
46 if [ "$RELEASE_ARCH" = "armhf" ] ; then
52 if [ "$RELEASE_ARCH" = "armhf" ] ; then
47 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland"
53 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland"
48 fi
54 fi
49
55
50 #build userland
56 #build userland
51 make -j "$(nproc)"
57 make -j "$(nproc)"
52
58
53 #back to root of scriptdir
59 #back to root of scriptdir
54 cd "${WORKDIR}"
60 cd "${WORKDIR}"
55
61
56 # Remove videocore sources
62 # Remove videocore sources
57 rm -fr "${R}"/tmp/userland/
63 rm -fr "${R}"/tmp/userland/
58 fi
64 fi
@@ -1,98 +1,101
1 #!/bin/sh
1 #!/bin/sh
2 #
2 #
3 # Build and Setup nexmon with monitor mode patch
3 # Build and Setup nexmon with monitor mode patch
4 #
4 #
5
5
6 # Load utility functions
6 # Load utility functions
7 . ./functions.sh
7 . ./functions.sh
8
8
9 if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then
9 if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then
10 # Copy existing nexmon sources into chroot directory
10 # Copy existing nexmon sources into chroot directory
11 if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then
11 if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then
12 # Copy local U-Boot sources
12 # Copy local U-Boot sources
13 cp -r "${NEXMONSRC_DIR}" "${R}/tmp"
13 cp -r "${NEXMONSRC_DIR}" "${R}/tmp"
14 else
14 else
15 # Create temporary directory for nexmon sources
15 # Create temporary directory for nexmon sources
16 temp_dir=$(as_nobody mktemp -d)
16 temp_dir=$(as_nobody mktemp -d)
17
17
18 # Fetch nexmon sources
18 # Fetch nexmon sources
19 as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}"
19 as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}"
20
20
21 # Copy downloaded nexmon sources
21 # Copy downloaded nexmon sources
22 mv "${temp_dir}/nexmon" "${R}"/tmp/
22 mv "${temp_dir}/nexmon" "${R}"/tmp/
23
23
24 # Set permissions of the nexmon sources
24 # Set permissions of the nexmon sources
25 chown -R root:root "${R}"/tmp/nexmon
25 chown -R root:root "${R}"/tmp/nexmon
26
26
27 # Remove temporary directory for nexmon sources
27 # Remove temporary directory for nexmon sources
28 rm -fr "${temp_dir}"
28 rm -fr "${temp_dir}"
29 fi
29 fi
30
30
31 # Set script Root
31 # Set script Root
32 export NEXMON_ROOT="${R}"/tmp/nexmon
32 export NEXMON_ROOT="${R}"/tmp/nexmon
33
33
34 # Build nexmon firmware outside the build system, if we can.
34 # Build nexmon firmware outside the build system, if we can.
35 cd "${NEXMON_ROOT}" || exit
35 cd "${NEXMON_ROOT}" || exit
36
36
37 # Make ancient isl build
37 # Make ancient isl build
38 cd buildtools/isl-0.10 || exit
38 cd buildtools/isl-0.10 || exit
39 ./configure
39 ./configure
40 make
40 make
41 cd ../.. || exit
41 cd ../.. || exit
42
42
43 # Disable statistics
43 # Disable statistics
44 touch DISABLE_STATISTICS
44 touch DISABLE_STATISTICS
45
45
46 # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh
46 # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh
47 export KERNEL="${KERNEL_IMAGE}"
47 export KERNEL="${KERNEL_IMAGE}"
48 export ARCH=arm
48 export ARCH=arm
49 export SUBARCH=arm
49 export SUBARCH=arm
50 export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
50 export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
51 export CC="${CC}"gcc
51 export CC="${CC}"gcc
52 export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so
52 export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so
53 export ZLIBFLATE="zlib-flate -compress"
53 export ZLIBFLATE="zlib-flate -compress"
54 export Q=@
54 export Q=@
55 export NEXMON_SETUP_ENV=1
55 export NEXMON_SETUP_ENV=1
56 export HOSTUNAME=$(uname -s)
56 export HOSTUNAME=$(uname -s)
57 export PLATFORMUNAME=$(uname -m)
57 export PLATFORMUNAME=$(uname -m)
58
58
59 # Make nexmon
59 # Make nexmon
60 make
60 make
61
61
62 # build patches
62 # build patches
63 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then
63 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then
64 cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit
64 cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit
65 sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/Makefile
65 sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/Makefile
66 make clean
66 make clean
67
67
68 # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems.
68 # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems.
69 LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
69 LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
70
70
71 # copy RPi0W & RPi3 firmware
71 # copy RPi0W & RPi3 firmware
72 mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin
72 mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin
73 cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin
73 cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin
74 cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin
74 cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin
75 fi
75 fi
76
76
77 <<<<<<< HEAD
77 if [ "$RPI_MODEL" = 3P ] ; then
78 if [ "$RPI_MODEL" = 3P ] ; then
79 =======
80 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
78 if [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
81 if [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
79 cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit
82 cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit
80 sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/Makefile
83 sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/Makefile
81 make clean
84 make clean
82
85
83 # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems.
86 # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems.
84 LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
87 LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
85
88
86 # RPi3B+ firmware
89 # RPi3B+ firmware
87 mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin
90 mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin
88 cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin
91 cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin
89 cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin
92 cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin
90 fi
93 fi
91
94
92 #Revert to previous directory
95 #Revert to previous directory
93 cd "${WORKDIR}" || exit
96 cd "${WORKDIR}" || exit
94
97
95 # Remove nexmon sources
98 # Remove nexmon sources
96 rm -fr "${NEXMON_ROOT}"
99 rm -fr "${NEXMON_ROOT}"
97
100
98 fi
101 fi
@@ -1,908 +1,936
1 #!/bin/sh
1 #!/bin/sh
2 ########################################################################
2 ########################################################################
3 # rpi23-gen-image.sh 2015-2017
3 # rpi23-gen-image.sh 2015-2017
4 #
4 #
5 # Advanced Debian "stretch" and "buster" bootstrap script for Raspberry Pi
5 # Advanced Debian "stretch" and "buster" bootstrap script for Raspberry Pi
6 #
6 #
7 # This program is free software; you can redistribute it and/or
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
10 # of the License, or (at your option) any later version.
11 #
11 #
12 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
12 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
13 #
13 #
14 # Big thanks for patches and enhancements by 20+ github contributors!
14 # Big thanks for patches and enhancements by 20+ github contributors!
15 ########################################################################
15 ########################################################################
16
16
17 # Are we running as root?
17 # Are we running as root?
18 if [ "$(id -u)" -ne "0" ] ; then
18 if [ "$(id -u)" -ne "0" ] ; then
19 echo "error: this script must be executed with root privileges!"
19 echo "error: this script must be executed with root privileges!"
20 exit 1
20 exit 1
21 fi
21 fi
22
22
23 # Check if ./functions.sh script exists
23 # Check if ./functions.sh script exists
24 if [ ! -r "./functions.sh" ] ; then
24 if [ ! -r "./functions.sh" ] ; then
25 echo "error: './functions.sh' required script not found!"
25 echo "error: './functions.sh' required script not found!"
26 exit 1
26 exit 1
27 fi
27 fi
28
28
29 # Load utility functions
29 # Load utility functions
30 . ./functions.sh
30 . ./functions.sh
31
31
32 # Load parameters from configuration template file
32 # Load parameters from configuration template file
33 if [ -n "$CONFIG_TEMPLATE" ] ; then
33 if [ -n "$CONFIG_TEMPLATE" ] ; then
34 use_template
34 use_template
35 fi
35 fi
36
36
37 # Introduce settings
37 # Introduce settings
38 set -e
38 set -e
39 echo -n -e "\n#\n# RPi 0/1/2/3 Bootstrap Settings\n#\n"
39 echo -n -e "\n#\n# RPi 0/1/2/3 Bootstrap Settings\n#\n"
40 set -x
40 set -x
41
41
42 # Raspberry Pi model configuration
42 # Raspberry Pi model configuration
43 RPI_MODEL=${RPI_MODEL:=2}
43 RPI_MODEL=${RPI_MODEL:=2}
44
44
45 # Debian release
45 # Debian release
46 RELEASE=${RELEASE:=buster}
46 RELEASE=${RELEASE:=buster}
47 if [ $RELEASE = "bullseye" ] ; then
47 if [ $RELEASE = "bullseye" ] ; then
48 RELEASE=testing
48 RELEASE=testing
49 fi
49 fi
50
50
51 # Kernel Branch
51 # Kernel Branch
52 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
52 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
53
53
54 # URLs
54 # URLs
55 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
55 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
56 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
56 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
57 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
57 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
58 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
59 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
58 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
60 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
59 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
61 VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland}
60 VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland}
62 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
61 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
63 NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git}
62 NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git}
64 SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git}
63 SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git}
65
64
66 # Kernel deb packages for 32bit kernel
65 # Kernel deb packages for 32bit kernel
67 RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb}
66 RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb}
68 RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb}
67 RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb}
69 # Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used
68 # Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used
69 <<<<<<< HEAD
70 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz}
70 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz}
71 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.19.80.20191022/bcmrpi3-kernel-bis-4.19.80.20191022.tar.xz}
71 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.19.80.20191022/bcmrpi3-kernel-bis-4.19.80.20191022.tar.xz}
72 # Default precompiled 64bit kernel
72 # Default precompiled 64bit kernel
73 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz}
73 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz}
74 =======
75 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.19.80.20191022/bcmrpi3-kernel-bis-4.19.80.20191022.tar.xz}
76 # Default precompiled 64bit kernel
77 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
74 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.19.80.20191022/bcmrpi3-kernel-4.19.80.20191022.tar.xz}
78 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.19.80.20191022/bcmrpi3-kernel-4.19.80.20191022.tar.xz}
75 # Sakaki BIS Kernel RPI4 - https://github.com/sakaki-/bcm2711-kernel-bis
79 # Sakaki BIS Kernel RPI4 - https://github.com/sakaki-/bcm2711-kernel-bis
76 RPI4_64_BIS_KERNEL_URL=${RPI4_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz}
80 RPI4_64_BIS_KERNEL_URL=${RPI4_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz}
77 # Default precompiled 64bit kernel - https://github.com/sakaki-/bcm2711-kernel
81 # Default precompiled 64bit kernel - https://github.com/sakaki-/bcm2711-kernel
78 RPI4_64_DEF_KERNEL_URL=${RPI4_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz}
82 RPI4_64_DEF_KERNEL_URL=${RPI4_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz}
79 # Generic
83 # Generic
80 RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL}
84 RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL}
81 RPI4_64_KERNEL_URL=${RPI4_64_KERNEL_URL:=$RPI4_64_DEF_KERNEL_URL}
85 RPI4_64_KERNEL_URL=${RPI4_64_KERNEL_URL:=$RPI4_64_DEF_KERNEL_URL}
82 # Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul)
86 # Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul)
83 KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git}
87 KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git}
84
88
85 # Build directories
89 # Build directories
86 WORKDIR=$(pwd)
90 WORKDIR=$(pwd)
87 BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}}
91 BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}}
88 BUILDDIR="${BASEDIR}/build"
92 BUILDDIR="${BASEDIR}/build"
89
93
90 # Chroot directories
94 # Chroot directories
91 R="${BUILDDIR}/chroot"
95 R="${BUILDDIR}/chroot"
92 ETC_DIR="${R}/etc"
96 ETC_DIR="${R}/etc"
93 LIB_DIR="${R}/lib"
97 LIB_DIR="${R}/lib"
94 BOOT_DIR="${R}/boot/firmware"
98 BOOT_DIR="${R}/boot/firmware"
95 KERNEL_DIR="${R}/usr/src/linux"
99 KERNEL_DIR="${R}/usr/src/linux"
96 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
100 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
97 BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt"
101 BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt"
98
102
99 # Firmware directory: Blank if download from github
103 # Firmware directory: Blank if download from github
100 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
104 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
101
105
102 # General settings
106 # General settings
103 SET_ARCH=${SET_ARCH:=32}
107 SET_ARCH=${SET_ARCH:=32}
104 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
108 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
105 PASSWORD=${PASSWORD:=raspberry}
109 PASSWORD=${PASSWORD:=raspberry}
106 USER_PASSWORD=${USER_PASSWORD:=raspberry}
110 USER_PASSWORD=${USER_PASSWORD:=raspberry}
107 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
111 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
108 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
112 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
109 EXPANDROOT=${EXPANDROOT:=true}
113 EXPANDROOT=${EXPANDROOT:=true}
110 ENABLE_DPHYSSWAP=${ENABLE_DPHYSSWAP:=true}
114 ENABLE_DPHYSSWAP=${ENABLE_DPHYSSWAP:=true}
111
115
112 # Keyboard settings
116 # Keyboard settings
113 XKB_MODEL=${XKB_MODEL:=""}
117 XKB_MODEL=${XKB_MODEL:=""}
114 XKB_LAYOUT=${XKB_LAYOUT:=""}
118 XKB_LAYOUT=${XKB_LAYOUT:=""}
115 XKB_VARIANT=${XKB_VARIANT:=""}
119 XKB_VARIANT=${XKB_VARIANT:=""}
116 XKB_OPTIONS=${XKB_OPTIONS:=""}
120 XKB_OPTIONS=${XKB_OPTIONS:=""}
117
121
118 # Network settings (DHCP)
122 # Network settings (DHCP)
119 ENABLE_DHCP=${ENABLE_DHCP:=true}
123 ENABLE_DHCP=${ENABLE_DHCP:=true}
120
124
121 # Network settings (static)
125 # Network settings (static)
122 NET_ADDRESS=${NET_ADDRESS:=""}
126 NET_ADDRESS=${NET_ADDRESS:=""}
123 NET_GATEWAY=${NET_GATEWAY:=""}
127 NET_GATEWAY=${NET_GATEWAY:=""}
124 NET_DNS_1=${NET_DNS_1:=""}
128 NET_DNS_1=${NET_DNS_1:=""}
125 NET_DNS_2=${NET_DNS_2:=""}
129 NET_DNS_2=${NET_DNS_2:=""}
126 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
130 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
127 NET_NTP_1=${NET_NTP_1:=""}
131 NET_NTP_1=${NET_NTP_1:=""}
128 NET_NTP_2=${NET_NTP_2:=""}
132 NET_NTP_2=${NET_NTP_2:=""}
129
133
130 # APT settings
134 # APT settings
131 APT_PROXY=${APT_PROXY:=""}
135 APT_PROXY=${APT_PROXY:=""}
132 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
136 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
133 KEEP_APT_PROXY=${KEEP_APT_PROXY:=false}
137 KEEP_APT_PROXY=${KEEP_APT_PROXY:=false}
134
138
135 # Feature settings
139 # Feature settings
136 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
140 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
137 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
141 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
138 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
142 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
139 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
143 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
140 ENABLE_I2C=${ENABLE_I2C:=false}
144 ENABLE_I2C=${ENABLE_I2C:=false}
141 ENABLE_SPI=${ENABLE_SPI:=false}
145 ENABLE_SPI=${ENABLE_SPI:=false}
142 ENABLE_IPV6=${ENABLE_IPV6:=true}
146 ENABLE_IPV6=${ENABLE_IPV6:=true}
143 ENABLE_SSHD=${ENABLE_SSHD:=true}
147 ENABLE_SSHD=${ENABLE_SSHD:=true}
144 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
148 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
145 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
149 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
146 ENABLE_SOUND=${ENABLE_SOUND:=true}
150 ENABLE_SOUND=${ENABLE_SOUND:=true}
147 ENABLE_DBUS=${ENABLE_DBUS:=true}
151 ENABLE_DBUS=${ENABLE_DBUS:=true}
148 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
152 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
149 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
153 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
150 ENABLE_XORG=${ENABLE_XORG:=false}
154 ENABLE_XORG=${ENABLE_XORG:=false}
151 ENABLE_WM=${ENABLE_WM:=""}
155 ENABLE_WM=${ENABLE_WM:=""}
152 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
156 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
153 ENABLE_USER=${ENABLE_USER:=true}
157 ENABLE_USER=${ENABLE_USER:=true}
154 USER_NAME=${USER_NAME:="pi"}
158 USER_NAME=${USER_NAME:="pi"}
155 ENABLE_ROOT=${ENABLE_ROOT:=false}
159 ENABLE_ROOT=${ENABLE_ROOT:=false}
156 ENABLE_QEMU=${ENABLE_QEMU:=false}
160 ENABLE_QEMU=${ENABLE_QEMU:=false}
157 ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false}
161 ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false}
158
162
159 # SSH settings
163 # SSH settings
160 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
164 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
161 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
165 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
162 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
166 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
163 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
167 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
164 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
168 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
165
169
166 # Advanced settings
170 # Advanced settings
167 ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false}
171 ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false}
168 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
172 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
169 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
173 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
170 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
174 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
171 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
175 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
172 ENABLE_USBBOOT=${ENABLE_USBBOOT=false}
176 ENABLE_USBBOOT=${ENABLE_USBBOOT=false}
173 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
177 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
174 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false}
178 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false}
175 ENABLE_NEXMON=${ENABLE_NEXMON:=false}
179 ENABLE_NEXMON=${ENABLE_NEXMON:=false}
176 VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""}
180 VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""}
177 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
181 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
178 NEXMONSRC_DIR=${NEXMONSRC_DIR:=""}
182 NEXMONSRC_DIR=${NEXMONSRC_DIR:=""}
179 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
183 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
180 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
184 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
181 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
185 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
182 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
186 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
183 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
187 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
184 ENABLE_SPLASH=${ENABLE_SPLASH:=true}
188 ENABLE_SPLASH=${ENABLE_SPLASH:=true}
185 ENABLE_LOGO=${ENABLE_LOGO:=true}
189 ENABLE_LOGO=${ENABLE_LOGO:=true}
186 ENABLE_SILENT_BOOT=${ENABLE_SILENT_BOOT=false}
190 ENABLE_SILENT_BOOT=${ENABLE_SILENT_BOOT=false}
187 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
191 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
188
192
189 # Kernel compilation settings
193 # Kernel compilation settings
190 BUILD_KERNEL=${BUILD_KERNEL:=true}
194 BUILD_KERNEL=${BUILD_KERNEL:=true}
191 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
195 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
192 KERNEL_THREADS=${KERNEL_THREADS:=1}
196 KERNEL_THREADS=${KERNEL_THREADS:=1}
193 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
197 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
194 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
198 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
195 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
199 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
196 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
200 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
197 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
201 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
198 KERNEL_ZSWAP=${KERNEL_ZSWAP:=false}
202 KERNEL_ZSWAP=${KERNEL_ZSWAP:=false}
199 KERNEL_VIRT=${KERNEL_VIRT:=false}
203 KERNEL_VIRT=${KERNEL_VIRT:=false}
200 KERNEL_BPF=${KERNEL_BPF:=false}
204 KERNEL_BPF=${KERNEL_BPF:=false}
201 KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=ondemand}
205 KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=ondemand}
202 KERNEL_SECURITY=${KERNEL_SECURITY:=false}
206 KERNEL_SECURITY=${KERNEL_SECURITY:=false}
203 KERNEL_NF=${KERNEL_NF:=false}
207 KERNEL_NF=${KERNEL_NF:=false}
204 KERNEL_DHKEY=${KERNEL_DHKEY:=true}
208 KERNEL_DHKEY=${KERNEL_DHKEY:=true}
205 KERNEL_BTRFS=${KERNEL_BTRFS:=false}
209 KERNEL_BTRFS=${KERNEL_BTRFS:=false}
206 KERNEL_NSPAN=${KERNEL_NSPAN:=false}
210 KERNEL_NSPAN=${KERNEL_NSPAN:=false}
207 KERNEL_POEHAT=${KERNEL_POEHAT:=false}
211 KERNEL_POEHAT=${KERNEL_POEHAT:=false}
208
212
209 # Kernel compilation from source directory settings
213 # Kernel compilation from source directory settings
210 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
214 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
211 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
215 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
212 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
216 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
213 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
217 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
214
218
215 # Reduce disk usage settings
219 # Reduce disk usage settings
216 REDUCE_APT=${REDUCE_APT:=true}
220 REDUCE_APT=${REDUCE_APT:=true}
217 REDUCE_DOC=${REDUCE_DOC:=true}
221 REDUCE_DOC=${REDUCE_DOC:=true}
218 REDUCE_MAN=${REDUCE_MAN:=true}
222 REDUCE_MAN=${REDUCE_MAN:=true}
219 REDUCE_VIM=${REDUCE_VIM:=false}
223 REDUCE_VIM=${REDUCE_VIM:=false}
220 REDUCE_BASH=${REDUCE_BASH:=false}
224 REDUCE_BASH=${REDUCE_BASH:=false}
221 REDUCE_HWDB=${REDUCE_HWDB:=true}
225 REDUCE_HWDB=${REDUCE_HWDB:=true}
222 REDUCE_SSHD=${REDUCE_SSHD:=true}
226 REDUCE_SSHD=${REDUCE_SSHD:=true}
223 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
227 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
224
228
225 # Encrypted filesystem settings
229 # Encrypted filesystem settings
226 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
230 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
227 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
231 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
228 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
232 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
233 <<<<<<< HEAD
229 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
234 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
235 =======
236 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
230 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64"}
237 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64"}
231 CRYPTFS_HASH=${CRYPTFS_HASH:="sha512"}
238 CRYPTFS_HASH=${CRYPTFS_HASH:="sha512"}
232 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
239 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
233 #Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup
240 #Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup
234 CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false}
241 CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false}
235 #Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated
242 #Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated
236 CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""}
243 CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""}
237
244
238 # Chroot scripts directory
245 # Chroot scripts directory
239 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
246 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
240
247
241 # Packages required in the chroot build environment
248 # Packages required in the chroot build environment
242 APT_INCLUDES=${APT_INCLUDES:=""}
249 APT_INCLUDES=${APT_INCLUDES:=""}
250 <<<<<<< HEAD
243 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"
251 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"
252 =======
253 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
244 APT_INCLUDES="${APT_INCLUDES},flex,bison,libssl-dev,apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
254 APT_INCLUDES="${APT_INCLUDES},flex,bison,libssl-dev,apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
245
255
246 # Packages to exclude from chroot build environment
256 # Packages to exclude from chroot build environment
247 APT_EXCLUDES=${APT_EXCLUDES:=""}
257 APT_EXCLUDES=${APT_EXCLUDES:=""}
248
258
249 # Packages required for bootstrapping
259 # Packages required for bootstrapping
260 <<<<<<< HEAD
250 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo"
261 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo"
262 =======
263 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
251 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus bison flex libssl-dev sudo"
264 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus bison flex libssl-dev sudo"
252 MISSING_PACKAGES=""
265 MISSING_PACKAGES=""
253
266
254 # Packages installed for c/c++ build environment in chroot (keep empty)
267 # Packages installed for c/c++ build environment in chroot (keep empty)
255 COMPILER_PACKAGES=""
268 COMPILER_PACKAGES=""
256
269
257 # Check if apt-cacher-ng has port 3142 open and set APT_PROXY
270 # Check if apt-cacher-ng has port 3142 open and set APT_PROXY
258 APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d')
271 APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d')
259 if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then
272 if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then
260 APT_PROXY=http://127.0.0.1:3142/
273 APT_PROXY=http://127.0.0.1:3142/
261 fi
274 fi
262
275
263 # Setup architecture specific settings
276 # Setup architecture specific settings
264 if [ -n "$SET_ARCH" ] ; then
277 if [ -n "$SET_ARCH" ] ; then
265 # 64-bit configuration
278 # 64-bit configuration
266 if [ "$SET_ARCH" = 64 ] ; then
279 if [ "$SET_ARCH" = 64 ] ; then
267 # General 64-bit depended settings
280 # General 64-bit depended settings
268 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
281 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
269 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
282 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
270 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
283 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
271
284
272 # Raspberry Pi model specific settings
285 # Raspberry Pi model specific settings
273 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
286 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
274 if [ "$RPI_MODEL" != 4 ] ; then
287 if [ "$RPI_MODEL" != 4 ] ; then
275 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
288 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
276 else
289 else
277 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
290 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
278 fi
291 fi
279
292
280 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
293 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
281 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
294 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
282 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
295 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
283 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
296 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
284 else
297 else
285 echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit"
298 echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit"
286 exit 1
299 exit 1
287 fi
300 fi
288 fi
301 fi
289
302
290 # 32-bit configuration
303 # 32-bit configuration
291 if [ "$SET_ARCH" = 32 ] ; then
304 if [ "$SET_ARCH" = 32 ] ; then
292 # General 32-bit dependend settings
305 # General 32-bit dependend settings
293 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
306 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
294 KERNEL_ARCH=${KERNEL_ARCH:=arm}
307 KERNEL_ARCH=${KERNEL_ARCH:=arm}
295 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
308 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
296
309
297 # Raspberry Pi model specific settings
310 # Raspberry Pi model specific settings
298 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
311 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
299 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
312 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
300 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
313 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
301 RELEASE_ARCH=${RELEASE_ARCH:=armel}
314 RELEASE_ARCH=${RELEASE_ARCH:=armel}
302 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
315 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
303 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
316 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
304 fi
317 fi
305
318
306 # Raspberry Pi model specific settings
319 # Raspberry Pi model specific settings
307 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
320 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
308 if [ "$RPI_MODEL" != 4 ] ; then
321 if [ "$RPI_MODEL" != 4 ] ; then
309 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
322 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
310 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
323 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
311 else
324 else
312 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
325 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
313 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7l.img}
326 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7l.img}
314 fi
327 fi
315
328
316 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
329 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
317 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
330 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
331 <<<<<<< HEAD
318 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
332 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
333 =======
334 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
319
335
320 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
336 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
321 fi
337 fi
322 fi
338 fi
323 # SET_ARCH not set
339 # SET_ARCH not set
324 else
340 else
325 echo "error: Please set '32' or '64' as value for SET_ARCH"
341 echo "error: Please set '32' or '64' as value for SET_ARCH"
326 exit 1
342 exit 1
327 fi
343 fi
328 # Device specific configuration and U-Boot configuration
344 # Device specific configuration and U-Boot configuration
329 case "$RPI_MODEL" in
345 case "$RPI_MODEL" in
330 0)
346 0)
331 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
347 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
332 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
348 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
333 ;;
349 ;;
334 1)
350 1)
335 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
351 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
336 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
352 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
337 ;;
353 ;;
338 1P)
354 1P)
339 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
355 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
340 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
356 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
341 ;;
357 ;;
342 2)
358 2)
343 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
359 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
344 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
360 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
345 ;;
361 ;;
346 3)
362 3)
347 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
363 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
348 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
364 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
349 ;;
365 ;;
350 3P)
366 3P)
351 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
367 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
352 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
368 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
353 ;;
369 ;;
354 4)
370 4)
355 DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb}
371 DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb}
356 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig}
372 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig}
357 ;;
373 ;;
358 *)
374 *)
359 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
375 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
360 exit 1
376 exit 1
361 ;;
377 ;;
362 esac
378 esac
363
379
364 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
380 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
365 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
381 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
366 # Include bluetooth packages on supported boards
382 # Include bluetooth packages on supported boards
367 if [ "$ENABLE_BLUETOOTH" = true ] ; then
383 if [ "$ENABLE_BLUETOOTH" = true ] ; then
368 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
384 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
369 fi
385 fi
370 if [ "$ENABLE_WIRELESS" = true ] ; then
386 if [ "$ENABLE_WIRELESS" = true ] ; then
371 APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb"
387 APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb"
372 fi
388 fi
373 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
389 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
374 # Check if the internal wireless interface is not supported by the RPi model
390 # Check if the internal wireless interface is not supported by the RPi model
375 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
391 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
376 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
392 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
377 exit 1
393 exit 1
378 fi
394 fi
379 fi
395 fi
380
396
381 if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then
397 if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then
382 echo "error: You have to compile kernel sources, if you want to enable nexmon"
398 echo "error: You have to compile kernel sources, if you want to enable nexmon"
383 exit 1
399 exit 1
384 fi
400 fi
385
401
386 # Prepare date string for default image file name
402 # Prepare date string for default image file name
387 DATE="$(date +%Y-%m-%d)"
403 DATE="$(date +%Y-%m-%d)"
388 if [ -z "$KERNEL_BRANCH" ] ; then
404 if [ -z "$KERNEL_BRANCH" ] ; then
389 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
405 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
390 else
406 else
391 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
407 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
392 fi
408 fi
393
409
394 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
410 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
395 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
411 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
396 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
412 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
397 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
413 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
398 exit 1
414 exit 1
399 fi
415 fi
400 fi
416 fi
401
417
402 # Add cmake to compile videocore sources
418 # Add cmake to compile videocore sources
403 if [ "$ENABLE_VIDEOCORE" = true ] ; then
419 if [ "$ENABLE_VIDEOCORE" = true ] ; then
404 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
420 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
405 fi
421 fi
406
422
407 # Add deps for nexmon
423 # Add deps for nexmon
408 if [ "$ENABLE_NEXMON" = true ] ; then
424 if [ "$ENABLE_NEXMON" = true ] ; then
425 <<<<<<< HEAD
409 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool"
426 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool"
427 =======
428 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
410 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf make autoconf automake build-essential libtool"
429 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf make autoconf automake build-essential libtool"
411 fi
430 fi
412
431
413 # Add libncurses5 to enable kernel menuconfig
432 # Add libncurses5 to enable kernel menuconfig
414 if [ "$KERNEL_MENUCONFIG" = true ] ; then
433 if [ "$KERNEL_MENUCONFIG" = true ] ; then
415 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev"
434 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev"
416 fi
435 fi
417
436
418 # Add ccache compiler cache for (faster) kernel cross (re)compilation
437 # Add ccache compiler cache for (faster) kernel cross (re)compilation
419 if [ "$KERNEL_CCACHE" = true ] ; then
438 if [ "$KERNEL_CCACHE" = true ] ; then
420 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
439 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
421 fi
440 fi
422
441
423 # Add cryptsetup package to enable filesystem encryption
442 # Add cryptsetup package to enable filesystem encryption
424 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
443 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
425 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
444 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
445 <<<<<<< HEAD
426 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
446 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
447 =======
448 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
427 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup,cryptsetup-initramfs"
449 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup,cryptsetup-initramfs"
428
450
429 # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package
451 # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package
430 if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then
452 if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then
431 APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs"
453 APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs"
432 fi
454 fi
433
455
434 if [ -z "$CRYPTFS_PASSWORD" ] ; then
456 if [ -z "$CRYPTFS_PASSWORD" ] ; then
435 echo "error: no password defined (CRYPTFS_PASSWORD)!"
457 echo "error: no password defined (CRYPTFS_PASSWORD)!"
436 exit 1
458 exit 1
437 fi
459 fi
438 ENABLE_INITRAMFS=true
460 ENABLE_INITRAMFS=true
439 fi
461 fi
440
462
441 # Add initramfs generation tools
463 # Add initramfs generation tools
442 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
464 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
443 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
465 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
444 fi
466 fi
445
467
446 # Add device-tree-compiler required for building the U-Boot bootloader
468 # Add device-tree-compiler required for building the U-Boot bootloader
447 if [ "$ENABLE_UBOOT" = true ] ; then
469 if [ "$ENABLE_UBOOT" = true ] ; then
448 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
470 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
449 fi
471 fi
450
472
451 if [ "$ENABLE_USBBOOT" = true ] ; then
473 if [ "$ENABLE_USBBOOT" = true ] ; then
452 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then
474 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then
453 echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P"
475 echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P"
454 exit 1
476 exit 1
455 fi
477 fi
456 fi
478 fi
457
479
458 # Check if root SSH (v2) public key file exists
480 # Check if root SSH (v2) public key file exists
459 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
481 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
460 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
482 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
461 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
483 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
462 exit 1
484 exit 1
463 fi
485 fi
464 fi
486 fi
465
487
466 # Check if $USER_NAME SSH (v2) public key file exists
488 # Check if $USER_NAME SSH (v2) public key file exists
467 if [ -n "$SSH_USER_PUB_KEY" ] ; then
489 if [ -n "$SSH_USER_PUB_KEY" ] ; then
468 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
490 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
469 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
491 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
470 exit 1
492 exit 1
471 fi
493 fi
472 fi
494 fi
473
495
474 if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then
496 if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then
475 echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON"
497 echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON"
476 exit 1
498 exit 1
477 fi
499 fi
478
500
479 # Check if all required packages are installed on the build system
501 # Check if all required packages are installed on the build system
480 for package in $REQUIRED_PACKAGES ; do
502 for package in $REQUIRED_PACKAGES ; do
481 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
503 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
482 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
504 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
483 fi
505 fi
484 done
506 done
485
507
486 # If there are missing packages ask confirmation for install, or exit
508 # If there are missing packages ask confirmation for install, or exit
487 if [ -n "$MISSING_PACKAGES" ] ; then
509 if [ -n "$MISSING_PACKAGES" ] ; then
488 echo "the following packages needed by this script are not installed:"
510 echo "the following packages needed by this script are not installed:"
489 echo "$MISSING_PACKAGES"
511 echo "$MISSING_PACKAGES"
490
512
491 printf "\ndo you want to install the missing packages right now? [y/n] "
513 printf "\ndo you want to install the missing packages right now? [y/n] "
492 read -r confirm
514 read -r confirm
493 [ "$confirm" != "y" ] && exit 1
515 [ "$confirm" != "y" ] && exit 1
494
516
495 # Make sure all missing required packages are installed
517 # Make sure all missing required packages are installed
518 <<<<<<< HEAD
496 apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
519 apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
520 =======
521 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
497 apt-get update && apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
522 apt-get update && apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
498 fi
523 fi
499
524
500 # Check if ./bootstrap.d directory exists
525 # Check if ./bootstrap.d directory exists
501 if [ ! -d "./bootstrap.d/" ] ; then
526 if [ ! -d "./bootstrap.d/" ] ; then
502 echo "error: './bootstrap.d' required directory not found!"
527 echo "error: './bootstrap.d' required directory not found!"
503 exit 1
528 exit 1
504 fi
529 fi
505
530
506 # Check if ./files directory exists
531 # Check if ./files directory exists
507 if [ ! -d "./files/" ] ; then
532 if [ ! -d "./files/" ] ; then
508 echo "error: './files' required directory not found!"
533 echo "error: './files' required directory not found!"
509 exit 1
534 exit 1
510 fi
535 fi
511
536
512 # Check if specified KERNELSRC_DIR directory exists
537 # Check if specified KERNELSRC_DIR directory exists
513 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
538 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
514 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
539 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
515 exit 1
540 exit 1
516 fi
541 fi
517
542
518 # Check if specified UBOOTSRC_DIR directory exists
543 # Check if specified UBOOTSRC_DIR directory exists
519 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
544 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
520 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
545 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
521 exit 1
546 exit 1
522 fi
547 fi
523
548
524 # Check if specified VIDEOCORESRC_DIR directory exists
549 # Check if specified VIDEOCORESRC_DIR directory exists
525 if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then
550 if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then
526 echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!"
551 echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!"
527 exit 1
552 exit 1
528 fi
553 fi
529
554
530 # Check if specified FBTURBOSRC_DIR directory exists
555 # Check if specified FBTURBOSRC_DIR directory exists
531 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
556 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
532 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
557 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
533 exit 1
558 exit 1
534 fi
559 fi
535
560
536 # Check if specified NEXMONSRC_DIR directory exists
561 # Check if specified NEXMONSRC_DIR directory exists
537 if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then
562 if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then
538 echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!"
563 echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!"
539 exit 1
564 exit 1
540 fi
565 fi
541
566
542 # Check if specified CHROOT_SCRIPTS directory exists
567 # Check if specified CHROOT_SCRIPTS directory exists
543 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
568 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
544 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
569 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
545 exit 1
570 exit 1
546 fi
571 fi
547
572
548 # Check if specified device mapping already exists (will be used by cryptsetup)
573 # Check if specified device mapping already exists (will be used by cryptsetup)
549 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
574 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
550 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
575 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
551 exit 1
576 exit 1
552 fi
577 fi
553
578
554 # Don't clobber an old build
579 # Don't clobber an old build
555 if [ -e "$BUILDDIR" ] ; then
580 if [ -e "$BUILDDIR" ] ; then
556 echo "error: directory ${BUILDDIR} already exists, not proceeding"
581 echo "error: directory ${BUILDDIR} already exists, not proceeding"
557 exit 1
582 exit 1
558 fi
583 fi
559
584
560 # Setup chroot directory
585 # Setup chroot directory
561 mkdir -p "${R}"
586 mkdir -p "${R}"
562
587
563 # Check if build directory has enough of free disk space >512MB
588 # Check if build directory has enough of free disk space >512MB
564 if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then
589 if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then
565 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
590 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
566 exit 1
591 exit 1
567 fi
592 fi
568
593
569 set -x
594 set -x
570
595
571 # Call "cleanup" function on various signals and errors
596 # Call "cleanup" function on various signals and errors
572 trap cleanup 0 1 2 3 6
597 trap cleanup 0 1 2 3 6
573
598
574 # Add required packages for the minbase installation
599 # Add required packages for the minbase installation
575 if [ "$ENABLE_MINBASE" = true ] ; then
600 if [ "$ENABLE_MINBASE" = true ] ; then
576 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
601 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
577 fi
602 fi
578
603
579 # Add parted package, required to get partprobe utility
604 # Add parted package, required to get partprobe utility
580 if [ "$EXPANDROOT" = true ] ; then
605 if [ "$EXPANDROOT" = true ] ; then
581 APT_INCLUDES="${APT_INCLUDES},parted"
606 APT_INCLUDES="${APT_INCLUDES},parted"
582 fi
607 fi
583
608
584 # Add dphys-swapfile package, required to enable swap
609 # Add dphys-swapfile package, required to enable swap
585 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
610 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
586 APT_INCLUDES="${APT_INCLUDES},dphys-swapfile"
611 APT_INCLUDES="${APT_INCLUDES},dphys-swapfile"
587 fi
612 fi
588
613
589 # Add dbus package, recommended if using systemd
614 # Add dbus package, recommended if using systemd
590 if [ "$ENABLE_DBUS" = true ] ; then
615 if [ "$ENABLE_DBUS" = true ] ; then
591 APT_INCLUDES="${APT_INCLUDES},dbus"
616 APT_INCLUDES="${APT_INCLUDES},dbus"
592 fi
617 fi
593
618
594 # Add iptables IPv4/IPv6 package
619 # Add iptables IPv4/IPv6 package
595 if [ "$ENABLE_IPTABLES" = true ] ; then
620 if [ "$ENABLE_IPTABLES" = true ] ; then
596 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
621 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
597 fi
622 fi
598 # Add apparmor for KERNEL_SECURITY
623 # Add apparmor for KERNEL_SECURITY
599 if [ "$KERNEL_SECURITY" = true ] ; then
624 if [ "$KERNEL_SECURITY" = true ] ; then
600 APT_INCLUDES="${APT_INCLUDES},apparmor,apparmor-utils,apparmor-profiles,apparmor-profiles-extra,libapparmor-perl"
625 APT_INCLUDES="${APT_INCLUDES},apparmor,apparmor-utils,apparmor-profiles,apparmor-profiles-extra,libapparmor-perl"
601 fi
626 fi
602
627
603 # Add openssh server package
628 # Add openssh server package
604 if [ "$ENABLE_SSHD" = true ] ; then
629 if [ "$ENABLE_SSHD" = true ] ; then
605 APT_INCLUDES="${APT_INCLUDES},openssh-server"
630 APT_INCLUDES="${APT_INCLUDES},openssh-server"
606 fi
631 fi
607
632
608 # Add alsa-utils package
633 # Add alsa-utils package
609 if [ "$ENABLE_SOUND" = true ] ; then
634 if [ "$ENABLE_SOUND" = true ] ; then
610 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
635 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
611 fi
636 fi
612
637
613 # Add rng-tools package
638 # Add rng-tools package
614 if [ "$ENABLE_HWRANDOM" = true ] ; then
639 if [ "$ENABLE_HWRANDOM" = true ] ; then
615 APT_INCLUDES="${APT_INCLUDES},rng-tools"
640 APT_INCLUDES="${APT_INCLUDES},rng-tools"
616 fi
641 fi
617
642
618 # Add fbturbo video driver
643 # Add fbturbo video driver
619 if [ "$ENABLE_FBTURBO" = true ] ; then
644 if [ "$ENABLE_FBTURBO" = true ] ; then
620 # Enable xorg package dependencies
645 # Enable xorg package dependencies
621 ENABLE_XORG=true
646 ENABLE_XORG=true
622 fi
647 fi
623
648
624 # Add user defined window manager package
649 # Add user defined window manager package
625 if [ -n "$ENABLE_WM" ] ; then
650 if [ -n "$ENABLE_WM" ] ; then
626 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
651 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
627
652
628 # Enable xorg package dependencies
653 # Enable xorg package dependencies
629 ENABLE_XORG=true
654 ENABLE_XORG=true
630 fi
655 fi
631
656
632 # Add xorg package
657 # Add xorg package
633 if [ "$ENABLE_XORG" = true ] ; then
658 if [ "$ENABLE_XORG" = true ] ; then
634 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
659 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
635 fi
660 fi
636
661
637 # Replace selected packages with smaller clones
662 # Replace selected packages with smaller clones
638 if [ "$ENABLE_REDUCE" = true ] ; then
663 if [ "$ENABLE_REDUCE" = true ] ; then
639 # Add levee package instead of vim-tiny
664 # Add levee package instead of vim-tiny
640 if [ "$REDUCE_VIM" = true ] ; then
665 if [ "$REDUCE_VIM" = true ] ; then
641 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
666 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
642 fi
667 fi
643
668
644 # Add dropbear package instead of openssh-server
669 # Add dropbear package instead of openssh-server
645 if [ "$REDUCE_SSHD" = true ] ; then
670 if [ "$REDUCE_SSHD" = true ] ; then
646 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
671 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
647 fi
672 fi
648 fi
673 fi
649
674
650 # Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available
675 # Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available
651 if [ "$ENABLE_SYSVINIT" = false ] ; then
676 if [ "$ENABLE_SYSVINIT" = false ] ; then
652 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
677 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
653 fi
678 fi
654
679
655 # Configure kernel sources if no KERNELSRC_DIR
680 # Configure kernel sources if no KERNELSRC_DIR
656 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
681 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
657 KERNELSRC_CONFIG=true
682 KERNELSRC_CONFIG=true
658 fi
683 fi
659
684
660 # Configure reduced kernel
685 # Configure reduced kernel
661 if [ "$KERNEL_REDUCE" = true ] ; then
686 if [ "$KERNEL_REDUCE" = true ] ; then
662 KERNELSRC_CONFIG=false
687 KERNELSRC_CONFIG=false
663 fi
688 fi
664
689
665 # Configure qemu compatible kernel
690 # Configure qemu compatible kernel
666 if [ "$ENABLE_QEMU" = true ] ; then
691 if [ "$ENABLE_QEMU" = true ] ; then
667 DTB_FILE=vexpress-v2p-ca15_a7.dtb
692 DTB_FILE=vexpress-v2p-ca15_a7.dtb
668 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
693 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
669 KERNEL_DEFCONFIG="vexpress_defconfig"
694 KERNEL_DEFCONFIG="vexpress_defconfig"
670 if [ "$KERNEL_MENUCONFIG" = false ] ; then
695 if [ "$KERNEL_MENUCONFIG" = false ] ; then
671 KERNEL_OLDDEFCONFIG=true
696 KERNEL_OLDDEFCONFIG=true
672 fi
697 fi
673 fi
698 fi
674
699
675 # Execute bootstrap scripts
700 # Execute bootstrap scripts
676 for SCRIPT in bootstrap.d/*.sh; do
701 for SCRIPT in bootstrap.d/*.sh; do
677 head -n 3 "$SCRIPT"
702 head -n 3 "$SCRIPT"
678 . "$SCRIPT"
703 . "$SCRIPT"
679 done
704 done
680
705
681 ## Execute custom bootstrap scripts
706 ## Execute custom bootstrap scripts
682 if [ -d "custom.d" ] ; then
707 if [ -d "custom.d" ] ; then
683 for SCRIPT in custom.d/*.sh; do
708 for SCRIPT in custom.d/*.sh; do
684 . "$SCRIPT"
709 . "$SCRIPT"
685 done
710 done
686 fi
711 fi
687
712
688 # Execute custom scripts inside the chroot
713 # Execute custom scripts inside the chroot
689 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
714 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
690 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
715 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
691 chroot_exec /bin/bash -x <<'EOF'
716 chroot_exec /bin/bash -x <<'EOF'
692 for SCRIPT in /chroot_scripts/* ; do
717 for SCRIPT in /chroot_scripts/* ; do
693 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
718 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
694 $SCRIPT
719 $SCRIPT
695 fi
720 fi
696 done
721 done
697 EOF
722 EOF
698 rm -rf "${R}/chroot_scripts"
723 rm -rf "${R}/chroot_scripts"
699 fi
724 fi
700
725
701 # Remove c/c++ build environment from the chroot
726 # Remove c/c++ build environment from the chroot
702 chroot_remove_cc
727 chroot_remove_cc
703
728
704 # Generate required machine-id
729 # Generate required machine-id
705 MACHINE_ID=$(dbus-uuidgen)
730 MACHINE_ID=$(dbus-uuidgen)
706 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
731 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
707 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
732 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
708
733
709 # APT Cleanup
734 # APT Cleanup
710 chroot_exec apt-get -y clean
735 chroot_exec apt-get -y clean
711 chroot_exec apt-get -y autoclean
736 chroot_exec apt-get -y autoclean
712 chroot_exec apt-get -y autoremove
737 chroot_exec apt-get -y autoremove
713
738
714 # Unmount mounted filesystems
739 # Unmount mounted filesystems
715 umount -l "${R}/proc"
740 umount -l "${R}/proc"
716 umount -l "${R}/sys"
741 umount -l "${R}/sys"
717
742
718 # Clean up directories
743 # Clean up directories
719 rm -rf "${R}/run/*"
744 rm -rf "${R}/run/*"
720 rm -rf "${R}/tmp/*"
745 rm -rf "${R}/tmp/*"
721
746
722 # Clean up APT proxy settings
747 # Clean up APT proxy settings
723 if [ "$KEEP_APT_PROXY" = false ] ; then
748 if [ "$KEEP_APT_PROXY" = false ] ; then
724 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
749 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
725 fi
750 fi
726
751
727 # Clean up files
752 # Clean up files
728 rm -f "${ETC_DIR}/ssh/ssh_host_*"
753 rm -f "${ETC_DIR}/ssh/ssh_host_*"
729 rm -f "${ETC_DIR}/dropbear/dropbear_*"
754 rm -f "${ETC_DIR}/dropbear/dropbear_*"
730 rm -f "${ETC_DIR}/apt/sources.list.save"
755 rm -f "${ETC_DIR}/apt/sources.list.save"
731 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
756 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
732 rm -f "${ETC_DIR}/*-"
757 rm -f "${ETC_DIR}/*-"
733 rm -f "${ETC_DIR}/resolv.conf"
758 rm -f "${ETC_DIR}/resolv.conf"
734 rm -f "${R}/root/.bash_history"
759 rm -f "${R}/root/.bash_history"
735 rm -f "${R}/var/lib/urandom/random-seed"
760 rm -f "${R}/var/lib/urandom/random-seed"
736 rm -f "${R}/initrd.img"
761 rm -f "${R}/initrd.img"
737 rm -f "${R}/vmlinuz"
762 rm -f "${R}/vmlinuz"
738 rm -f "${R}${QEMU_BINARY}"
763 rm -f "${R}${QEMU_BINARY}"
739
764
740 if [ "$ENABLE_QEMU" = true ] ; then
765 if [ "$ENABLE_QEMU" = true ] ; then
741 # Setup QEMU directory
766 # Setup QEMU directory
742 mkdir "${BASEDIR}/qemu"
767 mkdir "${BASEDIR}/qemu"
743
768
744 # Copy kernel image to QEMU directory
769 # Copy kernel image to QEMU directory
745 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
770 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
746
771
747 # Copy kernel config to QEMU directory
772 # Copy kernel config to QEMU directory
748 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
773 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
749
774
750 # Copy kernel dtbs to QEMU directory
775 # Copy kernel dtbs to QEMU directory
751 for dtb in "${BOOT_DIR}/"*.dtb ; do
776 for dtb in "${BOOT_DIR}/"*.dtb ; do
752 if [ -f "${dtb}" ] ; then
777 if [ -f "${dtb}" ] ; then
753 install_readonly "${dtb}" "${BASEDIR}/qemu/"
778 install_readonly "${dtb}" "${BASEDIR}/qemu/"
754 fi
779 fi
755 done
780 done
756
781
757 # Copy kernel overlays to QEMU directory
782 # Copy kernel overlays to QEMU directory
758 if [ -d "${BOOT_DIR}/overlays" ] ; then
783 if [ -d "${BOOT_DIR}/overlays" ] ; then
759 # Setup overlays dtbs directory
784 # Setup overlays dtbs directory
760 mkdir "${BASEDIR}/qemu/overlays"
785 mkdir "${BASEDIR}/qemu/overlays"
761
786
762 for dtb in "${BOOT_DIR}/overlays/"*.dtbo ; do
787 for dtb in "${BOOT_DIR}/overlays/"*.dtbo ; do
763 if [ -f "${dtb}" ] ; then
788 if [ -f "${dtb}" ] ; then
764 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
789 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
765 fi
790 fi
766 done
791 done
767 fi
792 fi
768
793
769 # Copy u-boot files to QEMU directory
794 # Copy u-boot files to QEMU directory
770 if [ "$ENABLE_UBOOT" = true ] ; then
795 if [ "$ENABLE_UBOOT" = true ] ; then
771 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
796 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
772 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
797 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
773 fi
798 fi
774 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
799 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
775 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
800 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
776 fi
801 fi
777 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
802 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
778 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
803 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
779 fi
804 fi
780 fi
805 fi
781
806
782 # Copy initramfs to QEMU directory
807 # Copy initramfs to QEMU directory
783 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
808 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
784 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
809 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
785 fi
810 fi
786 fi
811 fi
787
812
788 # Calculate size of the chroot directory in KB
813 # Calculate size of the chroot directory in KB
789 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
814 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
790
815
791 # Calculate the amount of needed 512 Byte sectors
816 # Calculate the amount of needed 512 Byte sectors
792 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
817 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
793 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
818 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
794 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
819 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
795
820
796 # The root partition is EXT4
821 # The root partition is EXT4
797 # This means more space than the actual used space of the chroot is used.
822 # This means more space than the actual used space of the chroot is used.
798 # As overhead for journaling and reserved blocks 35% are added.
823 # As overhead for journaling and reserved blocks 35% are added.
799 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
824 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
800
825
801 # Calculate required image size in 512 Byte sectors
826 # Calculate required image size in 512 Byte sectors
802 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
827 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
803
828
804 # Prepare image file
829 # Prepare image file
805 if [ "$ENABLE_SPLITFS" = true ] ; then
830 if [ "$ENABLE_SPLITFS" = true ] ; then
806 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
831 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
807 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
832 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
808 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
833 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
809 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
834 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
810
835
811 # Write firmware/boot partition tables
836 # Write firmware/boot partition tables
812 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
837 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
813 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
838 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
814 EOM
839 EOM
815
840
816 # Write root partition table
841 # Write root partition table
817 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
842 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
818 ${TABLE_SECTORS},${ROOT_SECTORS},83
843 ${TABLE_SECTORS},${ROOT_SECTORS},83
819 EOM
844 EOM
820
845
821 # Setup temporary loop devices
846 # Setup temporary loop devices
822 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
847 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
823 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
848 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
824 else # ENABLE_SPLITFS=false
849 else # ENABLE_SPLITFS=false
825 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
850 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
826 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
851 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
827
852
828 # Write partition table
853 # Write partition table
829 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
854 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
830 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
855 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
831 ${ROOT_OFFSET},${ROOT_SECTORS},83
856 ${ROOT_OFFSET},${ROOT_SECTORS},83
832 EOM
857 EOM
833
858
834 # Setup temporary loop devices
859 # Setup temporary loop devices
835 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
860 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
836 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
861 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
837 fi
862 fi
838
863
839 if [ "$ENABLE_CRYPTFS" = true ] ; then
864 if [ "$ENABLE_CRYPTFS" = true ] ; then
840 # Create dummy ext4 fs
865 # Create dummy ext4 fs
841 mkfs.ext4 "$ROOT_LOOP"
866 mkfs.ext4 "$ROOT_LOOP"
842
867
843 # Setup password keyfile
868 # Setup password keyfile
844 touch .password
869 touch .password
845 chmod 600 .password
870 chmod 600 .password
846 echo -n ${CRYPTFS_PASSWORD} > .password
871 echo -n ${CRYPTFS_PASSWORD} > .password
847
872
848 # Initialize encrypted partition
873 # Initialize encrypted partition
874 <<<<<<< HEAD
849 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
875 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
876 =======
877 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
850 cryptsetup --verbose --debug -q luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -h "${CRYPTFS_HASH}" -s "${CRYPTFS_XTSKEYSIZE}" .password
878 cryptsetup --verbose --debug -q luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -h "${CRYPTFS_HASH}" -s "${CRYPTFS_XTSKEYSIZE}" .password
851
879
852 # Open encrypted partition and setup mapping
880 # Open encrypted partition and setup mapping
853 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
881 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
854
882
855 # Secure delete password keyfile
883 # Secure delete password keyfile
856 shred -zu .password
884 shred -zu .password
857
885
858 # Update temporary loop device
886 # Update temporary loop device
859 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
887 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
860
888
861 # Wipe encrypted partition (encryption cipher is used for randomness)
889 # Wipe encrypted partition (encryption cipher is used for randomness)
862 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
890 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
863 fi
891 fi
864
892
865 # Build filesystems
893 # Build filesystems
866 mkfs.vfat "$FRMW_LOOP"
894 mkfs.vfat "$FRMW_LOOP"
867 mkfs.ext4 "$ROOT_LOOP"
895 mkfs.ext4 "$ROOT_LOOP"
868
896
869 # Mount the temporary loop devices
897 # Mount the temporary loop devices
870 mkdir -p "$BUILDDIR/mount"
898 mkdir -p "$BUILDDIR/mount"
871 mount "$ROOT_LOOP" "$BUILDDIR/mount"
899 mount "$ROOT_LOOP" "$BUILDDIR/mount"
872
900
873 mkdir -p "$BUILDDIR/mount/boot/firmware"
901 mkdir -p "$BUILDDIR/mount/boot/firmware"
874 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
902 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
875
903
876 # Copy all files from the chroot to the loop device mount point directory
904 # Copy all files from the chroot to the loop device mount point directory
877 rsync -a "${R}/" "$BUILDDIR/mount/"
905 rsync -a "${R}/" "$BUILDDIR/mount/"
878
906
879 # Unmount all temporary loop devices and mount points
907 # Unmount all temporary loop devices and mount points
880 cleanup
908 cleanup
881
909
882 # Create block map file(s) of image(s)
910 # Create block map file(s) of image(s)
883 if [ "$ENABLE_SPLITFS" = true ] ; then
911 if [ "$ENABLE_SPLITFS" = true ] ; then
884 # Create block map files for "bmaptool"
912 # Create block map files for "bmaptool"
885 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
913 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
886 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
914 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
887
915
888 # Image was successfully created
916 # Image was successfully created
889 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
917 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
890 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
918 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
891 else
919 else
892 # Create block map file for "bmaptool"
920 # Create block map file for "bmaptool"
893 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
921 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
894
922
895 # Image was successfully created
923 # Image was successfully created
896 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
924 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
897
925
898 # Create qemu qcow2 image
926 # Create qemu qcow2 image
899 if [ "$ENABLE_QEMU" = true ] ; then
927 if [ "$ENABLE_QEMU" = true ] ; then
900 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
928 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
901 QEMU_SIZE=16G
929 QEMU_SIZE=16G
902
930
903 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
931 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
904 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
932 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
905
933
906 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
934 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
907 fi
935 fi
908 fi
936 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant