#!/usr/bin/env python3 # 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()