OESF Portables Forum

Model Specific Forums => Sharp Zaurus => Zaurus - pdaXrom => Topic started by: louigi600 on June 14, 2007, 11:10:50 am

Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 14, 2007, 11:10:50 am
Anyone know if it's possible to tell the kernel what the nand flash partition layout is trough an append statement from the boot loader ?

Currently u-boot sends this info to kernel:
console=ttyS0,115200 console=tty1 root=/dev/mtdblock2 rootfstype=jffs2

This only tels the kernel where the root is (nand partition 2) but the nand partition physical layout is hard coded to kernel.

Being able to pass the nand partition layout via boot loader would avoid :
having this info hard coded to kernel sources,
having to rebuild the kernel if you intend to make a different layout.

Ok this goes a bit off topik but is closely related:
Currently the u-boot image used with pdaxrom would need to be rebuilt in order to change this append info but this is not mandatory as u-boot is capable of reading stuff from virtually anywhere (including an ext3 or jffs2 filesystem) but would require work to make it functional on Z.

Currently uboot is being used at about 5% of it's capabilities as it would be possible to:
pick up a kernel from SD/MMC/CF/MicroDrive with fat or ext2 filesystem on it (and other filesystems to but probably not intresting for linux),
pick up the kernel from the jffs2 root image on the onboard nand,
pick up the boot configuration data (which kernel to boot from where and which root filesystem to use ... etc) from a file instead of having it hard coded to the sources (the file could be anywhere just like the kernel),
it could even be possible to have the video and keyboard working at boot time so that one could pass extra parameters without serial console (or doo some debugging without the serial console) like one can do with grub or any conventional boot loader for x86 linux.

All this could mean to a common user not having to flash anything in order to upgrade a kernel or have 2 different releases  with 2 different kernels (including the more difficult combinations like beta3 and r198 or 2 different distributions) ... for any advanced user or developer ;-) well only immagination is the limit .

Am I the only one that would find this handy ?
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 14, 2007, 11:48:51 am
Ok this helps the append parameter:

The format for the command line is as follows:
mtdparts=<mtddef>[;<mtddef]
<mtddef>  := <mtd-id>:<partdef>[,<partdef>]
<partdef> := <size>[@offset][<name>][ro]
<mtd-id>  := unique name used in mapping driver/device (mtd->name)
<size>    := standard linux memsize OR "-" to denote all remaining space
<name>    := '(' NAME ')'

Examples:
pdaxrom u-boot ptdparts lauout (1 logical 0->7168k, jffs2 all the rest)
mtdparts=laze-0:7168k(Logical),-(JFFS2)

1 NOR Flash, with 1 single writable partition:
edb7312-nor:-

1 NOR Flash with 2 partitions, 1 NAND with one
edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)


But still the other off topick stuff is very intresting to me
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 15, 2007, 03:40:59 am
Ok I've a bit more info and a small correction to the above mtdpart data:

On my C760 there is actually 2 physically different flash chips:

C760,pdaxrom r197:
Sharp SL series flash device: 800000 at 0 (with one defined partition)
  sharpsl-flash:6d0000@120000(Boot POM Filesystem)ro
    currently defined in drivers/mtd/maps/sharpsl-flash.c

NAND device: Manuf ID: ec, Chip ID: 79 (with 2 or more defined partitions distro dependant)
  sharpsl-nand:700000(Logical),-(JFFS2)
    currently defined in drivers/mtd/nand/sharpsl.c

So actually the whole mtdpart data would look like this:
mtdparts=sharpsl-flash:6d0000@120000(Boot POM Filesystem)ro;sharpsl-nand:7168k(Logical),-(JFFS2)

If anyone is running something different that beta4 or above on their Z it would be intresting if they could add to this thread the partition layout for theyr model/distro.
Information can be gotten from /var/log/dmesg.
Title: Append Nand Flash Partiton Info
Post by: johnsutton on June 15, 2007, 07:38:36 am
This is surely the right way to go.  And maybe the NAND backup/restore problem can also be resolved?  This would be good as it is an impediment to the adoption of uboot.

I did some work around this issue some months ago - it seems to me that the partition table for the flash memory (or at least, a copy of it) is held somewhere in the first partition (the first 7Mb) and when the restore routine fails to find it there (because it has been overwritten by uboot) the restore then fails?

