From 5aaa828571ab16be2a8b36b48aca433df76c2bf9 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Sun, 30 Nov 2014 13:05:38 -0800 Subject: util/ipqheader: Add utility to create uber-SBL for IPQ8064 With the Storm image layout reworked, the very first blob read out of NOR SPI flash by the IPQ8064 maskrom is supposed to be a concatenation of three binaries: one to run on RPM, another one to run on AP, and the third one - the actual coreboot bootblock. This layout allows to greatly reduce the size and complexity of the two first blobs, as they do not need to include the SPI driver. The first binary in the input file list starts with the combined header, describing the rest of the blob. This utility copies the first input file into output, updating the combined header with the total size of the concatenated binaries. The second and third binaries in the combined image are required to be aligned at 256 byte offsets in the file as counted from the end of the combined header. The new utility allows to concatenate two or three files, always expecting the first file to be prepended by the combined header. For further reference below is the utility's help message: mbncat.py: [-v] [-h] [-o Output MBN] sbl1 sbl2 [bootblock] Concatenates up to three mbn files: two SBLs and a coreboot bootblock -h This message -v verbose -o Output file name, (default: sbl-ro.mbn) BRANCH=none BUG=chrome-os-partner:34161 TEST=run the new utility and compare the result with the output of the vendor provided tool. The output files are exactly the same. Change-Id: I1d3b3634ecc3f46ea88adb9b6c4fbfc017cc06ac Signed-off-by: Stefan Reinauer Original-Commit-Id: 94008340bc5eaf19d286b3feaa4091e5c5e285aa Original-Change-Id: I00724f7c75703fc90d7971c3cb337c33ca96f2b5 Original-Signed-off-by: Vadim Bendebury Original-Reviewed-on: https://chromium-review.googlesource.com/232047 Original-Reviewed-by: Manoj Juneja Original-Reviewed-by: David Hendricks Reviewed-on: http://review.coreboot.org/9572 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- util/ipqheader/mbncat.py | 200 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100755 util/ipqheader/mbncat.py (limited to 'util') diff --git a/util/ipqheader/mbncat.py b/util/ipqheader/mbncat.py new file mode 100755 index 0000000000..39c9d80072 --- /dev/null +++ b/util/ipqheader/mbncat.py @@ -0,0 +1,200 @@ +#!/usr/bin/python +# Copyright (c) 2014, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of The Linux Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import struct +import sys +import os + +"""A utility to generate ipq8064 uber SBL.. + +The very first blob (aka 'uber SBL') read out of NOR SPI flash by the IPQ8064 +maskrom is supposed to be a concatenation of up to three binaries: one to run +on the RPM, another one to run on the AP, and the third one - the actual +coreboot bootblock. + +The uber SBL starts with the combined header descriptor of 80 bytes, with the +first two 4 byte words set to certain values, and the total size of the +payload saved at offsets 28 and 32. + +To generate the uber SBL this utility expects two or three input file names in +the command line, the first file including the described header, and the +following one(s) - in QCA MBN format. This allows to create the uber SBL in +one or two invocations. + +The input files are concatenated together aligned at 256 byte boundary offset +from the combined header. See Usage() below for more details. + +The resulting uber SBL file is prepended by the same combined header adjusted +to reflect the new total file size. +""" + +DEFAULT_OUTPUT_FILE_NAME = 'sbl-ro.mbn' + +class NorSbl: + """Object representing the uber SBL.""" + + NOR_SBL1_HEADER = ' 3: + Usage(-1) + + nsbl = NorSbl(argv[0], verbose) + + for mbnf in argv[1:]: + nsbl.Append(mbnf) + + nsbl.Create(mbn_output) + +if __name__ == '__main__': + main() -- cgit v1.2.3