Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 1 | inherit image_types |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 2 | |
| 3 | # |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4 | # Create an image that can be written onto a SD card using dd. |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 5 | # |
| 6 | # The disk layout used is: |
| 7 | # |
| 8 | # 0 -> IMAGE_ROOTFS_ALIGNMENT - reserved for other data |
| 9 | # IMAGE_ROOTFS_ALIGNMENT -> BOOT_SPACE - bootloader and kernel |
| 10 | # BOOT_SPACE -> SDIMG_SIZE - rootfs |
| 11 | # |
| 12 | |
| 13 | # Default Free space = 1.3x |
| 14 | # Use IMAGE_OVERHEAD_FACTOR to add more space |
| 15 | # <---------> |
Andrew Geissler | 3e34fba | 2021-03-05 15:21:55 -0600 | [diff] [blame] | 16 | # 4MiB 48MiB SDIMG_ROOTFS |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 17 | # <-----------------------> <----------> <----------------------> |
| 18 | # ------------------------ ------------ ------------------------ |
| 19 | # | IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE | ROOTFS_SIZE | |
| 20 | # ------------------------ ------------ ------------------------ |
| 21 | # ^ ^ ^ ^ |
| 22 | # | | | | |
Andrew Geissler | 3e34fba | 2021-03-05 15:21:55 -0600 | [diff] [blame] | 23 | # 0 4MiB 4MiB + 48MiB 4MiB + 48Mib + SDIMG_ROOTFS |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 24 | |
| 25 | # This image depends on the rootfs image |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 26 | IMAGE_TYPEDEP:rpi-sdimg = "${SDIMG_ROOTFS_TYPE}" |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 27 | |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 28 | # Kernel image name |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 29 | SDIMG_KERNELIMAGE:raspberrypi ?= "kernel.img" |
| 30 | SDIMG_KERNELIMAGE:raspberrypi2 ?= "kernel7.img" |
| 31 | SDIMG_KERNELIMAGE:raspberrypi3-64 ?= "kernel8.img" |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 32 | |
| 33 | # Boot partition volume id |
Andrew Geissler | 3e34fba | 2021-03-05 15:21:55 -0600 | [diff] [blame] | 34 | # Shorten raspberrypi to just rpi to keep it under 11 characters |
| 35 | # now enforced by mkfs.vfat from dosfstools-4.2 |
| 36 | BOOTDD_VOLUME_ID ?= "${@d.getVar('MACHINE').replace('raspberrypi', 'rpi')}" |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 37 | |
| 38 | # Boot partition size [in KiB] (will be rounded up to IMAGE_ROOTFS_ALIGNMENT) |
Andrew Geissler | 3e34fba | 2021-03-05 15:21:55 -0600 | [diff] [blame] | 39 | BOOT_SPACE ?= "49152" |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 40 | |
| 41 | # Set alignment to 4MB [in KiB] |
| 42 | IMAGE_ROOTFS_ALIGNMENT = "4096" |
| 43 | |
| 44 | # Use an uncompressed ext3 by default as rootfs |
| 45 | SDIMG_ROOTFS_TYPE ?= "ext3" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 46 | SDIMG_ROOTFS = "${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${SDIMG_ROOTFS_TYPE}" |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 47 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 48 | # For the names of kernel artifacts |
| 49 | inherit kernel-artifact-names |
| 50 | |
Andrew Geissler | 9d7e0aa | 2020-08-21 15:56:44 -0500 | [diff] [blame] | 51 | RPI_SDIMG_EXTRA_DEPENDS ?= "" |
| 52 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 53 | do_image_rpi_sdimg[depends] = " \ |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 54 | parted-native:do_populate_sysroot \ |
| 55 | mtools-native:do_populate_sysroot \ |
| 56 | dosfstools-native:do_populate_sysroot \ |
| 57 | virtual/kernel:do_deploy \ |
Andrew Geissler | 26e4bea | 2020-11-30 19:54:03 -0600 | [diff] [blame] | 58 | rpi-bootfiles:do_deploy \ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 59 | ${@bb.utils.contains('MACHINE_FEATURES', 'armstub', 'armstubs:do_deploy', '' ,d)} \ |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 60 | ${@bb.utils.contains('RPI_USE_U_BOOT', '1', 'u-boot:do_deploy', '',d)} \ |
Andrew Geissler | 062316f | 2020-05-15 14:19:14 -0500 | [diff] [blame] | 61 | ${@bb.utils.contains('RPI_USE_U_BOOT', '1', 'u-boot-default-script:do_deploy', '',d)} \ |
Andrew Geissler | 9d7e0aa | 2020-08-21 15:56:44 -0500 | [diff] [blame] | 62 | ${RPI_SDIMG_EXTRA_DEPENDS} \ |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 63 | " |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 64 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 65 | do_image_rpi_sdimg[recrdeps] = "do_build" |
| 66 | |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 67 | # SD card image name |
Brad Bishop | 3112138 | 2019-12-06 18:34:07 -0500 | [diff] [blame] | 68 | SDIMG = "${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.rpi-sdimg" |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 69 | |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 70 | # Additional files and/or directories to be copied into the vfat partition from the IMAGE_ROOTFS. |
| 71 | FATPAYLOAD ?= "" |
| 72 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 73 | # SD card vfat partition image name |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 74 | SDIMG_VFAT_DEPLOY ?= "${RPI_USE_U_BOOT}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | SDIMG_VFAT = "${IMAGE_NAME}.vfat" |
| 76 | SDIMG_LINK_VFAT = "${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.vfat" |
| 77 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 78 | def split_overlays(d, out, ver=None): |
| 79 | dts = d.getVar("KERNEL_DEVICETREE") |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 80 | # Device Tree Overlays are assumed to be suffixed by '-overlay.dtb' (4.1.x) or by '.dtbo' (4.4.9+) string and will be put in a dedicated folder |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 81 | if out: |
| 82 | overlays = oe.utils.str_filter_out('\S+\-overlay\.dtb$', dts, d) |
| 83 | overlays = oe.utils.str_filter_out('\S+\.dtbo$', overlays, d) |
| 84 | else: |
| 85 | overlays = oe.utils.str_filter('\S+\-overlay\.dtb$', dts, d) + \ |
| 86 | " " + oe.utils.str_filter('\S+\.dtbo$', dts, d) |
| 87 | |
| 88 | return overlays |
| 89 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 90 | IMAGE_CMD:rpi-sdimg () { |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 91 | |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 92 | # Align partitions |
| 93 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) |
| 94 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) |
| 95 | SDIMG_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 96 | |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 97 | echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $ROOTFS_SIZE KiB" |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 98 | |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 99 | # Check if we are building with device tree support |
| 100 | DTS="${KERNEL_DEVICETREE}" |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 101 | |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 102 | # Initialize sdcard image file |
| 103 | dd if=/dev/zero of=${SDIMG} bs=1024 count=0 seek=${SDIMG_SIZE} |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 104 | |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 105 | # Create partition table |
| 106 | parted -s ${SDIMG} mklabel msdos |
| 107 | # Create boot partition and mark it as bootable |
| 108 | parted -s ${SDIMG} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) |
| 109 | parted -s ${SDIMG} set 1 boot on |
| 110 | # Create rootfs partition to the end of disk |
| 111 | parted -s ${SDIMG} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s |
| 112 | parted ${SDIMG} print |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 113 | |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 114 | # Create a vfat image with boot files |
| 115 | BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }') |
| 116 | rm -f ${WORKDIR}/boot.img |
Andrew Geissler | 1c34914 | 2019-02-19 19:49:56 -0600 | [diff] [blame] | 117 | mkfs.vfat -F32 -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS |
Andrew Geissler | 9d7e0aa | 2020-08-21 15:56:44 -0500 | [diff] [blame] | 118 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${BOOTFILES_DIR_NAME}/* ::/ || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/${BOOTFILES_DIR_NAME}/* into boot.img" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 119 | if [ "${@bb.utils.contains("MACHINE_FEATURES", "armstub", "1", "0", d)}" = "1" ]; then |
| 120 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/armstubs/${ARMSTUB} ::/ || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/armstubs/${ARMSTUB} into boot.img" |
| 121 | fi |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 122 | if test -n "${DTS}"; then |
| 123 | # Copy board device trees to root folder |
| 124 | for dtbf in ${@split_overlays(d, True)}; do |
| 125 | dtb=`basename $dtbf` |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 126 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$dtb ::$dtb || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/$dtb into boot.img" |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 127 | done |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 128 | |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 129 | # Copy device tree overlays to dedicated folder |
| 130 | mmd -i ${WORKDIR}/boot.img overlays |
| 131 | for dtbf in ${@split_overlays(d, False)}; do |
| 132 | dtb=`basename $dtbf` |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 133 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$dtb ::overlays/$dtb || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/$dtb into boot.img" |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 134 | done |
| 135 | fi |
| 136 | if [ "${RPI_USE_U_BOOT}" = "1" ]; then |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 137 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.bin ::${SDIMG_KERNELIMAGE} || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/u-boot.bin into boot.img" |
| 138 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/boot.scr ::boot.scr || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/boot.scr into boot.img" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 139 | if [ ! -z "${INITRAMFS_IMAGE}" -a "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 140 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${INITRAMFS_LINK_NAME}.bin ::${KERNEL_IMAGETYPE} || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${INITRAMFS_LINK_NAME}.bin into boot.img" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 141 | else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 142 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ::${KERNEL_IMAGETYPE} || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} into boot.img" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 143 | fi |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 144 | else |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 145 | if [ ! -z "${INITRAMFS_IMAGE}" -a "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 146 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${INITRAMFS_LINK_NAME}.bin ::${SDIMG_KERNELIMAGE} || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${INITRAMFS_LINK_NAME}.bin into boot.img" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 147 | else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 148 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ::${SDIMG_KERNELIMAGE} || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} into boot.img" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 149 | fi |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 150 | fi |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 151 | |
Andrew Geissler | 9d7e0aa | 2020-08-21 15:56:44 -0500 | [diff] [blame] | 152 | # Add files (eg. hypervisor binaries) from the deploy dir |
| 153 | if [ -n "${DEPLOYPAYLOAD}" ] ; then |
| 154 | echo "Copying deploy file payload into VFAT" |
| 155 | for entry in ${DEPLOYPAYLOAD} ; do |
| 156 | # Split entry at optional ':' to enable file renaming for the destination |
| 157 | if [ $(echo "$entry" | grep -c :) = "0" ] ; then |
| 158 | DEPLOY_FILE="$entry" |
| 159 | DEST_FILENAME="$entry" |
| 160 | else |
| 161 | DEPLOY_FILE="$(echo "$entry" | cut -f1 -d:)" |
| 162 | DEST_FILENAME="$(echo "$entry" | cut -f2- -d:)" |
| 163 | fi |
| 164 | mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${DEPLOY_FILE} ::${DEST_FILENAME} || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/${DEPLOY_FILE} into boot.img" |
| 165 | done |
| 166 | fi |
| 167 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 168 | if [ -n "${FATPAYLOAD}" ] ; then |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 169 | echo "Copying payload into VFAT" |
| 170 | for entry in ${FATPAYLOAD} ; do |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 171 | # use bbwarn instead of bbfatal to stop aborting on vfat issues like not supporting .~lock files |
| 172 | mcopy -v -i ${WORKDIR}/boot.img -s ${IMAGE_ROOTFS}$entry :: || bbwarn "mcopy cannot copy ${IMAGE_ROOTFS}$entry into boot.img" |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 173 | done |
| 174 | fi |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 175 | |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 176 | # Add stamp file |
| 177 | echo "${IMAGE_NAME}" > ${WORKDIR}/image-version-info |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 178 | mcopy -v -i ${WORKDIR}/boot.img ${WORKDIR}/image-version-info :: || bbfatal "mcopy cannot copy ${WORKDIR}/image-version-info into boot.img" |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 179 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 180 | # Deploy vfat partition |
| 181 | if [ "${SDIMG_VFAT_DEPLOY}" = "1" ]; then |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 182 | cp ${WORKDIR}/boot.img ${IMGDEPLOYDIR}/${SDIMG_VFAT} |
| 183 | ln -sf ${SDIMG_VFAT} ${SDIMG_LINK_VFAT} |
| 184 | fi |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 185 | |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 186 | # Burn Partitions |
| 187 | dd if=${WORKDIR}/boot.img of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) |
| 188 | # If SDIMG_ROOTFS_TYPE is a .xz file use xzcat |
| 189 | if echo "${SDIMG_ROOTFS_TYPE}" | egrep -q "*\.xz" |
| 190 | then |
| 191 | xzcat ${SDIMG_ROOTFS} | dd of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) |
| 192 | else |
| 193 | dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) |
| 194 | fi |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | ROOTFS_POSTPROCESS_COMMAND += " rpi_generate_sysctl_config ; " |
| 198 | |
| 199 | rpi_generate_sysctl_config() { |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 200 | # systemd sysctl config |
| 201 | test -d ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d && \ |
| 202 | echo "vm.min_free_kbytes = 8192" > ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d/rpi-vm.conf |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 203 | |
Brad Bishop | f27bdd5 | 2018-05-07 15:42:31 +0200 | [diff] [blame] | 204 | # sysv sysctl config |
| 205 | IMAGE_SYSCTL_CONF="${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf" |
| 206 | test -e ${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf && \ |
| 207 | sed -e "/vm.min_free_kbytes/d" -i ${IMAGE_SYSCTL_CONF} |
| 208 | echo "" >> ${IMAGE_SYSCTL_CONF} && echo "vm.min_free_kbytes = 8192" >> ${IMAGE_SYSCTL_CONF} |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 209 | } |