<!--
* 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 the "body" device to connect.
*  "show" - Parse and show device info in "file".
-->


<UCL>
<CFG>
	<STATE name="Recovery" dev="IMX23"/>
	<STATE name="Updater" dev="Updater"/>  
    <DEV name="IMX23" vid="15A2" pid="004F"/>
    <DEV name="Updater" vid="066F" pid="37FF"/>
</CFG>
<LIST name="Multichip NAND" desc="Install on multichip NAND">
<CMD type="boot" body="Recovery" file="updater.sb">Booting update firmware.</CMD>
<CMD type="find" body="Updater" timeout="60"/>
<CMD type="pull" body="?" file="device.xml">Getting device info.</CMD>
<CMD type="show" file="device.xml" />
<CMD type="push" body="mknod class/mtd,mtd0,/dev/mtd0"/>
<CMD type="push" body="mknod class/mtd,mtd1,/dev/mtd1"/>
<CMD type="push" body="mknod class/mtd,mtd2,/dev/mtd2"/>
<CMD type="push" body="mknod class/misc,ubi_ctrl,/dev/ubi_ctrl"/>
<!--
****************************TAKE CARE************************************
* Adding below line if the user wants to erase all blocks including bad blocks.
* Users may use this option only when the bad block flag is changed between two
* operations, like the first operation is for WinCE, and the second opertion is for
* Linux.
* Besides, ONLY adding below line at R&D periods, as this may will cause the whole
* Nand chip unstable.
*
* echo 1 > /sys/devices/platform/gpmi-nfc.0/ignorebad
*
-->
<CMD type="push" body="$ flash_eraseall /dev/mtd0">Erasing boot partition</CMD>
<CMD type="push" body="$ flash_eraseall /dev/mtd1">Erasing boot partition</CMD>
<CMD type="push" body="$ flash_eraseall /dev/mtd2">Erasing rootfs partition</CMD>
<!--
****************************TAKE CARE************************************
* If the user sets ignorebad flag above, please clear it here
* echo 0 > /sys/devices/platform/gpmi-nfc.0/ignorebad
*
-->
<CMD type="push" body="send" file="files/linux.sb">Sending firmware</CMD>
<CMD type="push" body="$ kobs-ng init $FILE">Flashing firmware</CMD>

<CMD type="push" body="$ ubiattach /dev/ubi_ctrl -m 2 -d 0">Attaching UBI partition</CMD>
<CMD type="push" body="mknod class/ubi,ubi0,/dev/ubi0"/>
<CMD type="push" body="$ ubimkvol /dev/ubi0 -n 0 -N rootfs0 -s 256MiB">Creating UBI volumes</CMD>
<CMD type="push" body="$ ubimkvol /dev/ubi0 -n 1 -N rootfs1 -s 256MiB">Creating UBI volumes</CMD>
<CMD type="push" body="$ ubimkvol /dev/ubi0 -n 2 -N data -m">Creating UBI volumes</CMD>
<CMD type="push" body="$ mkdir -p /mnt/ubi0; mount -t ubifs ubi0_0 /mnt/ubi0" />
<CMD type="push" body="$ mkdir -p /mnt/ubi1; mount -t ubifs ubi0_1 /mnt/ubi1" />
<CMD type="push" body="pipe tar -jxv -C /mnt/ubi0" file="files/rootfs.bin">Transfer rootfs</CMD>
<CMD type="push" body="frf">Finish Flashing NAND</CMD>
<CMD type="push" body="pipe tar -jxv -C /mnt/ubi1" file="files/rootfs.bin">Transfer rootfs</CMD>
<CMD type="push" body="frf">Finish Flashing NAND</CMD>
<CMD type="push" body="$ umount /mnt/ubi0">Unmounting</CMD>
<CMD type="push" body="$ umount /mnt/ubi1">Unmounting</CMD>
</LIST>

