Subversion Repositories DevTools

Rev

Rev 1107 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1107 Rev 1109
Line 49... Line 49...
49
#   Value: A hash of other entries
49
#   Value: A hash of other entries
50
#          These are
50
#          These are
51
#          Key: name        - Name of the partition
51
#          Key: name        - Name of the partition
52
#               root        - Partition mount point
52
#               root        - Partition mount point
53
#               size        - Size in Megabytes of the partition
53
#               size        - Size in Megabytes of the partition
-
 
54
#                             Set internally.
54
#                             'rest' is auto calculated
55
#                             'rest' is auto calculated, must be last
55
#               type        - Optional. If 'extended', then an extended
56
#               type        - Optional. If 'extended', then an extended
56
#                             partition will be created and all following
57
#                             partition will be created and all following
57
#                             partitions will be created in that extended
58
#                             partitions will be created in that extended
58
#                             partition
59
#                             partition
59
#               noprune     - Don't prune after partition
60
#               noprune     - Don't prune after partition
60
#                             Set internally.
61
#                             Set internally.
61
#
62
#
62
our %partitions = (
63
our %partitions = (
63
        0 => { name=>"fullfs",      root=>"/" ,         size=>20 * 1024 },     # Just for Test
64
        0 => { name=>"fullfs",  root=>"/"           },  # Just for Test
64
 
65
 
65
        1 => { name=>"rootfs",      root=>"/" ,         size=>30, },
66
        1 => { name=>"rootfs",  root=>"/"           },
66
        2 => { name=>"logfs" ,      root=>"/var/log" ,  size=>20, },
67
        2 => { name=>"logfs" ,  root=>"/var/log"    },
67
        3 => { name=>"afcfs",       root=>"/afc" ,      size=>150,  },
68
        3 => { name=>"afcfs",   root=>"/afc"        },
68
        4 => { name=>"varfs",       root=>"/var" ,      size=>"rest" },
69
        4 => { name=>"varfs",   root=>"/var"        },
69
 
70
 
70
#       4 => { type=>"extended" },
71
#       4 => { type=>"extended" },
71
    );
72
    );
72
 
73
 
73
#-------------------------------------------------------------------------------
74
#-------------------------------------------------------------------------------
Line 77... Line 78...
77
#
78
#
78
# Inputs          : $outdir             - Target directory
79
# Inputs          : $outdir             - Target directory
79
#                   $image_name         - Root name of the output image
80
#                   $image_name         - Root name of the output image
80
#                   $WORK               - Root of file system image
81
#                   $WORK               - Root of file system image
81
#                   $BUILD              - Scratch Work Area
82
#                   $BUILD              - Scratch Work Area
82
#                   $disk_blocks        - Size of target disk
83
#                   $diskGeometry       - Reference to disk Geometry hash
-
 
84
#                                         Keys are:
83
#                   $fullfs             - Size of test full fs
85
#                                           fullfs
84
#
-
 
-
 
86
#                                           size  
-
 
87
#                                           rootfs
-
 
88
#                                           logfs 
-
 
89
#                                           afcfs 
85
# Returns         : 
90
# Returns         :                         varfs 
86
#
91
#
87
sub CreateSdImage
92
sub CreateSdImage
88
{
93
{
89
    my ($outdir,$image_name,$WORK, $BUILD, $disk_blocks, $fullfs) = @_;
94
    my ($outdir,$image_name,$WORK, $BUILD, $diskGeometry ) = @_;
90
    my $install_grub = ( -f "$WORK/boot/grub/grub" );
95
    my $install_grub = ( -f "$WORK/boot/grub/grub" );
91
 
96
 
92
    #
97
    #
93
    #   Ensure that the required utility programs can be found and that they
98
    #   Ensure that the required utility programs can be found and that they
94
    #   are being consumed from packages and not from the users path
99
    #   are being consumed from packages and not from the users path
Line 97... Line 102...
97
        unless ( LocateProgInPath ('e2fsimage' ) );
102
        unless ( LocateProgInPath ('e2fsimage' ) );
98
 
103
 
99
    Error ( "Required utility program not found in package: grub" )
104
    Error ( "Required utility program not found in package: grub" )
100
        unless ( ! $install_grub || LocateProgInPath ('grub' ) );
105
        unless ( ! $install_grub || LocateProgInPath ('grub' ) );
101
 
106
 
102
    #
-
 
103
    #   Insert size of the FullFS
107
    Error ("CreateSdImage:disk-blocks must be specified")
104
    #   May be zero
108
        unless ( $diskGeometry->{'size'}  );
105
    #
-
 
106
    $partitions{0}{size} = $fullfs;
109
    my $disk_blocks = $diskGeometry->{'size'};
107
 
110
 
108
    #
111
    #
109
    #
112
    #
110
    #   Magic: The size of the SD card
113
    #   Magic: The size of the SD card
111
    #          This was determined by 'dd' ing an SD card and using the number of
114
    #          This was determined by 'dd' ing an SD card and using the number of
Line 127... Line 130...
127
    foreach my $partition ( sort keys %partitions )
130
    foreach my $partition ( sort keys %partitions )
128
    {
131
    {
129
        my $pdata = $partitions{$partition};
132
        my $pdata = $partitions{$partition};
130
        my $rest = 0;
133
        my $rest = 0;
131
 
134
 
-
 
135
        #
-
 
136
        #   Determine configured size
-
 
137
        #
-
 
138
        if ( $pdata->{name}  )
-
 
139
        {
-
 
140
            Error ("CreateSdImage: Partition size not specified: $pdata->{name} ")
-
 
141
                unless ( exists($diskGeometry->{$pdata->{name}}) );
-
 
142
            $pdata->{size} =  $diskGeometry->{$pdata->{name}} || 0;
-
 
143
        }
-
 
144
 
132
        unless ($partition )
145
        unless ($partition )
133
        {
146
        {
134
            $pdata->{size} *= 2;
147
            $pdata->{size} *= 2;
135
            next;
148
            next;
136
        }
149
        }
137
 
150
 
-
 
151
        #
-
 
152
        #   Validate the current start
-
 
153
        #
-
 
154
        if ( $pstart >= $disk_sectors )
-
 
155
        {
-
 
156
            my @data;
-
 
157
            foreach my $partition ( sort keys %partitions )
-
 
158
            {
-
 
159
                next unless ( $partition );
-
 
160
                my $pdata = $partitions{$partition};
-
 
161
                my $name = $pdata->{name};
-
 
162
                next unless ( $name );
-
 
163
 
-
 
164
                push @data, sprintf( "Partition-%d (%10s): Sector Size=~%5dM\n",
-
 
165
                            $partition,
-
 
166
                            $name,
-
 
167
                            ($diskGeometry->{$pdata->{name}} || 'Remainder') );
-
 
168
            }
-
 
169
            
-
 
170
            Error ("Invalid Disk Configuration. Partition Sizes exceed Disk size",
-
 
171
                   "Disk Size : $disk_blocks (~" . $disk_blocks / 1024 . ")M",
-
 
172
                    @data);
-
 
173
        }
-
 
174
 
138
        if (  exists $pdata->{type} && $pdata->{type} eq 'extended' )
175
        if (  exists $pdata->{type} && $pdata->{type} eq 'extended' )
139
        {
176
        {
140
            $pdata->{start} = $pstart;
177
            $pdata->{start} = $pstart;
141
            $pdata->{end} =   $disk_sectors;
178
            $pdata->{end} =   $disk_sectors;
142
            $pdata->{size} = ($disk_sectors - $pstart);
179
            $pdata->{size} = ($disk_sectors - $pstart);