## /*************************************************************************** ## * Copyright (c) 2010, Broadcom Corporation ## * All Rights Reserved ## * Confidential Property of Broadcom Corporation ## * ## * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE ## * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR ## * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. ## * ## * $brcm_Workfile: $ ## * $brcm_Revision: $ ## * $brcm_Date: $ ## * ## * Module Description: generate headers for securing application image ## * ## * Revision History: ## * ## * $brcm_Log: $ ## * ## * ## ***************************************************************************/ import os import sys import array import struct def usage() : print "usage : makeheaders.py " print "usage : makeheaders.py --scm " print "boot order - value of boot order field to place in the header" print "file name - name of the flash image for which to make header" return bhfname = "bootheader.bin" ahfname = "appheader.bin" shfname = "scmheader.bin" version = "TEST_IMAGE.BROADCOM.02.02.05.002" scm = 0 if (3 > len(sys.argv)) : usage() sys.exit(1) if ( "--scm" == sys.argv[1]) : scm = 1 else : bootorder = int(sys.argv[1]) fname = sys.argv[2] fsize = os.path.getsize(fname) print "%s size = %d" % (fname, fsize) if ((0 != (fsize % 64)) and (0 == scm)) : print "Size of compressed application is not aligned on 64 bytes" sys.exit(1) if(0 == scm) : bootheader = array.array('I', [bootorder, 0x7572, 0xFFFFFFFFL, 0xFFFFFFFFL]) bhfile = open(bhfname,"wb") bootheader.tofile(bhfile) bhfile.close() appheader = struct.pack("<4L64s12L", fsize, 1, 0x7572, 0x41544448, version, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL) ahfile = open(ahfname, "wb") ahfile.write(appheader) ahfile.close() else : scmheader = struct.pack("<4L12L", fsize, 0x00000001, 0x7572, 0x4c4d4353, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL) shfile = open(shfname, "wb") shfile.write(scmheader) shfile.close()