You say that "the nand partition physical layout is hard coded to kernel" but I don't understand how this can be true because the same kernel can be run on systems with different layouts, surely?

I wrote a script to mount NAND backup images on a linux desktop and in the course of doing this I tried to find the partition table so that the script could do the mounts automatically.  But I couldn't find it so had to hardcode the layout data in to the script ;-(

I'd like to get a comprehensive understanding of the boot process, so any comments are welcome!
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 15, 2007, 11:27:31 am
Quote
This is surely the right way to go.  And maybe the NAND backup/restore problem can also be resolved?  This would be good as it is an impediment to the adoption of uboot.
Probably not because pdaxrom beta4 and above flash layout is too different anyway from that the sharp tool expects
Quote
I did some work around this issue some months ago - it seems to me that the partition table for the flash memory (or at least, a copy of it) is held somewhere in the first partition (the first 7Mb) and when the restore routine fails to find it there (because it has been overwritten by uboot) the restore then fails?
u-boot targets the logic partition (mtd1) which is in the samgsung chip ... the firs 7Mb or so are in the sharpsl-flash (that is meant to be managed as read only).
There is however an image of the D+M menu copied into mdt1 and this is the one that fails sometimes (depending on model)
Quote
You say that "the nand partition physical layout is hard coded to kernel" but I don't understand how this can be true because the same kernel can be run on systems with different layouts, surely?
It is hard coded to kernel but can be (or at least should be) overridden with the kernel append. Currently pdaxrom does not use this feature (maybe other distro do).
I've not had the time to checkout the theory yet but I will.
Quote
I wrote a script to mount NAND backup images on a linux desktop and in the course of doing this I tried to find the partition table so that the script could do the mounts automatically.  But I couldn't find it so had to hardcode the layout data in to the script ;-(

I'd like to get a comprehensive understanding of the boot process, so any comments are welcome!
If you are using something different from beta4+ on any zaurus device could you please supply the info I'm inviting everybody to supply (see a few postings above).
Title: Append Nand Flash Partiton Info
Post by: johnsutton on June 16, 2007, 04:36:28 am
Is beta1 on c1000 interesting?  If so, you`ll need to tell me where to find the info.  I dumped dmesg to a file immediately after booting but this does not contain any mention of mtd?
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 16, 2007, 04:46:39 am
Quote
Is beta1 on c1000 interesting?  If so, you`ll need to tell me where to find the info.  I dumped dmesg to a file immediately after booting but this does not contain any mention of mtd?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=163281\"][{POST_SNAPBACK}][/a][/div]
There is no need to dump, the init scripts do that for you (there is a copy in /var/log/dmseg).
The command dmesg reads from kernel cyclic buffer that will eventually start overwriting entries while /var/log/dmsed is a dump ov the kernel buffer right after the boot process has finished.

Well things may look different in beta1 ... I'm not sure what to look for but you should see entries where the 2 flash devices are found and when the partitions in them are layed out.

I've translated the entries I found to make them look like mtdparts append commands; if you are not able to do that just cut and paste the entries in the dmesg and I;ll do the rest.
Title: Append Nand Flash Partiton Info
Post by: T3_slider on June 16, 2007, 10:21:36 am
Here's my output from beta 3:

