Updated slugimage to the latest upstream version, which fixes the small kernel bug which OpenWRT exposed.

SVN-Revision: 5923
v19.07.3_mercusys_ac12_duma
Rod Whitby 18 years ago
parent e7cd65a591
commit 21262ab671

@ -410,7 +410,7 @@ sub readInFirmware {
} }
else { else {
# Slurp up the data, based on whether a header is present or not # Slurp up the data, based on whether a header and/or data is present or not
if ($_->{'header'}) { if ($_->{'header'}) {
# Read the length, and grab the data based on the length. # Read the length, and grab the data based on the length.
@ -422,6 +422,11 @@ sub readInFirmware {
$_->{'data'} = substr($firmware_buf, $_->{'offset'} + $_->{'header'}, $data_len); $_->{'data'} = substr($firmware_buf, $_->{'offset'} + $_->{'header'}, $data_len);
} }
} }
elsif ($_->{'pseudo'} and not defined $_->{'file'} and
(substr($firmware_buf, $_->{'offset'}, $_->{'size'}) eq
(pack("C", 0xff) x $_->{'size'}))) {
$debug and printf("Skipping empty pseudo partition <%s>\n", $_->{'name'});
}
else { else {
# Grab the whole partition, using the maximum size. # Grab the whole partition, using the maximum size.
@ -557,6 +562,11 @@ sub readInFirmwareParts {
sub layoutPartitions { sub layoutPartitions {
my(@partitions) = @_; my(@partitions) = @_;
# Find the kernel partition, and save a pointer to it for later use
my $kernel;
map { ($_->{'name'} eq "Kernel") && ($kernel = $_); } @partitions;
$kernel or die "Couldn't find the kernel partition\n";
# Find the last variable size partition, and save a pointer to it for later use # Find the last variable size partition, and save a pointer to it for later use
my $lastdisk; my $lastdisk;
my $directory_offset; my $directory_offset;
@ -588,66 +598,33 @@ sub layoutPartitions {
$debug and printf("Pointer is 0x%08X\n", $pointer); $debug and printf("Pointer is 0x%08X\n", $pointer);
# If this is the last variable size partition, then fill the rest of the space. # Determine the start and offset of the current partition.
if ($_->{'name'} eq $lastdisk->{'name'}) { if (defined $_->{'offset'}) {
$_->{'size'} = paddedSize($directory_offset + $flash_start - $pointer); $_->{'start'} = $flash_start + $_->{'offset'};
$debug and printf("Padding last variable partition <%s> to 0x%08X bytes\n", $_->{'name'}, $_->{'size'}); # Check for running past the defined start of the partition.
} if (($pointer > $_->{'start'}) and not $_->{'pseudo'}) {
die sprintf("Ran out of flash space before <%s> - %s too large.\n", $_->{'name'},
# Handle requests for partition creation first. sprintf("0x%05X bytes", ($pointer - $_->{'start'})));
if (defined $_->{'size'} and not defined $_->{'data'} and ($_->{'name'} ne "FIS directory")) {
# A zero size is a request to fill all available space.
if ($_->{'size'} == 0) {
# Grab the start of the FIS directory, and use all the space up to there.
$_->{'size'} = paddedSize($directory_offset + $flash_start - $pointer);
# Create an empty partition of the requested size.
$_->{'data'} = padBytes("", $_->{'size'});
$debug and printf("Creating empty partition <%s> of 0x%08X bytes\n", $_->{'name'}, $_->{'size'});
}
if (not defined $_->{'offset'}) {
# Check to make sure that the requested size is not too large.
if (($pointer + $_->{'size'}) > ($flash_start + $directory_offset)) {
die "Ran out of flash space in <", $_->{'name'}, ">\n";
}
}
else {
# Check to make sure that the requested size is not too large.
if (($_->{'offset'} + $_->{'size'}) > ($flash_start + $directory_offset)) {
die "Ran out of flash space in <", $_->{'name'}, ">\n";
}
} }
} }
# Then handle known partitions, and allocate them. # If offset is not defined, then calculate it.
if (defined $_->{'size'}) { else {
$_->{'start'} = $pointer;
# Determine the start and offset of the current partition. $_->{'offset'} = $_->{'start'} - $flash_start;
if (defined $_->{'offset'}) { }
$_->{'start'} = $flash_start + $_->{'offset'};
}
# If offset is not defined, then calculate it. my $size = defined $_->{'data'} ? length($_->{'data'}) : 0;
else {
$_->{'start'} = $pointer;
$_->{'offset'} = $_->{'start'} - $flash_start;
}
my $size = defined $_->{'data'} ? length($_->{'data'}) : 0; # Add skip regions for the partitions with headers.
if ($_->{'header'} > 0) {
# Define the skip region for the initial Sercomm header.
push(@{$_->{'skips'}},
{ 'offset' => 0, 'size' => $_->{'header'}, 'data' => undef });
# Allow for the Sercomm header to be prepended to the data.
$size += $_->{'header'};
# Add skip regions for the partitions with headers. # Determine if the partition overlaps the ramdisk boundary.
if ($_->{'header'} > 0) {
# Define the skip region for the initial Sercomm header.
push(@{$_->{'skips'}},
{ 'offset' => 0, 'size' => $_->{'header'}, 'data' => undef });
# Allow for the Sercomm header to be prepended to the data.
$size += $_->{'header'};
}
# Determine if the partition requires a Sercomm skip region.
if (($_->{'offset'} < $ramdisk_offset) and if (($_->{'offset'} < $ramdisk_offset) and
(($_->{'offset'} + $size) > $ramdisk_offset)) { (($_->{'offset'} + $size) > $ramdisk_offset)) {
# Define the skip region for the inline Sercomm header. # Define the skip region for the inline Sercomm header.
@ -657,36 +634,64 @@ sub layoutPartitions {
# Allow for the Sercomm header to be inserted in the data. # Allow for the Sercomm header to be inserted in the data.
$size += 16; $size += 16;
} }
}
# Extend to another block if required. # Partitions without headers cannot have skip regions.
if ($size > $_->{'size'}) { elsif (($_->{'offset'} <= $ramdisk_offset) and
$_->{'size'} = $size; (($_->{'offset'} + $size) > $ramdisk_offset)) {
printf("Extending partition <%s> to 0x%08X bytes\n", $_->{'name'}, $_->{'size'}); # Pad the kernel until it extends past the ramdisk offset.
} push(@{$kernel->{'skips'}},
{ 'offset' => ($ramdisk_offset - $kernel->{'offset'}), 'size' => 16,
'data' => pack("N4", $block_size) });
$kernel->{'size'} = $ramdisk_offset - $kernel->{'offset'} + $block_size;
$kernel->{'data'} = padBytes($kernel->{'data'},
$kernel->{'size'} - $kernel->{'header'} - 16);
$_->{'offset'} = $ramdisk_offset + $block_size;
$_->{'start'} = $flash_start + $_->{'offset'};
$pointer = $_->{'start'};
$debug and printf("Extending kernel partition past ramdisk offset.\n");
}
# Keep the user appraised ... # If this is the last variable size partition, then fill the rest of the space.
$debug and printf("Allocated <%s> from 0x%08X to 0x%08X (%s / %s)\n", if ($_->{'name'} eq $lastdisk->{'name'}) {
$_->{'name'}, $_->{'start'}, $_->{'start'} + $_->{'size'}, $_->{'size'} = paddedSize($directory_offset + $flash_start - $pointer);
($size >= $block_size ? $debug and printf("Padding last variable partition <%s> to 0x%08X bytes\n", $_->{'name'}, $_->{'size'});
sprintf("%d blocks", numBlocks($size)) : }
sprintf("0x%05X bytes", $size)),
($_->{'size'} >= $block_size ? die sprintf("Partition size not defined in <%s>.\n", $_->{'name'})
sprintf("%d blocks", numBlocks($_->{'size'})) : unless defined $_->{'size'};
sprintf("0x%05X bytes", $_->{'size'})));
# Check to make sure we have not run out of room. # Extend to another block if required.
if (($_->{'start'} + $_->{'size'}) > ($flash_start + $flash_len)) { if ($size > $_->{'size'}) {
die "Ran out of flash space in <", $_->{'name'}, ">\n"; if ($_->{'name'} eq $lastdisk->{'name'}) {
die sprintf("Ran out of flash space in <%s> - %s too large.\n", $_->{'name'},
sprintf("0x%05X bytes", ($size - $_->{'size'})));
} }
$_->{'size'} = $size;
printf("Extending partition <%s> to 0x%08X bytes\n", $_->{'name'}, $_->{'size'});
}
$debug and printf("Moving pointer from 0x%08X to 0x%08X (0x%08X + 0x%08X)\n", # Keep the user appraised ...
$pointer, paddedSize($_->{'start'} + $_->{'size'}), $debug and printf("Allocated <%s> from 0x%08X to 0x%08X (%s / %s)\n",
$_->{'start'}, $_->{'size'}); $_->{'name'}, $_->{'start'}, $_->{'start'} + $_->{'size'},
($size >= $block_size ?
sprintf("%d blocks", numBlocks($size)) :
sprintf("0x%05X bytes", $size)),
($_->{'size'} >= $block_size ?
sprintf("%d blocks", numBlocks($_->{'size'})) :
sprintf("0x%05X bytes", $_->{'size'})));
# Check to make sure we have not run out of room.
if (($_->{'start'} + $_->{'size'}) > ($flash_start + $flash_len)) {
die "Ran out of flash space in <", $_->{'name'}, ">\n";
}
# Move the pointer up, in preparation for the next partition. $debug and printf("Moving pointer from 0x%08X to 0x%08X (0x%08X + 0x%08X)\n",
$pointer = paddedSize($_->{'start'} + $_->{'size'}); $pointer, paddedSize($_->{'start'} + $_->{'size'}),
$_->{'start'}, $_->{'size'});
} # Move the pointer up, in preparation for the next partition.
$pointer = paddedSize($_->{'start'} + $_->{'size'});
} @partitions; } @partitions;
@ -916,7 +921,7 @@ sub defaultPartitions {
'offset'=>0x007f8000, 'size'=>0x00004000, 'offset'=>0x007f8000, 'size'=>0x00004000,
'variable'=>0, 'header'=>0, 'pseudo'=>1, 'data'=>undef, 'byteswap'=>0}, 'variable'=>0, 'header'=>0, 'pseudo'=>1, 'data'=>undef, 'byteswap'=>0},
{'name'=>'Microcode', 'file'=>'NPE-B', {'name'=>'Microcode', 'file'=>'NPE-B',
'offset'=>0x007fc000, 'size'=>0x00003ff0, 'offset'=>0x007fc000, 'size'=>0x00003000,
'variable'=>0, 'header'=>16, 'pseudo'=>1, 'data'=>undef, 'byteswap'=>0}, 'variable'=>0, 'header'=>16, 'pseudo'=>1, 'data'=>undef, 'byteswap'=>0},
{'name'=>'Trailer', 'file'=>'Trailer', {'name'=>'Trailer', 'file'=>'Trailer',
'offset'=>0x007ffff0, 'size'=>0x00000010, 'offset'=>0x007ffff0, 'size'=>0x00000010,
@ -1110,10 +1115,7 @@ if (defined $ramdisk) {
if (defined $size) { if (defined $size) {
$entry{'size'} = $size * $block_size; $entry{'size'} = $size * $block_size;
# Create an empty partition of the requested size. # Create an empty partition of the requested size.
$entry{'data'} = padBytes("", $entry{'size'}); $entry{'data'} = padBytes("", $entry{'size'} - $entry{'header'});
if ($entry{'header'}) {
$entry{'data'} = padBytes("", $entry{'size'} - $entry{'header'});
}
} }
\%entry; \%entry;

Loading…
Cancel
Save