Flashing an Operating System onto the Plug

From PlugWiki

Jump to: navigation, search

Contents

Configuring the Plug Computer to Boot from the Local Storage

This section provides the steps to create the jffs2 image from the generic filesystem. This section shows the steps to copy the jffs2 image onto the NAND flash on the KW-6281(A0) based Sheeplug board, from the generic filesystem. The text is italicized to follow a syntax that identifies command line key strokes.

Create jffs2 Image:

1. On the Linux machine copy the generic filesystem sources folder.

2. Size of the NAND flash is 512MB on the Sheevaplug reference board. Hence remove the Linux source files, manuals folders, and information folders in order to reduce the size of the file so that the jffs2 image is of appropriate size. The diff is shown in Appendix A.

3. Install the latest MTD Utils package in the working directory on the Linux machine. The latest package is at the link below: \\10.80.124.115\public\work\Philip\Sheevaplug\Software\Docs

4. Go to the local folder where the generic file system folder resides. In this case, the generic filesystem is saved in the location /home/e-nas-getrootfs_Sheevaplug/.

5. Follow the commands below to create a jffs2 image. Substitute the name of your .jffs2 file for "generic."

home/e-nas-gen-rootfs_Sheevaplug# mkfs.jffs2 -l -e 0x20000 --pad -r/home/e-nas-gen-rootfs_Sheevaplug -o generic.jffs2
home/e-nas-gen-rootfs_Sheevaplug# chmod 777 generic.jffs2

6. Copy the generic.jffs2 image to the tftpboot folder. Substitute the name of your .jffs2 file for "generic."

home/e-nas-gen-rootfs_Sheevaplug# cp -a generic.jffs2 /tftpboot/

Understanding U-Boot, the Plug Computer Boot Loader

Accessing the NAND Solid State Memory

Writing jffs2 image to NAND Flash

On the console of the debug board follow the steps below to write the image to the NAND flash. Initially boot the debug board for the NFS location where uImage and jffs2 images are stored. The commands listed here are to be executed immediately after entering the login and password. [Command keystrokes are italicized.]

1. At the Linux prompt, check for the NAND flash partition

-sh-3.2# cat /proc/mtd

Image:Catprocmtd.jpg


2. Confirm that the NAND erase and write binaries are included. These should be found in the /bin directory on giving the commands below.

-sh-3.2# find .-name flash_erase
-sh-3.2# find .-name nandwrite

You should find both of these command in the /bin directory on the SELinux/raindrop JFFS2 file system for Gentoo [1].

3. Erase the partitions on the NAND excluding the U-Boot partition.

NOTE: Before any "flash_erase" command is done -- Please check /proc/mtd to make sure mtd1 is really the uImage and mtd2 is really rootfs. Direct from the factory, the mtd is shown to have two partitions and mtd0 is the uImage and mtd1 is the root!

-sh-3.2# flash_erase /dev/mtdblock1
-sh-3.2# flash_eraseall /dev/mtd1
-sh-3.2# flash_erase /dev/mtdblock2
-sh-3.2# flash_eraseall /dev/mtd2

You can use 'flash_erase' instead of 'flash_eraseall' on '/dev/mtd1' and '/dev/mtd2', however, if you want to make sure the entire flash is clean, use 'flash_eraseall' instead.

Image:Flasherase.jpg

4. Copy the uImage on the NAND flash.

-sh-3.2# cat uImage.Sheeva > /dev/mtdblock1

Image:Copyimage.jpg

5. Do a nandwrite to write the filesystem jffs2 image onto the NAND flash. Note the number of blocks that are used by the data. This is the length of the image which will be needed in the bootarguments while editing the bootargs commmand in U-Boot. Substitute the name of your .jffs2 file for "generic." The length of the boot argument will be something like "3c80000."

-sh-3.2# nandwrite /dev/mtd2 generic.jffs2

Image:Nandwrite.jpg

6. Create a mount directory.

