<!--
* Copyright (C) 2012, Freescale Semiconductor, Inc. All Rights Reserved.
* The CFG element contains a list of recognized usb devices.
*  DEV elements provide a name, class, vid and pid for each device.
*
* Each LIST element contains a list of update instructions.
*  "Install" - Erase media and install firmware.
*  "Update" - Update firmware only.
*
* Each CMD element contains one update instruction of attribute type.
*  "pull" - Does UtpRead(body, file) transaction.
*  "push" - Does UtpWrite(body, file) transaction.
*  "drop" - Does UtpCommand(body) then waits for device to disconnect.
*  "boot" - Finds configured device, forces it to "body" device and downloads "file".
*  "find" - Waits for "timeout" seconds for the "body" device to connect.
*  "show" - Parse and show device info in "file".
-->


<UCL>
  <CFG>
    <STATE name="BootStrap" dev="MX6SL" vid="15A2" pid="0063"/>
    <STATE name="BootStrap" dev="MX6D" vid="15A2" pid="0061"/>
    <STATE name="BootStrap" dev="MX6Q" vid="15A2" pid="0054"/>
    <STATE name="BootStrap" dev="MX6SX" vid="15A2" pid="0071"/>
    <STATE name="BootStrap" dev="MX6UL" vid="15A2" pid="007D"/>
    <STATE name="BootStrap" dev="MX7D" vid="15A2" pid="0076"/>
    <STATE name="Updater"   dev="MSC" vid="066F" pid="37FF"/>
  </CFG>

  <LIST name="KernelDts" desc="Download Kernel and dts">
    <CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-%board%.imx">Loading U-boot</CMD>

    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x80800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Kernel.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x12000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Kernel.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x83800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Initramfs.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x12C00000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Initramfs.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x83000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading device tree.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x18000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading device tree.</CMD>

    <CMD state="BootStrap" type="jump" > Jumping to OS image. </CMD>


    <!-- ########### -->
    <!--    Kernel   -->
    <!-- ########### -->

    <!-- create fat partition -->
    <CMD state="Updater" type="push" body="$ mkfs.vfat /dev/mmcblk%mmc%p1">Formatting rootfs partition</CMD>
    <CMD state="Updater" type="push" body="$ mkdir -p /mnt/mmcblk%mmc%p1"/>
    <CMD state="Updater" type="push" body="$ mount -t vfat /dev/mmcblk%mmc%p1 /mnt/mmcblk%mmc%p1"/>

    <!-- burn kernel -->
    <CMD state="Updater" type="push" body="send" file="files/zImage-%board%">Sending kernel zImage</CMD>
    <CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/zImage">write kernel image to sd card</CMD>

    <!-- burn dtb -->
    <CMD state="Updater" type="push" body="send" file="files/%board%-%dtb%.dtb">Sending DTB</CMD>
    <CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/%board%-%dtb%.dtb">write DTB</CMD>

	<!-- Add bootscript -->
    <CMD state="Updater" type="push" body="send" file="files/boot.scr">Sending bootscript</CMD>
    <CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/boot.scr">write bootscript</CMD>

    <CMD state="Updater" type="push" body="$ umount /mnt/mmcblk%mmc%p1">Unmounting vfat partition</CMD>
    
    <CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>    
  </LIST>


  <LIST name="BootLoadersToEmmc" desc="SPL and u-boot to eMMC">

    <CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-%board%.imx">Loading U-boot</CMD>

    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x80800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Kernel.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x12000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Kernel.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x83800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Initramfs.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x12C00000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Initramfs.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x83000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading device tree.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x18000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading device tree.</CMD>

    <CMD state="BootStrap" type="jump" > Jumping to OS image. </CMD>


    <!-- burn SPL -->
    <CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk%mmc% bs=1k seek=384 conv=fsync count=129">clear u-boot arg</CMD>
    <!-- access boot partition -->
    <CMD state="Updater" type="push" body="$ echo 0 > /sys/block/mmcblk%mmc%boot0/force_ro">access boot partition 1</CMD>

    <CMD state="Updater" type="push" body="send" file="files/SPL-%board%">Sending SPL</CMD>
    <CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%boot0 bs=512 seek=2">write SPL to eMMC</CMD>

    <CMD state="Updater" type="push" body="send" file="files/u-boot-%board%.img">Sending u-boot.img</CMD>
    <CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%boot0 bs=512 seek=138">write u-boot.img to eMMC</CMD>

    <CMD state="Updater" type="push" body="$ echo 1 > /sys/block/mmcblk%mmc%boot0/force_ro"> re-enable read-only access </CMD>
    <CMD state="Updater" type="push" body="$ echo 8 > /sys/block/mmcblk%mmc%/device/boot_config">enable boot partion 1 to boot</CMD>

    <CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
  </LIST>


  <LIST name="AllToEmmc" desc="Bootloaders, kernel and File system">
    <CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-%board%.imx">Loading U-boot</CMD>

    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x80800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Kernel.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x12000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Kernel.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x83800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Initramfs.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x12C00000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Initramfs.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x83000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading device tree.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x18000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading device tree.</CMD>

    <CMD state="BootStrap" type="jump" > Jumping to OS image. </CMD>

    <!-- create partition -->
    <CMD state="Updater" type="push" body="send" file="mksdcard.sh.tar">Sending partition shell</CMD>
    <CMD state="Updater" type="push" body="$ tar xf $FILE "> Partitioning...</CMD>
    <CMD state="Updater" type="push" body="$ sh mksdcard.sh /dev/mmcblk%mmc%"> Partitioning...</CMD>


    <!-- ########### -->
    <!-- Bootloaders -->
    <!-- ########### -->

    <CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk%mmc% bs=1k seek=384 conv=fsync count=129">clear u-boot arg</CMD>
    <!-- access boot partition -->
    <CMD state="Updater" type="push" body="$ echo 0 > /sys/block/mmcblk%mmc%boot0/force_ro">access boot partition 1</CMD>

    <CMD state="Updater" type="push" body="send" file="files/SPL-%board%">Sending SPL</CMD>
    <CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%boot0 bs=512 seek=2">write SPL to eMMC</CMD>

    <CMD state="Updater" type="push" body="send" file="files/u-boot-%board%.img">Sending u-boot.img</CMD>
    <CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%boot0 bs=512 seek=138">write u-boot.img to eMMC</CMD>

    <CMD state="Updater" type="push" body="$ echo 1 > /sys/block/mmcblk%mmc%boot0/force_ro"> re-enable read-only access </CMD>
    <CMD state="Updater" type="push" body="$ echo 8 > /sys/block/mmcblk%mmc%/device/boot_config">enable boot partion 1 to boot</CMD>

    <!-- ########### -->
    <!--    Kernel   -->
    <!-- ########### -->

    <!-- create fat partition -->
    <CMD state="Updater" type="push" body="$ mkfs.vfat /dev/mmcblk%mmc%p1">Formatting rootfs partition</CMD>
    <CMD state="Updater" type="push" body="$ mkdir -p /mnt/mmcblk%mmc%p1"/>
    <CMD state="Updater" type="push" body="$ mount -t vfat /dev/mmcblk%mmc%p1 /mnt/mmcblk%mmc%p1"/>

    <!-- burn kernel -->
    <CMD state="Updater" type="push" body="send" file="files/zImage-%board%">Sending kernel zImage</CMD>
    <CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/zImage">write kernel image to sd card</CMD>

    <!-- burn dtb -->
    <CMD state="Updater" type="push" body="send" file="files/%board%-%dtb%.dtb">Sending DTB</CMD>
    <CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/%board%-%dtb%.dtb">write DTB</CMD>

    <CMD state="Updater" type="push" body="$ umount /mnt/mmcblk%mmc%p1">Unmounting vfat partition</CMD>

    <!-- ########### -->
    <!--   Root FS   -->
    <!-- ########### -->

    <!-- burn rootfs -->
    <CMD state="Updater" type="push" body="pipe dd of=/dev/mmcblk%mmc%p2 bs=1M"
      file="files/%rootfs%-%board%.rootfs.ext3">Sending and writing rootfs</CMD>
    <CMD state="Updater" type="push" body="frf">Finishing rootfs write</CMD>

    <CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
  </LIST>


  <LIST name="AllToEmmcRootfsTar" desc="Bootloaders, kernel and File system where FS is a tar file">
    <CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-%board%.imx">Loading U-boot</CMD>

    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x80800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Kernel.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x12000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Kernel.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x83800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Initramfs.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x12C00000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Initramfs.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x83000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading device tree.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x18000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading device tree.</CMD>

    <CMD state="BootStrap" type="jump" > Jumping to OS image. </CMD>

    <!-- create partition -->
    <CMD state="Updater" type="push" body="send" file="mksdcard.sh.tar">Sending partition shell</CMD>
    <CMD state="Updater" type="push" body="$ tar xf $FILE "> Partitioning...</CMD>
    <CMD state="Updater" type="push" body="$ sh mksdcard.sh /dev/mmcblk%mmc%"> Partitioning...</CMD>


    <!-- ########### -->
    <!-- Bootloaders -->
    <!-- ########### -->

    <CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk%mmc% bs=1k seek=384 conv=fsync count=129">clear u-boot arg</CMD>
    <!-- access boot partition -->
    <CMD state="Updater" type="push" body="$ echo 0 > /sys/block/mmcblk%mmc%boot0/force_ro">access boot partition 1</CMD>

    <CMD state="Updater" type="push" body="send" file="files/SPL-%board%">Sending SPL</CMD>
    <CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%boot0 bs=512 seek=2">write SPL to eMMC</CMD>

    <CMD state="Updater" type="push" body="send" file="files/u-boot-%board%.img">Sending u-boot.img</CMD>
    <CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%boot0 bs=512 seek=138">write u-boot.img to eMMC</CMD>

    <CMD state="Updater" type="push" body="$ echo 1 > /sys/block/mmcblk%mmc%boot0/force_ro"> re-enable read-only access </CMD>
    <CMD state="Updater" type="push" body="$ echo 8 > /sys/block/mmcblk%mmc%/device/boot_config">enable boot partion 1 to boot</CMD>

    <!-- ########### -->
    <!--    Kernel   -->
    <!-- ########### -->

    <!-- create fat partition -->
    <CMD state="Updater" type="push" body="$ mkfs.vfat /dev/mmcblk%mmc%p1">Formatting rootfs partition</CMD>
    <CMD state="Updater" type="push" body="$ mkdir -p /mnt/mmcblk%mmc%p1"/>
    <CMD state="Updater" type="push" body="$ mount -t vfat /dev/mmcblk%mmc%p1 /mnt/mmcblk%mmc%p1"/>

    <!-- burn kernel -->
    <CMD state="Updater" type="push" body="send" file="files/zImage-%board%">Sending kernel zImage</CMD>
    <CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/zImage">write kernel image to sd card</CMD>

    <!-- burn dtb -->
    <CMD state="Updater" type="push" body="send" file="files/%board%-%dtb%.dtb">Sending DTB</CMD>
    <CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/%board%-%dtb%.dtb">write DTB</CMD>

    <CMD state="Updater" type="push" body="$ umount /mnt/mmcblk%mmc%p1">Unmounting vfat partition</CMD>

    <!-- ########### -->
    <!--   Root FS   -->
    <!-- ########### -->

    <!-- burn rootfs -->
    <CMD state="Updater" type="push" body="$ mkfs.ext3 -E nodiscard /dev/mmcblk%mmc%p2">Formatting rootfs partition</CMD>
    <CMD state="Updater" type="push" body="$ mkdir -p /mnt/mmcblk%mmc%p2"/>
    <CMD state="Updater" type="push" body="$ mount -t ext3 /dev/mmcblk%mmc%p2 /mnt/mmcblk%mmc%p2"/>
    <CMD state="Updater" type="push" body="pipe tar -jx -C /mnt/mmcblk%mmc%p2" file="files/%rootfs%-%board%.rootfs.tar.bz2">Sending and writing rootfs</CMD>
    <CMD state="Updater" type="push" body="frf">Finishing rootfs write</CMD>

    <CMD state="Updater" type="push" body="$ umount /mnt/mmcblk%mmc%p2">Unmounting rootfs partition</CMD>

    <CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
  </LIST>


  <LIST name="UpdateRootFsOnEmmc" desc="Write a new Root FS to e-mmc">
    <CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-%board%.imx">Loading U-boot</CMD>

    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x80800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Kernel.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x12000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Kernel.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x83800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Initramfs.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x12C00000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Initramfs.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x83000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading device tree.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x18000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading device tree.</CMD>

    <CMD state="BootStrap" type="jump" > Jumping to OS image. </CMD>


    <!-- ########### -->
    <!--   Root FS   -->
    <!-- ########### -->

    <!-- burn rootfs -->
    <CMD state="Updater" type="push" body="pipe dd of=/dev/mmcblk%mmc%p2 bs=1M"
      file="files/%rootfs%-%board%.rootfs.ext3">Sending and writing rootfs</CMD>
    <CMD state="Updater" type="push" body="frf">Finishing rootfs write</CMD>

    <CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
  </LIST>


  <LIST name="AllToEmmcFromUsb" desc="Bootloaders, kernel and File system loaded from USB memory">
    <CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-%board%.imx">Loading U-boot</CMD>

    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x80800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Kernel.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x12000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Kernel.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x83800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Initramfs.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x12C00000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Initramfs.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x83000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading device tree.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x18000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading device tree.</CMD>

    <CMD state="BootStrap" type="jump" > Jumping to OS image. </CMD>


    <!-- create partition -->
    <CMD state="Updater" type="push" body="send" file="mksdcard.sh.tar">Sending partition shell</CMD>
    <CMD state="Updater" type="push" body="$ tar xf $FILE "> Partitioning...</CMD>
    <CMD state="Updater" type="push" body="$ sh mksdcard.sh /dev/mmcblk%mmc%"> Partitioning...</CMD>

    <CMD state="Updater" type="push" body="send" file="waitusb.sh">Sending waitusb script</CMD>
    <CMD state="Updater" type="push" body="$ sh $FILE"> Waiting..</CMD>

    <CMD state="Updater" type="push" body="$ mkdir /mnt/usb">Create mount point</CMD>
    <CMD state="Updater" type="push" body="$ mount -r /dev/sda1 /mnt/usb">Mounting</CMD>

    <!-- ########### -->
    <!-- Bootloaders -->
    <!-- ########### -->

    <CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk%mmc% bs=1k seek=384 conv=fsync count=129">clear u-boot arg</CMD>
    <!-- access boot partition -->
    <CMD state="Updater" type="push" body="$ echo 0 > /sys/block/mmcblk%mmc%boot0/force_ro">access boot partition 1</CMD>

    <CMD state="Updater" type="push" body="$ dd if=/mnt/usb/SPL-%board% of=/dev/mmcblk%mmc%boot0 bs=512 seek=2">write SPL to eMMC</CMD>

    <CMD state="Updater" type="push" body="$ dd if=/mnt/usb/u-boot-%board%.img of=/dev/mmcblk%mmc%boot0 bs=512 seek=138">write u-boot.img to eMMC</CMD>

    <CMD state="Updater" type="push" body="$ echo 1 > /sys/block/mmcblk%mmc%boot0/force_ro"> re-enable read-only access </CMD>
    <CMD state="Updater" type="push" body="$ echo 8 > /sys/block/mmcblk%mmc%/device/boot_config">enable boot partion 1 to boot</CMD>

    <!-- ########### -->
    <!--    Kernel   -->
    <!-- ########### -->

    <!-- create fat partition -->
    <CMD state="Updater" type="push" body="$ mkfs.vfat /dev/mmcblk%mmc%p1">Formatting rootfs partition</CMD>
    <CMD state="Updater" type="push" body="$ mkdir -p /mnt/mmcblk%mmc%p1"/>
    <CMD state="Updater" type="push" body="$ mount -t vfat /dev/mmcblk%mmc%p1 /mnt/mmcblk%mmc%p1"/>

    <!-- burn kernel -->
    <CMD state="Updater" type="push" body="$ cp /mnt/usb/zImage-%board% /mnt/mmcblk%mmc%p1/zImage">write kernel image to sd card</CMD>

    <!-- burn dtb -->
    <CMD state="Updater" type="push" body="$ cp /mnt/usb/%board%-%dtb%.dtb /mnt/mmcblk%mmc%p1/%board%-%dtb%.dtb">write DTB</CMD>

    <CMD state="Updater" type="push" body="$ umount /mnt/mmcblk%mmc%p1">Unmounting vfat partition</CMD>

    <!-- ########### -->
    <!--   Root FS   -->
    <!-- ########### -->

    <!--    burn rootfs -->
    <CMD state="Updater" type="push" body="$ dd if=/mnt/usb/%rootfs%-%board%.rootfs.ext3 of=/dev/mmcblk%mmc%p2 bs=1M">write image</CMD>

    <CMD state="Updater" type="push" body="$ umount /mnt/usb">Un-mounting</CMD>
    <CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
  </LIST>


  <LIST name="ExpandRootFsEmmc" desc="Expands file system to use entire eMMC">
    <CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-%board%.imx">Loading U-boot</CMD>

    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x80800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Kernel.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/zImage-%board%" address="0x12000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Kernel.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x83800000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading Initramfs.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot" address="0x12C00000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Initramfs.</CMD>

    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x83000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL MX6SX">Loading device tree.</CMD>
    <CMD state="BootStrap" type="load" file="firmware/%board%-%dtb%.dtb" address="0x18000000"
      loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading device tree.</CMD>

    <CMD state="BootStrap" type="jump" > Jumping to OS image. </CMD>

    <!-- resize rootfs to use all available space -->
    <CMD state="Updater" type="push" body="send" file="resizedisk.sh">Sending resizedisk script</CMD>
    <CMD state="Updater" type="push" body="$ sh $FILE /dev/mmcblk%mmc%">Resizing disk..</CMD>

    <CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
  </LIST>
</UCL>
