Booting from CF is supported by DMM, no extra software needed. What you need:
1) A CF that has at least two partitions, one for boot and one for root
2) The boot partition must be the first partition on the CF, and must be formatted as a FAT partition.
3) The root partition can not be FAT, but could be e.g. ext3
4) A file on the the boot partition called "autorun.bat" that loads the boot screen image and the kernel. Kernel options are allowed, and must be used to change the root partition from flash (a default that is compiled into the kernel) to the root partition on CF.
5) Obviously all the needed boot files on the boot partition, and all the rest of the files in the image on the root partition.
Here's a small script (to be run on the 7025) to partition and format the CF. Change to fit your own needs.
#! /usr/bin/python
import os, sys, getopt
#################################################################
# This is GPL software.
# Written by noggie
#################################################################
# The script will prepare a CF for booting an image.
# - Partition with FAT + EXT3 (+ optionally swap)
# - Format partitions
# Partition sizes. The remainder goes to the ext3 partition.
# Swap is only made if the "-s" option is provided.
SIZE_FAT = 30 # MB
SIZE_SWAP = 96 # MB
# Some paths
CF_PREFIX = '/dev/ide/host1/bus0/target0/lun0/'
CF_DISK = CF_PREFIX + 'disc'
CF_FAT = CF_PREFIX + 'part1'
CF_EXT3 = CF_PREFIX + 'part2'
CF_SWAP = CF_PREFIX + 'part3'
PROC_PREFIX = '/proc/ide/hdc/'
# Optional arguments
opts, pargs = getopt.getopt(sys.argv[1:], 'svb', ['swap', 'verbose', 'batch'])
opts = dict(opts)
make_swap = (opts.has_key('-s') or opts.has_key('--swap'))
verbose = (opts.has_key('-v') or opts.has_key('--verbose'))
# Warn the poor user
if not opts.has_key('-b'):
sys.stdout.write('THIS WILL DELETE ANY PREVIOUS CONTENTS ON THE CF!!\n')
print 'Do you want to continue? '
if sys.stdin.readline().lower()[0] != 'y':
os.exit(1)
def vprint(fmt, *args):
if verbose:
sys.stderr.write(fmt % args)
# Get CF geometry
fd = open(PROC_PREFIX + 'geometry', 'r')
for line in fd:
if line.startswith('logical'):
cylinders, heads, sectors = line.replace('logical', '').strip().split('/')
fd.close()
# Convert strings to ints.
cylinders = int(cylinders)
heads = int(heads)
sectors = int(sectors)
cf_size = cylinders * heads * sectors
vprint('Geometry : %d/%d/%d (=%d MB)\n', cylinders, heads, sectors, cf_size/2048)
# Make sure CF is not in use
fd = open('/proc/mounts', 'r')
for line in fd:
if line.startswith(CF_PREFIX):
dir = line.split()[1]
vprint('Umounting %s\n', dir)
os.system('/bin/umount ' + dir)
fd.close()
fd = open('/proc/swaps', 'r')
for line in fd:
if line.startswith(CF_PREFIX):
dev = line.split()[0]
vprint('Removing swap %s\n', dev)
os.system('/sbin/swapoff ' + dev)
# Clear existing partition table
vprint('Clearing existing partition table\n');
fd = os.popen('2>/dev/null 1>&2 /sbin/sfdisk -q ' + CF_DISK, 'w')
fd.write('0,0\n')
fd.close()
# Compute new partitions
sectors_pr_mb = 1024 * 1024 / 512
sectors_pr_cyl = sectors * heads
fat_cyls = (SIZE_FAT * sectors_pr_mb) / sectors_pr_cyl + 1
if make_swap:
swap_cyls = (SIZE_SWAP * sectors_pr_mb) / sectors_pr_cyl + 1
else:
swap_cyls = 0
ext3_cyls = cylinders - 1 - fat_cyls - swap_cyls
vprint('Calculated partition sizes\n');
vprint('\tPartition table : 1 (=%d KB)\n', sectors_pr_cyl / 2)
vprint('\tFAT : %d (=%.2f KB)\n', fat_cyls, fat_cyls * sectors_pr_cyl / 2.0)
vprint('\tEXT3 : %d (=%.2f KB)\n', ext3_cyls, ext3_cyls * sectors_pr_cyl / 2.0)
vprint('\tswap : %d (=%.2f KB)\n', swap_cyls, swap_cyls * sectors_pr_cyl / 2.0)
# Create new partition table
vprint('Creating new partition table\n')
fd = os.popen('2>/dev/null 1>&2 /sbin/sfdisk -q ' + CF_DISK, 'w')
fd.write(',%d,6\n' % fat_cyls)
if make_swap:
fd.write(',%d,\n' % ext3_cyls)
fd.write(',,S\n')
else:
fd.write(',,\n')
fd.close()
if verbose:
os.system('/sbin/sfdisk -l ' + CF_DISK)
# Format partitions
vprint('Formatting partitions\n')
os.system('/usr/sbin/mkdosfs ' + CF_FAT)
os.system('/sbin/mkfs.ext3 ' + CF_EXT3)
if make_swap:
os.system('/sbin/mkswap ' + CF_SWAP)
# Make sure we have mount-points
for dir in ['/media/cf', '/media/cf2']:
try:
os.mkdir(dir)
except OSError:
pass
# Add entries to /etc/fstab, if necessary
fd = open('/etc/fstab', 'r')
fstab = fd.readlines()
fd.close()
changed = 0
if len(filter(lambda x: x.startswith(CF_FAT), fstab)) == 0:
fstab.append(CF_FAT + ' /media/cf auto defaults 0 0\n')
changed = 1
if len(filter(lambda x: x.startswith(CF_EXT3), fstab)) == 0:
fstab.append(CF_EXT3 + ' /media/cf2 auto defaults 0 0\n')
changed = 1
if make_swap and (len(filter(lambda x: x.startswith(CF_SWAP), fstab)) == 0):
fstab.append(CF_SWAP + ' swap swap defaults 0 0\n')
changed = 1
if changed:
fd = open('/etc/fstab', 'w')
fd.writelines(fstab)
fd.close()
# Finally, mount the partitions
os.system('/bin/mount /media/cf')
os.system('/bin/mount /media/cf2')
if make_swap:
os.system('/sbin/swapon ' + CF_SWAP)
Alles anzeigen
(Please excuse my python code, I'm still learning...)
The script assumes that you have the dosfstools package installed, it contains the "mkdosfs" program. You will also need a directory for the root partition on CF. The script assumes that this directory is /media/cf2
A simple way to make an image on CF is to mount the CF on your Linux PC and copy the files from your OE build environment. You could also make a copy of the existing files on flash, so that the CF contains a backup. The following script could perhaps be a starting point:
#! /bin/sh
cp /boot/* /media/cf
cd /media/cf2
cp -a /bin /etc /hdd /home /lib /sbin /share /tmp /usr .
mkdir boot dev media proc sys var
cd media
mkdir card cf cf2 cifs dvd hdd mmc1 net nfs ram realroot union usb
(
echo /cf/bootlogo.elf
echo /cf/vmlinux.gz root=/dev/hdc2 console=ttyS0,115200
) > /media/cf/autorun.bat
sed -e '/boot/s/^/#/' -e '/media\/cf/s/^/#/' /etc/fstab > /media/cf2/etc/fstab
echo "/dev/ide/host1/bus0/target0/lun0/part1 /boot auto defaults 0 0" >> /media/cf2/etc/fstab
Alles anzeigen
You could also unpack nfi files on your Linux PC if you have the required mtd and jffs2 modules for your kernel. Doing the same thing on the 7025 is possible, but it requires some extensive kernel patching, and you probably don't want to do that. I've got my own scripts to unpack nfi-files on my PC, but they are quite dependant on my own Linux setup and probably won't run on any other machine without some modifications. I don't have a problem posting them, but I kinda doubt that anybody would find them very interesting. Let me know if I'm wrong.