-sh-3.2# mkdir /mnt1

7. Mount the jffs2 image on the NAND flash mtdblock2.

-sh-3.2# mount -t jffs2 /dev/mtdblock2 /mnt1

When you mount the newly created JFFS2 file system, you will see many "CLEANMARKER" notices go by as JFFS2 checks each block, and at the end, because some images are made with xattr support for SELinux, you will see something similar to:

JFFS2 notice: (1436) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found. SELinux: initialized (dev jffs2, type jffs2), uses xattr

8. Restart the system and enter the U-Boot prompt. Hit a key immediately after restarting to stop the autoboot, allowing entry to the U-Boot prompt.

Image:Ubootboot.jpg

9. At the U-Boot prompt, change the following parameters.

Marvell>> setenv bootargs 'console=ttyS0,115200 mtdparts=cfi_flash:0x200000@0x100000(uImage)ro,<length of the image
in hex>@0x300000(rootfs)rw root=/dev/mtdblock2' 

NOTE: Explain how to get image size in hex and which image we are referring to

Marvell>> saveenv
Marvell>> setenv bootcmd 'nand read 0x800000 0x100000 0x200000; bootm 0x800000' 
Marvell>> saveenv

10. Reboot the system and the system should boot from the NAND flash.

[Note: Errors will occur if there is disagreement between the kernel and the .jffs2 file regarding the use of SElinux. Care must be taken with regard to using SElinux.]

The Steps to Flash the Plug Computer Solid State Memory

Appendix A: U-Boot Environment pre-NAND Flash

U-Boot environment before boot from NAND flash

