Debian NAND Flash Burning: Difference between revisions

From Variscite Wiki
(Branch from Yocto_NAND_Flash_Burning (23:58, 18 January 2023‎))
 
(Correct install OS name)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use MORTY_V1.0_DART-6UL as default
<!-- Set release according to "release" parameter in URL and use mx8m-debian-bullseye-5.4-2.1.x-v1.4 as default
--> {{INIT_RELEASE_PARAM|RELEASE_MORTY_V1.0_DART-6UL}}<!--
--> {{INIT_RELEASE_PARAM|mx8m-debian-bullseye-5.4-2.1.x-v1.4}}<!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{PageHeader|Installing Debian to the SOM's internal storage}} {{DocImage|category1=Debian|category2={{#var:HARDWARE_NAME}}}} __toc__
--> {{#varexists:DEFAULT_IMAGE_BB_NAME | | {{ #vardefine:DEFAULT_IMAGE_BB_NAME | fsl-image-gui }} }} <!--
--> {{#vardefine:BUILD_FOLDER_DISTRO | {{ #varexists:BUILD_FOLDER_X11 | {{#var:BUILD_FOLDER_X11}} | {{ #varexists:BUILD_FOLDER_XWAYLAND | {{#var:BUILD_FOLDER_XWAYLAND}} | {{#var:BUILD_FOLDER_B2QT}} }} }} }}<!--
--> {{#vardefine:SOC_SERIES|{{#var:SOC_SERIES|imx}}}} <!-- SOC_SERIES is not defined in some older YPC
--> {{PageHeader|Installing Yocto to the SOM's internal storage}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
= Introduction =
= Introduction =
All SOMs can either boot from an SD card or from their internal storage.<br>
All SOMs can either boot from an SD card or from their internal storage.<br>
Line 57: Line 53:


{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=|#default=
{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=|#default=
= Yocto Built binaries for NAND flash / eMMC =
= Debian Built binaries for NAND flash / eMMC =


The resulting images are located at tmp/deploy/images/{{#var:MACHINE_NAME}}.<br>
The resulting images are located at tmp/deploy/images/{{#var:MACHINE_NAME}}.<br>
{{#lst:Yocto_Build_Release|YOCTO_BUILD_RESULTS}}
{{#lst:Debian_Platform_Customization|{{#var:DEBIAN_BUILD_RESULTS_SECTION}}}}
{{#lst:Yocto_Platform_Customization|{{#var:YOCTO_BUILD_RESULTS_SECTION}}}}
}}
}}


= Installing the Yocto binaries =
= Installing the Debian binaries =
If you followed the [[Yocto_Build_Release#Create an extended SD card |Create an extended SD card]] steps, the [[#Images locations|Yocto binaries]] and the [[#Flashing scripts|flashing scripts]] will be included in your SD card. <br>
If you followed the [[Debian_Build_Release#Create a bootable SD card |Create a bootable SD card]] steps, the [[#Images locations|Debian binaries]] and the [[#Flashing scripts|flashing scripts]] will be included in your SD card. <br>
The flashing scripts are easy-to-use example scripts for flashing images into NAND flash / eMMC.<br>
The flashing scripts are easy-to-use example scripts for flashing images into NAND flash / eMMC.<br>
There is also a section below describing how to [[#Manual step-by-step flashing to NAND flash / eMMC|flash the images manually]].
There is also a section below describing how to [[#Manual step-by-step flashing to NAND flash / eMMC|flash the images manually]].
Line 71: Line 66:
== Images locations ==
== Images locations ==
Following is the directory structure on your SD card, which elaborates the files' location that the below installation scripts are expecting:
Following is the directory structure on your SD card, which elaborates the files' location that the below installation scripts are expecting:
{{#lst:Yocto_Platform_Customization|{{#var:SD_TREE_SECTION}}}}
{{#lst:Debian_Platform_Customization|{{#var:SD_TREE_SECTION}}}}


{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
Line 79: Line 74:
}}
}}
Plug the bootable SD card into your host machine and mount the rootfs partition - here we assume it is mounted on /media/rootfs.<br>
Plug the bootable SD card into your host machine and mount the rootfs partition - here we assume it is mounted on /media/rootfs.<br>
Copy all the mentioned yocto-built binaries to the SD card:
Copy all the mentioned debian-built binaries to the SD card:
<br>
<br>
* <span style="color:red">Note:</span> If you followed the [[Yocto_Build_Release#Create an extended SD card |Create an extended SD card]] steps, the [[#Flashing scripts|flashing scripts]] and all relevant binaries are already included in your SD card, and the below commands are redundant!<br>
* <span style="color:red">Note:</span> If you followed the [[Debian_Build_Release#Create an extended SD card |Create an extended SD card]] steps, the [[#Flashing scripts|flashing scripts]] and all relevant binaries are already included in your SD card, and the below commands are redundant!<br>


Setup:
Setup:
  $ export YOCTO_IMGS_PATH={{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_DISTRO}}/tmp/deploy/images/{{#var:MACHINE_NAME}}
  $ export DEBIAN_IMGS_PATH={{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_DISTRO}}/tmp/deploy/images/{{#var:MACHINE_NAME}}
  $ export P2_MOUNT_DIR=/media/rootfs/
  $ export P2_MOUNT_DIR=/media/rootfs/
  $ sudo mkdir -p ${P2_MOUNT_DIR}/opt/images/Yocto/
  $ sudo mkdir -p ${P2_MOUNT_DIR}/opt/images/Debian/


{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=|#default=
{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=|#default=
Linux:
Linux:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:KERNEL_IMAGE}} ${P2_MOUNT_DIR}/opt/images/Yocto/
  $ sudo cp ${DEBIAN_IMGS_PATH}/{{#var:KERNEL_IMAGE}} ${P2_MOUNT_DIR}/opt/images/Debian/


Device Tree:
Device Tree:
  $ for f in ${YOCTO_IMGS_PATH}/*.dtb; do if <nowiki>[[ -L $f ]] && [[</nowiki> $f != *{{#var:MACHINE_NAME}}.dtb <nowiki>]]</nowiki>; then sudo cp $f ${P2_MOUNT_DIR}/opt/images/Yocto/; fi done
  $ for f in ${DEBIAN_IMGS_PATH}/*.dtb; do if <nowiki>[[ -L $f ]] && [[</nowiki> $f != *{{#var:MACHINE_NAME}}.dtb <nowiki>]]</nowiki>; then sudo cp $f ${P2_MOUNT_DIR}/opt/images/Debian/; fi done
  $ sudo rename 's/{{#var:KERNEL_IMAGE}}-imx/imx/' ${P2_MOUNT_DIR}/opt/images/Yocto/*.dtb
  $ sudo rename 's/{{#var:KERNEL_IMAGE}}-imx/imx/' ${P2_MOUNT_DIR}/opt/images/Debian/*.dtb


NAND images:
NAND images:
  {{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A ||SPL:
  {{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A ||SPL:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:SPL_NAND_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Yocto/
  $ sudo cp ${DEBIAN_IMGS_PATH}/{{#var:SPL_NAND_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Debian/
  }}
  }}
   
   
  U-Boot:
  U-Boot:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:U-BOOT_NAND_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Yocto/
  $ sudo cp ${DEBIAN_IMGS_PATH}/{{#var:U-BOOT_NAND_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Debian/
   
   
  File System:
  File System:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.ubi ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.ubi
  $ sudo cp ${DEBIAN_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.ubi ${P2_MOUNT_DIR}/opt/images/Debian/rootfs.ubi
}}
}}
eMMC images:
eMMC images:
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|*'''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|*'''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
  File System:
  File System:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.gz
  $ sudo cp ${DEBIAN_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/Debian/rootfs.tar.gz
|}} <!--
|}} <!--


-->{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|*'''DART-MX6'''|}}
-->{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|*'''DART-MX6'''|}}
  {{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A ||SPL:
  {{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A ||SPL:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:SPL_SD_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Yocto/
  $ sudo cp ${DEBIAN_IMGS_PATH}/{{#var:SPL_SD_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Debian/
|}}
|}}


Line 121: Line 116:
  <br>
  <br>
  U-Boot:  
  U-Boot:  
  $ sudo cp ${YOCTO_IMGS_PATH}/imx-boot-{{#var:MACHINE_NAME}}-sd.bin ${P2_MOUNT_DIR}/opt/images/Yocto/{{#var:U-BOOT_SD_IMAGE_NAME}}
  $ sudo cp ${DEBIAN_IMGS_PATH}/imx-boot-{{#var:MACHINE_NAME}}-sd.bin ${P2_MOUNT_DIR}/opt/images/Debian/{{#var:U-BOOT_SD_IMAGE_NAME}}
   
   
  File System:
  File System:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.gz
  $ sudo cp ${DEBIAN_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/Debian/rootfs.tar.gz
|
|
  <br>
  <br>
  U-Boot:  
  U-Boot:  
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:U-BOOT_SD_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Yocto/
  $ sudo cp ${DEBIAN_IMGS_PATH}/{{#var:U-BOOT_SD_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Debian/
   
   
  File System:
  File System:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.gz
  $ sudo cp ${DEBIAN_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/Debian/rootfs.tar.gz
}}
}}


Line 137: Line 132:
The flashing scripts are located on the SD card at /usr/bin/:
The flashing scripts are located on the SD card at /usr/bin/:
  {{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
  {{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
  install_yocto.sh - Flash Yocto into eMMC (Run and follow usage instructions)
  install_debian.sh - Flash Debian into eMMC (Run and follow usage instructions)
|
|
  install_yocto.sh - Flash Yocto into NAND flash or eMMC (Run and follow usage instructions)
  install_debian.sh - Flash Debian into NAND flash or eMMC (Run and follow usage instructions)
}}
}}
  {{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
  {{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
  (install_yocto_emmc.sh - This script is being called by install_yocto.sh when choosing to install the rootfs to eMMC - it should not be called directly!)
  (install_debian_emmc.sh - This script is being called by install_debian.sh when choosing to install the rootfs to eMMC - it should not be called directly!)
  |}}
  |}}


Line 152: Line 147:
<br>
<br>
<pre>
<pre>
$ cd /opt/images/Yocto
$ cd /opt/images/Debian
</pre>
</pre>


Line 182: Line 177:


Flash the Linux Kernel image & Device Tree:<br>
Flash the Linux Kernel image & Device Tree:<br>
You need to use the right .dtb file for you hardware setup. See the [[#Yocto Built binaries for NAND flash / eMMC | table]] above for a complete description.
You need to use the right .dtb file for you hardware setup. See the [[#Debian Built binaries for NAND flash / eMMC | table]] above for a complete description.


  {{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
  {{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
Line 211: Line 206:
  * '''DART-MX6'''
  * '''DART-MX6'''
  $ export node=/dev/mmcblk2
  $ export node=/dev/mmcblk2
  $ cd /opt/images/Yocto
  $ cd /opt/images/Debian
* '''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
* '''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
}}
}}
  $ export node=/dev/{{#var:EMMC_ROOTFS_DEV}}  
  $ export node=/dev/{{#var:EMMC_ROOTFS_DEV}}  
  $ cd /opt/images/Yocto
  $ cd /opt/images/Debian


Make sure the eMMC is not mounted:
Make sure the eMMC is not mounted:
Line 333: Line 328:


= Summary =
= 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.<br>
We described the results of a Debian build, how to copy it to a bootable SD card and how to flash it to NAND and eMMC.<br>
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.<br>
With our extended SD card and our recovery SD card we provide an installation script located at /usr/bin/install_debian.sh. It is much safer to use it instead of flashing the system manually.<br>

Latest revision as of 20:35, 28 April 2023

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release mx8m-debian-bullseye-5.4-2.1.x-v1.4.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release


Installing Debian to the SOM's internal storage

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.


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).


Installing the Debian binaries

If you followed the Create a bootable SD card steps, the Debian 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.

Images locations

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


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 debian-built binaries to the SD card:

Setup:

$ export DEBIAN_IMGS_PATH=~/debian_imx8mq-var-dart_debian_bullseye//tmp/deploy/images/imx8m-var-dart
$ export P2_MOUNT_DIR=/media/rootfs/
$ sudo mkdir -p ${P2_MOUNT_DIR}/opt/images/Debian/


eMMC images:



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

File System:
$ sudo cp ${DEBIAN_IMGS_PATH}/-imx8m-var-dart.tar.gz ${P2_MOUNT_DIR}/opt/images/Debian/rootfs.tar.gz

Flashing scripts

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

install_debian.sh	- Flash Debian into eMMC (Run and follow usage instructions)


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/mmcblk1 
$ cd /opt/images/Debian

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/mmcblk1p2
$ mount ${node}p2 /run/media/mmcblk1p2
$ tar xvpf rootfs.tar.gz -C /run/media/mmcblk1p2
$ (cd /run/media/mmcblk1p2/boot; ln -fs imx8mq-var-dart-dt8mcustomboard.dtb imx8mq-var-dart-dt8mcustomboard.dtb)
$ sync
$ umount /run/media/mmcblk1p2


Summary

We described the results of a Debian 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_debian.sh. It is much safer to use it instead of flashing the system manually.