<LIST name="Singlechip NAND" desc="Install on singlechip NAND">
<CMD type="boot" body="Recovery" file="updater.sb" timeout="60">Booting update firmware.</CMD>
<CMD type="find" body="Updater" timeout="60"/>
<CMD type="pull" body="?" file="device.xml">Getting device info.</CMD>
<CMD type="show" file="device.xml" />
<CMD type="push" body="mknod class/mtd,mtd0,/dev/mtd0"/>
<CMD type="push" body="mknod class/mtd,mtd1,/dev/mtd1"/>
<CMD type="push" body="mknod class/misc,ubi_ctrl,/dev/ubi_ctrl"/>
<!--
****************************TAKE CARE************************************
* Adding below line if the user wants to erase all blocks including bad blocks.
* Users may use this option only when the bad block flag is changed between two
* operations, like the first operation is for WinCE, and the second opertion is for
* Linux.
* Besides, ONLY adding below line at R&D periods, as this may will cause the whole
* Nand chip unstable.
*
* echo 1 > /sys/devices/platform/gpmi-nfc.0/ignorebad
*
-->
<CMD type="push" body="$ echo 1 > /sys/bus/platform/drivers/gpmi-nfc/gpmi-nfc.0/ignorebad">Erasing rootfs partition</CMD>
<CMD type="push" body="$ flash_eraseall /dev/mtd0">Erasing rootfs partition</CMD>
<CMD type="push" body="$ flash_eraseall /dev/mtd1">Erasing rootfs partition</CMD>
<CMD type="push" body="$ echo 0 > /sys/bus/platform/drivers/gpmi-nfc/gpmi-nfc.0/ignorebad">Erasing rootfs partition</CMD>
<!--
****************************TAKE CARE************************************
* If the user sets ignorebad flag above, please clear it here
* echo 0 > /sys/devices/platform/gpmi-nfc.0/ignorebad
*
-->
<CMD type="push" body="send" file="files/linux.sb">Sending firmware</CMD>
<CMD type="push" body="$ kobs-ng init $FILE">Flashing firmware</CMD>

<CMD type="push" body="$ ubiattach /dev/ubi_ctrl -m 1 -d 0">Attaching UBI partition</CMD>
<CMD type="push" body="mknod class/ubi,ubi0,/dev/ubi0"/>
<CMD type="push" body="$ ubimkvol /dev/ubi0 -n 0 -N rootfs0 -m">Creating UBI volumes</CMD>
<CMD type="push" body="$ ubimkvol /dev/ubi0 -n 1 -N data -m">Creating UBI volumes</CMD>
<CMD type="push" body="$ mkdir -p /mnt/ubi0; mount -t ubifs ubi0_0 /mnt/ubi0" />
<CMD type="push" body="pipe tar -jxv -C /mnt/ubi0" file="files/rootfs.bin">Transfer rootfs</CMD>
<CMD type="push" body="frf">Finish Flashing NAND</CMD>
<CMD type="push" body="$ umount /mnt/ubi0">Unmounting</CMD>
<CMD type="push" body="!3">Done</CMD>

</LIST>
<LIST name="SD" desc="Install to SD card">
    <CMD type="boot" body="Recovery" file="updater.sb">Booting update firmware</CMD>
    <CMD type="find" body="Updater" timeout="60"/>
    <CMD type="pull" body="?" file="device.xml">Getting device info</CMD>
    <CMD type="show" file="device.xml"/>
    <CMD type="push" body="mknod block,mmcblk0,/dev/mmcblk0,block"/>
    <CMD type="push" body="send" file="fdisk-u.input">Sending fdisk input</CMD>
    <CMD type="push" body="$ fdisk -u /dev/mmcblk0 < $FILE">Partitioning SD card</CMD>
    <CMD type="push" body="mknod block/mmcblk0,mmcblk0p1,/dev/mmcblk0p1,block"/>
    <CMD type="push" body="mknod block/mmcblk0,mmcblk0p2,/dev/mmcblk0p2,block"/>
    <CMD type="push" body="mknod block/mmcblk0,mmcblk0p3,/dev/mmcblk0p3,block"/>
    <CMD type="push" body="send" file="files/linux.sb">Sending u-boot image</CMD>
    <CMD type="push" body="$ dd if=$FILE of=/dev/mmcblk0p2 bs=512 seek=4 conv=sync,notrunc">Writing Linux Kernel</CMD>
    <CMD type="push" body="$ mkfs.ext3 -j /dev/mmcblk0p3">Formatting rootfs partition</CMD>
    <CMD type="push" body="$ mkdir -p /mnt/mmcblk0p3"/> 
    <CMD type="push" body="$ mount /dev/mmcblk0p3 /mnt/mmcblk0p3"/>
    <CMD type="push" body="pipe tar -jxv -C /mnt/mmcblk0p3" file="files/rootfs.bin">Sending and writting rootfs</CMD>
    <CMD type="push" body="frf">Finishing rootfs write</CMD>
    <CMD type="push" body="$ umount /mnt/mmcblk0p3">Unmounting rootfs partition</CMD>
    <CMD type="push" body="!3">Done</CMD>
</LIST>
</UCL>
