diff options
author | Anton Gerasimov <anton.gerasimov@here.com> | 2019-02-21 15:54:39 +0100 |
---|---|---|
committer | Anton Gerasimov <anton.gerasimov@here.com> | 2019-02-25 15:35:01 +0100 |
commit | 690262acdba2511b14798c04b19d9dcc7df2d538 (patch) | |
tree | cdf2890f58fb10431fa9adf6c0bb1319c34816bf /recipes-sota | |
parent | 3b9b75140ea58f546829cb3cf1b234e5b650de77 (diff) | |
download | meta-updater-690262acdba2511b14798c04b19d9dcc7df2d538.tar.gz |
Add universal uEnv recipefeat/universaluenv
Signed-off-by: Anton Gerasimov <anton.gerasimov@here.com>
Diffstat (limited to 'recipes-sota')
5 files changed, 107 insertions, 0 deletions
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..6a179b7 --- /dev/null +++ b/recipes-sota/ota-u-boot-script/files/uEnv-fileenv.txt | |||
@@ -0,0 +1 @@ | |||
bootcmd_create_envfile=if test ! -e $sota_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..51eaf73 --- /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; | |||
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 @@ | |||
1 | bootcmd_rollbackenv=setenv kernel_image ${kernel_image2}; setenv ramdisk_image ${ramdisk_image2}; setenv fdt_file ${fdt_file2}; setenv bootargs ${bootargs2} | ||
2 | |||
3 | bootlimit=3 | ||
4 | |||
5 | bootcmd_set_rollback=if test ! "${rollback}" = "1"; then setenv rollback 1; setenv upgrade_available 0; saveenv; fi | ||
6 | altbootcmd=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..d890257 --- /dev/null +++ b/recipes-sota/ota-u-boot-script/files/uEnv.txt | |||
@@ -0,0 +1,34 @@ | |||
1 | bootcmd_fitconf= | ||
2 | bootcmd_create_envfile= | ||
3 | fit_conf= | ||
4 | |||
5 | sota_bootcommand=@@SOTA_BOOTLOADER_BOOTCOMMAND@@ | ||
6 | sota_kernel_addr=@@SOTA_BOOTLOADER_KERNEL_ADDR@@ | ||
7 | sota_ramdisk_addr=@@SOTA_BOOTLOADER_RAMDISK_ADDR@@ | ||
8 | sota_fdt_addr=@@SOTA_BOOTLOADER_FDT_ADDR@@ | ||
9 | sota_boot_part=@@SOTA_BOOTLOADER_BOOT_PART@@ | ||
10 | sota_main_part=@@SOTA_BOOTLOADER_MAIN_PART@@ | ||
11 | sota_root_device=@@SOTA_BOOTLOADER_ROOT_DEVICE@@ | ||
12 | |||
13 | @@INITFINISHED@@ | ||
14 | |||
15 | bootcmd_resetvars=setenv kernel_image; setenv bootargs; setenv kernel_image2; setenv bootargs2 | ||
16 | bootcmd_otenv=run bootcmd_resetvars; load ${sota_main_part} $loadaddr /boot/loader/uEnv.txt; env import -t $loadaddr $filesize | ||
17 | |||
18 | bootcmd_args=setenv bootargs "$bootargs $bootargs_fdt ostree_root=$sota_root_device root=/dev/ram0 rw rootwait rootdelay=2 ramdisk_size=8192 panic=1 @@SOTA_BOOTLOADER_EXTRA_PARAMS@@" | ||
19 | |||
20 | bootcmd_getroot=setexpr ostree_root gsub "^.*ostree=([^ ]*).*$" "\\\\1" "${bootargs}"; | ||
21 | |||
22 | bootcmd_load_kernel=load $sota_main_part $sota_kernel_addr "/boot"$kernel_image | ||
23 | |||
24 | bootcmd_load_ramdisk=if test -n "${sota_ramdisk_addr}"; then load $sota_main_part $sota_ramdisk_addr "/boot"$ramdisk_image; fi | ||
25 | |||
26 | bootcmd_load_fdt=if test -n "${sota_fdt_addr}"; then load $sota_main_part $sota_fdt_addr "/boot"$fdt_file; fi | ||
27 | |||
28 | bootcmd_load=run bootcmd_load_kernel; run bootcmd_load_ramdisk; run bootcmd_load_fdt; | ||
29 | |||
30 | bootcmd_run=$sota_bootcommand $sota_kernel_addr$fit_conf $sota_ramdisk_addr $sota_fdt_addr | ||
31 | |||
32 | bootcmd=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 test ! "${upgrade_available}" = "1"; then setenv upgrade_available 1; saveenv; fi; reset; fi | ||
33 | |||
34 | |||
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..de00148 --- /dev/null +++ b/recipes-sota/ota-u-boot-script/ota-u-boot-script.bb | |||
@@ -0,0 +1,63 @@ | |||
1 | DESCRIPTION = "Boot script template for OTA-enabled image" | ||
2 | LICENSE = "MIT" | ||
3 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | ||
4 | |||
5 | inherit deploy | ||
6 | |||
7 | SRC_URI = "file://uEnv-fileenv.txt \ | ||
8 | file://uEnv-fit.txt \ | ||
9 | file://uEnv-rollback.txt \ | ||
10 | file://uEnv.txt" | ||
11 | |||
12 | python () { | ||
13 | d.setVar('SOTA_BOOTLOADER_EXTRA_PARAMS', d.getVar('SOTA_BOOTLOADER_EXTRA_PARAMS').replace('/', '\/')) | ||
14 | d.setVar('SOTA_BOOTLOADER_BOOTCOMMAND', d.getVar('SOTA_BOOTLOADER_BOOTCOMMAND').replace('/', '\/')) | ||
15 | d.setVar('SOTA_BOOTLOADER_KERNEL_ADDR', d.getVar('SOTA_BOOTLOADER_KERNEL_ADDR').replace('/', '\/')) | ||
16 | d.setVar('SOTA_BOOTLOADER_RAMDISK_ADDR', d.getVar('SOTA_BOOTLOADER_RAMDISK_ADDR').replace('/', '\/')) | ||
17 | d.setVar('SOTA_BOOTLOADER_FDT_ADDR', d.getVar('SOTA_BOOTLOADER_FDT_ADDR').replace('/', '\/')) | ||
18 | d.setVar('SOTA_BOOTLOADER_BOOT_PART', d.getVar('SOTA_BOOTLOADER_BOOT_PART').replace('/', '\/')) | ||
19 | d.setVar('SOTA_BOOTLOADER_MAIN_PART', d.getVar('SOTA_BOOTLOADER_MAIN_PART').replace('/', '\/')) | ||
20 | d.setVar('SOTA_BOOTLOADER_ROOT_DEVICE', d.getVar('SOTA_BOOTLOADER_ROOT_DEVICE').replace('/', '\/')) | ||
21 | } | ||
22 | |||
23 | do_compile() { | ||
24 | |||
25 | UENV_TEMPLATE="${WORKDIR}/uEnv.template" | ||
26 | # Initialization portion | ||
27 | sed -n '0,/@@INITFINISHED@@/p' < ${WORKDIR}/uEnv.txt | head -n -1 > $UENV_TEMPLATE | ||
28 | |||
29 | # Support for FIT images | ||
30 | if [ "${KERNEL_IMAGETYPE}" = "fitImage" ]; then | ||
31 | cat ${WORKDIR}/uEnv-fit.txt >> $UENV_TEMPLATE | ||
32 | fi | ||
33 | |||
34 | # Rollback support | ||
35 | if [ -n "${SOTA_ROLLBACK_MECHANISM}" ]; then | ||
36 | cat ${WORKDIR}/uEnv-rollback.txt >> $UENV_TEMPLATE | ||
37 | |||
38 | if [ "${SOTA_ROLLBACK_MECHANISM}" = "file-env" ]; then | ||
39 | cat ${WORKDIR}/uEnv-fileenv.txt >> $UENV_TEMPLATE | ||
40 | fi | ||
41 | fi | ||
42 | |||
43 | # The rest of the base template | ||
44 | sed -n '/@@INITFINISHED@@/,$p' < ${WORKDIR}/uEnv.txt | sed -n '2,$p' >> $UENV_TEMPLATE | ||
45 | |||
46 | # Substitute the variables | ||
47 | sed -e 's/@@SOTA_BOOTLOADER_EXTRA_PARAMS@@/${SOTA_BOOTLOADER_EXTRA_PARAMS}/' \ | ||
48 | -e 's/@@SOTA_BOOTLOADER_BOOTCOMMAND@@/${SOTA_BOOTLOADER_BOOTCOMMAND}/' \ | ||
49 | -e 's/@@SOTA_BOOTLOADER_KERNEL_ADDR@@/${SOTA_BOOTLOADER_KERNEL_ADDR}/' \ | ||
50 | -e 's/@@SOTA_BOOTLOADER_RAMDISK_ADDR@@/${SOTA_BOOTLOADER_RAMDISK_ADDR}/' \ | ||
51 | -e 's/@@SOTA_BOOTLOADER_FDT_ADDR@@/${SOTA_BOOTLOADER_FDT_ADDR}/' \ | ||
52 | -e 's/@@SOTA_BOOTLOADER_BOOT_PART@@/${SOTA_BOOTLOADER_BOOT_PART}/' \ | ||
53 | -e 's/@@SOTA_BOOTLOADER_MAIN_PART@@/${SOTA_BOOTLOADER_MAIN_PART}/' \ | ||
54 | -e 's/@@SOTA_BOOTLOADER_ROOT_DEVICE@@/${SOTA_BOOTLOADER_ROOT_DEVICE}/' \ | ||
55 | "$UENV_TEMPLATE" > ${WORKDIR}/uEnv-final.txt | ||
56 | } | ||
57 | |||
58 | do_deploy() { | ||
59 | install -d ${DEPLOYDIR} | ||
60 | install -m 0644 ${WORKDIR}/uEnv-final.txt ${DEPLOYDIR}/uEnv.txt | ||
61 | } | ||
62 | |||
63 | addtask deploy after do_compile before do_build | ||