Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: BOOT FROM SPI DATAFLASH : filesystem format
PostPosted: Tue Aug 07, 2007 4:44 pm 
Offline

Joined: Fri Jun 15, 2007 5:25 pm
Posts: 12
Hi,
I work on an AT91RM9200-DK based product.
I was used to boot from a filesystem on a nfs server but, now, I want to boot from my SPI DataFlash.
In ext2 format, my filesystem's size is arround 13M but I have only 5M of free SPI DataFlash space. When I compress it in ext2.gz format, my filesystem's size decrease to 3M. It's just fine but I have some questions :
- can I boot from a ext2.gz filesystem which is store on SPI DataFlash... ?
- if yes : how ? What are the arguments needed by the kernel ?
- is there a more adapted format ?
Thanks by advance,
Joran


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 8:43 am 
Offline

Joined: Mon Jul 30, 2007 12:42 pm
Posts: 3
Location: Riesa (Germany)
Hi Joran,

do not use ext2 format. SquashFS, cramfs or jffs are your friends. Together with a build in MTD device driver you can boot this filssystems with root=/dev/mtdxxxx kernel parameter.

best regards
Jens


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 21, 2007 4:34 pm 
Offline

Joined: Fri Jun 15, 2007 5:25 pm
Posts: 12
Hi buser,
Thanks for this answer, I haven't seen it before...
But I don't know how I can create the MTD device in the /dev directory for my SPI Dataflash...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 5:18 pm 
Offline

Joined: Thu Aug 09, 2007 10:48 am
Posts: 106
Location: Artec Design LLC, Tallinn, Estonia
There are different ways to boot linux. You can either load a init ramdisk from bootloader to SDRAM and boot with that (and the initrd has then enough utilities to hook to some bigger storage and continue) or let the kernel mount the root from the device directly.
Secondly. To get mtd devices, you must specify them on kernel command line. Divide your dataflash to kernel and filesystem (maybe multiple partitions are needed), calcluate the offsets and lenghts of each (align them to erase block size) and construct the kernel command line parameter mtdparts= accordingly. For example, my flash layout is usually [bootloader, bootloader config, kernel, ro filesystem, rw filesystem] and in linux it is mapped as [whole flash, bootloader, bootloader config, kernel, ro filesystem root, rw filesystem area] Set the root= kernel command line parameter to the right partition, the first is mtd0, second mtd1 and so on (in my example, 4). If you boot the kernel without initfs, you must compile in the kernel the drivers needed for that filesystem (not as modules).

Now, choose the filesystem that is the best for you. Either use read-only (but better compression) squasfs, read-write jffs2 etc. Usually you need to mount /tmp as tmpfs in your init scripts, sometimes /var and /etc, too (or just symlink what's needed to be rw to /tmp/something).

Last, you must edit your scripts to create the filesystems. There are tools, that create your FS image. Some tools need root privileges to be able to create an image from the exact tree on your host computer; some tools allow the use of some configuration files to create device nodes and set required permissions while creating the image just on the image (so you don't need root access on host pc to set them earlier)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 28, 2007 5:18 pm 
Offline

Joined: Fri Jun 15, 2007 5:25 pm
Posts: 12
A big thanks for this helpful response.
I have changed my kernel and everything is working now.
I can boot with read only cramfs or jffs2.
Thanks again for this response, I think that it will be useful for many others peoples !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 9:08 am 
Offline

Joined: Wed Jul 04, 2007 8:01 am
Posts: 37
Hi Joran,

Can you provide some details on the steps you got the jffs2 system onto the NAND Flash and how you got that filesystem mounted ?

For example, upon kernel startup, how to write the jffs2 file into the NAND flash.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 12, 2007 1:28 pm 
Offline

Joined: Fri Sep 28, 2007 1:07 pm
Posts: 29
Second that, and additionally;
compared to block devices as regular harddrives(like the ones I am used to), you need to write a partitioning scheme to be able to write the filesystems and later mount them.
How are the
Code:
/dev/mtdX
created?

_________________
Gentoo Linux 2007.0
AT91SAM9263


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 23, 2007 10:34 pm 
Offline

Joined: Mon Apr 16, 2007 6:34 pm
Posts: 41
Location: Fargo, ND, USA
I think you need to edit the board support source in the kernel to create partitions. E.g. http://fxr.watson.org/fxr/source/arch/a ... x-2.6#L130 for the 9260ek. Then you just use mknod like you would for any other device in /dev/. The char devs have a weird minor number scheme, they alternate rw and ro, with each physical partition getting 2 minors.

Code:
root@omap5912osk:/media/hda1/alsa-lib-1.0.14/test/.libs$ ls -l /dev/mtd*
crw-rw----    1 root     root      90,   0 Jan  1  1970 /dev/mtd0
crw-rw----    1 root     root      90,   1 Jan  1  1970 /dev/mtd0ro
crw-rw----    1 root     root      90,   2 Jan  1  1970 /dev/mtd1
crw-rw----    1 root     root      90,   3 Jan  1  1970 /dev/mtd1ro
crw-rw----    1 root     root      90,   4 Jan  1  1970 /dev/mtd2
crw-rw----    1 root     root      90,   5 Jan  1  1970 /dev/mtd2ro
crw-rw----    1 root     root      90,   6 Jan  1  1970 /dev/mtd3
crw-rw----    1 root     root      90,   7 Jan  1  1970 /dev/mtd3ro
brw-rw----    1 root     disk      31,   0 Jan  1  1970 /dev/mtdblock0
brw-rw----    1 root     disk      31,   1 Jan  1  1970 /dev/mtdblock1
brw-rw----    1 root     disk      31,   2 Jan  1  1970 /dev/mtdblock2
brw-rw----    1 root     disk      31,   3 Jan  1  1970 /dev/mtdblock3
root@omap5912osk:/media/hda1/alsa-lib-1.0.14/test/.libs$ cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00020000 00020000 "bootloader"
mtd1: 00020000 00020000 "params"
mtd2: 00200000 00020000 "kernel"
mtd3: 01dc0000 00020000 "filesystem"


The above is from a non-at91 system, but the mtd layer works the same. You can see how the major and minor numbers relate to the partitions.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 9:27 am 
Offline

Joined: Fri Sep 28, 2007 1:07 pm
Posts: 29
Interesting. Thank you :)

_________________
Gentoo Linux 2007.0
AT91SAM9263


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: