##// END OF EJS Templates
Merge branch 'master' into rpifegen
vidal -
r182:a67eae38695d Fusion
parent child
Show More
@@ -0,0 +1,15
1 # Configuration template file used by rpi23-gen-image.sh
2 # Debian Stretch using the Arm64 for kernel compilation and Debian distribution.
3
4 RPI_MODEL=3
5 RELEASE=stretch
6 BUILD_KERNEL=true
7 KERNEL_ARCH=arm64
8 RELEASE_ARCH=arm64
9 CROSS_COMPILE=aarch64-linux-gnu-
10 QEMU_BINARY=/usr/bin/qemu-aarch64-static
11 KERNEL_DEFCONFIG=bcmrpi3_defconfig
12 KERNEL_BIN_IMAGE=Image
13 KERNEL_IMAGE=kernel8.img
14 KERNEL_BRANCH=rpi-4.11.y
15 ENABLE_WIRELESS=true
@@ -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` and `stretch`. Raspberry Pi 3 images are currently generated for 32-bit mode only.
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` and `stretch`. 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.
@@ -58,7 +58,10 Set Debian packages server address. Choose a server from the list of Debian worl
58 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.
59 59
60 60 ##### `APT_INCLUDES`=""
61 A comma separated list of additional packages to be installed during bootstrapping.
61 A comma separated list of additional packages to be installed by debootstrap during bootstrapping.
62
63 ##### `APT_INCLUDES_LATE`=""
64 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.
62 65
63 66 ---
64 67
@@ -69,6 +72,9 Specifiy the target Raspberry Pi hardware model. The script at this time support
69 72 ##### `RELEASE`="jessie"
70 73 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "jessie" and "stretch". `BUILD_KERNEL`=true will automatically be set if the Debian release `stretch` is used.
71 74
75 ##### `RELEASE_ARCH`="armhf"
76 Set the desired Debian release architecture.
77
72 78 ##### `HOSTNAME`="rpi$RPI_MODEL-$RELEASE"
73 79 Set system host name. It's recommended that the host name is unique in the corresponding subnet.
74 80
@@ -89,7 +95,7 Expand the root partition and filesystem automatically on first boot.
89 95
90 96 ---
91 97
92 #### Keyboard settings:
98 #### Keyboard settings:
93 99 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.
94 100
95 101 ##### `XKB_MODEL`=""
@@ -259,6 +265,24 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enab
259 265 ##### `BUILD_KERNEL`=false
260 266 Build and install the latest RPi2/3 Linux kernel. Currently only the default RPi2/3 kernel configuration is used. `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` is used.
261 267
268 ##### `CROSS_COMPILE`="arm-linux-gnueabihf-"
269 This sets the cross compile enviornment for the compiler.
270
271 ##### `KERNEL_ARCH`="arm"
272 This sets the kernel architecture for the compiler.
273
274 ##### `KERNEL_IMAGE`="kernel7.img"
275 Name of the image file in the boot partition.
276
277 ##### `KERNEL_BRANCH`=""
278 Name of the requested branch from the GIT location for the RPi Kernel. Default is using the current default branch from the GIT site.
279
280 ##### `QEMU_BINARY`="/usr/bin/qemu-arm-static"
281 Sets the QEMU enviornment for the Debian archive.
282
283 ##### `KERNEL_DEFCONFIG`="bcm2709_defconfig"
284 Sets the default config for kernel compiling.
285
262 286 ##### `KERNEL_REDUCE`=false
263 287 Reduce the size of the generated kernel by removing unwanted device, network and filesystem drivers (experimental).
264 288
@@ -345,8 +369,8 Sets key size in bits. The argument has to be a multiple of 8.
345 369 ##### `BASEDIR`=$(pwd)/images/${RELEASE}
346 370 Set a path to a working directory used by the script to generate an image.
347 371
348 ##### `IMAGE_NAME`=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE}
349 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.
372 ##### `IMAGE_NAME`=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}
373 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.
350 374
351 375 ## Understanding the script
352 376 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:
@@ -412,6 +436,9 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, th
412 436 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-frmw.img /dev/mmcblk0
413 437 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-root.img /dev/sdc
414 438 ```
439 ## Weekly image builds
440 The image files are provided by JRWR'S I/O PORT and are built once a Sunday at midnight UTC!
441 * [Debian Stretch Raspberry Pi2/3 Weekly Image Builds](https://jrwr.io/doku.php?id=projects:debianpi)
415 442
416 443 ## External links and references
417 444 * [Debian worldwide mirror sites](https://www.debian.org/mirror/list)
@@ -27,8 +27,7 fi
27 27 # Base debootstrap (unpack only)
28 28 http_proxy=${APT_PROXY} debootstrap ${EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian"
29 29
30 # Copy qemu emulator binary to chroot modified for changes in _apt management in buster
31 #install_exec "${QEMU_BINARY}" "${R}${QEMU_BINARY}"
30 # Copy qemu emulator binary to chroot
32 31 install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}"
33 32
34 33 # Copy debian-archive-keyring.pgp
@@ -41,6 +41,10 fi
41 41 chroot_exec apt-get -qq -y update
42 42 chroot_exec apt-get -qq -y -u dist-upgrade
43 43
44 if [ "$APT_INCLUDES_LATE" ] ; then
45 chroot_exec apt-get -qq -y install $(echo $APT_INCLUDES_LATE |tr , ' ')
46 fi
47
44 48 if [ -d packages ] ; then
45 49 for package in packages/*.deb ; do
46 50 cp $package ${R}/tmp
@@ -21,10 +21,14 if [ "$BUILD_KERNEL" = true ] ; then
21 21 fi
22 22 else # KERNELSRC_DIR=""
23 23 # Create temporary directory for kernel sources
24 temp_dir=$(sudo -u nobody mktemp -d)
24 temp_dir=$(as_nobody mktemp -d)
25 25
26 26 # Fetch current RPi2/3 kernel sources
27 sudo -u nobody git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}"
27 if [ -z "${KERNEL_BRANCH}" ] ; then
28 as_nobody -u nobody git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}"
29 else
30 as_nobody -u nobody git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}"
31 fi
28 32
29 33 # Copy downloaded kernel sources
30 34 mv "${temp_dir}/linux" "${R}/usr/src/"
@@ -94,12 +98,12 if [ "$BUILD_KERNEL" = true ] ; then
94 98 fi
95 99
96 100 # Cross compile kernel and modules
97 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" zImage modules dtbs
101 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_BIN_IMAGE}" modules dtbs
98 102 fi
99 103
100 104 # Check if kernel compilation was successful
101 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" ] ; then
102 echo "error: kernel compilation failed! (zImage not found)"
105 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then
106 echo "error: kernel compilation failed! (kernel image not found)"
103 107 cleanup
104 108 exit 1
105 109 fi
@@ -130,16 +134,23 if [ "$BUILD_KERNEL" = true ] ; then
130 134
131 135 # Copy dts and dtb device tree sources and binaries
132 136 mkdir "${BOOT_DIR}/overlays"
137
138 # Ensure the proper .dtb is located
139 if [ "$KERNEL_ARCH" = "arm" ] ; then
133 140 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOT_DIR}/"
141 else
142 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb "${BOOT_DIR}/"
143 fi
144
134 145 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOT_DIR}/overlays/"
135 146 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
136 147
137 148 if [ "$ENABLE_UBOOT" = false ] ; then
138 # Convert and copy zImage kernel to the boot directory
139 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
149 # Convert and copy kernel image to the boot directory
150 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
140 151 else
141 # Copy zImage kernel to the boot directory
142 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
152 # Copy kernel image to the boot directory
153 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
143 154 fi
144 155
145 156 # Remove kernel sources
@@ -149,8 +160,8 if [ "$BUILD_KERNEL" = true ] ; then
149 160 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
150 161
151 162 # Create symlinks for kernel modules
152 ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/build"
153 ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/source"
163 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
164 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
154 165 fi
155 166
156 167 else # BUILD_KERNEL=false
@@ -17,16 +17,16 if [ "$BUILD_KERNEL" = true ] ; then
17 17 cp ${RPI_FIRMWARE_DIR}/boot/start_x.elf ${BOOT_DIR}/start_x.elf
18 18 else
19 19 # Create temporary directory for boot binaries
20 temp_dir=$(sudo -u nobody mktemp -d)
20 temp_dir=$(as_nobody mktemp -d)
21 21
22 22 # Install latest boot binaries from raspberry/firmware github
23 sudo -u nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
24 sudo -u nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
25 sudo -u nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
26 sudo -u nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
27 sudo -u nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
28 sudo -u nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
29 sudo -u nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
23 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
24 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
26 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
27 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
28 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
29 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
30 30
31 31 # Move downloaded boot binaries
32 32 mv "${temp_dir}/"* "${BOOT_DIR}/"
@@ -89,11 +89,11 if [ "$ENABLE_WIRELESS" = true ] ; then
89 89 fi
90 90
91 91 # Create temporary directory for firmware binary blob
92 temp_dir=$(sudo -u nobody mktemp -d)
92 temp_dir=$(as_nobody mktemp -d)
93 93
94 94 # Fetch firmware binary blob
95 sudo -u nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin"
96 sudo -u nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt"
95 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin"
96 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt"
97 97
98 98 # Move downloaded firmware binary blob
99 99 mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/"
@@ -16,10 +16,10 if [ "$ENABLE_UBOOT" = true ] ; then
16 16 cp -r "${UBOOTSRC_DIR}" "${R}/tmp"
17 17 else
18 18 # Create temporary directory for U-Boot sources
19 temp_dir=$(sudo -u nobody mktemp -d)
19 temp_dir=$(as_nobody mktemp -d)
20 20
21 21 # Fetch U-Boot sources
22 sudo -u nobody git -C "${temp_dir}" clone "${UBOOT_URL}"
22 as_nobody git -C "${temp_dir}" clone "${UBOOT_URL}"
23 23
24 24 # Copy downloaded U-Boot sources
25 25 mv "${temp_dir}/u-boot" "${R}/tmp/"
@@ -15,10 +15,10 if [ "$ENABLE_FBTURBO" = true ] ; then
15 15 cp -r "${FBTURBOSRC_DIR}" "${R}/tmp"
16 16 else
17 17 # Create temporary directory for fbturbo sources
18 temp_dir=$(sudo -u nobody mktemp -d)
18 temp_dir=$(as_nobody mktemp -d)
19 19
20 20 # Fetch fbturbo sources
21 sudo -u nobody git -C "${temp_dir}" clone "${FBTURBO_URL}"
21 as_nobody git -C "${temp_dir}" clone "${FBTURBO_URL}"
22 22
23 23 # Move downloaded fbturbo sources
24 24 mv "${temp_dir}/xf86-video-fbturbo" "${R}/tmp/"
@@ -33,6 +33,11 chroot_exec() {
33 33 LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot ${R} $*
34 34 }
35 35
36 as_nobody() {
37 # Exec command as user nobody
38 sudo -E -u nobody LANG=C LC_ALL=C $*
39 }
40
36 41 install_readonly() {
37 42 # Install file with user read-only permissions
38 43 install -o root -g root -m 644 $*
@@ -56,6 +56,7 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
56 56 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
57 57 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
58 58 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
59 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
59 60
60 61 # URLs
61 62 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
@@ -68,9 +69,14 UBOOT_URL=${UBOOT_URL:=git://git.denx.de/u-boot.git}
68 69 # Build directories
69 70 BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}}
70 71 BUILDDIR="${BASEDIR}/build"
72
71 73 # Prepare date string for default image file name
72 74 DATE="$(date +%Y-%m-%d)"
73 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE}}
75 if [ -z "$KERNEL_BRANCH" ] ; then
76 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
77 else
78 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
79 fi
74 80
75 81 # Chroot directories
76 82 R="${BUILDDIR}/chroot"
@@ -160,6 +166,7 KERNEL_THREADS=${KERNEL_THREADS:=1}
160 166 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
161 167 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
162 168 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
169 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
163 170
164 171 # Kernel compilation from source directory settings
165 172 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
@@ -237,7 +244,11 fi
237 244
238 245 # Add packages required for kernel cross compilation
239 246 if [ "$BUILD_KERNEL" = true ] ; then
247 if [ "$KERNEL_ARCH" = "arm" ] ; then
240 248 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
249 else
250 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
251 fi
241 252 fi
242 253
243 254 # Add libncurses5 to enable kernel menuconfig
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant