##// END OF EJS Templates
Merge pull request #159 from burnbabyburn/refactor_mergeable...
drtyhlpr -
r386:ba5db7d5fd01 Fusion
parent child
Show More
@@ -1,6 +1,6
1 1 # rpi23-gen-image
2 2 ## Introduction
3 `rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for Raspberry Pi 2 (RPi2) and Raspberry Pi 3 (RPi3) computers. The script at this time supports the bootstrapping of the Debian (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```).
3 `rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for Raspberry Pi 2 (RPi2) and Raspberry Pi 3 (RPi3) computers. The script at this time supports the bootstrapping of the Debian (armhf) releases `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```).
4 4
5 5 ## Build dependencies
6 6 The following list of Debian packages must be installed on the build system because they are essentially required for the bootstrapping process. The script will check if all required packages are installed and missing packages will be installed automatically if confirmed by the user.
@@ -9,16 +9,7 The following list of Debian packages must be installed on the build system beca
9 9
10 10 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the RPi3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf) cross-compiler toolchain.
11 11
12 The script has been tested using the default `crossbuild-essential-armhf` toolchain meta package on Debian Linux `jessie` and `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information.
13
14 If a Debian Linux `jessie` build system is used it will be required to add the [Debian Cross-toolchains repository](http://emdebian.org/tools/debian/) first:
15
16 ```
17 echo "deb http://emdebian.org/tools/debian/ jessie main" > /etc/apt/sources.list.d/crosstools.list
18 sudo -u nobody wget -O - http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add -
19 dpkg --add-architecture armhf
20 apt-get update
21 ```
12 The script has been tested using the default `crossbuild-essential-armhf` toolchain meta package on Debian Linux and `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information.
22 13
23 14 ## Command-line parameters
24 15 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.
@@ -55,7 +46,7 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
55 46 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.
56 47
57 48 ##### `APT_PROXY`=""
58 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.
49 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.
59 50
60 51 ##### `APT_INCLUDES`=""
61 52 A comma separated list of additional packages to be installed by debootstrap during bootstrapping.
@@ -66,6 +57,10 A comma separated list of additional packages to be installed by apt after boots
66 57 ---
67 58
68 59 #### General system settings:
60 ##### `SET_ARCH`=32
61 Set Architecture to default 32bit. If you want to to compile 64bit (RPI3 or RPI3+) set it to `64`. This Option will set every needed crosscompiler or boeard specific option for a successful build.
62 If you want to change e.g. cross-compiler -> Templates alwys override defaults
63
69 64 ##### `RPI_MODEL`=2
70 65 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
71 66 `0` = Used for Raspberry Pi 0 and Raspberry Pi 0 W
@@ -76,8 +71,8 Specifiy the target Raspberry Pi hardware model. The script at this time support
76 71 `3P` = Used for Pi 3 model B+
77 72 `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used.
78 73
79 ##### `RELEASE`="jessie"
80 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "jessie", "stretch" and "buster". `BUILD_KERNEL`=true will automatically be set if the Debian releases `stretch` or `buster` are used.
74 ##### `RELEASE`="buster"
75 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "stretch" and "buster". `BUILD_KERNEL`=true will automatically be set if the Debian releases `stretch` or `buster` are used.
81 76
82 77 ##### `RELEASE_ARCH`="armhf"
83 78 Set the desired Debian release architecture.
@@ -453,13 +448,13 After the image file was successfully created by the `rpi23-gen-image.sh` script
453 448
454 449 ##### Flashing examples:
455 450 ```shell
456 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie.img /dev/mmcblk0
457 dd bs=4M if=./images/jessie/2017-01-23-rpi3-jessie.img of=/dev/mmcblk0
451 bmaptool copy ./images/buster/2017-01-23-rpi3-buster.img /dev/mmcblk0
452 dd bs=4M if=./images/buster/2017-01-23-rpi3-buster.img of=/dev/mmcblk0
458 453 ```
459 454 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
460 455 ```shell
461 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-frmw.img /dev/mmcblk0
462 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-root.img /dev/sdc
456 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-frmw.img /dev/mmcblk0
457 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-root.img /dev/sdc
463 458 ```
464 459
465 460 ## QEMU emulation
@@ -19,7 +19,7 if [ "$ENABLE_MINBASE" = true ] ; then
19 19 fi
20 20
21 21 # Base debootstrap (unpack only)
22 http_proxy=${APT_PROXY} debootstrap "${APT_EXCLUDES}" --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian"
22 http_proxy=${APT_PROXY} debootstrap ${APT_EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian"
23 23
24 24 # Copy qemu emulator binary to chroot
25 25 install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}"
@@ -12,28 +12,12 if [ -z "$APT_PROXY" ] ; then
12 12 fi
13 13
14 14 if [ "$BUILD_KERNEL" = false ] ; then
15 # Install APT pinning configuration for flash-kernel package
16 install_readonly files/apt/flash-kernel "${ETC_DIR}/apt/preferences.d/flash-kernel"
17
18 # Install APT sources.list
19 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
20 echo "deb ${COLLABORA_URL} ${RELEASE} rpi2" >> "${ETC_DIR}/apt/sources.list"
21
22 # Upgrade collabora package index and install collabora keyring
23 chroot_exec apt-get -qq -y update
24 chroot_exec apt-get -qq -y --allow-unauthenticated install collabora-obs-archive-keyring
25 else # BUILD_KERNEL=true
26 # Install APT sources.list
27 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
28
29 # Use specified APT server and release
30 sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "${ETC_DIR}/apt/sources.list"
31 sed -i "s/ jessie/ ${RELEASE}/" "${ETC_DIR}/apt/sources.list"
32 fi
33
34 # Allow the installation of non-free Debian packages
35 if [ "$ENABLE_NONFREE" = true ] ; then
36 sed -i "s/ contrib/ contrib non-free/" "${ETC_DIR}/apt/sources.list"
15 echo "Downloading precompiled kernel"
16 echo "error: not configured"
17 exit 1;
18 # BUILD_KERNEL=true
19 else
20 echo "No precompiled kernel repositories were added"
37 21 fi
38 22
39 23 # Upgrade package index and update all installed packages and changed dependencies
@@ -42,9 +42,9 fi
42 42
43 43 # Setup firmware boot cmdline
44 44 if [ "$ENABLE_SPLITFS" = true ] ; then
45 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1"
45 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
46 46 else
47 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1"
47 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
48 48 fi
49 49
50 50 # Add encrypted root partition to cmdline.txt
@@ -73,11 +73,6 else
73 73 CMDLINE="${CMDLINE} net.ifnames=1"
74 74 fi
75 75
76 # Set init to systemd if required by Debian release
77 if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
78 CMDLINE="${CMDLINE} init=/bin/systemd"
79 fi
80
81 76 # Install firmware boot cmdline
82 77 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
83 78
@@ -7,11 +7,11
7 7
8 8 # Install and setup hostname
9 9 install_readonly files/network/hostname "${ETC_DIR}/hostname"
10 sed -i "s/^rpi2-jessie/${HOSTNAME}/" "${ETC_DIR}/hostname"
10 sed -i "s/^RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hostname"
11 11
12 12 # Install and setup hosts
13 13 install_readonly files/network/hosts "${ETC_DIR}/hosts"
14 sed -i "s/rpi2-jessie/${HOSTNAME}/" "${ETC_DIR}/hosts"
14 sed -i "s/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts"
15 15
16 16 # Setup hostname entry with static IP
17 17 if [ "$NET_ADDRESS" != "" ] ; then
@@ -65,13 +65,12 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network"
65 65 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network"
66 66
67 67 # Move systemd network configuration if required by Debian release
68 if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
69 mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network"
70 if [ "$ENABLE_WIRELESS" = true ] ; then
71 mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network"
72 fi
73 rm -fr "${ETC_DIR}/systemd/network"
68 mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network"
69 # If WLAN is enabled copy wlan configuration too
70 if [ "$ENABLE_WIRELESS" = true ] ; then
71 mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network"
74 72 fi
73 rm -fr "${ETC_DIR}/systemd/network"
75 74
76 75 # Enable systemd-networkd service
77 76 chroot_exec systemctl enable systemd-networkd
@@ -11,9 +11,7 if [ "$ENABLE_IPTABLES" = true ] ; then
11 11
12 12 # make sure iptables-legacy is the used alternatives
13 13 #iptables-save and -restore are slaves of iptables and thus are set accordingly
14 if ! [ "$RELEASE" = jessie ] ; then
15 chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy
16 fi
14 chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy
17 15
18 16 # Install iptables systemd service
19 17 install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service"
@@ -28,11 +28,7 if [ "$ENABLE_FBTURBO" = true ] ; then
28 28 fi
29 29
30 30 # Install Xorg build dependencies
31 if [ "$RELEASE" = "jessie" ] ; then
32 chroot_exec apt-get -q -y --no-install-recommends install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev
33 elif [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
34 chroot_exec apt-get -q -y --no-install-recommends --allow-unauthenticated install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev
35 fi
31 chroot_exec apt-get -q -y --no-install-recommends --allow-unauthenticated install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev
36 32
37 33 # Build and install fbturbo driver inside chroot
38 34 chroot_exec /bin/bash -x <<'EOF'
@@ -46,12 +46,8 if [ "$ENABLE_REDUCE" = true ] ; then
46 46
47 47 # Replace bash shell by dash shell (experimental)
48 48 if [ "$REDUCE_BASH" = true ] ; then
49 if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
50 echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --allow-remove-essential bash
51 else
52 echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --force-yes bash
53 fi
54
49 # Purge bash and update alternatives
50 echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --allow-remove-essential bash
55 51 chroot_exec update-alternatives --install /bin/bash bash /bin/dash 100
56 52 fi
57 53
@@ -60,11 +56,6 if [ "$ENABLE_REDUCE" = true ] ; then
60 56 chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 libasound2 libasound2-data
61 57 fi
62 58
63 # Re-install tools for managing kernel modules
64 if [ "$RELEASE" = "jessie" ] ; then
65 chroot_exec apt-get -qq -y install module-init-tools
66 fi
67
68 59 # Remove GPU kernels
69 60 if [ "$ENABLE_MINGPU" = true ] ; then
70 61 rm -f "${BOOT_DIR}/start.elf"
@@ -1,1 +1,1
1 rpi2-jessie
1 RaspberryPI
@@ -1,5 +1,5
1 1 127.0.0.1 localhost
2 127.0.1.1 rpi2-jessie
2 127.0.1.1 RaspberryPI
3 3
4 4 ::1 localhost ip6-localhost ip6-loopback
5 5 ff02::1 ip6-allnodes
@@ -63,12 +63,8 chroot_install_cc() {
63 63 # Install c/c++ build environment inside the chroot
64 64 if [ -z "${COMPILER_PACKAGES}" ] ; then
65 65 COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }')
66
67 if [ "$RELEASE" = "jessie" ] ; then
68 chroot_exec apt-get -q -y --no-install-recommends install ${COMPILER_PACKAGES}
69 elif [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
70 chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES}
71 fi
66 # Install COMPILER_PACKAGES in chroot
67 chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES}
72 68 fi
73 69 }
74 70
@@ -1,9 +1,8
1 1 #!/bin/sh
2
3 2 ########################################################################
4 3 # rpi23-gen-image.sh 2015-2017
5 4 #
6 # Advanced Debian "jessie", "stretch" and "buster" bootstrap script for RPi2/3
5 # Advanced Debian "stretch" and "buster" bootstrap script for RPi2/3
7 6 #
8 7 # This program is free software; you can redistribute it and/or
9 8 # modify it under the terms of the GNU General Public License
@@ -43,57 +42,10 set -x
43 42 # Raspberry Pi model configuration
44 43 RPI_MODEL=${RPI_MODEL:=2}
45 44
46 #bcm2708-rpi-0-w.dtb (Used for Pi 0 and PI 0W)
47 RPI0_DTB_FILE=${RPI0_DTB_FILE:=bcm2708-rpi-0-w.dtb}
48 RPI0_UBOOT_CONFIG=${RPI0_UBOOT_CONFIG:=rpi_defconfig}
49
50 #bcm2708-rpi-b.dtb (Used for Pi 1 model A and B)
51 RPI1_DTB_FILE=${RPI1_DTB_FILE:=bcm2708-rpi-b.dtb}
52 RPI1_UBOOT_CONFIG=${RPI1_UBOOT_CONFIG:=rpi_defconfig}
53
54 #bcm2708-rpi-b-plus.dtb (Used for Pi 1 model B+ and A+)
55 RPI1P_DTB_FILE=${RPI1P_DTB_FILE:=bcm2708-rpi-b-plus.dtb}
56 RPI1P_UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG:=rpi_defconfig}
57
58 #bcm2709-rpi-2-b.dtb (Used for Pi 2 model B)
59 RPI2_DTB_FILE=${RPI2_DTB_FILE:=bcm2709-rpi-2-b.dtb}
60 RPI2_UBOOT_CONFIG=${RPI2_UBOOT_CONFIG:=rpi_2_defconfig}
61
62 #bcm2710-rpi-3-b.dtb (Used for Pi 3 model B)
63 RPI3_DTB_FILE=${RPI3_DTB_FILE:=bcm2710-rpi-3-b.dtb}
64 RPI3_UBOOT_CONFIG=${RPI3_UBOOT_CONFIG:=rpi_3_32b_defconfig}
65
66 #bcm2710-rpi-3-b-plus.dtb (Used for Pi 3 model B+)
67 RPI3P_DTB_FILE=${RPI3P_DTB_FILE:=bcm2710-rpi-3-b-plus.dtb}
68 RPI3P_UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG:=rpi_3_32b_defconfig}
69
70 45 # Debian release
71 RELEASE=${RELEASE:=jessie}
72 KERNEL_ARCH=${KERNEL_ARCH:=arm}
73 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
74 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
75 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
76 if [ "$KERNEL_ARCH" = "arm64" ] ; then
77 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
78 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
79 fi
80
81 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
82 #RASPBERRY PI 1, PI ZERO, PI ZERO W, AND COMPUTE MODULE DEFAULT Kernel BUILD CONFIGURATION
83 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
84 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
85 else
86 #RASPBERRY PI 2, PI 3, PI 3+, AND COMPUTE MODULE 3 DEFAULT Kernel BUILD CONFIGURATION
87 #https://www.raspberrypi.org/documentation/linux/kernel/building.md
88 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
89 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
90 fi
46 RELEASE=${RELEASE:=buster}
91 47
92 if [ "$RELEASE_ARCH" = "arm64" ] ; then
93 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
94 else
95 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
96 fi
48 #Kernel Branch
97 49 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
98 50
99 51 # URLs
@@ -103,7 +55,7 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-no
103 55 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
104 56 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
105 57 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
106 VIDEOCORE_URL=${VIDEOCORE_URL=https://github.com/raspberrypi/userland}
58 VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland}
107 59 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
108 60
109 61 # Build directories
@@ -130,6 +82,7 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
130 82 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
131 83
132 84 # General settings
85 SET_ARCH=${SET_ARCH:=32}
133 86 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
134 87 PASSWORD=${PASSWORD:=raspberry}
135 88 USER_PASSWORD=${USER_PASSWORD:=raspberry}
@@ -204,7 +157,7 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
204 157 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
205 158
206 159 # Kernel compilation settings
207 BUILD_KERNEL=${BUILD_KERNEL:=false}
160 BUILD_KERNEL=${BUILD_KERNEL:=true}
208 161 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
209 162 KERNEL_THREADS=${KERNEL_THREADS:=1}
210 163 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
@@ -213,12 +166,6 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
213 166 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
214 167 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
215 168
216 if [ "$KERNEL_ARCH" = "arm64" ] ; then
217 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
218 else
219 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
220 fi
221
222 169 # Kernel compilation from source directory settings
223 170 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
224 171 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
@@ -247,7 +194,7 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
247 194
248 195 # Packages required in the chroot build environment
249 196 APT_INCLUDES=${APT_INCLUDES:=""}
250 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils"
197 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup"
251 198
252 199 #Packages to exclude from chroot build environment
253 200 APT_EXCLUDES=${APT_EXCLUDES:=""}
@@ -266,36 +213,113 if [ "$ENABLE_SYSVINIT" = false ] ; then
266 213 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
267 214 fi
268 215
269 # Set Raspberry Pi model specific configuration
270 if [ "$RPI_MODEL" = 0 ] ; then
271 DTB_FILE=${RPI0_DTB_FILE}
272 UBOOT_CONFIG=${RPI0_UBOOT_CONFIG}
273 elif [ "$RPI_MODEL" = 1 ] ; then
274 DTB_FILE=${RPI1_DTB_FILE}
275 UBOOT_CONFIG=${RPI1_UBOOT_CONFIG}
276 elif [ "$RPI_MODEL" = 1P ] ; then
277 DTB_FILE=${RPI1P_DTB_FILE}
278 UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG}
279 elif [ "$RPI_MODEL" = 2 ] ; then
280 DTB_FILE=${RPI2_DTB_FILE}
281 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
282 elif [ "$RPI_MODEL" = 3 ] ; then
283 DTB_FILE=${RPI3_DTB_FILE}
284 UBOOT_CONFIG=${RPI3_UBOOT_CONFIG}
285 elif [ "$RPI_MODEL" = 3P ] ; then
286 DTB_FILE=${RPI3P_DTB_FILE}
287 UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG}
216 #Check if apt-cacher-ng has its default port open on and set APT_PROXY
217 if [ -n "$(lsof -i :3142)" ] ; then
218 HTTP_PROXY=http://127.0.0.1:3142/
219 fi
220
221 #make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go!
222 if [ -n "$SET_ARCH" ] ; then
223 echo "Setting Architecture specific settings"
224 ##################################
225 # 64 bit config
226 ##################################
227 if [ "$SET_ARCH" = 64 ] ; then
228 echo "64 bit mode selected - Setting up enviroment"
229 # 64 bit depended settings
230 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
231 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
232 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
233
234 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
235 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
236 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
237 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
238 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
239 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
240 else
241 echo "error: Only Raspberry PI 3 and 3B+ support 64bit"
242 exit 1
243 fi
244 fi
245
246 ##################################
247 # 32 bit config
248 ##################################
249 if [ "$SET_ARCH" = 32 ] ; then
250 echo "32 bit mode selected - Setting up enviroment"
251 #General 32bit configuration
252 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
253 KERNEL_ARCH=${KERNEL_ARCH:=arm}
254 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
255
256 #Raspberry setting grouped by board compability
257 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
258 echo "Setting settings for bcm2835 Raspberry PI boards"
259 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
260 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
261 RELEASE_ARCH=${RELEASE_ARCH:=armel}
262 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
263 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
264 fi
265 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
266 echo "Setting settings for bcm2837 Raspberry PI boards"
267 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
268 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
269 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
270 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
271 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
272 fi
273 fi
274 #SET_ARCH not set
288 275 else
289 echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!"
276 echo "error: Please set '32' or '64' as value for SET_ARCH"
290 277 exit 1
291 278 fi
292 279
293 # Check if the internal wireless interface is supported by the RPi model
294 if [ "$ENABLE_WIRELESS" = true ] && ([ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ]); then
280 #Device specific configuration and uboot-config
281 echo "Select DTB-File"
282 case "$RPI_MODEL" in
283 0)
284 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
285 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
286 ;;
287 1)
288 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
289 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
290 ;;
291 1P)
292 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
293 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
294 ;;
295 2)
296 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
297 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
298 ;;
299 3)
300 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
301 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
302 ;;
303 3P)
304 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
305 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
306 ;;
307 *)
308 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
309 exit 1
310 ;;
311 esac
312 echo "$DTB_FILE selected"
295 313
296 echo "error: The selected Raspberry Pi model has no internal wireless interface"
297 exit 1
298 fi
314 # Check if the internal wireless interface is supported by the RPi model
315 if [ "$ENABLE_WIRELESS" = true ] ; then
316 if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then
317 echo "error: The selected Raspberry Pi model has no internal wireless interface"
318 exit 1
319 else
320 echo "Raspberry Pi $RPI_MODEL has WIFI support"
321 fi
322 fi
299 323
300 324 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
301 325 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
@@ -305,26 +329,6 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
305 329 fi
306 330 fi
307 331
308 # Build RPi2/3 Linux kernel if required by Debian release
309 if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
310 BUILD_KERNEL=true
311 fi
312
313 # Add packages required for kernel cross compilation
314 if [ "$BUILD_KERNEL" = true ] ; then
315 if [ "$KERNEL_ARCH" = "arm" ] ; then
316 if [ "$RELEASE_ARCH" = "armel" ]; then
317 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
318 fi
319 if [ "$RELEASE_ARCH" = "armhf" ]; then
320 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
321 fi
322 fi
323 if [ "$RELEASE_ARCH" = "arm64" ]; then
324 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
325 fi
326 fi
327
328 332 if [ "$ENABLE_VIDEOCORE" = true ] ; then
329 333 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
330 334 fi
@@ -358,7 +362,7 fi
358 362
359 363 # Add device-tree-compiler required for building the U-Boot bootloader
360 364 if [ "$ENABLE_UBOOT" = true ] ; then
361 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex"
365 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
362 366 fi
363 367
364 368 # Check if root SSH (v2) public key file exists
@@ -470,11 +474,6 if [ "$ENABLE_MINBASE" = true ] ; then
470 474 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
471 475 fi
472 476
473 # Add required locales packages
474 if [ "$DEFLOCAL" != "en_US.UTF-8" ] || ([ -n XKB_MODEL ] || [ -n XKB_LAYOUT ] || [ -n XKB_VARIANT ] || [ -n XKB_OPTIONS ]); then
475 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
476 fi
477
478 477 # Add parted package, required to get partprobe utility
479 478 if [ "$EXPANDROOT" = true ] ; then
480 479 APT_INCLUDES="${APT_INCLUDES},parted"
@@ -537,10 +536,6 if [ "$ENABLE_REDUCE" = true ] ; then
537 536 fi
538 537 fi
539 538
540 if [ "$RELEASE" != "jessie" ] ; then
541 APT_INCLUDES="${APT_INCLUDES},libnss-systemd"
542 fi
543
544 539 # Configure kernel sources if no KERNELSRC_DIR
545 540 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
546 541 KERNELSRC_CONFIG=true
@@ -590,11 +585,6 fi
590 585 # Remove c/c++ build environment from the chroot
591 586 chroot_remove_cc
592 587
593 # Remove apt-utils
594 if [ "$RELEASE" = "jessie" ] ; then
595 chroot_exec apt-get purge -qq -y --force-yes apt-utils
596 fi
597
598 588 # Generate required machine-id
599 589 MACHINE_ID=$(dbus-uuidgen)
600 590 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant