summaryrefslogtreecommitdiffstats
path: root/src/build
diff options
context:
space:
mode:
authorMatthew Raybuck <matthew.raybuck@ibm.com>2019-08-08 08:19:15 -0500
committerDaniel M Crowell <dcrowell@us.ibm.com>2019-08-09 09:54:54 -0500
commit0f0b7c641abb16561970c51371ecbfb9f254481b (patch)
treef975c47d319091da588b01d71c5cc38e8baa7cca /src/build
parenteb3d4239bbecc49ac6f6d3a78ef196136caea07c (diff)
downloadtalos-hostboot-0f0b7c641abb16561970c51371ecbfb9f254481b.tar.gz
talos-hostboot-0f0b7c641abb16561970c51371ecbfb9f254481b.zip
Fix BPM flash image script to properly calculate line length
Before this commit, the flash image script made certain assumptions about the flash image file when calculating the number of bytes on a line. Those assumptions aren't always true. Therefore, this commit adds a function to properly determine the number of bytes on a line for any arbitrary amount of extraneous characters on the line by stripping them all off prior to calculation. Change-Id: Ibeea1f62177109a512920be1434557ac55510743 RTC:212448 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/81947 Reviewed-by: Christian R Geddes <crgeddes@us.ibm.com> Reviewed-by: William G Hoffa <wghoffa@us.ibm.com> Reviewed-by: Roland Veloz <rveloz@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/build')
-rwxr-xr-xsrc/build/buildpnor/buildBpmFlashImages.pl37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/build/buildpnor/buildBpmFlashImages.pl b/src/build/buildpnor/buildBpmFlashImages.pl
index 630ad5436..72219e3d9 100755
--- a/src/build/buildpnor/buildBpmFlashImages.pl
+++ b/src/build/buildpnor/buildBpmFlashImages.pl
@@ -145,11 +145,6 @@ sub generateFirmwareImage
use constant FW_START_ADDRESS_8000 => "\@8000";
use constant FW_START_ADDRESS_A000 => "\@A000";
- # Each line is plain text where each byte is separated by spaces.
- # To determine how many bytes are on the line divide by characters per byte
- # and number of spaces between bytes. 2 characters per byte + 1 space = 3
- use constant BYTES_PER_LINE_EXCLUDING_SPACES => 3;
-
# Spec for BPM updates says that the maximum size for the data portion of
# the payload is 16 bytes
use constant MAXIMUM_DATA_BYTES_FOR_PAYLOAD => 16;
@@ -211,7 +206,7 @@ sub generateFirmwareImage
# The length of the payload data. The maximum size of payload data is 16
# bytes which is conveniently the maximum size of any line in the file
# minus spaces and carriage return/line feeds.
- my $dataLength = length($line) / BYTES_PER_LINE_EXCLUDING_SPACES;
+ my $dataLength = calculateDataLength($line);
if ($dataLength > MAXIMUM_DATA_BYTES_FOR_PAYLOAD)
{
@@ -374,11 +369,6 @@ sub generateConfigImage
use constant SEGMENT_B_START_ADDRESS => 0x100;
use constant SEGMENT_A_START_ADDRESS => 0x180;
- # Each line is plain text where each byte is separated by spaces.
- # To determine how many bytes are on the line, divide by characters per byte
- # and number of spaces between bytes. 2 characters per byte + 1 space = 3
- use constant BYTES_PER_LINE_EXCLUDING_SPACES => 3;
-
# Spec for BPM updates says that the maximum size for the data portion of
# the payload is 16 bytes
use constant MAXIMUM_DATA_BYTES_FOR_PAYLOAD => 16;
@@ -445,7 +435,7 @@ sub generateConfigImage
# Bytes: The bytes to write to the BPM config data dump buffer.
# The length of the line. The maximum size of any line is 16 bytes.
- my $dataLength = length($line) / BYTES_PER_LINE_EXCLUDING_SPACES;
+ my $dataLength = calculateDataLength($line);
if ($dataLength > MAXIMUM_DATA_BYTES_FOR_PAYLOAD)
{
@@ -814,6 +804,29 @@ sub createFragment
return $fragment;
}
+################################################################################
+# @brief Calculates the data length of the line by stripping all spaces for it
+# dividing by the number of bytes on the line.
+#
+# @param[in] i_line The line to calculate the length on.
+#
+# @return The number of bytes on the line (length).
+################################################################################
+sub calculateDataLength
+{
+ my $i_line = shift;
+
+ # Strip all the spaces from the line.
+ $i_line =~ s/\s+//g;
+
+ # Each line is plain text where each byte is separated by spaces.
+ # To determine how many bytes are on the line, divide by characters per byte
+ use constant CHARS_PER_BYTE => 2;
+ my $dataLength = length($i_line) / CHARS_PER_BYTE;
+
+ return $dataLength;
+}
+
__END__
=head1 NAME
OpenPOWER on IntegriCloud