OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / bin / mkflashcancam
1 #!/bin/bash
2 ##############################################################################
3
4 #
5 #       mkflash -- construct an entire CanCam flash image.
6 #
7 #       (C) Copyright 1999-2003, Roman Wagner (rw@feith.de)
8 #
9
10 ##############################################################################
11
12 #
13 #       The starting MAC address... 00-0C-6B-80-XX-XX
14 #       This strings is in octal below, ugh...
15 #       If setting up 2 ethernet devices then set MAC1 as well.
16 #
17 MAC0="\000\014\153\200\000\000"
18 MAC1="\000\014\153\200\000\001"
19 #
20 #       Define the files to use.
21 #
22 FLASH=images/flash.bin
23 BOOT=vendors/Feith/boot/CanCam/boot.bin
24 IMAGE=images/imagez.bin
25
26 ##############################################################################
27
28 usage()
29 {
30         echo "usage: mkflashcancam"
31         exit 1
32 }
33
34 ##############################################################################
35
36 #
37 #       Check for any args...
38 #
39 if [ $# -gt 0 ]
40 then
41         usage
42 fi
43
44 #
45 #       All boards get 2 MAC addresses at first.
46 #
47 DUALETHER=1
48
49 #
50 #       Boot loader first.
51 #
52 cat $BOOT > $FLASH
53 SIZE=`wc $FLASH | awk '{ print $3}'`
54 PAD=`expr 65536 - $SIZE`
55 echo "BOOT: flash size=$SIZE padding=$PAD"
56 dd if=/dev/zero count=1 bs=$PAD >> $FLASH 2> /dev/null
57
58 #
59 #       Command line args next.
60 #
61 echo -e "CONSOLE=/dev/ttyS0\000\c" >> $FLASH
62 SIZE=`wc $FLASH | awk '{ print $3}'`
63 PAD=`expr 131072 - $SIZE`
64 echo "ARGS: flash size=$SIZE padding=$PAD"
65 dd if=/dev/zero count=1 bs=$PAD >> $FLASH 2> /dev/null
66
67 #
68 #       MAC address next.
69 #
70 echo -e "$MAC0\c" >> $FLASH
71 [ "$DUALETHER" = 1 ] && echo -e "$MAC1\c" >> $FLASH
72 SIZE=`wc $FLASH | awk '{ print $3}'`
73 PAD=`expr 196608 - $SIZE`
74 echo "MAC:  flash size=$SIZE padding=$PAD"
75 dd if=/dev/zero count=1 bs=$PAD >> $FLASH 2> /dev/null
76
77 #
78 #       Leave space for the file system.
79 #
80 SIZE=131072
81 PAD=0
82 echo "CFS:  flash size=$SIZE padding=$PAD"
83 dd if=/dev/zero count=1 bs=$SIZE >> $FLASH 2> /dev/null
84
85 #
86 #       Linux and file-system image.
87 #
88 cat $IMAGE >> $FLASH
89 SIZE=`wc $FLASH | awk '{ print $3}'`
90 PAD=`expr 1769472 - $SIZE`
91 echo "IMG:  flash size=$SIZE padding=$PAD"
92 #dd if=/dev/zero count=1 bs=$PAD >> $FLASH 2> /dev/null
93
94 cp $FLASH /tftpboot
95 exit 0