This appendix provides the U-Boot environment dump after Sheevaplug board has been configured to boot from NAND flash. Please set the bootargs, bootcmd, bootargs_root, rootpath, console, image_name and bootargs_end as shown below.

          __  __                      _ _ 
         |  \/  | __ _ _ ____   _____| | |
         | |\/| |/ _` | '__\ \ / / _ \ | |
         | |  | | (_| | |   \ V /  __/ | |
         |_|  |_|\__,_|_|    \_/ \___|_|_|
  _   _     ____              _
 | | | |   | __ )  ___   ___ | |_
 | | | |___|  _ \ / _ \ / _ \| __|
 | |_| |___| |_) | (_) | (_) | |_
  \___/    |____/ \___/ \___/ \__|

 


 ** MARVELL BOARD: SHEEVA PLUG LE

 U-Boot 1.1.4 (Dec 15 2008 - 11:13:12) Marvell version: 3.4.11
 
 U-Boot code: 00600000 -> 0067FFF0 BSS: -> 0069292C
 
 Soc: 88F6281 A0 (DDR2)
 CPU running @ 1200Mhz L2 running @ 400Mhz
 SysClock = 400Mhz , TClock = 200Mhz
 
 DRAM CAS Latency = 5 tRP = 5 tRAS = 18 tRCD=6
 DRAM CS[0] base 0x00000000 size 256MB
 DRAM CS[1] base 0x10000000 size 256MB
 DRAM Total size 512MB 16bit width
 Flash: 0 kB
 Addresses 8M - 0M are saved for the U-Boot usage.
 Mem malloc Initialization (8M - 7M): Done
 NAND:512 MB
 *** Warning - bad CRC or NAND, using default environment
 
 CPU : Marvell Feroceon (Rev 1)
 
 Streaming disabled
 Write allocate disabled
 
 USB 0: host mode
 PEX 0: interface detected no Link.
 Net: egiga0 [PRIME], egiga1
 Hit any key to stop autoboot: 3
 Marvell>> print serverip
 serverip=10.4.50.5
 Marvell>> print ipaddr
 ipaddr=10.4.50.165
 Marvell>> set serverip 10.81.24.171
 Marvell>> set ipaddr 10.81.24.224
 Marvell>> saveenv
 Saving Environment to NAND...
 Erasing Nand...Writing to Nand... done
 Marvell>> bubt u-boot-rd88f6281Sheevaplug_400db_nand.bin
 Using egiga0 device
 TFTP from server 10.81.24.171; our IP address is 10.81.24.224
 Filename 'u-boot-rd88f6281Sheevaplug_400db_nand.bin'.
 Load address: 0x2000000
 Loading:
 *_#################################################################
 ###########################
 done
 Bytes transferred = 470808 (72f18 hex)
 
 **Warning**
 If U-Boot Endiannes is going to change (LE->BE or BE->LE), Then Env
 parameters should be overriden..
 Override Env parameters? (y/n) y
 Erase Env parameters sector 655360...
 Erase 0 - 655360 ...
 Copy to Nand Flash...
 done
 Marvell>> print console
 console=console=ttyS0,115200
 mtdparts=nand_mtd:0xc0000@0(uboot)ro,0x1ff00000@0x100000(root)
 Marvell>> print image_name
 image_name=uImage
 Marvell>> print bootargs_end
 bootargs_end=:::DB88FXX81:eth0:none
 Marvell>> print bootargs_root
 bootargs_root=root=/dev/nfs rw
 Marvell>> set serverip 10.81.24.184
 Marvell>> set rootpath /home/e-nas-gen-rootfs-Sheevaplug
 Marvell>> set image_name uImage.Sheeva
 Marvell>> set console 'console=ttyS0,115200
 mtdparts=cfi_flash:0xf40000(root),0xc0000(uboot)ro'
 Marvell>> set bootcmd 'tftpboot 0x2000000 $(image_name);setenv bootargs
 $(console) $(bootargs_root) nfsroot=$(serverip):$(rootpath)
 ip=$(ipaddr):$(serverip)$(bootargs_end); bootm 0x2000000'
 Marvell>> saveenv
 Saving Environment to NAND...
 Erasing Nand...Writing to Nand... done
 Marvell>> reset

Appendix B: Files left off JFFS2 Image

The following files and directories have been removed from the generic filesystem sources so as to minimize the size of the jffs2 image.

 e-nas-gen-rootfs/home: bin
 e-nas-gen-rootfs/home: samba
 e-nas-gen-rootfs/home: slava
 e-nas-gen-rootfs: lost+found
 e-nas-gen-rootfs/usr/bin: eventlogadm
 e-nas-gen-rootfs/usr/bin: eventlogadm.old
 e-nas-gen-rootfs/usr/bin: findsmb.old
 e-nas-gen-rootfs/usr/bin: logger
 e-nas-gen-rootfs/usr/bin: logname
 e-nas-gen-rootfs/usr/bin: net.old
 e-nas-gen-rootfs/usr/bin: nmblookup.old
 e-nas-gen-rootfs/usr/bin: ntlm_auth.old
 e-nas-gen-rootfs/usr/bin: pdbedit.old
 e-nas-gen-rootfs/usr/bin: perl
 e-nas-gen-rootfs/usr/bin: profiles.old
 e-nas-gen-rootfs/usr/bin: rpcclient.old
 e-nas-gen-rootfs/usr/bin: smbcacls.old
 e-nas-gen-rootfs/usr/bin: smbclient.old
 e-nas-gen-rootfs/usr/bin: smbcontrol.old
 e-nas-gen-rootfs/usr/bin: smbcquotas.old
 e-nas-gen-rootfs/usr/bin: smbget.old
 e-nas-gen-rootfs/usr/bin: smbpasswd.old
 e-nas-gen-rootfs/usr/bin: smbspool.old
 e-nas-gen-rootfs/usr/bin: smbstatus.old
 e-nas-gen-rootfs/usr/bin: smbtar.old
 e-nas-gen-rootfs/usr/bin: smbtree.old
 e-nas-gen-rootfs/usr/bin: svlogd
 e-nas-gen-rootfs/usr/bin: tdbbackup
 e-nas-gen-rootfs/usr/bin: tdbbackup.old
 e-nas-gen-rootfs/usr/bin: tdbdump.old
 e-nas-gen-rootfs/usr/bin: tdbtool
 e-nas-gen-rootfs/usr/bin: tdbtool.old
 e-nas-gen-rootfs/usr/bin: testparm
 e-nas-gen-rootfs/usr/bin: testparm.old
 e-nas-gen-rootfs/usr: doc
 e-nas-gen-rootfs/usr: info
 e-nas-gen-rootfs/usr/local: BerkeleyDB.4.6
 e-nas-gen-rootfs/usr/local/bin: find2perl
 e-nas-gen-rootfs/usr/local/bin: perl
 e-nas-gen-rootfs/usr/local/bin: perl5.8.7
 e-nas-gen-rootfs/usr/local/bin: perlbug
 e-nas-gen-rootfs/usr/local/bin: perlcc
 e-nas-gen-rootfs/usr/local/bin: perldoc
 e-nas-gen-rootfs/usr/local/bin: perlivp
 e-nas-gen-rootfs/usr/local: info
 e-nas-gen-rootfs/usr/local/lib: perl5
 e-nas-gen-rootfs/usr/local: man
 e-nas-gen-rootfs/usr/local/share: doc
 e-nas-gen-rootfs/usr/local/share/locale: cs
 e-nas-gen-rootfs/usr/local/share/locale: de
 e-nas-gen-rootfs/usr/local/share/locale: el
 e-nas-gen-rootfs/usr/local/share/locale: eo
 e-nas-gen-rootfs/usr/local/share/locale: es
 e-nas-gen-rootfs/usr/local/share/locale: et
 e-nas-gen-rootfs/usr/local/share/locale: fr
 e-nas-gen-rootfs/usr/local/share/locale: gl
 e-nas-gen-rootfs/usr/local/share/locale: hr
 e-nas-gen-rootfs/usr/local/share/locale: id
 e-nas-gen-rootfs/usr/local/share/locale: it
 e-nas-gen-rootfs/usr/local/share/locale: ja
 e-nas-gen-rootfs/usr/local/share/locale: ko
 e-nas-gen-rootfs/usr/local/share/locale: nl
 e-nas-gen-rootfs/usr/local/share/locale: no
 e-nas-gen-rootfs/usr/local/share/locale: pl
 e-nas-gen-rootfs/usr/local/share/locale: pt_BR
 e-nas-gen-rootfs/usr/local/share/locale: ru
 e-nas-gen-rootfs/usr/local/share/locale: sl
 e-nas-gen-rootfs/usr/local/share/locale: sv
 e-nas-gen-rootfs/usr/local/share: man
 e-nas-gen-rootfs/usr: man
 e-nas-gen-rootfs/usr/sbin: debugfs
 e-nas-gen-rootfs/usr/sbin: debugreiserfs
 e-nas-gen-rootfs/usr/sbin: mount.cifs.old
 e-nas-gen-rootfs/usr/sbin: nmbd.old
 e-nas-gen-rootfs/usr/sbin: resize_reiserfs
 e-nas-gen-rootfs/usr/sbin: smbd.old
 e-nas-gen-rootfs/usr/sbin: swat.old
 e-nas-gen-rootfs/usr/sbin: umount.cifs.old
 e-nas-gen-rootfs/usr/share: doc
 e-nas-gen-rootfs/usr/share: i18n
 e-nas-gen-rootfs/usr/share/info: annotate.info.gz
 e-nas-gen-rootfs/usr/share/info: as.info.gz
 e-nas-gen-rootfs/usr/share/info: bash.info.gz
 e-nas-gen-rootfs/usr/share/info: bfd.info.gz
 e-nas-gen-rootfs/usr/share/info: binutils.info.gz
 e-nas-gen-rootfs/usr/share/info: configure.info.gz
 e-nas-gen-rootfs/usr/share/info: cpp.info
 e-nas-gen-rootfs/usr/share/info: cppinternals.info
 e-nas-gen-rootfs/usr/share/info: dir
 e-nas-gen-rootfs/usr/share/info: dir.old
 e-nas-gen-rootfs/usr/share/info: gcc.info
 e-nas-gen-rootfs/usr/share/info: gccinstall.info
 e-nas-gen-rootfs/usr/share/info: gccint.info
 e-nas-gen-rootfs/usr/share/info: gdb.info.gz
 e-nas-gen-rootfs/usr/share/info: gdbint.info.gz
 e-nas-gen-rootfs/usr/share/info: gprof.info.gz
 e-nas-gen-rootfs/usr/share/info: ld.info.gz
 e-nas-gen-rootfs/usr/share/info: libtool.info.gz
 e-nas-gen-rootfs/usr/share/info: m4.info.gz
 e-nas-gen-rootfs/usr/share/info: make.info-1.gz
 e-nas-gen-rootfs/usr/share/info: make.info-2.gz
 e-nas-gen-rootfs/usr/share/info: make.info.gz
 e-nas-gen-rootfs/usr/share/info: stabs.info.gz
 e-nas-gen-rootfs/usr/share/info: standards.info.gz
 e-nas-gen-rootfs/usr/share/info: termcap.info.gz
 e-nas-gen-rootfs/usr/share: locale
 e-nas-gen-rootfs/usr/share/man/man1: bash.1
 e-nas-gen-rootfs/usr/share/man/man1: bashbug.1
 e-nas-gen-rootfs/usr/share/man/man1: cpp.1
 e-nas-gen-rootfs/usr/share/man/man1: findsmb.1
 e-nas-gen-rootfs/usr/share/man/man1: free.1
 e-nas-gen-rootfs/usr/share/man/man1: g++.1
 e-nas-gen-rootfs/usr/share/man/man1: gcc.1
 e-nas-gen-rootfs/usr/share/man/man1: gcov.1
 e-nas-gen-rootfs/usr/share/man/man1: gdb.1
 e-nas-gen-rootfs/usr/share/man/man1: gdbserver.1
 e-nas-gen-rootfs/usr/share/man/man1: kill.1
 e-nas-gen-rootfs/usr/share/man/man1: log2pcap.1
 e-nas-gen-rootfs/usr/share/man/man1: m4.1
 e-nas-gen-rootfs/usr/share/man/man1: make.1
 e-nas-gen-rootfs/usr/share/man/man1: nmblookup.1
 e-nas-gen-rootfs/usr/share/man/man1: ntlm_auth.1
 e-nas-gen-rootfs/usr/share/man/man1: pgrep.1
 e-nas-gen-rootfs/usr/share/man/man1: pkill.1
 e-nas-gen-rootfs/usr/share/man/man1: pmap.1
 e-nas-gen-rootfs/usr/share/man/man1: profiles.1
 e-nas-gen-rootfs/usr/share/man/man1: ps.1
 e-nas-gen-rootfs/usr/share/man/man1: pwdx.1
 e-nas-gen-rootfs/usr/share/man/man1: rpcclient.1
 e-nas-gen-rootfs/usr/share/man/man1: skill.1
 e-nas-gen-rootfs/usr/share/man/man1: slabtop.1
 e-nas-gen-rootfs/usr/share/man/man1: smbcacls.1
 e-nas-gen-rootfs/usr/share/man/man1: smbclient.1
 e-nas-gen-rootfs/usr/share/man/man1: smbcontrol.1
 e-nas-gen-rootfs/usr/share/man/man1: smbcquotas.1
 e-nas-gen-rootfs/usr/share/man/man1: smbget.1
 e-nas-gen-rootfs/usr/share/man/man1: smbstatus.1
 e-nas-gen-rootfs/usr/share/man/man1: smbtar.1
 e-nas-gen-rootfs/usr/share/man/man1: smbtree.1
 e-nas-gen-rootfs/usr/share/man/man1: snice.1
 e-nas-gen-rootfs/usr/share/man/man1: strace.1
 e-nas-gen-rootfs/usr/share/man/man1: testparm.1
 e-nas-gen-rootfs/usr/share/man/man1: tload.1
 e-nas-gen-rootfs/usr/share/man/man1: top.1
 e-nas-gen-rootfs/usr/share/man/man1: uptime.1
 e-nas-gen-rootfs/usr/share/man/man1: vfstest.1
 e-nas-gen-rootfs/usr/share/man/man1: w.1
 e-nas-gen-rootfs/usr/share/man/man1: watch.1
 e-nas-gen-rootfs/usr/share/man/man1: wbinfo.1
 e-nas-gen-rootfs/usr/share/man: man3
 e-nas-gen-rootfs/usr/share/man: man5
 e-nas-gen-rootfs/usr/share/man: man7
 e-nas-gen-rootfs/usr/share/man: man8
 e-nas-gen-rootfs/usr: src
 e-nas-gen-rootfs/usr: swat
 Binary files e-nas-gen-rootfs/var/lock/brlock.tdb and e-nas-genrootfs_
 plugtop/var/lock/brlock.tdb differ
 Binary files e-nas-gen-rootfs/var/lock/connections.tdb and e-nas-genrootfs_
 plugtop/var/lock/connections.tdb differ
 Binary files e-nas-gen-rootfs/var/lock/unexpected.tdb and e-nas-genrootfs_
 plugtop/var/lock/unexpected.tdb differ

Appendix C: mkfs.jffs2 command help

linux-ezr7:/usr/src/marvell/marvell_builds/sheevaplug # /opt/mtd.tools.x86.linux.bin/mkfs.jffs2 --help
mkfs.jffs2: Usage: mkfs.jffs2 [OPTIONS]
Make a JFFS2 file system image from an existing directory tree

Options:
  -p, --pad[=SIZE]        Pad output to SIZE bytes with 0xFF. If SIZE is
                          not specified, the output is padded to the end of
                          the final erase block
  -r, -d, --root=DIR      Build file system from directory DIR (default: cwd)
  -s, --pagesize=SIZE     Use page size (max data node size) SIZE (default: 4KiB)
  -e, --eraseblock=SIZE   Use erase block size SIZE (default: 64KiB)
  -c, --cleanmarker=SIZE  Size of cleanmarker (default 12)
  -m, --compr-mode=MODE   Select compression mode (default: priortiry)
  -x, --disable-compressor=COMPRESSOR_NAME
                          Disable a compressor
  -X, --enable-compressor=COMPRESSOR_NAME
                          Enable a compressor
  -y, --compressor-priority=PRIORITY:COMPRESSOR_NAME
                          Set the priority of a compressor
  -L, --list-compressors  Show the list of the avaiable compressors
  -t, --test-compression  Call decompress and compare with the original (for test)
  -n, --no-cleanmarkers   Don't add a cleanmarker to every eraseblock
  -o, --output=FILE       Output to FILE (default: stdout)
  -l, --little-endian     Create a little-endian filesystem
  -b, --big-endian        Create a big-endian filesystem
  -D, --devtable=FILE     Use the named FILE as a device table file
  -f, --faketime          Change all file times to '0' for regression testing
  -q, --squash            Squash permissions and owners making all files be owned by root
  -U, --squash-uids       Squash owners making all files be owned by root
  -P, --squash-perms      Squash permissions on all files
      --with-xattr        stuff all xattr entries into image
      --with-selinux      stuff only SELinux Labels into jffs2 image
      --with-posix-acl    stuff only POSIX ACL entries into jffs2 image
  -h, --help              Display this help text
  -v, --verbose           Verbose operation
  -V, --version           Display version information
  -i, --incremental=FILE  Parse FILE and generate appendage output for it

Return to the Main Page

Personal tools