Personal tools

Yocto NAND Flash Burning

From Variscite Wiki

Jump to: navigation, search


Installing Yocto to the SOM's internal storage


1 Introduction

All SOMs can either boot from an SD card or from their internal storage.

The SOM's internal storage:
The Variscite DART-MX8M comes with eMMC, which holds U-Boot, the kernel image and the ext4 root file system.


2 eMMC structure

0-8 MiB      : Non-partitioned space, saved for U-Boot.
8 MiB-End: "rootfs" - An ext4 partition containing the root file system (including Linux image and the device tree blobs under /boot).


3 Installing the Yocto binaries

If you followed the Create an extended SD card steps, the Yocto binaries and the flashing scripts will be included in your SD card.
The flashing scripts are easy-to-use example scripts for flashing images into NAND flash / eMMC.
There is also a section below describing how to flash the images manually.

3.1 Images locations

Following is the directory structure on your SD card, which elaborates the files' location that the below installation scripts are expecting:

/opt/images/
└── Yocto
    ├── imx-boot-sd.bin
    └── rootfs.tar.gz


3.1.1 Prepare the images for flashing to eMMC

Plug the bootable SD card into your host machine and mount the rootfs partition - here we assume it is mounted on /media/rootfs.
Copy all the mentioned yocto-built binaries to the SD card:

Setup:

$ export YOCTO_IMGS_PATH=~/var-fsl-yocto//tmp/deploy/images/imx8m-var-dart
$ export P2_MOUNT_DIR=/media/rootfs/
$ sudo mkdir -p ${P2_MOUNT_DIR}/opt/images/Yocto/



eMMC images:



U-Boot: 
$ sudo cp ${YOCTO_IMGS_PATH}/imx-boot-imx8m-var-dart-sd.bin ${P2_MOUNT_DIR}/opt/images/Yocto/imx-boot-sd.bin

File System:
$ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-imx8m-var-dart.tar.gz ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.gz

3.2 Flashing scripts

The flashing scripts are located on the SD card at /usr/bin/:

install_yocto.sh	- Flash Yocto into eMMC (Run and follow usage instructions)


3.3 Manual step-by-step flashing to eMMC

Flashing the eMMC requires several steps including partitioning, file system formatting and image extraction.
We recommend to use our provided scripts to perform this task.

Use the prepared SD card to boot the board and run the following:

$ export node=/dev/mmcblk0 
$ cd /opt/images/Yocto

Make sure the eMMC is not mounted:

$ umount ${node}p*

Delete current data on eMMC:

$ for((i=1; i<=16; i++)); do [ -e ${node}p${i} ] && dd if=/dev/zero of=${node}p${i} bs=1M count=1 conv=fsync; done
$ dd if=/dev/zero of=${node} bs=1M count=8 conv=fsync

Create a partition table:

$ (echo n; echo p; echo 1; echo 16384; echo; echo p; echo w) | fdisk -u $node
$ sync

Format the partitions:

$ mkfs.ext4 ${node}p1 -L rootfs
$ sync

Flash U-Boot:

$ dd if=imx-boot-sd.bin of=${node} bs=1K seek=33 conv=fsync

Extract the rootfs archive:

$ mkdir /run/media/mmcblk0p1
$ mount ${node}p1 /run/media/mmcblk0p1
$ tar xvpf rootfs.tar.gz -C /run/media/mmcblk0p1
$ (cd /run/media/mmcblk0p1/boot; ln -fs fsl-imx8mq-var-dart-emmc-wifi-lvds.dtb fsl-imx8mq-var-dart.dtb)
$ sync
$ umount /run/media/mmcblk0p1


4 Summary

We described the results of a Yocto build, how to copy it to a bootable SD card and how to flash it to NAND and eMMC.
With our extended SD card and our recovery SD card we provide an installation script located at /usr/bin/install_yocto.sh. It is much safer to use it instead of flashing the system manually.