Topic UsingPCCard not in WebOrder Using PC Card "disks" with U-Boot and Linux
U-Boot provides only basic functionality to access PC Card based
"disks": you can print the partition table and read and write blocks
(addressed by absolute block number), but there is no support to
create new partitions or to read files from any type of filesystem.
[Such features could be easily added as U-Boot extensions aka
"standalone programs", but so far it has not been implemented yet.]
As usual, you can get some information about the available IDE
commands using the
help command in U-Boot:
=> help ide
ide reset - reset IDE controller
ide info - show available IDE devices
ide device [dev] - show or set current device
ide part [dev] - print partition table of one or all IDE devices
ide read addr blk# cnt
ide write addr blk# cnt - read/write `cnt' blocks starting at block `blk#'
to/from memory address `addr'
That means you will have to partition the "disk" on your host system;
U-Boot can be configured for DOS and
MacOS? type partition tables.
Since U-Boot cannot read files from a filesystem you should create
one (or more) small partitions (maybe 1 MB or so) if you want to boot
from the "disk".
For example on a 128 MB
CompactFlash card we could create the
following partiton table under Linux:
# fdisk /dev/hda
hda: hda1 hda2 hda3 hda4
Command (m for help): p
Disk /dev/hda: 8 heads, 32 sectors, 978 cylinders
Units = cylinders of 256 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 17 2160 83 Linux
/dev/hda2 18 34 2176 83 Linux
/dev/hda3 35 803 98432 83 Linux
/dev/hda4 804 978 22400 82 Linux swap
Command (m for help): q
# mkswap /dev/hda4
Setting up swapspace version 1, size = 22933504 bytes
Here we have two small boot partitions (
/dev/hda1 and
/dev/hda2, 2
MB each), one big partition to hold a filesystem (
/dev/hda3, 99 MB),
and a swap partition (
/dev/hda4, 22 MB). We also initialized
/dev/hda4 as swap space.
U-Boot will recognize this partition table as follows:
=> ide part
Partition Map for IDE device 0 -- Partition Type: DOS
Partition Start Sector Num Sectors Type
1 32 4320 83
2 4352 4352 83
3 8704 196864 83
4 205568 44800 82
We can now load a Linux kernel image over ethernet and store it both
of the boot partitions:
=> tftp 100000 /tftpboot/uImage
ARP broadcast 1
TFTP from server 10.0.0.2; our IP address is 10.0.0.99
Filename '/tftpboot/uImage'.
Load address: 0x100000
Loading: #################################################################
##############################################
done
Bytes transferred = 566888 (8a668 hex)
=> ide write 100000 0x20 0x800
IDE write: device 0 block # 32, count 2048 ... 2048 blocks written: OK
=> ide write 100000 0x1100 0x800
IDE write: device 0 block # 4352, count 2048 ... 2048 blocks written: OK
This requires a little more explanation: as you can see from the
output of the
help ide command, the
write subcommand takes 3 arguments: a memory
address from where the data are read, an (absolute) block number on
the disk where the writing starts, and a number of disk blocks.
Since U-Boot expects all input in hex notation we have to perform
some calculation: partition 1 starts at block (or sector) number 32,
which is 0x20; partition 2 starts at block number 4352 = 0x1100.
We used a block count of 0x800 = 2048 in both cases - this means we
wrote 2048 block of 512 bytes each, or a 1024 kB - much more than the
actual size of the LInux kernel image - but the partition is big
enough and we are on the safe side, so we didn't bother to calculate
the exact block count.
To boot from a disk you can use the
diskboot command:
=> help diskboot
diskboot loadAddr dev:part
The
diskboot command (or short
disk) expects a load address in
RAM, and a combination of device and partition numbers, separated by a
colon. It then reads the image from disk and stores it in memory. We
can now boot it using the
bootm command [to automatically boot the
image define the U-Boot environment
autostart with the value =yes=].
=> disk 400000 0:1
Loading from IDE device 0, partition 1: Name: hda1
Type: PPCBoot
Image Name: Linux-2.4.4
Created: 2001-11-11 18:11:11 UTC
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 566824 Bytes = 553 kB = 0 MB
Load Address: 00000000
Entry Point: 00000000
=> bootm 400000
## Booting image at 00400000 ...
Image Name: Linux-2.4.4
Created: 2001-11-11 18:11:11 UTC
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 566824 Bytes = 553 kB = 0 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Linux version 2.4.4 (wd@denx.denx.de) (gcc version 2.95.2 19991024 (release)) #1 Sun Nov 11 19:05:47 MET 2001
On node 0 totalpages: 8192
...
We can use the same method that we used to store a Linux kernel image
to a disk partition to load a filesystem image into another partiton
- as long as the image fits into physical RAM - but usually it's
easier to initialize the filesystem either on the host system
(swapping the PC Card between host and target is easy enough), or you
can use the configuration with root filesystem over NFS to populate
the filesystem on the target.
You only have to set the
bootargs variable to boot
Linux with root filesystem on disk, for instance:
=> setenv bootargs root=/dev/hda3
=> setenv autostart yes
=> disk 400000 0:1
Loading from IDE device 0, partition 1: Name: hda1
Type: PPCBoot
Image Name: Linux-2.4.4
Created: 2001-11-11 18:11:11 UTC
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 566824 Bytes = 553 kB = 0 MB
Load Address: 00000000
Entry Point: 00000000
Automatic boot of image at addr 0x00400000 ...
## Booting image at 00400000 ...
Image Name: Linux-2.4.4
Created: 2001-11-11 18:11:11 UTC
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 566824 Bytes = 553 kB = 0 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Linux version 2.4.4 (wd@denx.denx.de) (gcc version 2.95.2 19991024 (release)) #1 Sun Nov 11 19:05:47 MET 2001
On node 0 totalpages: 8192
zone(0): 8192 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/hda3 ip=10.0.0.99:10.0.0.2::255.0.0.0:tqm::off panic=1
Decrementer Frequency: 3000000
Calibrating delay loop... 47.82 BogoMIPS
Memory: 30548k available (1088k kernel code, 488k data, 48k init, 0k highmem)
Dentry-cache hash table entries: 4096 (order: 3, 32768 bytes)
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 2048 (order: 2, 16384 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Starting kswapd v1.8
CPM UART driver version 0.03
ttyS0 on SMC1 at 0x0280, BRG1
ttyS1 on SMC2 at 0x0380, BRG2
pty: 256 Unix98 ptys configured
block: queued sectors max/low 20226kB/6742kB, 64 slots per queue
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Uniform Multi-Platform E-IDE driver Revision: 6.31
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
PCMCIA slot B: phys mem e0000000...ec000000 (size 0c000000)
Card ID: CF 128MB CH
Fixed Disk Card
IDE interface
[silicon] [unique] [single] [sleep] [standby] [idle] [low power]
hda: probing with STATUS(0x50) instead of ALTSTATUS(0x41)
hda: CF 128MB, ATA DISK drive
ide0 at 0xc7000320-0xc7000327,0xc3000106 on irq 13
hda: 250368 sectors (128 MB) w/16KiB Cache, CHS=978/8/32
Partition check:
hda: hda1 hda2 hda3 hda4
eth0: FEC ENET Version 0.2, FEC irq 3, MII irq 4, addr 00:cb:bd:00:00:11
JFFS version 1.0, (C) 1999, 2000 Axis Communications AB
Amd/Fujitsu Extended Query Table v1.1 at 0x0040
number of JEDEC chips: 1
ICU862 flash bank 0: Using static image partition definition
Creating 8 MTD partitions on "ICU862 Bank 0":
0x00000000-0x00100000 : "kernel"
0x00100000-0x00400000 : "initrd"
0x00400000-0x00800000 : "jffs"
0x00800000-0x00c00000 : "cramfs"
0x00c00000-0x00f00000 : "jffs2"
0x00f00000-0x00f40000 : "ppcboot"
0x00f40000-0x00f80000 : "environment"
0x00f80000-0x01000000 : "spare"
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 2048 bind 2048)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
hda: hda1 hda2 hda3 hda4
hda: hda1 hda2 hda3 hda4
VFS: Mounted root (ext2 filesystem) readonly.
Freeing unused kernel memory: 48k init
init started: BusyBox v0.51 (2001.11.06-02:06+0000) multi-call binary
BusyBox v0.51 (2001.11.06-02:06+0000) Built-in shell (lash)
Enter 'help' for a list of built-in commands.
#