summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--classes/sota.bbclass11
-rw-r--r--recipes-sota/ota-u-boot-script/files/uEnv-fileenv.txt1
-rw-r--r--recipes-sota/ota-u-boot-script/files/uEnv-fit.txt1
-rw-r--r--recipes-sota/ota-u-boot-script/files/uEnv-rollback.txt8
-rw-r--r--recipes-sota/ota-u-boot-script/files/uEnv.txt33
-rw-r--r--recipes-sota/ota-u-boot-script/ota-u-boot-script.bb50
6 files changed, 104 insertions, 0 deletions
diff --git a/classes/sota.bbclass b/classes/sota.bbclass
index 92b4c43..12f8148 100644
--- a/classes/sota.bbclass
+++ b/classes/sota.bbclass
@@ -38,6 +38,15 @@ GARAGE_TARGET_NAME ?= "${OSTREE_BRANCHNAME}"
38GARAGE_TARGET_VERSION ?= "" 38GARAGE_TARGET_VERSION ?= ""
39GARAGE_TARGET_URL ?= "https://example.com/" 39GARAGE_TARGET_URL ?= "https://example.com/"
40 40
41SOTA_BOOTLOADER_EXTRA_PARAMS ??= ""
42SOTA_BOOTLOADER_BOOTCOMMAND ??= "bootm"
43SOTA_BOOTLOADER_KERNEL_ADDR ??= "\$\{ramdisk_addr_r\}"
44SOTA_BOOTLOADER_RAMDISK_ADDR ??= "-"
45SOTA_BOOTLOADER_FDT_ADDR ??= "-"
46SOTA_BOOTLOADER_BOOT_PART ??= "mmc 0:1"
47SOTA_BOOTLOADER_MAIN_PART ??= "mmc 0:2"
48SOTA_BOOTLOADER_ROOT_DEVICE ??= "/dev/mmcblk0p2"
49
41SOTA_MACHINE ??="none" 50SOTA_MACHINE ??="none"
42SOTA_MACHINE_rpi ?= "raspberrypi" 51SOTA_MACHINE_rpi ?= "raspberrypi"
43SOTA_MACHINE_porter ?= "porter" 52SOTA_MACHINE_porter ?= "porter"
@@ -49,4 +58,6 @@ SOTA_MACHINE_am335x-evm ?= "am335x-evm-wifi"
49SOTA_OVERRIDES_BLACKLIST = "ostree ota" 58SOTA_OVERRIDES_BLACKLIST = "ostree ota"
50SOTA_REQUIRED_VARIABLES = "OSTREE_REPO OSTREE_BRANCHNAME OSTREE_OSNAME OSTREE_BOOTLOADER OSTREE_BOOT_PARTITION GARAGE_SIGN_REPO GARAGE_TARGET_NAME" 59SOTA_REQUIRED_VARIABLES = "OSTREE_REPO OSTREE_BRANCHNAME OSTREE_OSNAME OSTREE_BOOTLOADER OSTREE_BOOT_PARTITION GARAGE_SIGN_REPO GARAGE_TARGET_NAME"
51 60
61do_image_wic[depends] += " ota-u-boot-script:do_deploy "
62
52inherit sota_sanity sota_${SOTA_MACHINE} image_repo_manifest 63inherit sota_sanity sota_${SOTA_MACHINE} image_repo_manifest
diff --git a/recipes-sota/ota-u-boot-script/files/uEnv-fileenv.txt b/recipes-sota/ota-u-boot-script/files/uEnv-fileenv.txt
new file mode 100644
index 0000000..3646416
--- /dev/null
+++ b/recipes-sota/ota-u-boot-script/files/uEnv-fileenv.txt
@@ -0,0 +1 @@
bootcmd_create_envfile=if test ! -e ${updater_boot_part} uboot.env; then saveenv; fi;
diff --git a/recipes-sota/ota-u-boot-script/files/uEnv-fit.txt b/recipes-sota/ota-u-boot-script/files/uEnv-fit.txt
new file mode 100644
index 0000000..64e34b0
--- /dev/null
+++ b/recipes-sota/ota-u-boot-script/files/uEnv-fit.txt
@@ -0,0 +1 @@
bootcmd_fitconf=run bootcmd_getroot; if test -e ${sota_main_part} "${ostree_root}/usr/lib/fit_conf"; then load ${sota_main_part} $loadaddr "${ostree_root}/usr/lib/fit_conf"; env import -t $loadaddr $filesize; fi; setenv sota_kernel_addr ${sota_kernel_addr}${fit_conf}
diff --git a/recipes-sota/ota-u-boot-script/files/uEnv-rollback.txt b/recipes-sota/ota-u-boot-script/files/uEnv-rollback.txt
new file mode 100644
index 0000000..07b6b22
--- /dev/null
+++ b/recipes-sota/ota-u-boot-script/files/uEnv-rollback.txt
@@ -0,0 +1,8 @@
1bootcmd_rollbackenv=setenv kernel_image ${kernel_image2}; setenv ramdisk_image ${ramdisk_image2}; setenv fdt_file ${fdt_file2}; setenv bootargs ${bootargs2}
2
3bootlimit=3
4
5bootcmd_set_rollback=if test ! "${rollback}" = "1"; then setenv rollback 1; setenv upgrade_available 0; saveenv; fi
6altbootcmd=run bootcmd_create_envfile; run bootcmd_otenv; run bootcmd_set_rollback; if test -n "${kernel_image2}"; then run bootcmd_rollbackenv; fi; run bootcmd_args; run bootcmd_fitconf; run bootcmd_load; run bootcmd_run; reset
7
8
diff --git a/recipes-sota/ota-u-boot-script/files/uEnv.txt b/recipes-sota/ota-u-boot-script/files/uEnv.txt
new file mode 100644
index 0000000..0cd97b7
--- /dev/null
+++ b/recipes-sota/ota-u-boot-script/files/uEnv.txt
@@ -0,0 +1,33 @@
1bootcmd_fitconf=
2bootcmd_create_envfile=
3
4sota_bootcommand=bootm
5sota_kernel_addr=${ramdisk_addr_r}
6sota_ramdisk_addr=-
7sota_fdt_addr=-
8sota_boot_part=mmc 0:1
9sota_main_part=mmc 0:2
10sota_root_device=/dev/mmcblk0p2
11
12%%INITFINISHED%%
13
14bootcmd_resetvars=setenv kernel_image; setenv bootargs; setenv kernel_image2; setenv bootargs2
15bootcmd_otenv=run bootcmd_resetvars; load ${updater_main_part} $loadaddr /boot/loader/uEnv.txt; env import -t $loadaddr $filesize
16
17bootcmd_args=setenv bootargs "$bootargs $bootargs_fdt ostree_root=${updater_root_device} root=/dev/ram0 rw rootwait rootdelay=2 ramdisk_size=8192 panic=1 %%SOTA_EXTRA_BOOTCMD%%"
18
19bootcmd_getroot=setexpr ostree_root gsub "^.*ostree=([^ ]*).*$" "\\\\1" "${bootargs}";
20
21bootcmd_load_kernel=load ${updater_main_part} ${sota_kernel_addr} "/boot"$kernel_image
22
23bootcmd_load_ramdisk=if ! "${sota_ramdisk_addr}" = "-"; then load ${updater_main_part} ${sota_ramdisk_addr} "/boot"$ramdisk_image; fi
24
25bootcmd_load_fdt=if ! "${sota_fdt_addr}" = "-"; then load ${updater_main_part} ${sota_fdt_addr} "/boot"$fdt_file; fi
26
27bootcmd_load=run bootcmd_load_kernel; run bootcmd_load_ramdisk; run bootcmd_load_fdt;
28
29bootcmd_run=${sota_bootcommand} ${sota_kernel_addr} ${sota_ramdisk_addr} ${sota_fdt_addr}
30
31bootcmd=if test "${rollback}" = "1"; then run altbootcmd; else run bootcmd_create_envfile; run bootcmd_otenv; run bootcmd_args; run bootcmd_fitconf; run bootcmd_load; run bootcmd_run; if ! "${upgrade_available}" = "1"; then setenv upgrade_available 1; saveenv; fi; reset; fi
32
33
diff --git a/recipes-sota/ota-u-boot-script/ota-u-boot-script.bb b/recipes-sota/ota-u-boot-script/ota-u-boot-script.bb
new file mode 100644
index 0000000..5c7ed57
--- /dev/null
+++ b/recipes-sota/ota-u-boot-script/ota-u-boot-script.bb
@@ -0,0 +1,50 @@
1DESCRIPTION = "Boot script template for OTA-enabled image"
2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4
5inherit deploy
6
7SRC_URI = "file://uEnv-fileenv.txt \
8 file://uEnv-fit.txt \
9 file://uEnv-rollback.txt \
10 file://uEnv.txt"
11
12do_deploy() {
13
14 UENV_TEMPLATE=$(mktemp)
15 # Initialization portion
16 sed -n '0,/%%INITFINISHED%%/p' < ${WORKDIR}/uEnv.txt | head -n -1 > $UENV_TEMPLATE
17
18 # Support for FIT images
19 if [ "${KERNEL_IMAGETYPE_SOTA}" = "fitImage"]; then
20 cat ${WORKDIR}/uEnv-fit.txt >> $UENV_TEMPLATE
21 fi
22
23 # Rollback support
24 if [ -n "${SOTA_ROLLBACK_MECHANISM}" ]; then
25 cat ${WORKDIR}/uEnv-rollback.txt >> $UENV_TEMPLATE
26
27 if [ "${SOTA_ROLLBACK_MECHANISM}" = "file-env" ];
28 cat ${WORKDIR}/uEnv-fileenv.txt >> $UENV_TEMPLATE
29 fi
30 fi
31
32 # The rest of the base template
33 sed -n '/%%INITFINISHED%%/,$p' < ${WORKDIR}/uEnv.txt | sed -n '2,$p' >> $UENV_TEMPLATE
34
35 # Substitute the variables
36 sed -e 's/@@SOTA_BOOTLOADER_EXTRA_PARAMS@@/${SOTA_BOOTLOADER_EXTRA_PARAMS}' \
37 -e 's/@@SOTA_BOOTLOADER_BOOTCOMMAND@@/${SOTA_BOOTLOADER_BOOTCOMMAND}' \
38 -e 's/@@SOTA_BOOTLOADER_KERNEL_ADDR@@/${SOTA_BOOTLOADER_KERNEL_ADDR}' \
39 -e 's/@@SOTA_BOOTLOADER_RAMDISK_ADDR@@/${SOTA_BOOTLOADER_RAMDISK_ADDR}' \
40 -e 's/@@SOTA_BOOTLOADER_FDT_ADDR@@/${SOTA_BOOTLOADER_FDT_ADDR}' \
41 -e 's/@@SOTA_BOOTLOADER_BOOT_PART@@/${SOTA_BOOTLOADER_BOOT_PART}' \
42 -e 's/@@SOTA_BOOTLOADER_MAIN_PART@@/${SOTA_BOOTLOADER_KERNEL_MAIN_PART}' \
43 -e 's/@@SOTA_BOOTLOADER_ROOT_DEVICE@@/${SOTA_BOOTLOADER_ROOT_DEVICE}' \
44 "$UENV_TEMPLATE" > ${DEPLOY_DIR_IMAGE}/uEnv.txt
45
46
47 if [ -n ""]
48}
49
50addtask deploy before do_package