<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>coding &#187; nand</title>
	<atom:link href="http://www.coding.com.br/tag/nand/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coding.com.br</link>
	<description>have you coded today?</description>
	<lastBuildDate>Thu, 18 Aug 2011 17:29:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>linux booting on ubifs partitions</title>
		<link>http://www.coding.com.br/embarcado/linux-booting-on-ubifs-partitions/</link>
		<comments>http://www.coding.com.br/embarcado/linux-booting-on-ubifs-partitions/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 17:01:31 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[embarcado]]></category>
		<category><![CDATA[nand]]></category>
		<category><![CDATA[ubifs]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=1561</guid>
		<description><![CDATA[UBIFS is relatively new on embedded systems but my guess is that they&#8217;ll become the standard on embedded market. To start, the first step is enable UBIFS support in kernel. I exaggerated on some debug options, fell free to avoid:
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_RESERVE=1
CONFIG_MTD_UBI_DEBUG=y
CONFIG_MTD_UBI_DEBUG_MSG=y
CONFIG_UBIFS_FS=y
CONFIG_UBIFS_FS_LZO=y
CONFIG_UBIFS_FS_ZLIB=y
Next I used a simple rootfs &#8211; basically busybox + mtd-utils &#8211; to create/format the partitions, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">UBIFS is relatively new on embedded systems but my guess is that they&#8217;ll <a href="http://free-electrons.com/pub/conferences/2008/elce/flash-filesystems.pdf" target="_blank">become the standard</a> on embedded market. To start, the first step is enable UBIFS support in kernel. I exaggerated on some <em>debug</em> options, fell free to avoid:</p>
<p style="padding-left: 30px;">CONFIG_MTD_UBI=y<br />
CONFIG_MTD_UBI_WL_THRESHOLD=4096<br />
CONFIG_MTD_UBI_BEB_RESERVE=1<br />
CONFIG_MTD_UBI_DEBUG=y<br />
CONFIG_MTD_UBI_DEBUG_MSG=y<br />
CONFIG_UBIFS_FS=y<br />
CONFIG_UBIFS_FS_LZO=y<br />
CONFIG_UBIFS_FS_ZLIB=y</p>
<p style="text-align: justify;">Next I used a simple<em> rootfs</em> &#8211; basically <a href="http://www.busybox.net/" target="_blank">busybox</a> + <a href="http://git.infradead.org/mtd-utils.git" target="_blank">mtd-utils</a> &#8211; to create/format the partitions, suppose that you kernel <a href="http://www.coding.com.br/embarcado/mtd-partitions-tips/" target="_blank">divided</a> the memory in the following parts:</p>
<p style="padding-left: 30px;"># cat /proc/mtd<br />
mtd0: 00300000 00020000 &#8220;bootloader&#8221; *<br />
mtd1: 00500000 00020000 &#8220;nand.kernel&#8221; **<br />
mtd2: 00100000 00020000 &#8220;nand.ramdisk&#8221;<br />
<strong>mtd3: 06400000 00020000 &#8220;nand.system&#8221;</strong></p>
<p>*,** The<em> bootloade</em>r and <em>nand.kernel</em> I flashed via u-boot.</p>
<p>1. <strong>The first time<br />
</strong></p>
<p style="text-align: justify;">This is only needed when you create the partition for the first time. Steps are erasing the flash, detaching the UBI [if it was previously attached], format on UBI model, attach again, creating the volume (specifying a name) and finally mounting.<strong><br />
</strong></p>
<pre style="padding-left: 30px;">flash_eraseall /dev/mtd3

ubidetach /dev/ubi_ctrl -m 3
ubiformat /dev/mtd3 -y
ubiattach /dev/ubi_ctrl -m 3
ubimkvol /dev/ubi0 -N system -m
mount -t ubifs ubi0:<strong>system</strong> /mnt/ubi

[ copy your rootfs ]

umount /mnt/ubi</pre>
<p><strong>system</strong> is the name that I choose for partition, could be any.</p>
<p>2. <strong> Editing</strong></p>
<p>Suppose that you need edit some files on your UBIFS , then you only need:</p>
<pre style="padding-left: 30px;">ubiattach /dev/ubi_ctrl -m 3
mount -t ubifs ubi0:system /mnt/ubi</pre>
<p>3. <strong>Boot</strong></p>
<p>In order to boot, you need add some parameters to u-boot.</p>
<pre style="padding-left: 30px;">setenv bootargs 'console=ttymxc0,115200 <strong>rootfstype=ubifs ubi.mtd=3 root=ubi0:system</strong> init=...'</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/embarcado/linux-booting-on-ubifs-partitions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using nandsim to mount large images</title>
		<link>http://www.coding.com.br/embarcado/using-nandsim-to-mount-large-images/</link>
		<comments>http://www.coding.com.br/embarcado/using-nandsim-to-mount-large-images/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 01:57:26 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[embarcado]]></category>
		<category><![CDATA[jffs2]]></category>
		<category><![CDATA[mtd]]></category>
		<category><![CDATA[nand]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=168</guid>
		<description><![CDATA[Since I&#8217;m still using 32-bit machines I had to switch the way I mount large (&#62; 128MiB) JFFS2 images. Now I&#8217;m using NAND simulator, an extremely useful debugging and development tool which simulates NAND flashes in RAM. The main problem with mtdram is  related with space reserved to vmalloc function on 32-bits processors (an hardware [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Since I&#8217;m still using 32-bit machines I had to switch the way I mount large (&gt; 128MiB) JFFS2 images. Now I&#8217;m using NAND simulator, an extremely useful debugging and development tool which simulates NAND flashes in RAM. The main problem with mtdram is  related with space reserved to vmalloc function on 32-bits processors (an hardware dependent issue). Checking /proc/meminfo you can see the difference:</p>
<pre>32-bit: VmallocTotal:   122880 kB
64-bit: VmallocTotal:   34359738367 kB</pre>
<p style="text-align: justify;">Nandsim uses another design to access memory, it creates a slab allocation for an array to allow large chunks of memory, the following functions contains more information:</p>
<pre style="text-align: justify;">static int __init <strong>init_mtdram</strong>(void) in drivers/mtd/devices/<strong>mtdram.c</strong>
static int <strong>alloc_device</strong>(struct nandsim *ns) in drivers/mtd/nand/<strong>nandsim.c</strong></pre>
<p>Lets remember the &#8220;original&#8221; way (using mdtram) to mount an JFFS2 image:</p>
<pre>modprobe mtd
modprobe mtdblock
<strong>modprobe mtdram total_size=10240 erase_size=16</strong>
dd if=image.jffs2 of=/dev/mtdblock0
mount -t jffs2 /dev/mtdblock0 /mount-point</pre>
<p>And the new one with nandsim:</p>
<pre>modprobe mtd
modprobe mtdblock
<strong>modprobe nandsim first_id_byte=0x20 second_id_byte=0x71
</strong>dd if=image.jffs2 of=/dev/mtdblock0
mount -t jffs2 /dev/mtdblock0 /mount-point</pre>
<p>And check both:</p>
<pre>cat /proc/mtd
dev:    size   erasesize  name
mtd0: 08000000 00004000 "NAND simulator partition 0"
mtd1: 00400000 00004000 "mtdram test device"</pre>
<p style="text-align: justify;">With mtdram you can define any value to <em>erase_size</em> but with nandsim you need pre-defined memory parameters found in manufacturer datasheet, to select the simulated flash type one should specify ID bytes of your flasher (I&#8217;ve tested with pages of 512 and 2048 bytes).  For more information click <a href="http://www.linux-mtd.infradead.org/faq/nand.html#L_nand_nandsim" target="_blank">here</a>.</p>
<p style="text-align: justify;">You can use nandsim to mount another flash file systems, such as: YAFFS2, CramFS and UBIFS.</p>
<p style="text-align: justify;">As described on first paragraph, nandsim is much more than just a &#8220;mount tool&#8221;. It can reproduce real condition of memory and lead developers make experiments without real hardware. I&#8217;m still learning the possibilities, if you would like to contribute leave an comment.</p>
<p><strong>Endianess issue</strong></p>
<p>If you need convert an image from <em>big endian</em> to <em>little endian</em> (specially on x86 systems) use <strong>jffs2dump</strong>.</p>
<pre style="text-align: justify;">jffs2dump -b big_endian.img -e new_little_endian.img</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/embarcado/using-nandsim-to-mount-large-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
