Personal tools

1-1-1-1-2-1-10

From ICOP tech wiki

Revision as of 08:48, 6 March 2020 by Viky6 (talk | contribs) (Created page with " <div id="column-content"> <div id="content"> <a id="top"></a> <h1 id="firstHeading" class="firstHeading">Yocto NAND Flash Burning</h1> <div id="bodyConten...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<a id="top"></a>

Yocto NAND Flash Burning

From Variscite Wiki

Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a>


Installing Yocto to the SOM's internal storage


Contents

  • <a href="#Introduction">1 Introduction</a>
  • <a href="#eMMC_structure">2 eMMC structure</a>
  • <a href="#Installing_the_Yocto_binaries">3 Installing the Yocto binaries</a>
    • <a href="#Images_locations">3.1 Images locations</a>
      • <a href="#Prepare_the_images_for_flashing_to_eMMC">3.1.1 Prepare the images for flashing to eMMC</a>
    • <a href="#Flashing_scripts">3.2 Flashing scripts</a>
    • <a href="#Manual_step-by-step_flashing_to_eMMC">3.3 Manual step-by-step flashing to eMMC</a>
  • <a href="#Summary">4 Summary</a>

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-MINI 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 <a href="/index.php?title=Yocto_Build_Release#Create_an_extended_SD_card" title="Yocto Build Release">Create an extended SD card</a> steps, the <a href="#Images_locations">Yocto binaries</a> and the <a href="#Flashing_scripts">flashing scripts</a> 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 <a href="#Manual_step-by-step_flashing_to_NAND_flash_.2F_eMMC">flash the images manually</a>.

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:

  • Note: If you followed the <a href="/index.php?title=Yocto_Build_Release#Create_an_extended_SD_card" title="Yocto Build Release">Create an extended SD card</a> steps, the <a href="#Flashing_scripts">flashing scripts</a> and all relevant binaries are already included in your SD card, and the below commands are redundant!

Setup:

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

{{#ifeq: imx8 | imx8 || Linux:

$ sudo cp ${YOCTO_IMGS_PATH}/Image.gz ${P2_MOUNT_DIR}/opt/images/Yocto/

Device Tree:

$ for f in ${YOCTO_IMGS_PATH}/*.dtb; do if [[ -L $f ]] && [[ $f != *imx8mm-var-dart.dtb ]]; then sudo cp $f ${P2_MOUNT_DIR}/opt/images/Yocto/; fi done
$ sudo rename 's/Image.gz-imx/imx/' ${P2_MOUNT_DIR}/opt/images/Yocto/*.dtb


eMMC images:



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

File System:
$ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-imx8mm-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/mmcblk2 
$ 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/mmcblk2p1
$ mount ${node}p1 /run/media/mmcblk2p1
$ tar xvpf rootfs.tar.gz -C /run/media/mmcblk2p1

$ sync
$ umount /run/media/mmcblk2p1


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.