diff options
-rw-r--r-- | classes/image_types_ostree.bbclass | 5 | ||||
-rw-r--r-- | classes/sdcard_image-rpi-ota.bbclass | 191 | ||||
-rw-r--r-- | recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend | 1 | ||||
-rw-r--r-- | recipes-bsp/bootfiles/rpi-config_git.bbappend | 3 | ||||
-rw-r--r-- | recipes-bsp/u-boot-otascript/u-boot-otascript.bb | 26 | ||||
-rw-r--r-- | recipes-bsp/u-boot-otascript/u-boot-otascript/boot.scr | 3 | ||||
-rw-r--r-- | recipes-bsp/u-boot-otascript/u-boot-otascript/uEnv.txt | 7 | ||||
-rw-r--r-- | recipes-bsp/u-boot/u-boot_2016.11.bb | 7 | ||||
-rw-r--r-- | recipes-core/images/initramfs-ostree-image.bb | 4 | ||||
-rw-r--r-- | recipes-sota/ostree/ostree_git.bb | 2 |
10 files changed, 245 insertions, 4 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 4353af7..f3eafd7 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -9,6 +9,9 @@ IMAGE_DEPENDS_ostree = "ostree-native:do_populate_sysroot \ | |||
9 | export OSTREE_REPO | 9 | export OSTREE_REPO |
10 | export OSTREE_BRANCHNAME | 10 | export OSTREE_BRANCHNAME |
11 | 11 | ||
12 | RAMDISK_EXT ?= ".ext4.gz" | ||
13 | RAMDISK_EXT_arm = ".ext4.gz.u-boot" | ||
14 | |||
12 | IMAGE_CMD_ostree () { | 15 | IMAGE_CMD_ostree () { |
13 | if [ -z "$OSTREE_REPO" ]; then | 16 | if [ -z "$OSTREE_REPO" ]; then |
14 | bbfatal "OSTREE_REPO should be set in your local.conf" | 17 | bbfatal "OSTREE_REPO should be set in your local.conf" |
@@ -93,7 +96,7 @@ IMAGE_CMD_ostree () { | |||
93 | checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} | cut -f 1 -d " "` | 96 | checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} | cut -f 1 -d " "` |
94 | 97 | ||
95 | cp ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} boot/vmlinuz-${checksum} | 98 | cp ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} boot/vmlinuz-${checksum} |
96 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_INITRAMFS_IMAGE}-${MACHINE}.ext4.gz boot/initramfs-${checksum} | 99 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_INITRAMFS_IMAGE}-${MACHINE}${RAMDISK_EXT} boot/initramfs-${checksum} |
97 | 100 | ||
98 | cd ${WORKDIR} | 101 | cd ${WORKDIR} |
99 | 102 | ||
diff --git a/classes/sdcard_image-rpi-ota.bbclass b/classes/sdcard_image-rpi-ota.bbclass new file mode 100644 index 0000000..12c1f40 --- /dev/null +++ b/classes/sdcard_image-rpi-ota.bbclass | |||
@@ -0,0 +1,191 @@ | |||
1 | inherit image_types | ||
2 | inherit linux-raspberrypi-base | ||
3 | |||
4 | # | ||
5 | # Create an image that can by written onto a SD card using dd. | ||
6 | # | ||
7 | # The disk layout used is: | ||
8 | # | ||
9 | # 0 -> IMAGE_ROOTFS_ALIGNMENT - reserved for other data | ||
10 | # IMAGE_ROOTFS_ALIGNMENT -> BOOT_SPACE - bootloader and kernel | ||
11 | # BOOT_SPACE -> SDIMG_OTA_SIZE - rootfs | ||
12 | # | ||
13 | |||
14 | # Default Free space = 1.3x | ||
15 | # Use IMAGE_OVERHEAD_FACTOR to add more space | ||
16 | # <---------> | ||
17 | # 4MiB 40MiB SDIMG_OTA_ROOTFS | ||
18 | # <-----------------------> <----------> <----------------------> | ||
19 | # ------------------------ ------------ ------------------------ | ||
20 | # | IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE | OTAROOT_SIZE | | ||
21 | # ------------------------ ------------ ------------------------ | ||
22 | # ^ ^ ^ ^ | ||
23 | # | | | | | ||
24 | # 0 4MiB 4MiB + 40MiB 4MiB + 40Mib + SDIMG_OTA_ROOTFS | ||
25 | |||
26 | # This image depends on the rootfs image | ||
27 | IMAGE_TYPEDEP_rpi-sdimg-ota = "${SDIMG_OTA_ROOTFS_TYPE}" | ||
28 | |||
29 | # Set kernel and boot loader | ||
30 | IMAGE_BOOTLOADER ?= "bcm2835-bootfiles" | ||
31 | |||
32 | # Set initramfs extension | ||
33 | KERNEL_INITRAMFS ?= "" | ||
34 | |||
35 | # Kernel image name | ||
36 | SDIMG_OTA_KERNELIMAGE_raspberrypi ?= "kernel.img" | ||
37 | SDIMG_OTA_KERNELIMAGE_raspberrypi2 ?= "kernel7.img" | ||
38 | |||
39 | # Boot partition volume id | ||
40 | BOOTDD_VOLUME_ID ?= "${MACHINE}" | ||
41 | |||
42 | # Boot partition size [in KiB] (will be rounded up to IMAGE_ROOTFS_ALIGNMENT) | ||
43 | BOOT_SPACE ?= "40960" | ||
44 | |||
45 | # Set alignment to 4MB [in KiB] | ||
46 | IMAGE_ROOTFS_ALIGNMENT = "4096" | ||
47 | |||
48 | # Use an uncompressed ext3 by default as rootfs | ||
49 | SDIMG_OTA_ROOTFS_TYPE ?= "otaimg" | ||
50 | SDIMG_OTA_ROOTFS = "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${SDIMG_OTA_ROOTFS_TYPE}" | ||
51 | |||
52 | IMAGE_DEPENDS_rpi-sdimg-ota = " \ | ||
53 | parted-native \ | ||
54 | mtools-native \ | ||
55 | dosfstools-native \ | ||
56 | virtual/kernel:do_deploy \ | ||
57 | ${IMAGE_BOOTLOADER} \ | ||
58 | u-boot \ | ||
59 | " | ||
60 | IMAGE_TYPEDEP_rpi-sdimg-ota = "otaimg" | ||
61 | |||
62 | # SD card image name | ||
63 | SDIMG_OTA = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.rpi-sdimg-ota" | ||
64 | |||
65 | # Compression method to apply to SDIMG_OTA after it has been created. Supported | ||
66 | # compression formats are "gzip", "bzip2" or "xz". The original .rpi-sdimg-ota file | ||
67 | # is kept and a new compressed file is created if one of these compression | ||
68 | # formats is chosen. If SDIMG_OTA_COMPRESSION is set to any other value it is | ||
69 | # silently ignored. | ||
70 | #SDIMG_OTA_COMPRESSION ?= "" | ||
71 | |||
72 | # Additional files and/or directories to be copied into the vfat partition from the IMAGE_ROOTFS. | ||
73 | FATPAYLOAD ?= "" | ||
74 | |||
75 | IMAGEDATESTAMP = "${@time.strftime('%Y.%m.%d',time.gmtime())}" | ||
76 | IMAGE_CMD_rpi-sdimg-ota[vardepsexclude] += "IMAGEDATESTAMP" | ||
77 | IMAGE_CMD_rpi-sdimg-ota[vardepsexclude] += "DATETIME" | ||
78 | |||
79 | IMAGE_CMD_rpi-sdimg-ota () { | ||
80 | |||
81 | # Align partitions | ||
82 | OTAROOT_SIZE=`du -Lb ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${SDIMG_OTA_ROOTFS_TYPE} | cut -f1` | ||
83 | OTAROOT_SIZE=$(expr ${OTAROOT_SIZE} / 1024 + 1) | ||
84 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) | ||
85 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) | ||
86 | SDIMG_OTA_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $OTAROOT_SIZE) | ||
87 | |||
88 | echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $OTAROOT_SIZE KiB" | ||
89 | |||
90 | # Check if we are building with device tree support | ||
91 | DTS="${@get_dts(d, None)}" | ||
92 | |||
93 | # Initialize sdcard image file | ||
94 | dd if=/dev/zero of=${SDIMG_OTA} bs=1024 count=0 seek=${SDIMG_OTA_SIZE} | ||
95 | |||
96 | # Create partition table | ||
97 | parted -s ${SDIMG_OTA} mklabel msdos | ||
98 | # Create boot partition and mark it as bootable | ||
99 | parted -s ${SDIMG_OTA} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) | ||
100 | parted -s ${SDIMG_OTA} set 1 boot on | ||
101 | # Create rootfs partition to the end of disk | ||
102 | parted -s ${SDIMG_OTA} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s | ||
103 | parted ${SDIMG_OTA} print | ||
104 | |||
105 | # Create a vfat image with boot files | ||
106 | BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG_OTA} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }') | ||
107 | rm -f ${WORKDIR}/boot.img | ||
108 | mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS | ||
109 | sync | ||
110 | |||
111 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/* ::/ | ||
112 | |||
113 | if test -n "${DTS}"; then | ||
114 | # Device Tree Overlays are assumed to be suffixed by '-overlay.dtb' string and will be put in a dedicated folder | ||
115 | DT_OVERLAYS="${@split_overlays(d, 0)}" | ||
116 | DT_ROOT="${@split_overlays(d, 1)}" | ||
117 | |||
118 | # Copy board device trees to root folder | ||
119 | for DTB in ${DT_ROOT}; do | ||
120 | DTB_BASE_NAME=`basename ${DTB} .dtb` | ||
121 | |||
122 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb ::${DTB_BASE_NAME}.dtb | ||
123 | done | ||
124 | |||
125 | # Copy device tree overlays to dedicated folder | ||
126 | mmd -i ${WORKDIR}/boot.img overlays | ||
127 | for DTB in ${DT_OVERLAYS}; do | ||
128 | DTB_BASE_NAME=`basename ${DTB} .dtb` | ||
129 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb ::overlays/${DTB_BASE_NAME}.dtbo | ||
130 | done | ||
131 | fi | ||
132 | |||
133 | case "${KERNEL_IMAGETYPE}" in | ||
134 | "uImage") | ||
135 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.bin ::${SDIMG_OTA_KERNELIMAGE} | ||
136 | ;; | ||
137 | *) | ||
138 | bbfatal "Kernel uImage is required for OTA image. Please set KERNEL_IMAGETYPE to \"uImage\"" | ||
139 | ;; | ||
140 | esac | ||
141 | |||
142 | if [ -n ${FATPAYLOAD} ] ; then | ||
143 | echo "Copying payload into VFAT" | ||
144 | for entry in ${FATPAYLOAD} ; do | ||
145 | # add the || true to stop aborting on vfat issues like not supporting .~lock files | ||
146 | mcopy -i ${WORKDIR}/boot.img -s -v ${IMAGE_ROOTFS}$entry :: || true | ||
147 | done | ||
148 | fi | ||
149 | |||
150 | # Add stamp file | ||
151 | echo "${IMAGE_NAME}-${IMAGEDATESTAMP}" > ${WORKDIR}/image-version-info | ||
152 | mcopy -i ${WORKDIR}/boot.img -v ${WORKDIR}//image-version-info :: | ||
153 | |||
154 | # Burn Partitions | ||
155 | sync | ||
156 | dd if=${WORKDIR}/boot.img of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync | ||
157 | # If SDIMG_OTA_ROOTFS_TYPE is a .xz file use xzcat | ||
158 | if echo "${SDIMG_OTA_ROOTFS_TYPE}" | egrep -q "*\.xz" | ||
159 | then | ||
160 | xzcat ${SDIMG_OTA_ROOTFS} | dd of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync | ||
161 | else | ||
162 | dd if=${SDIMG_OTA_ROOTFS} of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync | ||
163 | fi | ||
164 | |||
165 | # Optionally apply compression | ||
166 | case "${SDIMG_OTA_COMPRESSION}" in | ||
167 | "gzip") | ||
168 | gzip -k9 "${SDIMG_OTA}" | ||
169 | ;; | ||
170 | "bzip2") | ||
171 | bzip2 -k9 "${SDIMG_OTA}" | ||
172 | ;; | ||
173 | "xz") | ||
174 | xz -k "${SDIMG_OTA}" | ||
175 | ;; | ||
176 | esac | ||
177 | } | ||
178 | |||
179 | ROOTFS_POSTPROCESS_COMMAND += " rpi_generate_sysctl_config ; " | ||
180 | |||
181 | rpi_generate_sysctl_config() { | ||
182 | # systemd sysctl config | ||
183 | test -d ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d && \ | ||
184 | echo "vm.min_free_kbytes = 8192" > ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d/rpi-vm.conf | ||
185 | |||
186 | # sysv sysctl config | ||
187 | IMAGE_SYSCTL_CONF="${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf" | ||
188 | test -e ${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf && \ | ||
189 | sed -e "/vm.min_free_kbytes/d" -i ${IMAGE_SYSCTL_CONF} | ||
190 | echo "" >> ${IMAGE_SYSCTL_CONF} && echo "vm.min_free_kbytes = 8192" >> ${IMAGE_SYSCTL_CONF} | ||
191 | } | ||
diff --git a/recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend b/recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend new file mode 100644 index 0000000..74aa6b1 --- /dev/null +++ b/recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend | |||
@@ -0,0 +1 @@ | |||
RDEPENDS_${PN} += " u-boot-otascript" | |||
diff --git a/recipes-bsp/bootfiles/rpi-config_git.bbappend b/recipes-bsp/bootfiles/rpi-config_git.bbappend new file mode 100644 index 0000000..6e53993 --- /dev/null +++ b/recipes-bsp/bootfiles/rpi-config_git.bbappend | |||
@@ -0,0 +1,3 @@ | |||
1 | do_deploy_append() { | ||
2 | echo "device_tree_address=0x0c800000" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt | ||
3 | } | ||
diff --git a/recipes-bsp/u-boot-otascript/u-boot-otascript.bb b/recipes-bsp/u-boot-otascript/u-boot-otascript.bb new file mode 100644 index 0000000..9f5f0ca --- /dev/null +++ b/recipes-bsp/u-boot-otascript/u-boot-otascript.bb | |||
@@ -0,0 +1,26 @@ | |||
1 | DESCRIPTION = "Boot script for launching OTA-enabled images on raspberrypi" | ||
2 | LICENSE = "MIT" | ||
3 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | ||
4 | |||
5 | DEPENDS = "u-boot-mkimage-native" | ||
6 | |||
7 | COMPATIBLE_MACHINE = "raspberrypi" | ||
8 | |||
9 | SRC_URI = "file://boot.scr \ | ||
10 | file://uEnv.txt" | ||
11 | |||
12 | S = "${WORKDIR}" | ||
13 | |||
14 | inherit deploy | ||
15 | |||
16 | do_deploy() { | ||
17 | install -d ${DEPLOYDIR}/bcm2835-bootfiles | ||
18 | |||
19 | mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Ostree boot script" -d ${S}/boot.scr ${DEPLOYDIR}/bcm2835-bootfiles/boot.scr | ||
20 | install -m 0755 ${S}/uEnv.txt ${DEPLOYDIR}/bcm2835-bootfiles/uEnv.txt | ||
21 | } | ||
22 | |||
23 | addtask deploy before do_package after do_install | ||
24 | do_deploy[dirs] += "${DEPLOYDIR}/bcm2835-bootfiles" | ||
25 | |||
26 | PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
diff --git a/recipes-bsp/u-boot-otascript/u-boot-otascript/boot.scr b/recipes-bsp/u-boot-otascript/u-boot-otascript/boot.scr new file mode 100644 index 0000000..dc13f85 --- /dev/null +++ b/recipes-bsp/u-boot-otascript/u-boot-otascript/boot.scr | |||
@@ -0,0 +1,3 @@ | |||
1 | fatload mmc 0:1 $loadaddr /uEnv.txt | ||
2 | env import -t $loadaddr $filesize | ||
3 | run bootcmd | ||
diff --git a/recipes-bsp/u-boot-otascript/u-boot-otascript/uEnv.txt b/recipes-bsp/u-boot-otascript/u-boot-otascript/uEnv.txt new file mode 100644 index 0000000..f6c0570 --- /dev/null +++ b/recipes-bsp/u-boot-otascript/u-boot-otascript/uEnv.txt | |||
@@ -0,0 +1,7 @@ | |||
1 | fdt_addr_r=0x0c800000 | ||
2 | bootcmd_dtb=fdt addr $fdt_addr_r; fdt get value bootargs_fdt /chosen bootargs | ||
3 | bootcmd_otenv=ext2load mmc 0:2 $loadaddr /boot/loader/uEnv.txt; env import -t $loadaddr $filesize | ||
4 | bootcmd_args=setenv bootargs "$bootargs $bootargs_fdt ostree_root=/dev/mmcblk0p2 root=/dev/ram0 rw rootwait rootdelay=2 ramdisk_size=8192" | ||
5 | bootcmd_load=ext2load mmc 0:2 $kernel_addr_r "/boot"$kernel_image; ext2load mmc 0:2 $ramdisk_addr_r "/boot"$ramdisk_image | ||
6 | bootcmd_run=bootm $kernel_addr_r $ramdisk_addr_r $fdt_addr_r | ||
7 | bootcmd=run bootcmd_dtb; run bootcmd_otenv; run bootcmd_args; run bootcmd_load; run bootcmd_run | ||
diff --git a/recipes-bsp/u-boot/u-boot_2016.11.bb b/recipes-bsp/u-boot/u-boot_2016.11.bb new file mode 100644 index 0000000..a05b37f --- /dev/null +++ b/recipes-bsp/u-boot/u-boot_2016.11.bb | |||
@@ -0,0 +1,7 @@ | |||
1 | require recipes-bsp/u-boot/u-boot.inc | ||
2 | |||
3 | DEPENDS += "dtc-native" | ||
4 | |||
5 | SRCREV = "5ea3e51fc481613a8dee8c02848d1b42c81ad892" | ||
6 | |||
7 | PV = "v2016.11+git${SRCPV}" | ||
diff --git a/recipes-core/images/initramfs-ostree-image.bb b/recipes-core/images/initramfs-ostree-image.bb index e4123d4..8eea07c 100644 --- a/recipes-core/images/initramfs-ostree-image.bb +++ b/recipes-core/images/initramfs-ostree-image.bb | |||
@@ -13,9 +13,9 @@ IMAGE_LINGUAS = "" | |||
13 | 13 | ||
14 | LICENSE = "MIT" | 14 | LICENSE = "MIT" |
15 | 15 | ||
16 | # was ${INITRAMFS_FSTYPES} which defaults to cpio.gz | ||
17 | # due to xattr, we need ext3/4 | ||
18 | IMAGE_FSTYPES = "ext4.gz" | 16 | IMAGE_FSTYPES = "ext4.gz" |
17 | IMAGE_FSTYPES_append_arm = " ext4.gz.u-boot" | ||
18 | |||
19 | inherit core-image | 19 | inherit core-image |
20 | 20 | ||
21 | IMAGE_ROOTFS_SIZE = "8192" | 21 | IMAGE_ROOTFS_SIZE = "8192" |
diff --git a/recipes-sota/ostree/ostree_git.bb b/recipes-sota/ostree/ostree_git.bb index c2aeb2f..87f7138 100644 --- a/recipes-sota/ostree/ostree_git.bb +++ b/recipes-sota/ostree/ostree_git.bb | |||
@@ -2,7 +2,7 @@ SUMMARY = "Tool for managing bootable, immutable, versioned filesystem trees" | |||
2 | LICENSE = "GPLv2+" | 2 | LICENSE = "GPLv2+" |
3 | LIC_FILES_CHKSUM = "file://COPYING;md5=5f30f0716dfdd0d91eb439ebec522ec2" | 3 | LIC_FILES_CHKSUM = "file://COPYING;md5=5f30f0716dfdd0d91eb439ebec522ec2" |
4 | 4 | ||
5 | inherit autotools-brokensep pkgconfig systemd | 5 | inherit autotools-brokensep pkgconfig systemd gobject-introspection |
6 | 6 | ||
7 | INHERIT_remove_class-native = "systemd" | 7 | INHERIT_remove_class-native = "systemd" |
8 | 8 | ||