summaryrefslogtreecommitdiffstats
path: root/recipes-sota/ota-u-boot-script/ota-u-boot-script.bb
blob: 5c7ed570ec2387279b2bd4793250570cccb93862 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
DESCRIPTION = "Boot script template for OTA-enabled image"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

inherit deploy

SRC_URI = "file://uEnv-fileenv.txt \
           file://uEnv-fit.txt \
           file://uEnv-rollback.txt \
           file://uEnv.txt"

do_deploy() {

  UENV_TEMPLATE=$(mktemp)
  # Initialization portion
  sed -n '0,/%%INITFINISHED%%/p' < ${WORKDIR}/uEnv.txt | head -n -1 > $UENV_TEMPLATE

  # Support for FIT images
  if [ "${KERNEL_IMAGETYPE_SOTA}" = "fitImage"]; then
    cat ${WORKDIR}/uEnv-fit.txt >> $UENV_TEMPLATE
  fi

  # Rollback support
  if [ -n "${SOTA_ROLLBACK_MECHANISM}" ]; then
    cat ${WORKDIR}/uEnv-rollback.txt >> $UENV_TEMPLATE

    if [ "${SOTA_ROLLBACK_MECHANISM}" = "file-env" ];
      cat ${WORKDIR}/uEnv-fileenv.txt >> $UENV_TEMPLATE
    fi
  fi

  # The rest of the base template
  sed -n '/%%INITFINISHED%%/,$p' < ${WORKDIR}/uEnv.txt | sed -n '2,$p' >> $UENV_TEMPLATE

  # Substitute the variables
  sed -e 's/@@SOTA_BOOTLOADER_EXTRA_PARAMS@@/${SOTA_BOOTLOADER_EXTRA_PARAMS}' \
      -e 's/@@SOTA_BOOTLOADER_BOOTCOMMAND@@/${SOTA_BOOTLOADER_BOOTCOMMAND}' \
      -e 's/@@SOTA_BOOTLOADER_KERNEL_ADDR@@/${SOTA_BOOTLOADER_KERNEL_ADDR}' \
      -e 's/@@SOTA_BOOTLOADER_RAMDISK_ADDR@@/${SOTA_BOOTLOADER_RAMDISK_ADDR}' \
      -e 's/@@SOTA_BOOTLOADER_FDT_ADDR@@/${SOTA_BOOTLOADER_FDT_ADDR}' \
      -e 's/@@SOTA_BOOTLOADER_BOOT_PART@@/${SOTA_BOOTLOADER_BOOT_PART}' \
      -e 's/@@SOTA_BOOTLOADER_MAIN_PART@@/${SOTA_BOOTLOADER_KERNEL_MAIN_PART}' \
      -e 's/@@SOTA_BOOTLOADER_ROOT_DEVICE@@/${SOTA_BOOTLOADER_ROOT_DEVICE}' \
    "$UENV_TEMPLATE" > ${DEPLOY_DIR_IMAGE}/uEnv.txt


  if [ -n ""]
}

addtask deploy before do_package