AnsweredAssumed Answered

How to Reboot Android when the u-boot is in SPI NOR

Question asked by Mike Domondon on Oct 8, 2019
Latest reply on Oct 11, 2019 by Mike Domondon

Hi,

 

I have a product where, via Mfg Tool, I save the uboot to SPI-NOR and save the rest of the android binaries to eMMC. The download of the binaries is successful. The u-boot and kernel loads, Android OS boots up successfully.

 

My problem arises when I try to reboot the Android OS. I do this via the "reboot" command in the serial connection. When I send the command my device hangs after the reset. The u-boot does not start. If I save the u-boot in eMMC together with the rest of the binaries, I am able to successfully reboot.

 

Here is the snippet of my mfgtool script for the spi nor:

 

<LIST name="IVG-NOR-Android" desc="Choose eMMC as media">

<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-ivgmfg-6q.imx" ifdev="MX6Q">Loading U-boot</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage" 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="0x12C00000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Initramfs.</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage-imx6q-ivgmfg.dtb" address="0x18000000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q">Loading device tree.</CMD>


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

<CMD state="Updater" type="push" body="$ flash_erase /dev/mtd%nor_part% 0 0x20">Erasing Spi Nor</CMD>
<CMD state="Updater" type="push" body="send" file="files/android/%folder%/u-boot-imx%soc%.imx" >Sending u-boot.bin</CMD>
<CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mtd%nor_part% bs=1k seek=1" ifdev="MX6Q MX6D MX6SL MX6UL">write U-Boot to NOR flash</CMD>

<!-- wait /dev/mmcblk%mmc% ready -->
<CMD state="Updater" type="push" body="$ while [ ! -e /dev/mmcblk%mmc% ]; do sleep 1; echo waiting...; done ">Waiting for the mmc ready</CMD>

<!-- burn uboot -->
<CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk%mmc% bs=1k seek=768 conv=fsync count=136">clear u-boot arg</CMD>
<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/android/%folder%/u-boot-imx%soc%.imx" >Sending u-boot.bin</CMD>

<CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%boot0 bs=512 seek=2">write U-Boot to sd card</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="$ mmc bootpart enable 1 1 /dev/mmcblk%mmc%">enable boot partion 1 to boot</CMD>
<CMD state="Updater" type="push" body="$ ls -l /dev/mmc* ">Formatting sd partition</CMD>

<CMD state="Updater" type="push" body="send" file="files/android/%folder%/partition-table.img" >Sending and writting partition-table.img</CMD>
<CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%">write gpt table to mmc</CMD>
<CMD state="Updater" type="push" body="$ hdparm -z /dev/mmcblk%mmc%">Dectecting emmc partition</CMD>
<CMD state="Updater" type="push" body="$ gdisk -l /dev/mmcblk%mmc% ">List emmc partition</CMD>

<CMD state="Updater" type="push" body="send" file="files/android/%folder%/boot-imx%soc%.img" >Sending and writting boot.img</CMD>
<CMD state="Updater" type="push" body="$ echo `gdisk -l /dev/mmcblk%mmc% | grep -w boot | awk '{print $1}'` > /tmp/partIdx">find boot partition</CMD>
<CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%p`cat /tmp/partIdx`">write boot.img to boot</CMD>

<CMD state="Updater" type="push" body="$ ls -l /dev/mmc* ">List partitions</CMD>
<CMD state="Updater" type="push" body="$ echo `gdisk -l /dev/mmcblk%mmc% | grep -w cache | awk '{print $1}'` > /tmp/partIdx">find cache partition</CMD>
<CMD state="Updater" type="push" body="$ mkfs.ext4 -F -E nodiscard /dev/mmcblk%mmc%p`cat /tmp/partIdx`">Formatting cache partition</CMD>
<CMD state="Updater" type="push" body="$ echo `gdisk -l /dev/mmcblk%mmc% | grep -w device | awk '{print $1}'` > /tmp/partIdx">find device partition</CMD>
<CMD state="Updater" type="push" body="$ mkfs.ext4 -F -E nodiscard /dev/mmcblk%mmc%p`cat /tmp/partIdx`">Formatting device partition</CMD>
<CMD state="Updater" type="push" body="$ echo `gdisk -l /dev/mmcblk%mmc% | grep -w userdata | awk '{print $1}'` > /tmp/partIdx">find data partition</CMD>
<CMD state="Updater" type="push" body="$ mkfs.ext4 -F -E nodiscard -b 4096 -m 0 -O ^flex_bg,^uninit_bg /dev/mmcblk%mmc%p`cat /tmp/partIdx`">Formatting data partition</CMD>

<CMD state="Updater" type="push" body="$ mount -o remount,size=1024M rootfs /">change size of tmpfs</CMD>
<CMD state="Updater" type="push" body="send" file="files/android/%folder%/system.img" >Sending system.img</CMD>
<CMD state="Updater" type="push" body="$ echo `gdisk -l /dev/mmcblk%mmc% | grep -w system | awk '{print $1}'` > /tmp/partIdx">find system</CMD>
<CMD state="Updater" type="push" body="$ simg2img $FILE /dev/mmcblk%mmc%p`cat /tmp/partIdx`">writting sparse system.img</CMD>

<!-- Write userdata.img is optional, for some customer this is needed, but it's optional. -->
<!-- Also, userdata.img will have android unit test, you can use this to do some auto test. -->
<!-- <CMD state="Updater" type="push" onError="ignore" body="pipe dd of=/dev/mmcblk0p7" file="file/android/userdate.img"> Sending userdata.img(optional) </CMD>
<CMD state="Updater" type="push" body="frf">flush the memory.</CMD> -->
<CMD state="Updater" type="push" body="send" file="files/android/%folder%/recovery-imx%soc%.img">Sending and writting recovery.img</CMD>
<CMD state="Updater" type="push" body="$ echo `gdisk -l /dev/mmcblk%mmc% | grep -w 'recovery$' | awk '{print $1}'` > /tmp/partIdx">find boot partition</CMD>

<CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%p`cat /tmp/partIdx`">write recovery.img to recovery partition</CMD>

<CMD state="Updater" type="push" body="$ sync">Sync file system</CMD>
<CMD state="Updater" type="push" body="frf">Finishing rootfs write</CMD>

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

Outcomes