#!/bin/sh

BROOT=/boot
BROOT=/tmp/PL/boot
KERNIMAGE=$BROOT/uImage-kirkwood
INITRD=$BROOT/uinitrd-kirkwood

# Write Kernel to flash:
mtddevice=$( grep -- "uImage" /proc/mtd | awk -F: '{print $1}' )
flash_eraseall -j /dev/$mtddevice
nandwrite -pm /dev/$mtddevice $KERNIMAGE

# Write uInitrd-formatted initrd to flash:
mtddevice=$( grep -- "root" /proc/mtd | awk -F: '{print $1}' )
flash_eraseall -j /dev/$mtddevice
nandwrite -pm /dev/$mtddevice $INITRD

# Check the number of blocks that are used by data.
# This is needed by the boot args:

# You can then mount the jffs2 filesystem as a block device and check it:
#mkdir /mnt/jffs2check
#mount /dev/$( echo $mtddevice | sed 's?mtd?mtdblock?g' ) /mnt/jffs2check
