summaryrefslogtreecommitdiffstats
path: root/recipes-sota/ota-u-boot-script/ota-u-boot-script.bb
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-sota/ota-u-boot-script/ota-u-boot-script.bb')
-rw-r--r--recipes-sota/ota-u-boot-script/ota-u-boot-script.bb63
1 files changed, 63 insertions, 0 deletions
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 @@
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
12python () {
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
23do_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
58do_deploy() {
59 install -d ${DEPLOYDIR}
60 install -m 0644 ${WORKDIR}/uEnv-final.txt ${DEPLOYDIR}/uEnv.txt
61}
62
63addtask deploy after do_compile before do_build