OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / bin / mkintelflash
1 ##############################################################################
2
3 #
4 #       mkintelflash -- construct an entire NETtel/x86 intel flash image.
5 #
6 #       (C) Copyright 2001-2002, Greg Ungerer (gerg@snapgear.com)
7 #
8
9 ##############################################################################
10
11 #
12 #       Define the files to use.
13 #
14 FLASH=images/flash.bin
15 KERNEL=images/bzImage
16 ROMFS=images/romfs.img
17 JFFS=images/jffs.img
18 JFFS2=images/jffs2.img
19 BIOS=boot/x86/bios128k.bin
20
21 FLASHSIZE=8388608
22 #FLASHSIZE=16777216
23
24 ##############################################################################
25
26 usage()
27 {
28         echo "usage: mkintelflash"
29         exit 1
30 }
31
32 ##############################################################################
33
34 #
35 #       Check for any args...
36 #
37 if [ $# -gt 0 ]
38 then
39         usage
40 fi
41
42 #
43 #       Figure out what filesystem type to use...
44 #
45 if [ -f "$JFFS2" ]
46 then
47         FSTYPE="JFFS2:"
48         FS=$JFFS2
49 elif [ -f "$JFFS" ]
50 then
51         FSTYPE="JFFS: "
52         FS=$JFFS
53 elif [ -f "$ROMFS" ]
54 then
55         FSTYPE="ROMFS:"
56         FS=$ROMFS
57 else
58         echo "ERROR: no filesystem image found??"
59         exit 1
60 fi
61
62 #
63 #       Kernel first (896k in size)
64 #
65 cat $KERNEL > $FLASH
66 SIZE=`wc $FLASH | awk '{ print $3}'`
67 PAD=`expr 1048576 - $SIZE`
68 echo "KERNEL: flash size=$SIZE padding=$PAD"
69 dd if=/dev/zero count=1 bs=$PAD >> $FLASH 2> /dev/null
70
71 #
72 #       Filesystem image.
73 #
74 cat $FS >> $FLASH
75 SIZE=`wc $FLASH | awk '{ print $3}'`
76 PAD=`expr $FLASHSIZE - 131072 - $SIZE`
77 echo "$FSTYPE  flash size=$SIZE padding=$PAD"
78 dd if=/dev/zero count=1 bs=$PAD 2> /dev/null | tr \\000 \\377 >> $FLASH
79
80 #
81 #       BIOS (128k in size)
82 #
83 cat $BIOS >> $FLASH
84 SIZE=`wc $FLASH | awk '{ print $3}'`
85 echo "BIOS:   flash size=$SIZE"
86
87 exit 0