##// 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 # rpi23-gen-image
1 # rpi23-gen-image
2 ## Introduction
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 ## Build dependencies
5 ## Build dependencies
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.
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 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.
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.
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.
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 ```
22
13
23 ## Command-line parameters
14 ## Command-line parameters
24 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.
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 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.
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 ##### `APT_PROXY`=""
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 ##### `APT_INCLUDES`=""
51 ##### `APT_INCLUDES`=""
61 A comma separated list of additional packages to be installed by debootstrap during bootstrapping.
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 #### General system settings:
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 ##### `RPI_MODEL`=2
64 ##### `RPI_MODEL`=2
70 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
65 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
71 `0` = Used for Raspberry Pi 0 and Raspberry Pi 0 W
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 `3P` = Used for Pi 3 model B+
71 `3P` = Used for Pi 3 model B+
77 `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used.
72 `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used.
78
73
79 ##### `RELEASE`="jessie"
74 ##### `RELEASE`="buster"
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.
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 ##### `RELEASE_ARCH`="armhf"
77 ##### `RELEASE_ARCH`="armhf"
83 Set the desired Debian release architecture.
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 ##### Flashing examples:
449 ##### Flashing examples:
455 ```shell
450 ```shell
456 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie.img /dev/mmcblk0
451 bmaptool copy ./images/buster/2017-01-23-rpi3-buster.img /dev/mmcblk0
457 dd bs=4M if=./images/jessie/2017-01-23-rpi3-jessie.img of=/dev/mmcblk0
452 dd bs=4M if=./images/buster/2017-01-23-rpi3-buster.img of=/dev/mmcblk0
458 ```
453 ```
459 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
454 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
460 ```shell
455 ```shell
461 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-frmw.img /dev/mmcblk0
456 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-frmw.img /dev/mmcblk0
462 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-root.img /dev/sdc
457 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-root.img /dev/sdc
463 ```
458 ```
464
459
465 ## QEMU emulation
460 ## QEMU emulation
@@ -19,7 +19,7 if [ "$ENABLE_MINBASE" = true ] ; then
19 fi
19 fi
20
20
21 # Base debootstrap (unpack only)
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 # Copy qemu emulator binary to chroot
24 # Copy qemu emulator binary to chroot
25 install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}"
25 install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}"
@@ -12,28 +12,12 if [ -z "$APT_PROXY" ] ; then
12 fi
12 fi
13
13
14 if [ "$BUILD_KERNEL" = false ] ; then
14 if [ "$BUILD_KERNEL" = false ] ; then
15 # Install APT pinning configuration for flash-kernel package
15 echo "Downloading precompiled kernel"
16 install_readonly files/apt/flash-kernel "${ETC_DIR}/apt/preferences.d/flash-kernel"
16 echo "error: not configured"
17
17 exit 1;
18 # Install APT sources.list
18 # BUILD_KERNEL=true
19 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
19 else
20 echo "deb ${COLLABORA_URL} ${RELEASE} rpi2" >> "${ETC_DIR}/apt/sources.list"
20 echo "No precompiled kernel repositories were added"
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"
37 fi
21 fi
38
22
39 # Upgrade package index and update all installed packages and changed dependencies
23 # Upgrade package index and update all installed packages and changed dependencies
@@ -42,9 +42,9 fi
42
42
43 # Setup firmware boot cmdline
43 # Setup firmware boot cmdline
44 if [ "$ENABLE_SPLITFS" = true ] ; then
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 else
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 fi
48 fi
49
49
50 # Add encrypted root partition to cmdline.txt
50 # Add encrypted root partition to cmdline.txt
@@ -73,11 +73,6 else
73 CMDLINE="${CMDLINE} net.ifnames=1"
73 CMDLINE="${CMDLINE} net.ifnames=1"
74 fi
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 # Install firmware boot cmdline
76 # Install firmware boot cmdline
82 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
77 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
83
78
@@ -7,11 +7,11
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/^rpi2-jessie/${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/rpi2-jessie/${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
@@ -65,13 +65,12 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network"
65 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network"
65 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network"
66
66
67 # Move systemd network configuration if required by Debian release
67 # Move systemd network configuration if required by Debian release
68 if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
68 mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network"
69 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
70 if [ "$ENABLE_WIRELESS" = true ] ; then
71 mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network"
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"
74 fi
72 fi
73 rm -fr "${ETC_DIR}/systemd/network"
75
74
76 # Enable systemd-networkd service
75 # Enable systemd-networkd service
77 chroot_exec systemctl enable systemd-networkd
76 chroot_exec systemctl enable systemd-networkd
@@ -11,9 +11,7 if [ "$ENABLE_IPTABLES" = true ] ; then
11
11
12 # make sure iptables-legacy is the used alternatives
12 # make sure iptables-legacy is the used alternatives
13 #iptables-save and -restore are slaves of iptables and thus are set accordingly
13 #iptables-save and -restore are slaves of iptables and thus are set accordingly
14 if ! [ "$RELEASE" = jessie ] ; then
14 chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy
15 chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy
16 fi
17
15
18 # Install iptables systemd service
16 # Install iptables systemd service
19 install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service"
17 install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service"
@@ -28,11 +28,7 if [ "$ENABLE_FBTURBO" = true ] ; then
28 fi
28 fi
29
29
30 # Install Xorg build dependencies
30 # Install Xorg build dependencies
31 if [ "$RELEASE" = "jessie" ] ; then
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
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
36
32
37 # Build and install fbturbo driver inside chroot
33 # Build and install fbturbo driver inside chroot
38 chroot_exec /bin/bash -x <<'EOF'
34 chroot_exec /bin/bash -x <<'EOF'
@@ -46,12 +46,8 if [ "$ENABLE_REDUCE" = true ] ; then
46
46
47 # Replace bash shell by dash shell (experimental)
47 # Replace bash shell by dash shell (experimental)
48 if [ "$REDUCE_BASH" = true ] ; then
48 if [ "$REDUCE_BASH" = true ] ; then
49 if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
49 # Purge bash and update alternatives
50 echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --allow-remove-essential bash
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
55 chroot_exec update-alternatives --install /bin/bash bash /bin/dash 100
51 chroot_exec update-alternatives --install /bin/bash bash /bin/dash 100
56 fi
52 fi
57
53
@@ -60,11 +56,6 if [ "$ENABLE_REDUCE" = true ] ; then
60 chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 libasound2 libasound2-data
56 chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 libasound2 libasound2-data
61 fi
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 # Remove GPU kernels
59 # Remove GPU kernels
69 if [ "$ENABLE_MINGPU" = true ] ; then
60 if [ "$ENABLE_MINGPU" = true ] ; then
70 rm -f "${BOOT_DIR}/start.elf"
61 rm -f "${BOOT_DIR}/start.elf"
@@ -1,1 +1,1
1 rpi2-jessie
1 RaspberryPI
@@ -1,5 +1,5
1 127.0.0.1 localhost
1 127.0.0.1 localhost
2 127.0.1.1 rpi2-jessie
2 127.0.1.1 RaspberryPI
3
3
4 ::1 localhost ip6-localhost ip6-loopback
4 ::1 localhost ip6-localhost ip6-loopback
5 ff02::1 ip6-allnodes
5 ff02::1 ip6-allnodes
@@ -63,12 +63,8 chroot_install_cc() {
63 # Install c/c++ build environment inside the chroot
63 # Install c/c++ build environment inside the chroot
64 if [ -z "${COMPILER_PACKAGES}" ] ; then
64 if [ -z "${COMPILER_PACKAGES}" ] ; then
65 COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }')
65 COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }')
66
66 # Install COMPILER_PACKAGES in chroot
67 if [ "$RELEASE" = "jessie" ] ; then
67 chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES}
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
72 fi
68 fi
73 }
69 }
74
70
@@ -1,9 +1,8
1 #!/bin/sh
1 #!/bin/sh
2
3 ########################################################################
2 ########################################################################
4 # rpi23-gen-image.sh 2015-2017
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 # This program is free software; you can redistribute it and/or
7 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
8 # modify it under the terms of the GNU General Public License
@@ -43,57 +42,10 set -x
43 # Raspberry Pi model configuration
42 # Raspberry Pi model configuration
44 RPI_MODEL=${RPI_MODEL:=2}
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 # Debian release
45 # Debian release
71 RELEASE=${RELEASE:=jessie}
46 RELEASE=${RELEASE:=buster}
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
91
47
92 if [ "$RELEASE_ARCH" = "arm64" ] ; then
48 #Kernel Branch
93 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
94 else
95 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
96 fi
97 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
49 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
98
50
99 # URLs
51 # URLs
@@ -103,7 +55,7 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-no
103 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
55 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
104 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
56 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
105 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
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 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
59 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
108
60
109 # Build directories
61 # Build directories
@@ -130,6 +82,7 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
130 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
82 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
131
83
132 # General settings
84 # General settings
85 SET_ARCH=${SET_ARCH:=32}
133 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
86 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
134 PASSWORD=${PASSWORD:=raspberry}
87 PASSWORD=${PASSWORD:=raspberry}
135 USER_PASSWORD=${USER_PASSWORD:=raspberry}
88 USER_PASSWORD=${USER_PASSWORD:=raspberry}
@@ -204,7 +157,7 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
204 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
157 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
205
158
206 # Kernel compilation settings
159 # Kernel compilation settings
207 BUILD_KERNEL=${BUILD_KERNEL:=false}
160 BUILD_KERNEL=${BUILD_KERNEL:=true}
208 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
161 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
209 KERNEL_THREADS=${KERNEL_THREADS:=1}
162 KERNEL_THREADS=${KERNEL_THREADS:=1}
210 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
163 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
@@ -213,12 +166,6 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
213 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
166 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
214 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
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 # Kernel compilation from source directory settings
169 # Kernel compilation from source directory settings
223 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
170 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
224 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
171 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
@@ -247,7 +194,7 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
247
194
248 # Packages required in the chroot build environment
195 # Packages required in the chroot build environment
249 APT_INCLUDES=${APT_INCLUDES:=""}
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 #Packages to exclude from chroot build environment
199 #Packages to exclude from chroot build environment
253 APT_EXCLUDES=${APT_EXCLUDES:=""}
200 APT_EXCLUDES=${APT_EXCLUDES:=""}
@@ -266,36 +213,113 if [ "$ENABLE_SYSVINIT" = false ] ; then
266 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
213 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
267 fi
214 fi
268
215
269 # Set Raspberry Pi model specific configuration
216 #Check if apt-cacher-ng has its default port open on and set APT_PROXY
270 if [ "$RPI_MODEL" = 0 ] ; then
217 if [ -n "$(lsof -i :3142)" ] ; then
271 DTB_FILE=${RPI0_DTB_FILE}
218 HTTP_PROXY=http://127.0.0.1:3142/
272 UBOOT_CONFIG=${RPI0_UBOOT_CONFIG}
219 fi
273 elif [ "$RPI_MODEL" = 1 ] ; then
220
274 DTB_FILE=${RPI1_DTB_FILE}
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!
275 UBOOT_CONFIG=${RPI1_UBOOT_CONFIG}
222 if [ -n "$SET_ARCH" ] ; then
276 elif [ "$RPI_MODEL" = 1P ] ; then
223 echo "Setting Architecture specific settings"
277 DTB_FILE=${RPI1P_DTB_FILE}
224 ##################################
278 UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG}
225 # 64 bit config
279 elif [ "$RPI_MODEL" = 2 ] ; then
226 ##################################
280 DTB_FILE=${RPI2_DTB_FILE}
227 if [ "$SET_ARCH" = 64 ] ; then
281 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
228 echo "64 bit mode selected - Setting up enviroment"
282 elif [ "$RPI_MODEL" = 3 ] ; then
229 # 64 bit depended settings
283 DTB_FILE=${RPI3_DTB_FILE}
230 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
284 UBOOT_CONFIG=${RPI3_UBOOT_CONFIG}
231 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
285 elif [ "$RPI_MODEL" = 3P ] ; then
232 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
286 DTB_FILE=${RPI3P_DTB_FILE}
233
287 UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG}
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 else
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 exit 1
277 exit 1
291 fi
278 fi
292
279
293 # Check if the internal wireless interface is supported by the RPi model
280 #Device specific configuration and uboot-config
294 if [ "$ENABLE_WIRELESS" = true ] && ([ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ]); then
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"
314 # Check if the internal wireless interface is supported by the RPi model
297 exit 1
315 if [ "$ENABLE_WIRELESS" = true ] ; then
298 fi
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 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
324 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
301 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
325 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
@@ -305,26 +329,6 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
305 fi
329 fi
306 fi
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 if [ "$ENABLE_VIDEOCORE" = true ] ; then
332 if [ "$ENABLE_VIDEOCORE" = true ] ; then
329 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
333 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
330 fi
334 fi
@@ -358,7 +362,7 fi
358
362
359 # Add device-tree-compiler required for building the U-Boot bootloader
363 # Add device-tree-compiler required for building the U-Boot bootloader
360 if [ "$ENABLE_UBOOT" = true ] ; then
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 fi
366 fi
363
367
364 # Check if root SSH (v2) public key file exists
368 # Check if root SSH (v2) public key file exists
@@ -470,11 +474,6 if [ "$ENABLE_MINBASE" = true ] ; then
470 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
474 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
471 fi
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 # Add parted package, required to get partprobe utility
477 # Add parted package, required to get partprobe utility
479 if [ "$EXPANDROOT" = true ] ; then
478 if [ "$EXPANDROOT" = true ] ; then
480 APT_INCLUDES="${APT_INCLUDES},parted"
479 APT_INCLUDES="${APT_INCLUDES},parted"
@@ -537,10 +536,6 if [ "$ENABLE_REDUCE" = true ] ; then
537 fi
536 fi
538 fi
537 fi
539
538
540 if [ "$RELEASE" != "jessie" ] ; then
541 APT_INCLUDES="${APT_INCLUDES},libnss-systemd"
542 fi
543
544 # Configure kernel sources if no KERNELSRC_DIR
539 # Configure kernel sources if no KERNELSRC_DIR
545 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
540 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
546 KERNELSRC_CONFIG=true
541 KERNELSRC_CONFIG=true
@@ -590,11 +585,6 fi
590 # Remove c/c++ build environment from the chroot
585 # Remove c/c++ build environment from the chroot
591 chroot_remove_cc
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 # Generate required machine-id
588 # Generate required machine-id
599 MACHINE_ID=$(dbus-uuidgen)
589 MACHINE_ID=$(dbus-uuidgen)
600 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
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