diff options
author | Richard J. Knight <rjknight@us.ibm.com> | 2017-10-27 16:14:07 -0500 |
---|---|---|
committer | William G. Hoffa <wghoffa@us.ibm.com> | 2017-11-08 11:25:50 -0500 |
commit | 1100f64331cb45c9c0ac439f673b962bf98c27d3 (patch) | |
tree | e66dffc70a6f950a85b5297abea0388b7b4df6a6 /src/build/tools | |
parent | 219a0628c4f8f773b930b6936b9a9474e0da829b (diff) | |
download | talos-hostboot-1100f64331cb45c9c0ac439f673b962bf98c27d3.tar.gz talos-hostboot-1100f64331cb45c9c0ac439f673b962bf98c27d3.zip |
Add script to edit hostboot binary images to enable CFM testing
-Add editimgid perl script to grab image id from binary file
and upate it with /cfm extension
-Modify hbfw/img/makefile to call script when CFM_TEST_IMAGE
environment variable is set
-Update hbRelease and dist.targets to process the new perl
script
Change-Id: Ib4816e44932b37c2b432969b8f910d4f0ed381b2
RTC:160351
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/48957
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: PAMELA J. EGGLER <eggler@us.ibm.com>
Reviewed-by: Stephen M. Cprek <smcprek@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: William G. Hoffa <wghoffa@us.ibm.com>
Diffstat (limited to 'src/build/tools')
-rwxr-xr-x | src/build/tools/editimgid | 92 | ||||
-rwxr-xr-x | src/build/tools/hbRelease | 1 |
2 files changed, 93 insertions, 0 deletions
diff --git a/src/build/tools/editimgid b/src/build/tools/editimgid new file mode 100755 index 000000000..ac4016715 --- /dev/null +++ b/src/build/tools/editimgid @@ -0,0 +1,92 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/build/tools/editimgid $ +# +# OpenPOWER HostBoot Project +# +# Contributors Listed Below - COPYRIGHT 2017 +# [+] International Business Machines Corp. +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# +# IBM_PROLOG_END_TAG +use strict; + +use Getopt::Long; + +my $imageIdSym = "hbi_ImageId"; + +my $img = ""; +my $symsFile = ""; + + +sub usage +{ + ## needs to files as inputs + print "Need 2 file names. \nUsage:\n"; + print "\teditimgid --binFile <path to image>/hostboot.bin --symsFile <path to syms file>/hhbicore.syms\n\n"; + exit -1; +} + + +GetOptions('binFile=s' => \$img, + 'symsFile=s' => \$symsFile); + +usage() unless $img and $symsFile; + +#example from hbicore.syms: +# V,0002f008,00000000,00000000,hbi_ImageId +# 1. find the hbi_ImageId +# 2. chop off columns 1,2 +# 3. now the address is in the first 8 columns, chop off the rest +my $addressStr = `grep hbi_ImageId $symsFile | colrm 1 2 | colrm 9`; + +#if the address is empty or we got a bad rc - exit +if ($addressStr eq '' || $? ) +{ + printf "error reading address from $symsFile"; + exit(-1); +} +my $address = hex $addressStr; + +#image id is a 128 byte field, written as a null terminated +#string, extract all but the null terminator +my $imageId = `dd if=$img bs=1 skip=$address count=127`; + +if ($imageId eq '' || $?) +{ + print "error reading image id tag from $img rc=$?\n"; + exit (-1); +} + +#remove any non printable chars from the data +$imageId =~ s/[^[:print:]]+//g; + +$imageId = $imageId . "/" . "cfm"; + +#make sure we can edit the file +my $mode = 0755; +chmod $mode, $img; + +my $cmd = "echo -n $imageId | dd of=$img conv=notrunc bs=1 "; + +# write back the full 127 byte field +$cmd = $cmd . "seek=$address count=127 >& /dev/null"; + +system("$cmd") == 0 + or die "Failed to update the image RC=$?"; + +exit $? diff --git a/src/build/tools/hbRelease b/src/build/tools/hbRelease index 67ab9e663..248f36227 100755 --- a/src/build/tools/hbRelease +++ b/src/build/tools/hbRelease @@ -430,6 +430,7 @@ sub execute_pre_release { $CMVC_FILES .= "src/hbfw/img/hostboot_bootloader.bin "; $CMVC_FILES .= "src/hbfw/img/hostboot_securerom.bin "; + $CMVC_FILES .= "src/hbfw/img/editimgid "; } |