Code: [Select]
Linux version 2.4.20 (sash@pdaX86) (gcc version 2.95.3 20010315 (release)) #1 Sat, 25 Mar 2006 15:03:52 +0000
CPU: XScale-PXA270 revision 7
Machine: SHARP Borzoi
Converting old-style param struct to taglist
Ignoring unrecognised tag 0x00000000
Turbo Mode clock : 416.00MHz (*2.0, active)
Run Mode clock   : 208.00MHz
System bus clock : 208.00MHz (1/1)
Memory clock     : 208.00MHz (1/1)
LCD clock        : 104.00MHz (1/2)
Security risk: creating user accessible mapping for 0x08000000 at 0xf1000000
On node 0 totalpages: 16384
zone(0): 16384 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: console=ttyS0 root=/dev/mtdblock2 mtdparts=sharpsl-nand:7168k@0k(smf),123904k@7168k(root),-(home) jffs2_orphaned_inodes=delete RTC_RESET=1 EQUIPMENT=5 LOGOLANG=1 DEFYEAR=2007 LOGO=1 LAUNCH=q
Console: colour dummy device 80x30
Calibrating delay loop... 415.33 BogoMIPS
Memory: 64MB = 64MB total
Memory: 62212KB available (2071K code, 415K data, 80K init)
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount-cache hash table entries: 1024 (order: 1, 8192 bytes)
Buffer-cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
RCSR = 1
full reset !
apm: BIOS version 1.2 Flags 0x02 (Driver version 1.14)
FCS : CCCR = 2000210
enable_irq(120) unbalanced from c000c768
batok installed
Starting kswapd
Journalled Block Device driver loaded
JFFS2 version 2.1. (C) 2001, 2002 Red Hat, Inc., designed by Axis Communications AB.
Sharp SL-Series PXA fb driver initialized.
reset resolution unkown => 480x640
Console: switching to colour frame buffer device 80x30
fb0: SHARPSL_PXAFB frame buffer device
keyboard initilaized.
pty: 256 Unix98 ptys configured
Serial driver version 5.05c (2001-07-08) with no serial options enabled
SharpSL serial driver version 5.05c (2001-07-08) with no serial options enabled
ttyS00 at 0xf8100000x (irq = 22) is a 16550A
ttyS01 at 0xf8700000x (irq = 20) is a 16550A, using IRDA
ttyS02 at 0xf8200000x (irq = 21) is a 16550A
rs_init: IRDA H/W initializaion
sharpled_init: done.
spitz remote controller
Cotulla Real Time Clock driver v1.00
Cotulla Touch Screen driver initialized
Uniform Multi-Platform E-IDE driver Revision: 6.31
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
loop: loaded (max 8 devices)
PPP generic driver version 2.4.2
PPP BSD Compression module registered
SCSI subsystem driver Revision: 1.00
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
Spitz audio driver initialize
Sharp SL series flash device: 1000000 at 0
Using static partision definition
Creating 1 MTD partitions on "sharpsl-flash":
0x00140000-0x007f0000 : "Filesystem"
NAND device: Manufacture ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MB 3,3V)
Creating 3 MTD partitions on "NAND 128MB 3,3V":
0x00000000-0x00700000 : "smf"
0x00700000-0x08000000 : "root"
0x08000000-0x08000000 : "home"
mtd: partition "home" is out of reach -- disabled
Linux Kernel Card Services 3.1.31
  options:  [pm]
