Personal tools

Log in

Changes

From IGEP - ISEE Wiki

Jump to: navigation, search

Prepare a bootable NAND/eMMC

42 bytes removed, 09:42, 14 May 2018
no edit summary
Now we can flash the MLO in the first partition '''/dev/mtd0'''. It important to know that in this case (because it is a NAND flash and we have to record the MLO) we have to flash it four times in the first 4 blocks of this partition. In order to know the exact addresses we can check the documentation of the chip developer (in this case: [http://jira.isee.biz:8090/pages/viewpage.action?pageId=6619137 AM335x U-Boot User's Guide (Texas Documentation)] <span class="mw-headline">'''NAND Layout'''</span>) and will get the offset addresses '''[0x0 0x20000 0x40000 0x60000]''' . For each one of this addresses we have to write:
nandwrite -p -s[https://en.wikipedia.org/wiki/UBIFS /dev/mtd0 [https://en.wikipedia.org/wiki/UBIFS /dev/mtd0</address> 
For example:
nandwrite -p -s 0x0 /dev/mtd0 /home/root/flash_files/MLO<br data-attributes="%20/">nandwrite -p -s 0x20000 /dev/mtd0 /home/root/flash_files/MLO<br data-attributes="%20/">nandwrite -p -s 0x40000 /dev/mtd0 /home/root/flash_files/MLO<br data-attributes="%20/">nandwrite -p -s 0x60000 /dev/mtd0 /home/root/flash_files/MLO
 
Then we will flash into the second partition '''/dev/mtd1''' the u-boot.img:
nandwrite -p /dev/mtd1
 
For example:
nandwrite -p /dev/mtd1 /home/root/flash_files/u-boot.img
 In order to flash the rootfs we use the <a class="external-link" href="[https://en.wikipedia.org/wiki/UBIFS" rel="nofollow">UBIFS] (<span class="mw-redirect">filesystem</span> for unmanaged flash memory devices) in the last partition '''/dev/mtd3'''. We are using a UBIFS in order to do it:]]
{| class="contenttable sortable"
|}<div class="confluence-information-macro-body"></div>
ubiformat /dev/mtd3<br data-attributes="%20/">ubiattach -p /dev/mtd3<br data-attributes="%20/">ubimkvol /dev/ubi0 -N filesystem -m
 
Then, we can flash the rootfs:
mkdir /tmp/flashroot<br data-attributes="%20/">mount -t ubifs ubi0:rootfs /tmp/flashroot/<br data-attributes="%20/">cd /tmp/flashroot/<br data-attributes="%20/">tar -xf -C .<br data-attributes="%20/">cd /<br data-attributes="%20/">umount /tmp/flashroot<br data-attributes="%20/">ubidetach -p /dev/mtd3
 
For example:
umount /run/media/mmcblk2*<br data-attributes="%20/">parted -s /dev/mmcblk2 mklabel msdos
 
Now we use '''sfdisk''' to create the partitions. We are creating two partitions:
sfdisk -D -H 255 -S 63 /dev/mmcblk2 << THEEND<br data-attributes="%20/">1,8,0x0C,*<br data-attributes="%20/">9,,,-<br data-attributes="%20/">THEEND
 
We can check the partitions are correctly set using:
fdisk -l /dev/mmcblk2
 
The result should be similar to the following:
tar -xf -C /tmp/mmcblk2p2/<br data-attributes="%20/">For example:<br data-attributes="%20/">tar -xf<br data-attributes="%20/">/opt/firmware/isee-fsl-image-dev-imx6dl-igep0046d10-20170712121141.rootfs.<br data-attributes="%20/">tar.bz2 -C /tmp/mmcblk2p2/
 
At this point you can flash the u-boot.imx image using dd command and dissebling the read only protection:
RO_PROTECTION=`cat /sys/block/mmcblk2/force_ro`<br data-attributes="%20/">echo 0 > /sys/block/mmcblk2/force_ro<br data-attributes="%20/">dd if= of=/dev/mmcblk2 bs=512 seek=2 2> /dev/null<br data-attributes="%20/">echo $RO_PROTECTION > /sys/block/mmcblk2/force_ro<br data-attributes="%20/">sync
 
For example:
RO_PROTECTION=`cat /sys/block/mmcblk2/force_ro`<br data-attributes="%20/">echo 0 > /sys/block/mmcblk2/force_ro<br data-attributes="%20/">dd if=/tmp/mmcblk2p2/boot/u-boot.imx of=/dev/mmcblk2 bs=512 seek=2 2><br data-attributes="%20/">/dev/null<br data-attributes="%20/">echo $RO_PROTECTION > /sys/block/mmcblk2/force_ro<br data-attributes="%20/">sync
 
Finally we copy the zImage and the dtb into the first partition (boot partition)
cp /tmp/mmcblk2p1<br data-attributes="%20/">cp -f /tmp/mmcblk2p1
 
For example:
cp /tmp/mmcblk2p2/boot/zImage /tmp/mmcblk2p1<br data-attributes="%20/">cp -f /tmp/mmcblk2p2/boot/imx6*.dtb /tmp/mmcblk2p1
560
edits