[U-Boot-Users] DiskOnChip, filesystems, and other booting options

Hello everyone,
I've finished porting U-boot 0.3.0 to my MPX823 board. It contains a 512KB 29LV040 that boots u-boot, an extra 8MB DiskOnChip Millenium, and an Ethernet controller (it contains other hardware as well, but that's not relevant).
I can now successfully boot the board into Linux by tftp'ing the kernel, and using root nfs (exported NFS is /opt/eldk/ppc_8xx - thanks Worlfgang!).
I compiled my own kernel based on the latest linuxppc_2_4 CVS branch. I can successfully access my DiskOnchip under both u-boot and Linux.
I now want to boot my board from the on-board Flash.
In an ideal world, I would like the DiskOnChip to be: 1. Partition into one or more partitions 2. Boot the kernel from a file in one of the partitions (could be FAT) 3. mount root from separate partition, (if kernel is on FAT), or same partition as the kernel (if possible).
I'm slightly confused as to the status of JFFS2, DOS partitioning, DOS FAT/VFAT, and the DiskOnChip support. More specifically:
1. As far as I can tell, the only DiskOnChip support are the "doc read" and "doc write" commands, therefore if I use these commands I must load the kernel directly off the raw sectors - no filesystem support whatsoever. Am I correct?
2. Does the "doc read" and "doc write" use the NFTL layer, or do they access the raw device sectors?
3. As far as I can tell, the FAT support is hardwired to the floppy controller device, and the DOS partition support is wired to the IDE support. Am I right? It seems to me it is quite trivial to construct a simple interface (a struct containing the block device geometry, plus a pointer to sector read function), and have both the partitioning and the DOS FAT code access this. This could help support DOS filesystems on D.O.C, floppies and IDE devices.
4. What is the best way to achieve my requirements above? (booting a kernel from a filesystem on the D.O.C). Can JFFS2 help me in any way?
5. Failing all the above, can I partition the device under Linux into 2 partitions, write down the sector range for the 1st partition, and use it to read/write the kernel using the "doc read" and "doc write interface"? I would then mount the 2nd partition after booting the kernel.
thanks, Udi

Dear Udi,
in message fsrgav0iq16cgicc588ms3p7nvc2gtogbb@4ax.com you wrote:
In an ideal world, I would like the DiskOnChip to be:
Maybe you can find some useful information in section ``7.3. Using Disk On Chip "Drives"'' at http://www.denx.de/doc/CPU86/advanced-topics.html#DISK-ON-CHIP
- Partition into one or more partitions
You can use "nftl_format" to crewate a "binary partition" (which is ideal to hold one or more Linux kernel images) and you can use "fdisk" to partition the remainder of the DoC in the classical way.
- Boot the kernel from a file in one of the partitions (could be FAT)
Put the kernel in the binary partition, and boot it from there.
Or extend U-Boot and add MSDOS filesystem support.
- mount root from separate partition, (if kernel is on FAT), or same
partition as the kernel (if possible).
Put the kernel in the binary partition, and mount one of teh regular partitions as root filesystem.
I'm slightly confused as to the status of JFFS2, DOS partitioning, DOS FAT/VFAT, and the DiskOnChip support. More specifically:
JFFS2 has nothing to do with this. DOS FAT/VFAT support is non- existent.
- As far as I can tell, the only DiskOnChip support are the "doc read" and
"doc write" commands, therefore if I use these commands I must load the kernel directly off the raw sectors - no filesystem support whatsoever. Am I correct?
No, you are not correct.
First, the "doc" command provides more sub-commands, like "doc info" or "doc erase".
"help doc" helps ;-)
- Does the "doc read" and "doc write" use the NFTL layer, or do they access
the raw device sectors?
They do not use NFTL. They use raw binary offset addresses.
- As far as I can tell, the FAT support is hardwired to the floppy controller
device, and the DOS partition support is wired to the IDE support. Am I right?
???
It seems to me it is quite trivial to construct a simple interface (a struct containing the block device geometry, plus a pointer to sector read function), and have both the partitioning and the DOS FAT code access this. This could help support DOS filesystems on D.O.C, floppies and IDE devices.
Are you talking about U-Boot or Linux here?
- What is the best way to achieve my requirements above? (booting a kernel
from a filesystem on the D.O.C). Can JFFS2 help me in any way?
See the document mentioned above. It contains pretty detailed instructions. And no, JFFS2 has nothing to do with it.
- Failing all the above, can I partition the device under Linux into 2
partitions, write down the sector range for the 1st partition, and use it to read/write the kernel using the "doc read" and "doc write interface"? I would then mount the 2nd partition after booting the kernel.
Yes, you can do that. See above.
Best regards,
Wolfgang Denk

