> In short, I'm porting linux to a custom PPC board. Well, we've got the
> platform
> specific code written, and are to the point of mounting the root fs.
>
> We have a root image, but for some reason seem to be unable to determine what
> boot parameters to load into the kernel to get it to work. In short I was
> wondering how to get the kernel to recognize a ramdisk at a specific location
> and to mount this as the root device.
>
> Do I need to use initrd?
> How do I specify through the command line to use the disk and the like.
>
> I have tried various messages to kernel, but all result in a panic saying
> it can
> not mount root device 00:00
>
> This is for 2.3.30 btw.
>
> Also, a bug we found earlier today has use confused. We are using cross
> compilers from ix86 to PPC and the latest binutils, but the linker was
> overlapping static and globals located in the .sbss regions. We hacked the
> linker to eliminate this problem, but it still concered me that this would
> happen.
>
You need initrd compiled into the kernel.
This is the script I use to generate a bootable floppy with the
ramdisk as root.
#!/bin/sh
#
# This creates a RAM Disk image and installs it, along with the kernel
# onto a floppy disk. This floppy disk image can boot a system or be
# copied into a NVRAM Disk image for diskless booting.
#
# Created 12-SEP-1999 Richard B. Johnson
#
export VER=$1
RAMDISK_IMAGE=/tmp/RamImage-${VER}
RAMDISK=/tmp/Ramdisk
TMPC=/tmp/Temp.c
TMPF=/tmp/TmpExe
DISKSIZE=2048
SYS=/usr/src/linux-${VER}/arch/i386/boot/bzImage
if [ "$1" = "" ] ;
then
echo "Usage:"
echo "make_ramdisk <version>"
exit 1
fi
if [ ! -f ${SYS} ] ;
then
echo "File not found, ${SYS}"
exit 1
fi
if ! dd if=/dev/fd0 of=/dev/null bs=1k count=1 2>/dev/null ;
then
echo "Floppy drive error!"
echo "Maybe no diskette in the drive?"
exit 1
fi
#
# Make a little program called sleep.
#
echo "int main(int count, char *argv[]){">${TMPC}
echo "if(count < 2) return 0;">>${TMPC}
echo "return sleep(atoi(argv[1]));}">>${TMPC}
gcc -O2 -o sleep ${TMPC}
strip sleep
#
# Make a little program called modprobe. This just returns 0.
#
echo "int main(){">${TMPC}
echo "return 0;}">>${TMPC}
gcc -O2 -o modprobe ${TMPC}
strip modprobe
rm ${TMPC}
#
# Make a RAM Disk file and mount it using the loop device.
# Remove the lost+found directory to save space.
#
umount ${RAMDISK} 2>/dev/null
mkdir ${RAMDISK} 2>/dev/null
dd if=/dev/zero of=${RAMDISK_IMAGE} bs=1k count=${DISKSIZE}
mke2fs -Fq ${RAMDISK_IMAGE} ${DISKSIZE}
mount -o loop ${RAMDISK_IMAGE} ${RAMDISK}
rmdir ${RAMDISK}/lost+found
#
# Make the required directories in the RAM Disk.
#
mkdir -m 777 ${RAMDISK}/dev
mkdir -m 777 ${RAMDISK}/etc
mkdir -m 777 ${RAMDISK}/lib
mkdir -m 777 ${RAMDISK}/usr
mkdir -m 777 ${RAMDISK}/usr/local
mkdir -m 777 ${RAMDISK}/bin
mkdir -m 777 ${RAMDISK}/sbin
mkdir -m 777 ${RAMDISK}/tmp
mkdir -m 777 ${RAMDISK}/proc
#
# Make the required devices.
#
mknod ${RAMDISK}/dev/null c 1 3
mknod ${RAMDISK}/dev/ram0 b 1 0
mknod ${RAMDISK}/dev/ram1 b 1 1
mknod ${RAMDISK}/dev/mem c 1 1
mknod ${RAMDISK}/dev/ttyS0 c 4 64
mknod ${RAMDISK}/dev/tty0 c 4 0
mknod ${RAMDISK}/dev/tty1 c 4 1
mknod ${RAMDISK}/dev/tty2 c 4 2
mknod ${RAMDISK}/dev/tty3 c 4 3
mknod ${RAMDISK}/dev/tty4 c 4 4
mknod ${RAMDISK}/dev/tty c 5 0
mknod ${RAMDISK}/dev/ttyp0 c 3 0
mknod ${RAMDISK}/dev/ttyp1 c 3 1
mknod ${RAMDISK}/dev/ttyp2 c 3 2
mknod ${RAMDISK}/dev/ttyp3 c 3 3
mknod ${RAMDISK}/dev/ttyp4 c 3 4
mknod ${RAMDISK}/dev/ttyp5 c 3 5
mknod ${RAMDISK}/dev/ptyp0 c 2 0
mknod ${RAMDISK}/dev/ptyp1 c 2 1
mknod ${RAMDISK}/dev/ptyp2 c 2 2
mknod ${RAMDISK}/dev/ptyp3 c 2 3
mknod ${RAMDISK}/dev/ptyp4 c 2 4
mknod ${RAMDISK}/dev/ptyp5 c 2 5
mknod ${RAMDISK}/dev/zero c 1 5
mknod ${RAMDISK}/dev/GPIB c 125 0
mknod ${RAMDISK}/dev/NVRAM c 126 0
mknod ${RAMDISK}/dev/platinum c 127 0
#
# Set some compatibility links.
#
ln -s /dev/tty0 ${RAMDISK}/dev/systty
ln -s /dev/tty0 ${RAMDISK}/dev/console
ln -s /dev/ram1 ${RAMDISK}/dev/ram
ln -s /lib ${RAMDISK}/usr/lib
ln -s /lib ${RAMDISK}/usr/local/lib
ln -s /lib/ld-linux.so.2 ${RAMDISK}/lib/ld.so
#
# Copy some network-card drivers. You may need more. If so,
# modify ../server/sinit.c to try the additional ones you add.
#
cp /lib/modules/${VER}/net/eepro100.o ${RAMDISK}/lib/eepro100.o
cp /lib/modules/${VER}/net/3c509.o ${RAMDISK}/lib/3c509.o
cp /lib/modules/${VER}/net/3c59x.o ${RAMDISK}/lib/3c59x.o
#
# Copy the files and libraries. All of the files are stripped
# to save space.
#
cp sleep ${RAMDISK}/bin/sleep
cp modprobe ${RAMDISK}/sbin/modprobe
cp ${TOPDIR}/lib/libplatinum.so ${RAMDISK}/lib/libplatinum.so
cp ${TOPDIR}/modules/gpib_drvr.o ${RAMDISK}/lib/gpib_drvr.o
cp ${TOPDIR}/modules/ramdisk.o ${RAMDISK}/lib/ramdisk.o
cp ${TOPDIR}/gpib/gpib ${RAMDISK}/sbin/gpib
cp ${TOPDIR}/server/sinit ${RAMDISK}/sbin/init
cp ${TOPDIR}/server/server ${RAMDISK}/sbin/server
cp ${TOPDIR}/monitor/monitor ${RAMDISK}/sbin/monitor
cp ${TOPDIR}/rs232c/rs232c ${RAMDISK}/sbin/rs232c
cp ${TOPDIR}/control/control ${RAMDISK}/sbin/control
cp ${TOPDIR}/status/status ${RAMDISK}/sbin/status
cp ${TOPDIR}/status/show ${RAMDISK}/sbin/show
cp ${TOPDIR}/status/showcon ${RAMDISK}/sbin/showcon
#
cp ${TOPDIR}/fft/tfftdp ${TMPF}
strip ${TMPF}
cp ${TMPF} ${RAMDISK}/bin/tfftdp
#
cp /sbin/insmod ${TMPF}
strip ${TMPF}
cp ${TMPF} ${RAMDISK}/sbin/insmod
#
cp /sbin/rmmod ${TMPF}
strip ${TMPF}
cp ${TMPF} ${RAMDISK}/sbin/rmmod
#
cp /sbin/ifconfig ${TMPF}
strip ${TMPF}
cp ${TMPF} ${RAMDISK}/sbin/ifconfig
#
cp /sbin/route ${TMPF}
strip ${TMPF}
cp ${TMPF} ${RAMDISK}/sbin/route
#
cp /lib/libc.so.6 ${TMPF}
strip ${TMPF}
cp ${TMPF} ${RAMDISK}/lib/libc.so.6
#
cp /lib/libm.so.6 ${TMPF}
strip ${TMPF}
cp ${TMPF} ${RAMDISK}/lib/libm.so.6
#
cp /lib/ld-linux.so.2 ${TMPF}
strip ${TMPF}
cp ${TMPF} ${RAMDISK}/lib/ld-linux.so.2
rm ${TMPF}
#
cp /usr/local/lib/libc.so ${RAMDISK}/lib/libc.so
#
# Unmount the RAM Disk. Remove its mount-point but save the file itself.
#
sync
df ${RAMDISK}
umount ${RAMDISK}
rmdir ${RAMDISK}
#
# Make an ext2 file-system on a floppy and mount it. Remove the
# lost+found directory to save space.
#
umount /mnt 2>/dev/null
mke2fs -q /dev/fd0
mount /dev/fd0 /mnt
rmdir /mnt/lost+found
#
# Compress the RAM Disk image into a file on the mounted file-system.
# Remove the original RAM Disk image, then copy the required boot
# files to the mounted file-system also.
#
gzip < ${RAMDISK_IMAGE} >/mnt/initrd-${VER}
rm ${RAMDISK_IMAGE}
cp ${SYS} /mnt/vmlinuz-${VER}
cp /boot/boot.b /mnt/boot.b
cp message /mnt/message
#
# Now execute lilo to install the boot-loader onto the mounted file-
# system. Lilo allows its configuration to be taken from standard input
# which is undocumented.
#
lilo -C - <<EOF
#
# Lilo boot-configuration script.
#
boot = /dev/fd0
message = /mnt/message
map = /mnt/map
backup = /dev/null
compact
vga = normal # force sane state
install = /mnt/boot.b
image = /mnt/vmlinuz-${VER}
initrd = /mnt/initrd-${VER}
root = /dev/ram0
label = Platinum
EOF
#
# Show the results and unmount the file-system.
#
df /dev/fd0
umount /dev/fd0
#
#
After I make the bootable floppy and test it. I then raw-copy
the disk to NVRAM after the boot image. I made a NVRAM device
driver for Linux. It is accessed through device NVRAM. This
is the script for that. File ramdisk.bin is a 'DOS built' PROM
image to take over "drive A:" and boot. Of course you are not
using an Intel machine, but the idea's the same.
#!/bin/sh
#
if ! lsmod | egrep ramdisk >/dev/null ;
then insmod ./ramdisk.o
fi
if ! dd if=/dev/fd0 of=/dev/null bs=1k count=1 2>/dev/null ;
then
echo "Floppy drive error!"
echo "Maybe no diskette in the drive?"
exit 1
fi
if [ ! -e NVRAM ] ;
then
mknod NVRAM c 126 0
fi
cp /dos/drive_C/ramdisk/ramdisk.bin .
cat ramdisk.bin /dev/fd0 >NVRAM
rmmod ramdisk
Cheers,
Dick Johnson
Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/