As I have not been able to boot from mmc/sd since a little "accident", I
am now going through the process of getting my beagleboard to boot linux
from NAND flash.
These are the steps I have taken
1. Erase all flash !
2. Unbrick board using u-boot v2 to load u-boot v1 etc.
3. Try reading x-loader from mmc using fatload. Board hangs
4. Load x-loader via serial and write to nand.
5. Load u-boot v1 via serial and write to nand
6. Load uimage via serial and write to nand
So far, so good. But when it comes to getting a file system for NAND I
confess to be stuck. I understand a jffs2 file system is required but I
don't know how to go about building one of these for the beagleboard.
Any help would be much appreciated.
TIA
Bob
What's the issue? Getting a root file system at all or jffs2 in
particular?
To get a root fs, have a look to the file system images at [1] or
koen's images [2].
To put root fs into NAND, the easiest way is to boot kernel, mount MMC
card (with tar.gz image of root fs) and NAND root fs partition, erase
NAND root fs partition from kernel using mtd utils and then just
extract tar.gz root fs image from SD card to NAND fs partition. E.g.
something like
flash_eraseall -j /dev/mtd4
mkdir -p /mnt/mmc
mkdir -p /mnt/nand
mount /dev/mmcblk0p1 /mnt/mmc/
mount -t jffs2 /dev/mtdblock4 /mnt/nand
cd /mnt/nand
tar xvfz /mnt/mmc/rootfs.tar.gz .
Does this work? If it works, would be nice if you could update [3].
Please note that writing jffs2 root fs with U-Boot like described in
[4] often doesn't work because of some differences between U-Boot and
kernel NAND/jffs2 handling.
Dirk
[1] http://code.google.com/p/beagleboard/wiki/BeagleSourceCode "8MB
Ramdisk File System Image" or "File system Image with ALSA libraries"
[3] http://elinux.org/BeagleBoardNAND#Writing_file_system_with_kernel
[4] http://elinux.org/BeagleBoardNAND#Writing_file_system_with_U-Boot
I am trying to figure that out too several days ago. I was trying to
write rootfs from google code project to NAND so I can have a known good
default configuration. That rootfs is ext2 instead of jffs2. It turns out
the type of file system might not be important.
Here is what I have done:
1. Calculate the rootfs nand write size: use rootfs size, rounded up to
128KB boundary.
2. Write the rootfs to NAND with commnad "nand write" to address 0x680000
3. change bootcmd environment variable to something like this:
bootcmd=nand read 0x80300000 0x280000 0x1e0000; nand read 0x81600000
0x680000 0x340000; bootm 0x80300000
4. change bootargs environment variable to something like this:
bootargs=console=ttyS2,115200n8 ramdisk_size=8192 root=/dev/ram0 rw
rootfstype=ext2 initrd=0x81600000,8M nohz=0ff
5. try boot, if working, saveenv, boot
regards,
Guo
Dirk Behme wrote:
> Robert Hibberdine wrote:
>
>> Hi all,
>>
>> As I have not been able to boot from mmc/sd since a little "accident", I
>> am now going through the process of getting my beagleboard to boot linux
>> from NAND flash.
>>
>> These are the steps I have taken
>>
>> 1. Erase all flash !
>> 2. Unbrick board using u-boot v2 to load u-boot v1 etc.
>> 3. Try reading x-loader from mmc using fatload. Board hangs
>> 4. Load x-loader via serial and write to nand.
>> 5. Load u-boot v1 via serial and write to nand
>> 6. Load uimage via serial and write to nand
>>
>> So far, so good. But when it comes to getting a file system for NAND I
>> confess to be stuck. I understand a jffs2 file system is required but I
>> don't know how to go about building one of these for the beagleboard.
>>
>
> What's the issue? Getting a root file system at all or jffs2 in
> particular?
>
>
Well, I just need a file system in NAND because at present my mmc doe
not seem to work. And I was under the impression that for a NAND
filesystem you needed jffs2...Can I use a ext3 filesystem in NAND?
> To get a root fs, have a look to the file system images at [1] or
> koen's images [2].
>
> To put root fs into NAND, the easiest way is to boot kernel, mount MMC
> card (with tar.gz image of root fs) and NAND root fs partition, erase
> NAND root fs partition from kernel using mtd utils and then just
> extract tar.gz root fs image from SD card to NAND fs partition. E.g.
> something like
>
>
Agreed that this would be the easiest way to do this BUT as I said I
can't use my mmc/sd. So I need to loadb my filesystem and then write it
to NAND. The question is how would I package up an such an ext3
filesystem so I could load it into the board and write it to nand...
ahhhh wait a minute, a possible answer just came to me, I could package
it as a RAM file system. Would this work??
Thanks again,
Bob
Bob
In my u-boot bootcmd, I load ext2 rootfs from NAND to memory, then in
bootargs, tell kernel to mount rootfs from memory instead of NAND. In this
use case, my NAND will be fine, right?
Another thing, I tried to use Angstrom distribution, since it has jffs2
rootfs and newer kernel than one in google code project (I am trying to
get DSP programming working). But about 50% the time, the kernel will lock up during boot. And minicom serial port console
seems also sluggish. Anyone else has this kind of trouble?
Thanks,
Guo
Thanks again
Bob
On Sun, 14 Sep 2008, Robert Hibberdine wrote:
>
> Thanks for this..
> But I don't quite understand how you packaged the file system... as a
> ramfs??
I just download the rootfs from
http://beagleboard.googlecode.com/files/rd-ext2-8M.bin
I don't know how it is packaged. I am newbie to Linux.
> Also, your bootcmd. Is this just copying the rootfs from flash to ram
> and then the kernel uses at ramfs at /dv/ram0?
>
Yes. It is /dev/ram0 not /dv/ram0.
Answered by Koen ;)
>>To get a root fs, have a look to the file system images at [1] or
>>koen's images [2].
>>
>>To put root fs into NAND, the easiest way is to boot kernel, mount MMC
>>card (with tar.gz image of root fs) and NAND root fs partition, erase
>>NAND root fs partition from kernel using mtd utils and then just
>>extract tar.gz root fs image from SD card to NAND fs partition. E.g.
>>something like
>>
>>
>
> Agreed that this would be the easiest way to do this BUT as I said I
> can't use my mmc/sd.
Your MMC is totally dead? You can't even mount it from kernel? Note
that it is a difference to boot from MMC (this is done by ROM
bootloader which might (but shouldn't) fail) or to boot from NAND and
then mount MMC from kernel.
> So I need to loadb my filesystem and then write it
> to NAND.
I propose to not write root fs from U-Boot. Use kernel instead to
write jffs2 root fs to NAND.
> The question is how would I package up an such an ext3
> filesystem so I could load it into the board and write it to nand...
> ahhhh wait a minute, a possible answer just came to me, I could package
> it as a RAM file system. Would this work??
Yes, if you can't boot from MMC and kernel can't mount MMC as root fs
(are you really sure?), you can use e.g. Ramdisk [1] or NFS [2] (or
USB stick?) as kernel's root fs medium and then write root fs from kernel.
Dirk
Btw: If you have some luck and some experts are there discussing
something like this would be faster and easier at IRC
[1] http://wiki.davincidsp.com/index.php?title=Initrd#initramfs
As already mentioned for NAND you want different kind of filesystems
as the technology is quite different.
The most common one is jffs2, but recently ubifs[1] has emerged and
it's superior by far [2].
I just posted the script I use to generate both jffs2 and ubifs images:
http://gist.github.com/11332
In order to boot from jffs2:
root=/dev/mtdblock4 rootfstype=jffs2
In order to boot from ubifs:
ubi.mtd=4 root=ubi0:rootfs rootfstype=ubifs
The problem is how to write the image to NAND, that's the step I still
haven't been able to do on the Beagle. These are my notes, but
probably won't work:
fatload mmc 0 82000000 rootfs-ubifs.bin
nand unlock
nand ecc sw
nand erase 680000 10000000
nand write 82000000 680000 F20000
fatload mmc 0 82000000 rootfs-jffs2.bin
nand unlock
nand ecc sw
nand erase 680000 F980000
nand write 82000000 680000 B80000
Best regards.
[1] http://www.linux-mtd.infradead.org/doc/ubifs.html
[2] http://lwn.net/Articles/276025/
--
Felipe Contreras
No, that was on my workstation.
>> The problem is how to write the image to NAND, that's the step I still haven't been able to do on the Beagle.
>
> Have you tried using the MTD utils flash_eraseall -j and nandwrite?
> I've seen this approach used by others when they are preparing and
> writing the nand with the jffs2 file system. I've not been able to
> try this myself because I'm still trying to get MTD utils compiled.
I think I tried that a long time ago.
I prefer to use u-boot to flash images for NAND, but since that's not
working perhaps I should try with mtd-utils too.
I think Koen's images have mtd-utils installed.
--
Felipe Contreras
Yes. It also handles bad block management on the NAND.
>
> I'm assuming that to make a jffs2, yaffs2, or ubifs file systems that
> you need a mkfs.jffs2, mkfs.yaffs2, or mkfs.ubifs utility, right? As
> I understand it, these applications will format the NAND and prepare
> it for use. You can then untar some rootfs directory tree on the
> NAND, change the uboot bootargs to use the proper NAND partition as
> the rootfs, and then boot the Beagleboard using this NAND partition as
> your rootfs. Am I right so far?
There are 2 basic ways of doing it. One way is to create a filesystem image on
the host and write it to the NAND with nandwrite. The other way is to create
a blank filesystem and add things to it like any other filesystem.
The tools mkfs.jffs2, etc are for creating the filesystem image. To create a
blank filesystem on flash, (assuming all the support is in the kernel), do:
flash_unlock /dev/mtdN
flash_eraseall /dev/mtdN
mount -t FSTYPE /dev/mtdblockN /mnt
where N is the partition number. Look at the boot log or /proc/mtd for a list
of partitions. Avoid 0 and 1 as those tend to be U-boot and X-Loader. The
flash_unlock may be unnecessary as some U-boot/kernel combinations unlock it
on startup.
FSTYPE is jffs2, yaffs, etc. JFFS2 requires the type to be specified at each
use. Yaffs seems to know how to autodetect it after the first time.
>
> Has anyone got their Beagleboard running the rootfs from a NAND
> partition? If so, can you share some details about how you did it?
I had JFFS2 running start with a blank file system that slowly got populated.
>
> Where did you get the mkfs.jffs2, mkfs.yaffs2, or mkfs.ubifs tools? I
> think these are part of MTD utils, but I haven't had any success cross-
> compiling these utils for the Beagleboard. I also tried loading the
> Angstrom Distribution [1] but didn't find the MTD-utils included in
> that image.
There is also a fstool utility that should do the equivalent functions.
-- Hunyue
You really should try the "The other way is to create a blank
filesystem and add things to it like any other filesystem." way
described below, i.e. using the kernel to write the fs. Using kernel
itself to write the fs it has to mount later as rootfs is known to be
easier than writing (probably incomatible) fs image with (probably
incomatible) U-boot.
Maybe
http://wiki.davincidsp.com/index.php?title=Filesystem_in_NOR_or_NAND
and
http://elinux.org/BeagleBoardNAND
can help you.
(ignore the "Writing file system with U-Boot" section, unfortunately
what you want, the "Writing file system with kernel" is still missing)
> At the time of booting, the kernel would uncompress and then spew a
> lot of non-Ascii chars on the console. In short, it would simply not
> boot.
>
> So a few questions:
>
> 1. Does the basic mvista
It's not a MontaVista kernel...
> kernel have mtd/jffs2/nand support? I picked
> up the kernel from [git clone git://source.mvista.com/git/linux-omap-2.6.git
... it is the community kernel hosted on a MontaVista server.
If you enable mtd/jffs2/nand in your kernel, it has mtd/jffs2/nand
support.
> ] and ran the default board defconfig scripts before compiling the
> kernel. The same image boots up like a breeze with ramfs.
>
> 2. Is my bootargs correct?
> bootargs console=ttyS2,115200n8 noinitrd root=/dev/mtdblock4
> rootfstype=jffs2 rw rootdelay=1 nohz=off
Regarding rootfs seems fine. You should use rootwait instead of
rootdelay=1, though.
Dirk
It needs to be specified because on a NAND device, you can only erase in
discrete sizes. This means all files must start on a erase size block boundry
or you will have issues later on when the file is modified. This isn't seen
much on disk-centric file systems as they tend to have a common sector size;
whereas, on flash this can vary from part to part.
>
> If I want to write a directory tree to NAND from the kernel through a
> jffs2 mountpiont, I should be able to just extract a regular tarball
> of the tree to the NAND, right?
Yes.
-- Hunyue