XNAND2-Update: Difference between revisions

From embeddedTS Manuals
(Let Bash do the math.)
No edit summary
Line 34: Line 34:
<source lang=bash>
<source lang=bash>
cp nandctl mnt/sbin/nandctl
cp nandctl mnt/sbin/nandctl
cp nbd-client mnt/sbin/nbd-client
sync
sync
</source>
</source>

Revision as of 10:10, 16 December 2016

These instructions only apply for XNAND product shipped *after* January 15, 2017.  Product shipped before this date should not be updated with the new nandctl software unless specifically directed by Technologic Systems' Support Engineers.  This article provides you with the necessary information to update an existing XNAND image with the new nandctl software.

You will need a workstation running Linux to prepare this update. From 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 nandctl binary in the same local directory.

Next run this command:

sudo fdisk -l xnandimg.dd

This will produce some technical output very similar to this:

Disk xnandimg.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
xnandimg.dd1               1        5119        2559+  da  Non-FS data
xnandimg.dd2            5120       10239        2560   da  Non-FS data
xnandimg.dd3           10240      524287      257024   83  Linux

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.

From here it is possible to mount the image's initrd partition directly inside the parent file system:

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

You can now copy the new nandctl and nbd-client directly into the disk image:

cp nandctl mnt/sbin/nandctl
sync

It is now safe to unmount the updated image and rename appropriately:

sudo umount mnt
mv xnandimg.dd xnand2img.dd