Intel PXA250/210 PCMCIA (CS release 3.1.31)
pxa_pcmcia_init(0)
pxa_pcmcia_init(1)
Backlight Driver Initialized.
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 4096)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NetWinder Floating Point Emulator V0.97 (double precision)
IrCOMM protocol (Dag Brattli)
cramfs: wrong magic
FAT: bogus logical sector size 381
Eep. Child "cookies" (ino #3790) of dir ino #515 doesn't exist!
Inode #512 was a directory with children - removing those too...
Inode #513 was a directory with children - removing those too...
Inode #515 was a directory with children - removing those too...
Cannot remove child "cookies", ino #3790, because it doesn't exist
Inode #518 was a directory with children - removing those too...
Inode #519 was a directory with children - removing those too...
Inode #521 was a directory with children - removing those too...
Inode #522 was a directory with children - removing those too...
Inode #8335 was a directory with children - removing those too...
Inode #4398 was a directory with children - removing those too...
Inode #4399 was a directory with children - removing those too...
Inode #4403 was a directory with children - removing those too...
Inode #4407 was a directory with children - removing those too...
Inode #3781 was a directory with children - removing those too...
Inode #3782 was a directory with children - removing those too...
Inode #3783 was a directory with children - removing those too...
VFS: Mounted root (jffs2 filesystem) readonly.
Freeing init memory: 80K
Warning: unable to open an initial console.
Warning: Remapping obsolete /dev/fb* minor 32 to 1
I moved my /home directory to my hd (I have repartitioned my hd to contain the original 2 9MB partitions, a 256MB swap partition and the rest an ext2 partition if that helps (although I don't think that makes a difference).

I have a lot of inode errors that don't appear to affect anything in any way so I haven't done anything about them.
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 16, 2007, 04:03:02 pm
The intresting information there is:
Code: [Select]
Sharp SL series flash device: 1000000 at 0
Using static partision definition
Creating 1 MTD partitions on "sharpsl-flash":
0x00140000-0x007f0000 : "Filesystem"
NAND device: Manufacture ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MB 3,3V)
Creating 3 MTD partitions on "NAND 128MB 3,3V":
0x00000000-0x00700000 : "smf"
0x00700000-0x08000000 : "root"
0x08000000-0x08000000 : "home"
mtd: partition "home" is out of reach -- disabled

Which would translate to:
Sharp SL series flash device: 1000000 at 0
  sharpsl-flash:6b0000@140000(Filesystem)

NAND device:
    sharpsl-nand:700000(smf),100000@700000(root) .....

Not sure what would happen with the home with this warning:
mtd: partition "home" is out of reach -- disabled

This is robably because you made a custom one in the MD .... but I thinks you wasted a lot of space in the NAND flash.

Thanks for the feedback anyway.
BTW are you using a C3x00/1000 ? ... it does not look like one of the corgi family
Title: Append Nand Flash Partiton Info
Post by: pelrun on June 16, 2007, 09:10:28 pm
Quote
I have a lot of inode errors that don't appear to affect anything in any way so I haven't done anything about them.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=163294\"][{POST_SNAPBACK}][/a][/div]

You can't fix them, they aren't real errors.  That part of the boot process just isn't reading the partition properly. Once it's mounted later on all of those "errors" vanish.

louigi600 - a Borzoi is a 3100.
Title: Append Nand Flash Partiton Info
Post by: T3_slider on June 16, 2007, 10:31:49 pm
Actually it's a C3200 which is treated like a C3100 in pdaXrom beta 3.  It's in my signature.

As for wasting space in NAND, it's actually because I resized the root partition to the full 121 MB, therefore removing any space for the home partition and making it out of reach until the microdrive is mounted properly.
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 17, 2007, 03:51:35 am
Quote
louigi600 - a Borzoi is a 3100.
YEa I guess I should have lokked here
Code: [Select]
CPU: XScale-PXA270 revision 7
Machine: SHARP Borzoi
before asking ;-) ... but it appears as if on some devices this is not 100% reliable ...
Since you have a real Borzi can you supply the intresting parts of dmesg too?

Quote
Actually it's a C3200 which is treated like a C3100 in pdaXrom beta 3.  It's in my signature.

As for wasting space in NAND, it's actually because I resized the root partition to the full 121 MB, therefore removing any space for the home partition and making it out of reach until the microdrive is mounted properly.
Yea I see now I missed a "0" so also the mtdparts stuff was wrong

Sharp SL series flash device: 1000000 at 0
sharpsl-flash:6b0000@140000(Filesystem)

NAND device:
sharpsl-nand:700000(smf),7900000@700000(root),0@8000000(home)
Title: Append Nand Flash Partiton Info
Post by: pelrun on June 17, 2007, 06:20:31 am
Ok, here's my Z's interesting bits (ooo err):

Code: [Select]
Kernel command line: console=ttyS0 root=/dev/mtdblock2 mtdparts=sharpsl-nand:7168k@0k(smf),51200k@7168k(root),-(home) jffs2_orphaned_inodes=delete EQUIPMENT=4 LOGOLANG=1 DEFYEAR=2006 LOGO=1 LAUNCH=q

Sharp SL series flash device: 1000000 at 0
Using static partision definition
Creating 1 MTD partitions on "sharpsl-flash":
0x00140000-0x007f0000 : "Filesystem"
NAND device: Manufacture ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MB 3,3V)
Creating 3 MTD partitions on "NAND 128MB 3,3V":
0x00000000-0x00700000 : "smf"
0x00700000-0x03900000 : "root"
0x03900000-0x08000000 : "home"

I think I just went with defaults on my install, but I can't be 100% sure.
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 17, 2007, 09:09:48 am
Intresting I did not notice that before .... beta3 is receiving the in the kernel command line also the mtdparts stuff r121 and above (and probably also beta4 and above) do not get any of the mtdparts stuff. Apparently you can express sizes and offset also in decimal with human feesable extensions ;-) ... I missed that too ! (thanks pelrun).

Is this the sharp boot loader passing the kernel command line or is it a dirty kernel source trick ?
Title: Append Nand Flash Partiton Info
Post by: pelrun on June 17, 2007, 09:27:10 am
Can it be a kernel source trick? The values are dependent on what you enter during installation, and there's no compilation going on then.
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 17, 2007, 12:40:33 pm
Quote
Can it be a kernel source trick? The values are dependent on what you enter during installation, and there's no compilation going on then.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=163319\"][{POST_SNAPBACK}][/a][/div]
Text inside kernel can be changed (with precautions) witout recompiling ... anyway something is done during installation that ither has to do with boot loader or with kernel without recompiling .... do you know exactly what ?
Title: Append Nand Flash Partiton Info
Post by: johnsutton on June 19, 2007, 07:19:43 am
Here are two extracts from dmesg for beta1 running on c1000:

