How to create ucl for NAND Flash media for Linux

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create ucl for NAND Flash media for Linux

Jump to solution
1,662 Views
oliverortega
Contributor I

Can some help me how to create a script in the ucl file for flashing uboot and Image to NAND flash. I can only see in the existing ucl file a "NAND(UBI)- Android" but none for NAND-Linux. I'm using imx502 device.

Thank you.

Labels (1)
0 Kudos
1 Solution
725 Views
israelpz
Senior Contributor I

Hi,

There's already a script which writes into the nand. Maybe your ucl file doesn't come with this. Anyways i going to paste it.

If you get nay error you should check the following:

1) Your cpio file system should have mtd tools installed.

2) Your u-boot(the one to write in the nand) should support your nand and also should have the CONFIG_CMD_NAND macro enable when you compiled.

3) Ensure the linux kernel ( the one on the mfg tool) detect the nand and mount as mtd device.

You can erase the ubi fs part if you don't need that.

Regards,

-Israel.

Here is the script:

<LIST name="Sabre-ARD-SABREAUTO-NAND" desc="Choose NAND as media">

  <CMD  type="find" body="Recovery" timeout="180"/>

  <CMD  type="boot" body="Recovery" file ="u-boot-mx6q-sabreauto-nand.bin" >Loading uboot.</CMD>

  <CMD type="load" file="uImage-mx6q-sabreauto-nand" address="0x10800000"

  loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" >Doing Kernel.</CMD>

  <CMD  type="load" file="initramfs.cpio.gz.uboot" address="0x10C00000"

  loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" >Doing Initramfs.</CMD>

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

  <CMD  type="find" body="Updater" timeout="180"/>

  <CMD  type="push" body="$ flash_eraseall /dev/mtd0">Erasing Kernel partition</CMD>

  <!--burn the uboot to NAND: -->

  <CMD  type="push" body="send" file="files/u-boot.bin">Sending U-Boot</CMD>

  <CMD  type="push" body="$ kobs-ng init --chip_0_device_path=/dev/mtd0 $FILE">Flashing Bootloader</CMD>

  <!--burn the kernel to NAND: -->

  <CMD  type="push" body="$ flash_eraseall /dev/mtd1">Erasing rootfs partition</CMD>

  <CMD  type="push" body="send" file="files/uImage-mx6q-sabreauto-nand">Sending Kernel Image</CMD>

  <CMD  type="push" body="$ nandwrite /dev/mtd1 -p $FILE">Flashing Kernel</CMD>

  <!--burn the rootfs to NAND: -->

  <CMD  type="push" body="$ flash_eraseall /dev/mtd2">Erasing rootfs partition</CMD>

  <CMD  type="push" body="$ ubiformat /dev/mtd2"/>

  <CMD  type="push" body="$ ubiattach /dev/ubi_ctrl -m 2">Attaching UBI partition</CMD>

  <CMD  type="push" body="$ ubimkvol /dev/ubi0 -Nrootfs -s67108864"/>

  <CMD  type="push" body="$ mkdir -p /mnt/mtd2"/>

  <CMD  type="push" body="$ mount -t ubifs ubi0:rootfs /mnt/mtd2"/>

  <CMD  type="push" body="pipe tar -jxv -C /mnt/mtd2" file="files/rootfs.tar.bz2">Sending and writting rootfs</CMD>

  <CMD  type="push" body="frf">Finishing rootfs write</CMD>

  <CMD  type="push" body="$ umount /mnt/mtd2">Unmounting rootfs partition</CMD>

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

</LIST>

View solution in original post

0 Kudos
1 Reply
726 Views
israelpz
Senior Contributor I

Hi,

There's already a script which writes into the nand. Maybe your ucl file doesn't come with this. Anyways i going to paste it.

If you get nay error you should check the following:

1) Your cpio file system should have mtd tools installed.

2) Your u-boot(the one to write in the nand) should support your nand and also should have the CONFIG_CMD_NAND macro enable when you compiled.

3) Ensure the linux kernel ( the one on the mfg tool) detect the nand and mount as mtd device.

You can erase the ubi fs part if you don't need that.

Regards,

-Israel.

Here is the script:

<LIST name="Sabre-ARD-SABREAUTO-NAND" desc="Choose NAND as media">

  <CMD  type="find" body="Recovery" timeout="180"/>

  <CMD  type="boot" body="Recovery" file ="u-boot-mx6q-sabreauto-nand.bin" >Loading uboot.</CMD>

  <CMD type="load" file="uImage-mx6q-sabreauto-nand" address="0x10800000"

  loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" >Doing Kernel.</CMD>

  <CMD  type="load" file="initramfs.cpio.gz.uboot" address="0x10C00000"

  loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" >Doing Initramfs.</CMD>

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

  <CMD  type="find" body="Updater" timeout="180"/>

  <CMD  type="push" body="$ flash_eraseall /dev/mtd0">Erasing Kernel partition</CMD>

  <!--burn the uboot to NAND: -->

  <CMD  type="push" body="send" file="files/u-boot.bin">Sending U-Boot</CMD>

  <CMD  type="push" body="$ kobs-ng init --chip_0_device_path=/dev/mtd0 $FILE">Flashing Bootloader</CMD>

  <!--burn the kernel to NAND: -->

  <CMD  type="push" body="$ flash_eraseall /dev/mtd1">Erasing rootfs partition</CMD>

  <CMD  type="push" body="send" file="files/uImage-mx6q-sabreauto-nand">Sending Kernel Image</CMD>

  <CMD  type="push" body="$ nandwrite /dev/mtd1 -p $FILE">Flashing Kernel</CMD>

  <!--burn the rootfs to NAND: -->

  <CMD  type="push" body="$ flash_eraseall /dev/mtd2">Erasing rootfs partition</CMD>

  <CMD  type="push" body="$ ubiformat /dev/mtd2"/>

  <CMD  type="push" body="$ ubiattach /dev/ubi_ctrl -m 2">Attaching UBI partition</CMD>

  <CMD  type="push" body="$ ubimkvol /dev/ubi0 -Nrootfs -s67108864"/>

  <CMD  type="push" body="$ mkdir -p /mnt/mtd2"/>

  <CMD  type="push" body="$ mount -t ubifs ubi0:rootfs /mnt/mtd2"/>

  <CMD  type="push" body="pipe tar -jxv -C /mnt/mtd2" file="files/rootfs.tar.bz2">Sending and writting rootfs</CMD>

  <CMD  type="push" body="frf">Finishing rootfs write</CMD>

  <CMD  type="push" body="$ umount /mnt/mtd2">Unmounting rootfs partition</CMD>

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

</LIST>

0 Kudos