{"id":985,"date":"2010-09-07T12:46:57","date_gmt":"2010-09-07T19:46:57","guid":{"rendered":"http:\/\/wp.colliertech.org\/cj\/?p=985"},"modified":"2010-09-07T12:53:38","modified_gmt":"2010-09-07T19:53:38","slug":"debian-on-sheeva-plug-internal-nand-flash","status":"publish","type":"post","link":"https:\/\/wp.c9h.org\/cj\/?p=985","title":{"rendered":"Debian on Sheeva Plug internal NAND flash"},"content":{"rendered":"<p>After a bit of work, I got the sheeva plug working the way I wanted it to.  First of all, I grabbed a spare 1G USB flash disk I had laying around and installed Debian squeeze to it by following tbm&#8217;s instructions here:<\/p>\n<p><a href=\"http:\/\/www.cyrius.com\/debian\/kirkwood\/sheevaplug\/install.html\">http:\/\/www.cyrius.com\/debian\/kirkwood\/sheevaplug\/install.html<\/a><\/p>\n<p>After debian was installed to the USB disk, I removed it from the plug and used dd on my laptop to create an image of the filesystem.  I mounted the filesystem as a loopback device and created a jffs2 partition image from it after doing a bit of minor tweaking.  I placed the USB disk back in the plug and booted to it.  Using this intermediate filesystem and the mtd-tools package, I wrote the new jffs2 image to the NAND mtd device.  I then modified the uboot environment to suit, saved, and now have a working setup.<\/p>\n<p>Detailed instructions are below.<\/p>\n<h3>pre-requisites<\/h3>\n<p>Connect the plug to your network with the rj-45\/cat5 cable.<\/p>\n<p>Connect a USB flash drive to the plug.  I used a 1G drive, but 512M should be sufficient.<\/p>\n<p>Install the &#8216;tftpd&#8217; package on a machine on your network. You&#8217;ll also need screen on the machine that you use to connect to the plug&#8217;s serial terminal.  I&#8217;ll assume these are the same host.  You need the IP address of the tftp server.  In this example, we will assume that the IP is 192.168.1.2 and that you will assign 192.168.1.200 to the plug.<\/p>\n<p>$ sudo apt-get install tftpd screen<\/p>\n<p>Place <a href=\"http:\/\/www.cyrius.com\/tmp\/beta1\/marvell\/sheevaplug\/uImage\">uImage<\/a>, <a href=\"http:\/\/www.cyrius.com\/tmp\/beta1\/marvell\/sheevaplug\/uInitrd\">uInitrd<\/a>, and <a href=\"http:\/\/wp.colliertech.org\/cj\/wp-content\/uploads\/2010\/09\/07\/uboot.bin\">uBoot<\/a> in the \/srv\/tftp directory:<\/p>\n<p>$ sudo wget -O \/srv\/tftp\/uImage http:\/\/www.cyrius.com\/tmp\/beta1\/marvell\/sheevaplug\/uImage<br \/>\n$ sudo wget -O \/srv\/tftp\/uInitrd http:\/\/www.cyrius.com\/tmp\/beta1\/marvell\/sheevaplug\/uInitrd<br \/>\n$ sudo wget -O \/srv\/tftp\/uBoot http:\/\/wp.colliertech.org\/cj\/wp-content\/uploads\/2010\/09\/07\/uboot.bin<\/p>\n<h2>Connecting to the serial console<\/h2>\n<p>We are now ready to boot the plug.  Note that you have to be quick with the screen command.  I recommend you type it out and get ready to press the enter key.  You have to interrupt the bootloader in order to enter the u-boot console.  Attach the power and immediately enter the following command:<\/p>\n<p>$ screen -S sheeva \/dev\/ttyUSB0 cs8,ixoff,115200<\/p>\n<p>If you did this right, you should see a prompt like this:<\/p>\n<p>Marvell&gt;&gt;<\/p>\n<h2>update uboot<\/h2>\n<p>As per tbm&#8217;s instructions, you can now update the uboot if needed.  Instructions for that are here:<\/p>\n<p><a href=\"http:\/\/www.cyrius.com\/debian\/kirkwood\/sheevaplug\/uboot-upgrade.html\">http:\/\/www.cyrius.com\/debian\/kirkwood\/sheevaplug\/uboot-upgrade.html<\/a><\/p>\n<p>I&#8217;ll put them inline here for completeness.<\/p>\n<pre>\r\nMarvell&gt;&gt; setenv serverip 192.168.1.2 # IP of your TFTP server\r\nMarvell&gt;&gt; setenv ipaddr 192.168.1.200 # IP of the plug\r\nMarvell&gt;&gt; bubt uboot.bin\r\n<\/pre>\n<p>be sure to answer &#8216;n&#8217; to the question about env parameters.<\/p>\n<p>Now reset the device.  Don&#8217;t forget to interrupt the bootloader so we can get back to the prompt:<\/p>\n<pre>\r\nMarvell&gt;&gt; reset\r\n<\/pre>\n<p>Let the device know that you will be running a mainline kernel and set the arcNumber:<\/p>\n<pre>\r\nMarvell&gt;&gt; setenv mainlineLinux yes\r\nMarvell&gt;&gt; setenv arcNumber 2097\r\nMarvell&gt;&gt; saveenv\r\nMarvell&gt;&gt; reset\r\n<\/pre>\n<h2>Install Debian to the USB disk<\/h2>\n<p>Interrupt the boot process once more.  We are now ready to run the debian installer.  I&#8217;ll leave the details as an exercise for the reader.  The following should put you into the installer, which you are probably quite familiar with by now.<\/p>\n<p><b>NB<\/b>: I will assume that you will use a single ext3 partition for the entire system.  This will make it easier to build a jffs2 image out of the resultant partition on the USB disk.<\/p>\n<pre>\r\nMarvell&gt;&gt; setenv serverip 192.168.1.2\r\nMarvell&gt;&gt; setenv ipaddr 192.168.1.147\r\nMarvell&gt;&gt; tftpboot 0x01100000 uInitrd\r\nMarvell&gt;&gt; tftpboot 0x00800000 uImage\r\nMarvell&gt;&gt; setenv bootargs console=ttyS0,115200n8 base-installer\/initramfs-tools\/driver-policy=most\r\nMarvell&gt;&gt; bootm 0x00800000 0x01100000\r\n<\/pre>\n<h2>build a jffs2 image<\/h2>\n<p>Once the installation has completed, power down the plug and remove the USB disk.  Put the USB disk in the machine you used to get the console on the plug and note what device the kernel assigns to it.  In my case, it was given sdc, so debian is installed to \/dev\/sdc1.  I will use these values for this example.<\/p>\n<p>If the filesystem was automatically mounted, unmount it.  Create a disk image of the partition and mount it as a loopback device.<\/p>\n<pre>\r\n$ sudo umount \/dev\/sdc1\r\n$ dd if=\/dev\/sdc1 of=\/tmp\/debian.img\r\n$ mkdir \/tmp\/mnt\r\n$ sudo mount -o loop \/tmp\/debian.img \/tmp\/mnt\r\n<\/pre>\n<p>You can now remove the USB disk and return it to the plug.<\/p>\n<p>Modify the \/etc\/fstab file.  The root filesystem will be \/dev\/mtdblock2 and of fs type jffs2.  My fstab file looks like the following:<\/p>\n<pre>\r\nproc            \/proc           proc    defaults        0       0\r\n\/dev\/mtdblock2 \/               jffs2    errors=remount-ro 0       1\r\n<\/pre>\n<p>We can now create a jffs2 image from the mounted and altered fresh install:<\/p>\n<pre>\r\n$ sudo mkfs.jffs2 -l \\\r\n  -e 0x20000 \\\r\n  -X zlib \\\r\n  --eraseblock=128KiB \\\r\n  --pad \\\r\n  --output=\/tmp\/rootfs.jffs2 \\\r\n  --compression-mode=priority \\\r\n  -n \\\r\n  --squash \\\r\n  -r \/tmp\/mnt\r\n<\/pre>\n<h2>write jffs2 to nand<\/h2>\n<p>Now that we have an image to flash to the NAND, let&#8217;s boot off of the USB disk.  It should now be attached to the plug.  Power on the plug and use screen to get a console.  Interrupt the bootloader and enter the following commands:<\/p>\n<pre>\r\nMarvell&gt;&gt; setenv bootargs_console console=ttyS0,115200\r\nMarvell&gt;&gt; setenv bootcmd_usb 'usb start; ext2load usb 0:1 0x01100000 \/boot\/uInitrd; ext2load usb 0:1 0x00800000 \/boot\/uImage'\r\nMarvell&gt;&gt; setenv bootcmd 'setenv bootargs $(bootargs_console); run bootcmd_usb; bootm 0x00800000 0x01100000'\r\nMarvell&gt;&gt; run bootcmd\r\n<\/pre>\n<p>Log in as root with the credentials you configured during the install.  You will need to install a few packages in order to complete the nand flash.  You can then ssh to the host on which you created the jffs2 image and cat it to stdout, piping this to nandwrite:<\/p>\n<pre>\r\n$ sudo apt-get install mtd-utils\r\n$ ssh user@192.168.1.2 cat \/tmp\/rootfs.jffs2 | sudo nandwrite \/dev\/mtd2 -p -\r\n<\/pre>\n<p>You now have a jffs2 image on the nand.<\/p>\n<h2>Configure u-boot<\/h2>\n<p>One more reboot to set u-boot&#8217;s environment, and you will be done.  Power down and remove the USB disk.  Power on and get the serial console using screen.  Break into the bootloader and enter the following commands:<\/p>\n<pre>\r\nMarvell&gt;&gt; setenv bootargs_console console=ttyS0,115200\r\nMarvell&gt;&gt; setenv mtdpartitions mtdparts=orion_mtd:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs)\r\nMarvell&gt;&gt; setenv bootargs_root root=\/dev\/mtdblock2 rw rootfstype=jffs2\r\nMarvell&gt;&gt; setenv bootcmd 'setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_root); nand read.e 0x00800000 0x00100000 0x00400000; bootm 0x00800000'\r\nMarvell&gt;&gt; saveenv\r\nMarvell&gt;&gt; reset\r\n<\/pre>\n<p>You should now be good to go.<\/p>\n\n<div class=\"twitter-share\"><a href=\"https:\/\/twitter.com\/intent\/tweet?via=cjamescollier\" class=\"twitter-share-button\">Tweet<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>After a bit of work, I got the sheeva plug working the way I wanted it to. First of all, I grabbed a spare 1G USB flash disk I had laying around and installed Debian squeeze to it by following tbm&#8217;s instructions here: http:\/\/www.cyrius.com\/debian\/kirkwood\/sheevaplug\/install.html After debian was installed to the USB disk, I removed it [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[60,17,79,47,163,210],"tags":[],"class_list":["post-985","post","type-post","status-publish","format-standard","hentry","category-colliertech","category-debian","category-free-software","category-linux","category-networking","category-ubuntu-us-wa"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1YDIB-fT","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts\/985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=985"}],"version-history":[{"count":3,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts\/985\/revisions"}],"predecessor-version":[{"id":987,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts\/985\/revisions\/987"}],"wp:attachment":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}