############################################################################## # # mkflash -- construct an entire NETtel flash image. # # (C) Copyright 1999-2000, Greg Ungerer (gerg@moreton.com.au) # ############################################################################## # # The starting MAC address... 00-D0-CF-XX-XX-XX # This strings is in octal below, ugh... # If setting up 2 ethernet devices then set MAC1 as well. # MAC0="\000\320\317\000\001\040" MAC1="\000\320\317\000\001\041" # # Define the files to use. # FLASH=images/flash.bin BOOT=boot/boot.bin IMAGE=images/imagez.bin ############################################################################## usage() { echo "usage: mkflash" exit 1 } ############################################################################## # # Check for any args... # if [ $# -gt 0 ] then usage fi # # Check where to see if we're in a cygwin /w32 environment # if so, use the 'zeros' program, instead of /dev/zero # if [ `set | grep -i mach|grep -i -c cygwin` -ge 1 ] then CYGWIN=1 else CYGWIN=0 fi # # All boards get 2 MAC addresses at first. # DUALETHER=1 # # Boot loader first. # cat $BOOT > $FLASH SIZE=`wc $FLASH | awk '{ print $3}'` PAD=`expr 16384 - $SIZE` echo "BOOT: flash size=$SIZE padding=$PAD" if [ $CYGWIN -eq 1 ] then zeros $PAD >> $FLASH else dd if=/dev/zero count=1 bs=$PAD >> $FLASH 2> /dev/null fi # # Command line args next. # echo -e "CONSOLE=/dev/null\000\c" >> $FLASH SIZE=`wc $FLASH | awk '{ print $3}'` PAD=`expr 24576 - $SIZE` echo "ARGS: flash size=$SIZE padding=$PAD" if [ $CYGWIN -eq 1 ] then zeros $PAD >> $FLASH else dd if=/dev/zero count=1 bs=$PAD >> $FLASH 2> /dev/null fi # # MAC address next. # echo -e "$MAC0\c" >> $FLASH [ "$DUALETHER" = 1 ] && echo -e "$MAC1\c" >> $FLASH SIZE=`wc $FLASH | awk '{ print $3}'` PAD=`expr 65536 - $SIZE` echo "MAC: flash size=$SIZE padding=$PAD" if [ $CYGWIN -eq 1 ] then zeros $PAD >> $FLASH else dd if=/dev/zero count=1 bs=$PAD >> $FLASH 2> /dev/null fi # # Leave space for the file system. # SIZE=65536 PAD=0 echo "CFS: flash size=$SIZE padding=$PAD" if [ $CYGWIN -eq 1 ] then zeros $SIZE >> $FLASH else dd if=/dev/zero count=1 bs=$SIZE >> $FLASH 2> /dev/null fi # # Linux and file-system image. # cat $IMAGE >> $FLASH SIZE=`wc $FLASH | awk '{ print $3}'` PAD=`expr 2097152 - $SIZE` #####PAD=`expr 1048576 - $SIZE` echo "IMG: flash size=$SIZE padding=$PAD" if [ $CYGWIN -eq 1 ] then zeros $PAD >> $FLASH else dd if=/dev/zero count=1 bs=$PAD >> $FLASH 2> /dev/null fi cp $FLASH /tftpboot exit 0