From bc88548f09df044cd7c8daa0b4805e31f5e51aee Mon Sep 17 00:00:00 2001 From: Elizabeth Liner Date: Tue, 12 Sep 2017 20:24:30 -0500 Subject: Removing first byte from MEMD binary Change-Id: I8cd48e40be7e3f756daba2019e410881d563085d Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/46118 Tested-by: Jenkins Server Reviewed-by: Stephen M. Cprek Reviewed-by: Christian R. Geddes Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell --- src/build/buildpnor/memd_creation.pl | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/build/buildpnor/memd_creation.pl') diff --git a/src/build/buildpnor/memd_creation.pl b/src/build/buildpnor/memd_creation.pl index aa0298988..cf549a5bf 100755 --- a/src/build/buildpnor/memd_creation.pl +++ b/src/build/buildpnor/memd_creation.pl @@ -101,9 +101,27 @@ print $fh $num_bin; # Read in the MEMD binary, and concatenate to this file. foreach my $file (@memd_files) { + # Checking that first byte equals "84" + # The VPD spec has '84' as their first byte for a record, however it is + # not needed for the hostboot structure to add in into the VPD structure, + # so we remove it here before creating the MEMD binary + my $first_byte = `head -c 1 $file`; + die "System command failed: $?" if $?; + + $first_byte =~ s/(.)/sprintf("%x",ord($1))/eg; + if(!($first_byte == 84)) + { + die "Incorrect first byte, MEMD file is invalid"; + } + + # Removing the first byte of the MEMD binary + my $new_file = "edited_memd.dat"; + run_command("tail -c +2 $file > $new_file"); + run_command("mv $new_file $file"); + seek($fh, $offset, 0); print "Writing the file $file...\n"; - open(my $in_file, '<', $file) or die "Cound not open file '$file' $!"; + open(my $in_file, '<', $file) or die "Could not open file '$file' $!"; while ( <$in_file> ) { -- cgit v1.2.1