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 | |
parent | 3b9b75140ea58f546829cb3cf1b234e5b650de77 (diff) | |
download | meta-updater-feat/universaluenv.tar.gz |
Add universal uEnv recipefeat/universaluenv
Signed-off-by: Anton Gerasimov <anton.gerasimov@here.com>
-rw-r--r-- | README.adoc | 16 | ||||
-rw-r--r-- | classes/image_types_ostree.bbclass | 7 | ||||
-rw-r--r-- | classes/sota.bbclass | 17 | ||||
-rw-r--r-- | classes/sota_raspberrypi.bbclass | 8 | ||||
-rw-r--r-- | recipes-sota/ota-u-boot-script/files/uEnv-fileenv.txt | 1 | ||||
-rw-r--r-- | recipes-sota/ota-u-boot-script/files/uEnv-fit.txt | 1 | ||||
-rw-r--r-- | recipes-sota/ota-u-boot-script/files/uEnv-rollback.txt | 8 | ||||
-rw-r--r-- | recipes-sota/ota-u-boot-script/files/uEnv.txt | 34 | ||||
-rw-r--r-- | recipes-sota/ota-u-boot-script/ota-u-boot-script.bb | 63 |
9 files changed, 146 insertions, 9 deletions
diff --git a/README.adoc b/README.adoc index 27ecabf..d425095 100644 --- a/README.adoc +++ b/README.adoc | |||
@@ -70,9 +70,20 @@ If your board isn't supported yet, you can add board integration code yourself. | |||
70 | 1. Make the board boot into http://www.denx.de/wiki/U-Boot[U-Boot] | 70 | 1. Make the board boot into http://www.denx.de/wiki/U-Boot[U-Boot] |
71 | 2. Make U-boot import variables from /boot/loader/uEnv.txt and load the kernel with initramfs and kernel command line arguments according to what is set in this file. | 71 | 2. Make U-boot import variables from /boot/loader/uEnv.txt and load the kernel with initramfs and kernel command line arguments according to what is set in this file. |
72 | 72 | ||
73 | You may take a look into https://github.com/advancedtelematic/meta-updater-minnowboard[Minnowboard] or https://github.com/advancedtelematic/meta-updater-raspberrypi[Raspberry Pi] integration layers for examples. | 73 | There is a flexible universal U-boot script provided by meta-updater to do OSTree-enabled boot, `ota-u-boot-script`. It is not being deployed by default, so you should enable it in your machine configuration. This script can be configured with following variables: |
74 | 74 | ||
75 | Although we have used U-Boot so far, other boot loaders can be configured work with OSTree as well. | 75 | * `SOTA_BOOTLOADER_BOOTCOMMAND` - command U-Boot will use to load the kernel. Normally is either `bootm` or `bootz`. |
76 | * `SOTA_BOOTLOADER_BOOT_PART` - boot partition the script will use. Now only used for storing the U-Boot environment. Should be a full partition name, e.g. `mmc 0:1`. | ||
77 | * `SOTA_BOOTLOADER_MAIN_PART` - the partition where the OSTree sysroot resides. Should be a full partition name, e.g. `mmc 0:1` | ||
78 | * `SOTA_BOOTLOADER_KERNEL_ADDR` - address to load the kernel to. Can't refer to another variable, should be a (normally hex) number e.g. `0x02700000`. | ||
79 | * `SOTA_BOOTLOADER_RAMDISK_ADDR` - address to load the ramdisk to. Can't refer to another variable, should be a (normally hex) number e.g. `0x02700000`. Set to empty when using FIT image with ramdisk packed (`KERNEL_IMAGETYPE = "fitImage"`). | ||
80 | * `SOTA_BOOTLOADER_FDT_ADDR` - address to load the device tree to. Can't refer to another variable, should be a (normally hex) number e.g. `0x02700000`. Set to empty when no device tree is used. | ||
81 | * `SOTA_BOOTLOADER_ROOT_DEVICE` - the partition where the OSTree sysroot resides as linux device path, e.g. `/dev/mmcblk0p2`. | ||
82 | * `SOTA_BOOTLOADER_EXTRA_PARAMS` - extra parameters to add to kernel command line. Note that these parameters will be non-updatable, it is recommended in most cases to use `OSTREE_KERNEL_ARGS` instead. | ||
83 | |||
84 | Although meta-updater is best integrated with U-Boot so far, basic support for Grub also exists. In addition to these two bootloaders libostree also supports SysLinux. | ||
85 | |||
86 | Normally there still has to be some platform-dependent integration snippet that would source the script provided by meta-updater and/or OSTree. For an example of such snippets you can look into https://github.com/advancedtelematic/meta-updater-raspberrypi[Raspberry Pi] (U-Boot) and https://github.com/advancedtelematic/meta-updater-minnowboard[Minnowboard] (Grub, directly loads snippet provided by libostree) integration layers. | ||
76 | 87 | ||
77 | == SOTA-related variables in local.conf | 88 | == SOTA-related variables in local.conf |
78 | 89 | ||
@@ -82,6 +93,7 @@ Although we have used U-Boot so far, other boot loaders can be configured work w | |||
82 | * `OSTREE_COMMIT_SUBJECT` - Commit subject used by OSTree. Defaults to `Commit-id: ${IMAGE_NAME}` | 93 | * `OSTREE_COMMIT_SUBJECT` - Commit subject used by OSTree. Defaults to `Commit-id: ${IMAGE_NAME}` |
83 | * `OSTREE_UPDATE_SUMMARY` - Set this to '1' to update summary of OSTree repository on each commit. '0' by default. | 94 | * `OSTREE_UPDATE_SUMMARY` - Set this to '1' to update summary of OSTree repository on each commit. '0' by default. |
84 | * `OSTREE_DEPLOY_DEVICETREE` - Set this to '1' to include devicetree(s) to boot | 95 | * `OSTREE_DEPLOY_DEVICETREE` - Set this to '1' to include devicetree(s) to boot |
96 | * `OSTREE_KERNEL_ARGS` - Parameters to kernel command line. | ||
85 | * `INITRAMFS_IMAGE` - initramfs/initrd image that is used as a proxy while booting into OSTree deployment. Do not change this setting unless you are sure that your initramfs can serve as such a proxy. | 97 | * `INITRAMFS_IMAGE` - initramfs/initrd image that is used as a proxy while booting into OSTree deployment. Do not change this setting unless you are sure that your initramfs can serve as such a proxy. |
86 | * `SOTA_PACKED_CREDENTIALS` - when set, your ostree commit will be pushed to a remote repo as a bitbake step. This should be the path to a zipped credentials file in https://github.com/advancedtelematic/aktualizr/blob/master/docs/credentials.adoc[the format accepted by garage-push]. | 98 | * `SOTA_PACKED_CREDENTIALS` - when set, your ostree commit will be pushed to a remote repo as a bitbake step. This should be the path to a zipped credentials file in https://github.com/advancedtelematic/aktualizr/blob/master/docs/credentials.adoc[the format accepted by garage-push]. |
87 | * `SOTA_DEPLOY_CREDENTIALS` - when set to '1' (default value), deploys credentials to the built image. Override it in `local.conf` to built a generic image that can be provisioned manually after the build. | 99 | * `SOTA_DEPLOY_CREDENTIALS` - when set to '1' (default value), deploys credentials to the built image. Override it in `local.conf` to built a generic image that can be provisioned manually after the build. |
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 29da78e..a6c9155 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -112,7 +112,12 @@ IMAGE_CMD_ostree () { | |||
112 | touch boot/initramfs-${checksum} | 112 | touch boot/initramfs-${checksum} |
113 | else | 113 | else |
114 | if [ "${OSTREE_DEPLOY_DEVICETREE}" = "1" ] && [ -n "${KERNEL_DEVICETREE}" ]; then | 114 | if [ "${OSTREE_DEPLOY_DEVICETREE}" = "1" ] && [ -n "${KERNEL_DEVICETREE}" ]; then |
115 | checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${KERNEL_DEVICETREE} | sha256sum | cut -f 1 -d " ") | 115 | kernel_ostree_fullpath="" |
116 | for blob in ${KERNEL_DEVICETREE}; do | ||
117 | kernel_ostree_fullpath="$kernel_ostree_fullpath ${DEPLOY_DIR_IMAGE}/$blob" | ||
118 | done | ||
119 | |||
120 | checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} $kernel_ostree_fullpath | sha256sum | cut -f 1 -d " ") | ||
116 | for DTS_FILE in ${KERNEL_DEVICETREE}; do | 121 | for DTS_FILE in ${KERNEL_DEVICETREE}; do |
117 | DTS_FILE_BASENAME=$(basename ${DTS_FILE}) | 122 | DTS_FILE_BASENAME=$(basename ${DTS_FILE}) |
118 | cp ${DEPLOY_DIR_IMAGE}/${DTS_FILE_BASENAME} boot/devicetree-${DTS_FILE_BASENAME}-${checksum} | 123 | cp ${DEPLOY_DIR_IMAGE}/${DTS_FILE_BASENAME} boot/devicetree-${DTS_FILE_BASENAME}-${checksum} |
diff --git a/classes/sota.bbclass b/classes/sota.bbclass index 92b4c43..236a3bb 100644 --- a/classes/sota.bbclass +++ b/classes/sota.bbclass | |||
@@ -21,7 +21,11 @@ WKS_FILE_sota ?= "sdimage-sota.wks" | |||
21 | 21 | ||
22 | EXTRA_IMAGEDEPENDS_append_sota = " parted-native mtools-native dosfstools-native" | 22 | EXTRA_IMAGEDEPENDS_append_sota = " parted-native mtools-native dosfstools-native" |
23 | 23 | ||
24 | INITRAMFS_FSTYPES ?= "${@oe.utils.ifelse(d.getVar('OSTREE_BOOTLOADER') == 'u-boot', 'cpio.gz.u-boot', 'cpio.gz')}" | 24 | # Has to be an override, because 'INITRAMFS_FSTYPES ?=' is not strong enough to override the default value |
25 | INITRAMFS_FSTYPES_sota ?= "${@oe.utils.ifelse(d.getVar('OSTREE_BOOTLOADER') == 'u-boot' and d.getVar('KERNEL_IMAGETYPE') != 'fitImage', 'cpio.gz.u-boot', 'cpio.gz')}" | ||
26 | |||
27 | # Deploy config fragment list to OSTree root fs | ||
28 | IMAGE_INSTALL_append = "${@oe.utils.ifelse(d.getVar('KERNEL_IMAGETYPE') == 'fitImage', ' fit-conf', ' ')}" | ||
25 | 29 | ||
26 | # Please redefine OSTREE_REPO in order to have a persistent OSTree repo | 30 | # Please redefine OSTREE_REPO in order to have a persistent OSTree repo |
27 | export OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" | 31 | export OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" |
@@ -38,6 +42,15 @@ GARAGE_TARGET_NAME ?= "${OSTREE_BRANCHNAME}" | |||
38 | GARAGE_TARGET_VERSION ?= "" | 42 | GARAGE_TARGET_VERSION ?= "" |
39 | GARAGE_TARGET_URL ?= "https://example.com/" | 43 | GARAGE_TARGET_URL ?= "https://example.com/" |
40 | 44 | ||
45 | SOTA_BOOTLOADER_EXTRA_PARAMS ??= "" | ||
46 | SOTA_BOOTLOADER_BOOTCOMMAND ??= "bootm" | ||
47 | SOTA_BOOTLOADER_KERNEL_ADDR ??= "0x02700000" | ||
48 | SOTA_BOOTLOADER_RAMDISK_ADDR ??= "" | ||
49 | SOTA_BOOTLOADER_FDT_ADDR ??= "" | ||
50 | SOTA_BOOTLOADER_BOOT_PART ??= "mmc 0:1" | ||
51 | SOTA_BOOTLOADER_MAIN_PART ??= "mmc 0:2" | ||
52 | SOTA_BOOTLOADER_ROOT_DEVICE ??= "/dev/mmcblk0p2" | ||
53 | |||
41 | SOTA_MACHINE ??="none" | 54 | SOTA_MACHINE ??="none" |
42 | SOTA_MACHINE_rpi ?= "raspberrypi" | 55 | SOTA_MACHINE_rpi ?= "raspberrypi" |
43 | SOTA_MACHINE_porter ?= "porter" | 56 | SOTA_MACHINE_porter ?= "porter" |
@@ -49,4 +62,6 @@ SOTA_MACHINE_am335x-evm ?= "am335x-evm-wifi" | |||
49 | SOTA_OVERRIDES_BLACKLIST = "ostree ota" | 62 | SOTA_OVERRIDES_BLACKLIST = "ostree ota" |
50 | SOTA_REQUIRED_VARIABLES = "OSTREE_REPO OSTREE_BRANCHNAME OSTREE_OSNAME OSTREE_BOOTLOADER OSTREE_BOOT_PARTITION GARAGE_SIGN_REPO GARAGE_TARGET_NAME" | 63 | SOTA_REQUIRED_VARIABLES = "OSTREE_REPO OSTREE_BRANCHNAME OSTREE_OSNAME OSTREE_BOOTLOADER OSTREE_BOOT_PARTITION GARAGE_SIGN_REPO GARAGE_TARGET_NAME" |
51 | 64 | ||
65 | do_image_wic[depends] += " ota-u-boot-script:do_deploy " | ||
66 | |||
52 | inherit sota_sanity sota_${SOTA_MACHINE} image_repo_manifest | 67 | inherit sota_sanity sota_${SOTA_MACHINE} image_repo_manifest |
diff --git a/classes/sota_raspberrypi.bbclass b/classes/sota_raspberrypi.bbclass index e1c0054..88b5f21 100644 --- a/classes/sota_raspberrypi.bbclass +++ b/classes/sota_raspberrypi.bbclass | |||
@@ -2,16 +2,12 @@ RPI_USE_U_BOOT_sota = "1" | |||
2 | 2 | ||
3 | KERNEL_CLASSES_append_sota = " kernel-fitimage" | 3 | KERNEL_CLASSES_append_sota = " kernel-fitimage" |
4 | KERNEL_IMAGETYPE_sota = "fitImage" | 4 | KERNEL_IMAGETYPE_sota = "fitImage" |
5 | INITRAMFS_FSTYPES = "cpio.gz" | ||
6 | OSTREE_KERNEL = "${KERNEL_IMAGETYPE}-${INITRAMFS_IMAGE}-${MACHINE}-${KERNEL_FIT_LINK_NAME}" | 5 | OSTREE_KERNEL = "${KERNEL_IMAGETYPE}-${INITRAMFS_IMAGE}-${MACHINE}-${KERNEL_FIT_LINK_NAME}" |
7 | 6 | ||
8 | # DTB needs to be relocated to apply overlays | 7 | # DTB needs to be relocated to apply overlays |
9 | UBOOT_DTB_LOADADDRESS = "0x05000000" | 8 | UBOOT_DTB_LOADADDRESS = "0x05000000" |
10 | UBOOT_DTBO_LOADADDRESS = "0x06000000" | 9 | UBOOT_DTBO_LOADADDRESS = "0x06000000" |
11 | 10 | ||
12 | # Deploy config fragment list to OSTree root fs | ||
13 | IMAGE_INSTALL_append = " fit-conf" | ||
14 | |||
15 | PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" | 11 | PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" |
16 | UBOOT_ENTRYPOINT_sota ?= "0x00008000" | 12 | UBOOT_ENTRYPOINT_sota ?= "0x00008000" |
17 | 13 | ||
@@ -19,7 +15,7 @@ IMAGE_FSTYPES_remove_sota = "rpi-sdimg" | |||
19 | OSTREE_BOOTLOADER ?= "u-boot" | 15 | OSTREE_BOOTLOADER ?= "u-boot" |
20 | 16 | ||
21 | # OSTree puts its own boot.scr to bcm2835-bootfiles | 17 | # OSTree puts its own boot.scr to bcm2835-bootfiles |
22 | IMAGE_BOOT_FILES_sota = "bcm2835-bootfiles/* u-boot.bin;${SDIMG_KERNELIMAGE}" | 18 | IMAGE_BOOT_FILES_sota = "bcm2835-bootfiles/* uEnv.txt u-boot.bin;${SDIMG_KERNELIMAGE}" |
23 | 19 | ||
24 | # Just the overlays that will be used should be listed | 20 | # Just the overlays that will be used should be listed |
25 | KERNEL_DEVICETREE_raspberrypi2_sota ?= " bcm2709-rpi-2-b.dtb " | 21 | KERNEL_DEVICETREE_raspberrypi2_sota ?= " bcm2709-rpi-2-b.dtb " |
@@ -35,3 +31,5 @@ OSTREE_KERNEL_ARGS_sota ?= " 8250.nr_uarts=1 bcm2708_fb.fbwidth=656 bcm2708_fb.f | |||
35 | 31 | ||
36 | SOTA_CLIENT_FEATURES_append = " ubootenv" | 32 | SOTA_CLIENT_FEATURES_append = " ubootenv" |
37 | 33 | ||
34 | SOTA_ROLLBACK_MECHANISM = "file-env" | ||
35 | |||
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 | ||