Kernel command line: console=ttyS0 root=/dev/mtdblock2 mtdparts=sharpsl-nand:7168k@0k(smf),59392k@7168k(root),-(home) jffs2_orphaned_inodes=delete EQUIPMENT=0 LOGOLANG=1 DEFYEAR=2006 LOGO=1 LAUNCH=q

Sharp SL series flash device: 1000000 at 0
Using static partision definition
Creating 1 MTD partitions on "sharpsl-flash":
0x00140000-0x007f0000 : "Filesystem"
NAND device: Manufacture ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MB 3,3V)
Creating 3 MTD partitions on "NAND 128MB 3,3V":
0x00000000-0x00700000 : "smf"
0x00700000-0x04100000 : "root"
0x04100000-0x08000000 : "home"
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 19, 2007, 10:56:26 am
Quote
I'd like to get a comprehensive understanding of the boot process, so any comments are welcome!
Quite some time ago I attempted to grab fragments of information concerning how the Z boot. Not sure how accurate that is but if anyone has any hints, corrections, info or links concerning this I'll be glad to update the doc.

I'll put up the cxx0_boot.txt (http://www.seicento.selfip.org/zaurus/docs/cxx0_boot.txt) document on my home page as soo as possible. If you don't find the doc avalible in the "Zaurus" (left menu) and "Documentation" on the top bar please try later.
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 21, 2007, 05:17:54 pm
Ok there is good chances that we could have kernel loaded from MMC fat formated partition.
Not sure if this is possible with the 2006-04-18-1106 version of u-boot.
I've managed to get the newest u-boot sources patched with the zaurus stuff but unfortunatly although it builds it will not boot anything.

Need a serial cable for Z to do some debugging ...

Anyone have a serial cable ... or know where I can get one for an honest proce ?
Title: Append Nand Flash Partiton Info
Post by: johnsutton on June 24, 2007, 01:25:50 pm
Where would you plug in a serial cable?  On a C1000, for instance?

PS Thanks for the document re boot process, very useful.
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 24, 2007, 01:58:48 pm
Quote
Where would you plug in a serial cable?  On a C1000, for instance?

PS Thanks for the document re boot process, very useful.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=163646\"][{POST_SNAPBACK}][/a][/div]
The c1k should have a sharp io connector in the back covered by a grey rubber cap (more or less where the Cx60 has the SD/MMC slot.
I've never used it because the rubber caps looks as if it will brake if I pull it out so I'll do all my debugging with my c760 ;-)
Title: Append Nand Flash Partiton Info
Post by: pelrun on June 25, 2007, 12:18:44 am
The cxxxx's io port cap won't break if you pull it out, but it probably isn't strong enough to withstand repeated use without getting loose. Not that it matters so much, ZThinCable's don't seem to work with the newer models.

That means I could probably sell my ZThinCable-M; I have to see if the guy who I gave my 860 to wants it first though.
Title: Append Nand Flash Partiton Info
Post by: louigi600 on June 25, 2007, 02:56:13 pm
Quote
The cxxxx's io port cap won't break if you pull it out, but it probably isn't strong enough to withstand repeated use without getting loose.
Well when I'll really need to pull it out I'll try again ... but so fat every time I tryed without actually neading to connect anything I stopped because it really loked like I'd end up with 2 pieces of rubber in my hands.
Quote
Not that it matters so much, ZThinCable's don't seem to work with the newer models.
Never Mind ... I was able to build a serial interface cable for my C760 out of some scrap electronics material (a ICL232 and a cd4069) taken out of some junk I recovered from scrap at work.
ASAP I'll document the work on my home page "ZElectronics" section.
Title: Append Nand Flash Partiton Info
Post by: louigi600 on July 01, 2007, 05:08:03 am
Ok I've documented the cable on my home page and I'va also tested it successfully on my SL-5500, C760 and C1000. I've not tryed it out on my C860 because I assume if it works on the C760 it will also work on the C860 ;-)