I've actually used menuconfig to build a generic kirkwood image (both attitude_adjustment and backfire) but neither seems to load. I could totally be giving it wrong boot commands.
At the U-Boot prompt I have been able to edit the nfsboot env variables and it does load whatever files I provide (via tftp) into memory. When I try to boot from the uImage file, I get to "...booting the kernel." and no further.
I'm looking at the /usr/bin/update file now to see how Linksys flashes new images:
# cat /usr/bin/update
#!/bin/sh
VERBOSE="no"
PRIMARY="no"
PRIROOTFSMTD=
AlTROOTFSMTD=
MOUNTEDMTD=
check_error() {
if [ $? -ne 0 ]; then
echo -e "Failed, exiting..."
exit 1
else
echo -e "OK!"
fi
}
# return 0 if booted via nfs
# else return 1
check_mountnfs() {
if `cat /proc/mounts | grep "\/dev\/root" | grep "nfs" 2>&1 > /dev/null`
then
return 0
fi
return 1
}
# return 0 if booted via nfs
# else return 1
check_mountjffs2() {
if `cat /proc/mounts | grep "\/dev\/root" | grep "jffs2" 2>&1 > /dev/null`
then
return 0
fi
return 1
}
# return 0 if booted via primary NAND partition
# return 1 if booted via alternate NAND partition
check_mount() {
# get primary and alternate
PRIROOTFSMTD=`cat /proc/mtd | grep "rootfs" | grep -v "alt_" | cut -d':' -f1 | cut -f2 -d"d"`
ALTROOTFSMTD=`cat /proc/mtd | grep "alt_rootfs" | cut -d':' -f1 | cut -f2 -d"d"`
# get the MTD of the current mounted rootfs
MOUNTEDMTD=`cat /proc/self/mountinfo | grep "\/dev\/root" | cut -f3 -d' ' | cut -f2 -d':'`
if [ "$MOUNTEDMTD" -eq "$PRIROOTFSMTD" ]
then
return 0
fi
if [ "$MOUNTEDMTD" -eq "$ALTROOTFSMTD" ]
then
return 1
fi
return 255
}
erase_and_program() {
if [ -c /dev/$2 ] && [ ! -z $3 ] && [ -e $3 ]; then
FLASH_TYPE=`mtd_debug info /dev/$2 | grep "mtd.type" | cut -d' ' -f3`
echo -e "updating $1"
if [ ${FLASH_TYPE} = "MTD_NORFLASH" ]; then
#echo -ne "\tErasing...\t"
#flash_eraseall -q /dev/$2
#check_error
echo -ne "\tProgramming NOR flash (takes a long, long while, please wait)...\t"
if [ "$VERBOSE" = "yes" ]; then
flashcp -v $3 /dev/$2
else
flashcp $3 /dev/$2
fi
check_error
fi
if [ ${FLASH_TYPE} = "MTD_NANDFLASH" ]; then
echo -ne "\tErasing...\t"
if [ "$VERBOSE" = "yes" ]; then
flash_eraseall -j /dev/$2
else
flash_eraseall -q -j /dev/$2
fi
check_error
echo -ne "\tProgramming...\t"
if [ "$VERBOSE" = "yes" ]; then
nandwrite -m -a -p /dev/$2 $3
else
nandwrite -q -m -a -p /dev/$2 $3
fi
check_error
fi
fi
}
print_under_construction()
{
echo -e "\t$1 update not supported at this time."
exit 1
}
usage()
{
cat << EOF
| |
.|||. .|||.
..:|||||||:...:|||||||:..
C i s c o S y s t e m s
usage: $0 options
OPTIONS:
-f rootfs (optional) Specify path to rootfs image (usually: jffs2.rootfs.img)
-u u-boot (optional) Specify path to u-boot image (usually: u-boot.img)
-k kernel (optional) Specify path to kernel image (usually: uImage.img)
-h --help Print this help message
EOF
}
if [ -z "$1" ]; then
usage
exit 1
fi
while getopts ":h:pf:k:u::v" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
c)
CONFIG_IMAGE=$OPTARG
;;
f)
FIRMWARE_IMAGE=$OPTARG
;;
r)
RESCUE_IMAGE=$OPTARG
;;
u)
print_under_construction "u-boot image"
UBOOT_IMAGE=$OPTARG
;;
k)
KERNEL_IMAGE=$OPTARG
;;
d)
DTB_IMAGE=$OPTARG
;;
p)
PRIMARY="yes"
;;
v)
VERBOSE="yes"
;;
?)
usage
exit 1
esac
done
if [ -e /proc/mtd ]; then
CONFIG_BLKDEV=`cat /proc/mtd | grep "config img" | cut -d':' -f1`
DTB_BLKDEV=`cat /proc/mtd | grep "device tree img" | cut -d':' -f1`
# check if trying to update the partition you are currently mounted on
check_mountjffs2
RET=$?
# if mounted JFFS2 mtd, then check if trying to update a mounted mtd
if [ $RET -eq 0 ]; then
check_mount
RET=$?
# if booted on primary mtd && trying to update primary mtd
if [ $RET -eq 0 ] && [ "$PRIMARY" = "yes" ]; then
echo -e "Failed. Cannot update a currently mounted root file system..."
exit 1
fi
# if booted on alternate mtd && trying to update alternate mtd
if [ $RET -eq 1 ] && [ "$PRIMARY" = "no" ]; then
echo -e "Failed. Cannot update a currently mounted root file system..."
exit 1
fi
fi
if [ "$PRIMARY" = "yes" ]; then
FIRMWARE_BLKDEV=`cat /proc/mtd | grep "rootfs" | grep -v "alt_" | cut -d':' -f1`
KERNEL_BLKDEV=`cat /proc/mtd | grep "kernel" | grep -v "alt_" | cut -d':' -f1`
else
FIRMWARE_BLKDEV=`cat /proc/mtd | grep "alt_rootfs" | cut -d':' -f1`
KERNEL_BLKDEV=`cat /proc/mtd | grep "alt_kernel" | cut -d':' -f1`
fi
RESCUE_BLKDEV=`cat /proc/mtd | grep "rescue img" | cut -d':' -f1`
UBOOT_BLKDEV=`cat /proc/mtd | grep "u-boot img" | cut -d':' -f1`
fi
erase_and_program "u-boot image" ${UBOOT_BLKDEV} ${UBOOT_IMAGE}
if [ "$PRIMARY" = "yes" ]; then
erase_and_program "primary firmware image" ${FIRMWARE_BLKDEV} ${FIRMWARE_IMAGE}
erase_and_program "primary kernel image" ${KERNEL_BLKDEV} ${KERNEL_IMAGE}
else
erase_and_program "alternate firmware image" ${FIRMWARE_BLKDEV} ${FIRMWARE_IMAGE}
erase_and_program "alternate kernel image" ${KERNEL_BLKDEV} ${KERNEL_IMAGE}
fi