summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/build/buildpnor/buildBpmFlashImages.pl16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/build/buildpnor/buildBpmFlashImages.pl b/src/build/buildpnor/buildBpmFlashImages.pl
index ba65dab0a..a2ad7c438 100755
--- a/src/build/buildpnor/buildBpmFlashImages.pl
+++ b/src/build/buildpnor/buildBpmFlashImages.pl
@@ -146,14 +146,17 @@ sub generateFirmwareImage
# the payload is 16 bytes
use constant MAXIMUM_DATA_BYTES_FOR_PAYLOAD => 16;
- # images use carriage return which by default chomp doesn't remove so update
- # local $/ to remove that character.
- local $/ = "\r\n";
+ # Ensure that the diamond operator ( <> ) is searching for \n to determine
+ # where the end of a line is in the image file.
+ local $/ = "\n";
my $blocks = undef;
while (my $line = <$inputFileHandle>)
{
- chomp($line);
+ # Strip off the end-of-line character \n and optionally \r if it exists.
+ # Since the image files were created on a windows OS and this script
+ # runs on linux this will not be handled properly by chomp.
+ $line =~ s/\r?\n$//;
# The end of the firmware data section is marked by a 'q'
if (substr($line, 0, 1) eq "q")
@@ -239,6 +242,11 @@ sub generateFirmwareImage
print "number of blocks: $numberOfBlocks\n";
}
+ if (!defined($blocks))
+ {
+ die "Unable to process image file: $i_fileName";
+ }
+
# Write the version information to the file.
print $outputFileHandle pack("(H2)*", @version)
or die "Failed to write to output file: $imageFile";
OpenPOWER on IntegriCloud