On Fri, 25 Apr 2003 01:18:43 +0200, Wolfgang Denk wd@denx.de wrote:
Dear Udi,
Thanks for your help Wolfgang!
in message fsrgav0iq16cgicc588ms3p7nvc2gtogbb@4ax.com you wrote:
In an ideal world, I would like the DiskOnChip to be:
Maybe you can find some useful information in section ``7.3. Using Disk On Chip "Drives"'' at http://www.denx.de/doc/CPU86/advanced-topics.html#DISK-ON-CHIP
Thanks, I just began reading it, and it looks like it answers all my questions. My D.O.C was already partitioned with 1MB binary partition, which I successfully used for the Linux kernel. However, I still didn't manage to get my D.O.C working under Linux, (see below, at the end of this EMail).
- As far as I can tell, the only DiskOnChip support are the "doc read" and
"doc write" commands, therefore if I use these commands I must load the kernel directly off the raw sectors - no filesystem support whatsoever. Am I correct?
No, you are not correct.
First, the "doc" command provides more sub-commands, like "doc info" or "doc erase".
"help doc" helps ;-)
Yes, I know about these - what I meant was that the D.O.C support is still at the sector level, without any filesystem support.
- Does the "doc read" and "doc write" use the NFTL layer, or do they access
the raw device sectors?
They do not use NFTL. They use raw binary offset addresses.
As far as I know (correct me if I'm wrong), NFTL does block-level remapping of bad blocks as well as wear levering by constantly changing the logical<>physical sector mapping on each write (so that if you write the same "logical" sector 1000 times it would spread over all the flash).
If my understanding is accurate, how can I use the U-Boot raw sectors without disturbing the NFTL mapping that is handled by the Linux MTD package?
Besides, I've peeked into the D.O.C code in U-boot and it's full of NFTL references. In fact, as far as I can see, binary partitions are part of NFTL. (And U-BOOT successfully identifies a 1MB on my D.O.C - it was probably preformatted when I got it - its not a new board).
- As far as I can tell, the FAT support is hardwired to the floppy controller
device, and the DOS partition support is wired to the IDE support. Am I right?
???
I've been looking at the files in fs/fdos/... and the CMD_FDC, CMD_FDOS code which calls them., and I see it contains complete code to read a FAT filesystem.
It seems to me it is quite trivial to construct a simple interface (a struct containing the block device geometry, plus a pointer to sector read function), and have both the partitioning and the DOS FAT code access this. This could help support DOS filesystems on D.O.C, floppies and IDE devices.
Are you talking about U-Boot or Linux here?
Yes, see above. I mean reusing the code from fs/fdos.
- What is the best way to achieve my requirements above? (booting a kernel
from a filesystem on the D.O.C). Can JFFS2 help me in any way?
See the document mentioned above. It contains pretty detailed instructions. And no, JFFS2 has nothing to do with it.
I understand from the above that I don't need it, but just for the sake of understanding - couldn't I drop the NFTL+normal filesystem and use JFFS2 over the raw D.O.C sectors, since JFFS2 does bad block mapping and wear levering (or does it??)
OK, so where to I stand now? 1. My kernel correctly identifies the D.O.C but for some reason manages to mount it only partially. /dev/mtdchar0 is non functional, but /dev/nftla seems to work between reboots. I can correctly partition the D.O.C using fdisk, and the format is kept when I leave fdisk and re-run it, btu once I reboot, all the partitioning done is lost.
I think this part of my questions should be sent to the MTD list I guess.
------------------------------------------------------------------- => run 'b' ARP broadcast 1 TFTP from server 10.10.10.4; our IP address is 10.10.10.8 Filename 'uImage'. Load address: 0x500000 Loading: ################################################################# ################################################################# # done Bytes transferred = 666269 (a2a9d hex) ## Booting image at 00500000 ... Image Name: Linux Kernel Image Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 666205 Bytes = 650.6 kB Load Address: 00000000 Entry Point: 00000000 Verifying Checksum ... OK Uncompressing Kernel Image ... OK Linux version 2.4.21-pre7 (udif@localhost.localdomain) (gcc version 2.95.4 20010319 (prerelease/franzo/20011204)) #5 Thu Apr 24 21:04:12 IDT 2003 On node 0 totalpages: 4096 zone(0): 4096 pages. zone(1): 0 pages. zone(2): 0 pages. Kernel command line: /dev/nfs rw nfsroot=10.10.10.4:/opt/eldk/ppc_8xx ip=dhcp Decrementer Frequency = 180000000/60 Calibrating delay loop... 47.71 BogoMIPS Memory: 14448k available (1264k kernel code, 404k data, 64k init, 0k highmem) Dentry cache hash table entries: 2048 (order: 2, 16384 bytes) Inode cache hash table entries: 1024 (order: 1, 8192 bytes) Mount cache hash table entries: 512 (order: 0, 4096 bytes) Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes) Page-cache hash table entries: 4096 (order: 2, 16384 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 Starting kswapd devfs: v1.12c (20020818) Richard Gooch (rgooch@atnf.csiro.au) devfs: boot_options: 0x0 Installing knfsd (copyright (C) 1996 okir@monad.swb.de). CPM UART driver version 0.03 ttyS00 at 0x0280 is a SMC ttyS01 at 0x0380 is a SMC pty: 256 Unix98 ptys configured eth0: CPM ENET Version 0.2 on SCC2, 00:50:01:02:03:04 RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize loop: loaded (max 8 devices) Using configured DiskOnChip probe address 0x4000000 DiskOnChip Millennium found at address 0x4000000 Flash chip found: Manufacturer ID: 98, Chip ID: E6 (Toshiba:NAND 8MB 3,3V) 1 flash chips found. Total DiskOnChip size: 8 MiB NFTL driver: nftlcore.c $Revision: 1.87 $, nftlmount.c $Revision: 1.31 $ Unreferenced block 130, formatting it Partition check: nftla: unknown partition table devfs_register(disc): NULL ops, got c0169364 from major table NET4: Linux TCP/IP 1.0 for NET4.0 IP Protocols: ICMP, UDP, TCP, IGMP IP: routing cache hash table of 512 buckets, 4Kbytes TCP: Hash tables configured (established 1024 bind 1024) Sending DHCP requests ., OK IP-Config: Got DHCP answer from 0.0.0.0, my address is 10.10.10.10 IP-Config: Complete: device=eth0, addr=10.10.10.10, mask=255.255.255.0, gw=10.10.10.1, host=10.10.10.10, domain=, nis-domain=(none), bootserver=0.0.0.0, rootserver=10.10.10.4, rootpath= ip_conntrack version 2.1 (128 buckets, 1024 max) - 292 bytes per conntrack ip_tables: (C) 2000-2002 Netfilter core team arp_tables: (C) 2002 David S. Miller NET4: Unix domain sockets 1.0/SMP for Linux NET4.0. Looking up port of RPC 100003/2 on 10.10.10.4 Looking up port of RPC 100005/1 on 10.10.10.4 VFS: Mounted root (nfs filesystem). Freeing unused kernel memory: 64k init INIT: version 2.78 booting Welcome to DENX Embedded Linux Environment Press 'I' to enter interactive startup. Mounting proc filesystem: [ OK ] Configuring kernel parameters: [ OK ] Cannot access the Hardware Clock via any known method. Use the --debug option to see the details of our search for an access method. Setting clock : Sat Dec 13 18:57:33 EST 1952 [ OK ] Activating swap partitions: [ OK ] Setting hostname 10.10.10.10: [ OK ] modprobe: Can't open dependencies file /lib/modules/2.4.21-pre7/modules.dep (No such file or directory) Checking filesystems [ OK ] Mounting local filesystems: [ OK ] Enabling swap space: [ OK ] INIT: Entering runlevel: 3 Entering non-interactive startup Starting system logger: [ OK ] Starting kernel logger: [ OK ] Starting xinetd: [ OK ]
10 login: root
Last login: Sat Dec 13 12:40:42 on console bash-2.05# eraseall /dev/mtdchar0 eraseall: /dev/mtdchar0: No such device bash-2.05# bash-2.05# nftl_format /dev/mtdchar0 0x000C0000 $Id: nftl_format.c,v 1.19 2002/05/01 10:59:04 dwmw2 Exp $ Open flash device: No such device bash-2.05# bash-2.05# fdisk /dev/nftla Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable.
Command (m for help): p
Command (m for help): Disk /dev/nftla: 14 heads, 1 sectors, 1000 cylinders Units = cylinders of 14 * 512 bytes
Device Boot Start End Blocks Id System
Command (m for help): Command (m for help): n
Command action e extended p primary partition (1-4) Command action e extended p primary partition (1-4) p
Partition number (1-4): Value out of range. Partition number (1-4): 1
First cylinder (1-1000, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-1000, default 1000):
Using default value 1000
Command (m for help): Command (m for help): p
Disk /dev/nftla: 14 heads, 1 sectors, 1000 cylinders Units = cylinders of 14 * 512 bytes
Device Boot Start End Blocks Id System /dev/nftla1 1 1000 6999+ 83 Linux
Command (m for help): Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: If you have created or modified any DOS 6.x partitions, please see the fdisk manual page for additional information. Syncing disks. bash-2.05# bash-2.05# fdisk /dev/nftla
Command (m for help): p
Command (m for help): Disk /dev/nftla: 14 heads, 1 sectors, 1000 cylinders Units = cylinders of 14 * 512 bytes
Device Boot Start End Blocks Id System /dev/nftla1 1 1000 6999+ 83 Linux
Command (m for help): Command (m for help): q
bash-2.05# -------------------------------------------------------------------
Best regards,
Wolfgang Denk
thanks, Udi
participants (3)
-
Udi Finkelstein
-
Udi Finkelstein
-
Wolfgang Denk