source: svn/trunk/newcon3bcm2_21bu/dta/src/bootloader/makeheaders.py @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 2.5 KB
Line 
1## /***************************************************************************
2##  *     Copyright (c) 2010, Broadcom Corporation
3##  *     All Rights Reserved
4##  *     Confidential Property of Broadcom Corporation
5##  *
6##  *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7##  *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8##  *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9##  *
10##  * $brcm_Workfile: $
11##  * $brcm_Revision: $
12##  * $brcm_Date: $
13##  *
14##  * Module Description: generate headers for securing application image
15##  *
16##  * Revision History:
17##  *
18##  * $brcm_Log: $
19##  *
20##  *
21##  ***************************************************************************/
22
23import os
24import sys
25import array
26import struct
27
28def usage() :
29    print "usage : makeheaders.py <boot order> <file name>"
30    print "usage : makeheaders.py --scm <scm loader file>"
31    print "boot order - value of boot order field to place in the header"
32    print "file name - name of the flash image for which to make header"
33    return
34
35
36bhfname = "bootheader.bin"
37ahfname = "appheader.bin"
38shfname = "scmheader.bin"
39version = "TEST_IMAGE.BROADCOM.02.02.05.002"
40scm = 0
41
42if (3 > len(sys.argv)) :
43    usage()
44    sys.exit(1)
45
46if ( "--scm" == sys.argv[1]) :
47    scm = 1
48else :
49    bootorder = int(sys.argv[1])
50   
51fname = sys.argv[2]
52fsize = os.path.getsize(fname)
53
54print "%s size = %d" % (fname, fsize)
55if ((0 != (fsize % 64)) and (0 == scm)) :
56    print "Size of compressed application is not aligned on 64 bytes"
57    sys.exit(1)
58
59if(0 == scm) :
60    bootheader = array.array('I', [bootorder, 0x7572, 0xFFFFFFFFL, 0xFFFFFFFFL])
61    bhfile = open(bhfname,"wb")
62    bootheader.tofile(bhfile)
63    bhfile.close()
64
65    appheader = struct.pack("<4L64s12L", fsize, 1, 0x7572, 0x41544448, version,
66                            0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL,
67                            0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL,
68                            0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL)
69    ahfile = open(ahfname, "wb")
70    ahfile.write(appheader)
71    ahfile.close()
72else :
73    scmheader = struct.pack("<4L12L", fsize, 0x00000001, 0x7572, 0x4c4d4353,
74                            0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL,
75                            0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL,
76                            0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL)
77    shfile = open(shfname, "wb")
78    shfile.write(scmheader)
79    shfile.close()
Note: See TracBrowser for help on using the repository browser.