XNAND2-Update: Difference between revisions

From embeddedTS Manuals
(Added a sentence about production environments that don't use dd to image the entire device.)
(Clarified sections, added detail, made notes about updating SD as well as NAND)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
An XNAND2 based image will work on boards with either the old XNAND boot code or the new XNAND2 boot code.  However boards with XNAND2 boot code will not work with an old XNAND image, so it is important to update all production programing/imaging processes to utilize the XNAND2 nandctl.  The following section provides you with the necessary information to update an existing XNAND image with the new XNAND2 nandctl software.
An XNAND2 formatted NAND device will work on supported products with any bootrom date, whether or not the bootrom supports XNAND2.  However, devices can only be booted from the XNAND technology that their bootrom supports.  An XNAND2 formatted NAND cannot be booted from a bootrom that only supports XNAND1 and vice versa.  This allows for application support of XNAND2, regardless of bootrom support, but only if NAND is not the boot media.  Because of this, it is important to update all programming and production processes to support XNAND2.  For other production preparation processes that do not re-image the entire device, it is still important to confirm the production process is using the XNAND2 nandctl binary dated October 2016 or later. The following section provides the necessary information to update an existing XNAND1 image with the new XNAND2 nandctl software.


For other production preparation processes that do not re-image the entire device, it is important to confirm the production process uses the XNAND2 nandctl binary dated 10/2016 or later.
The latest nandctl binary is compatible with both XNAND1 and XNAND2; however it will assume that disk initialization will be targeted at XNAND2 support and it is not possible to force XNAND1 formatting.  Because of this, the bootrom should be updated to be compatible with XNAND2 before using '--xnandinit' against a NAND device using the latest nandctl binary.  TS-BOOTROMs with a date after October 2016 are compatible with and able to boot XNAND2 devices.


You will need a workstation running Linux to prepare this updateFrom your Linux workstation (or Virtual Machine), open a terminal window and copy your original production dd file to the local home directory.  For purposes of this article we will call this xnandimg.dd.  You will also need the new XNAND2 nandctl binary in the same local directory.
This update will walk through the steps of updating the nandctl binary contained in a customized production imageThese steps are not necessary when using our stock image, only if your production process is using an SD or NAND image that has been based on any of our previous shipping images. Note that both SD and NAND images should be updated to properly support XNAND2 in all situations.


Next run this command:
To prepare this update, a workstation running linux is necessary, either in a virtual machine or native install.  From the workstation, open a terminal window and copy your original production image file to a local working directory (this is done to limit working on production used images).  This file will be referenced as diskimg.dd in the following instructions.  The latest XNAND2 compatible nandctl binary (link to download is at the top of this section) should also be downloaded in the same working directory.
<source lang=bash>sudo fdisk -l xnandimg.dd</source>


This will produce some technical output very similar to this:
Next, run the following command:
<source lang=bash>sudo fdisk -l diskimg.dd</source>
 
This will produce output like the following:
<source lang=bash>
<source lang=bash>
Disk xnandimg.dd: 268 MB, 268435456 bytes
Disk diskimg.dd: 268 MB, 268435456 bytes
255 heads, 63 sectors/track, 32 cylinders, total 524288 sectors
255 heads, 63 sectors/track, 32 cylinders, total 524288 sectors
Units = sectors of 1 * 512 = 512 bytes
Units = sectors of 1 * 512 = 512 bytes
Line 18: Line 20:


      Device Boot      Start         End      Blocks   Id  System
      Device Boot      Start         End      Blocks   Id  System
xnandimg.dd1               1        5119        2559+  da  Non-FS data
diskimg.dd1               1        5119        2559+  da  Non-FS data
xnandimg.dd2            5120       10239        2560   da  Non-FS data
diskimg.dd2            5120       10239        2560   da  Non-FS data
xnandimg.dd3           10240      524287      257024   83  Linux
diskimg.dd3           10240      524287      257024   83  Linux
</source>
</source>


We need two important pieces of information:  The start sector of the initrd partition, and the sector size.  In the case of the test file above, this is sector 5120, and 512 bytes.  Multiply these two numbers to obtain the necessary offset:  5120 * 512 = 2621440.
The above is the partition table of an XNAND disk.  An image for an SD card will have 4 partitions rather than 3, but the same basic layout.  The necessary information is the start sector of the second partition with the Id of "da," and the "Sector size" listed above the partition table. In this case it is partition 2 in which the start block is 5120 and the Sector size is 512. Multiply the two numbers to obtain the necessary offset:  5120 * 512 = 2621440.


From here it is possible to mount the image's initrd partition directly inside the parent file system:
Next, the initrd partition from the disk image file is mounted to a folder created in the working directory:


<source lang=bash>
<source lang=bash>
mkdir mnt
mkdir mnt
sudo mount -orw,loop,offset=$((5120*512)) xnandimg.dd mnt
sudo mount -orw,loop,offset=$((5120*512)) diskimg.dd mnt/
</source>
</source>


You can now copy the new XNAND2 nandctl directly into the disk image:
The new XNAND2 nandctl binary is copied to the mounted folder structure


<source lang=bash>
<source lang=bash>
Line 39: Line 41:
</source>
</source>


It is now safe to unmount the updated image and rename appropriately:
The disk image can be unmounted and renamed as needed:


<source lang=bash>
<source lang=bash>
sudo umount mnt
sudo umount mnt
mv xnandimg.dd xnand2img.dd
mv diskimg.dd diskimg-xnand2.dd
</source>
</source>

Latest revision as of 16:03, 2 February 2017

An XNAND2 formatted NAND device will work on supported products with any bootrom date, whether or not the bootrom supports XNAND2.  However, devices can only be booted from the XNAND technology that their bootrom supports. An XNAND2 formatted NAND cannot be booted from a bootrom that only supports XNAND1 and vice versa. This allows for application support of XNAND2, regardless of bootrom support, but only if NAND is not the boot media. Because of this, it is important to update all programming and production processes to support XNAND2. For other production preparation processes that do not re-image the entire device, it is still important to confirm the production process is using the XNAND2 nandctl binary dated October 2016 or later. The following section provides the necessary information to update an existing XNAND1 image with the new XNAND2 nandctl software.

The latest nandctl binary is compatible with both XNAND1 and XNAND2; however it will assume that disk initialization will be targeted at XNAND2 support and it is not possible to force XNAND1 formatting. Because of this, the bootrom should be updated to be compatible with XNAND2 before using '--xnandinit' against a NAND device using the latest nandctl binary. TS-BOOTROMs with a date after October 2016 are compatible with and able to boot XNAND2 devices.

This update will walk through the steps of updating the nandctl binary contained in a customized production image. These steps are not necessary when using our stock image, only if your production process is using an SD or NAND image that has been based on any of our previous shipping images. Note that both SD and NAND images should be updated to properly support XNAND2 in all situations.

To prepare this update, a workstation running linux is necessary, either in a virtual machine or native install. From the workstation, open a terminal window and copy your original production image file to a local working directory (this is done to limit working on production used images).  This file will be referenced as diskimg.dd in the following instructions. The latest XNAND2 compatible nandctl binary (link to download is at the top of this section) should also be downloaded in the same working directory.

Next, run the following command:

sudo fdisk -l diskimg.dd

This will produce output like the following:

Disk diskimg.dd: 268 MB, 268435456 bytes
255 heads, 63 sectors/track, 32 cylinders, total 524288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

      Device Boot      Start         End      Blocks   Id  System
diskimg.dd1                1        5119        2559+  da  Non-FS data
diskimg.dd2             5120       10239        2560   da  Non-FS data
diskimg.dd3            10240      524287      257024   83  Linux

The above is the partition table of an XNAND disk. An image for an SD card will have 4 partitions rather than 3, but the same basic layout. The necessary information is the start sector of the second partition with the Id of "da," and the "Sector size" listed above the partition table. In this case it is partition 2 in which the start block is 5120 and the Sector size is 512. Multiply the two numbers to obtain the necessary offset:  5120 * 512 = 2621440.

Next, the initrd partition from the disk image file is mounted to a folder created in the working directory:

mkdir mnt
sudo mount -orw,loop,offset=$((5120*512)) diskimg.dd mnt/

The new XNAND2 nandctl binary is copied to the mounted folder structure

cp nandctl mnt/sbin/nandctl
sync

The disk image can be unmounted and renamed as needed:

sudo umount mnt
mv diskimg.dd diskimg-xnand2.dd