source: rubycfg_asp/trunk/asp_dcre/arch/ccrx/post_cfg.py@ 313

Last change on this file since 313 was 313, checked in by coas-nagasima, 7 years ago

ソースを追加

File size: 3.3 KB
Line 
1#!python
2import subprocess
3import os
4import sys
5import re # for regular expression
6import shutil
7import os.path
8
9#
10# variable definition
11#
12INCLUDES = []
13CFG1_DEF_TABLES = []
14
15# set relative path from top proj
16proj_rel_dir = "../"
17
18# call definition file
19common.Source(proj_rel_dir + "def.py")
20
21# path
22src_abs_path = os.path.abspath(proj_rel_dir + SRCDIR)
23
24# call common file
25common.Source(src_abs_path + "/arch/ccrx/common.py")
26
27#
28# convert map file
29#
30inputfile = open("./DefaultBuild/cfg.map")
31outputfile = open("cfg1_out.syms", 'w')
32
33r1 = re.compile("^\s+(_\w+)")
34r2 = re.compile("^\s+([0-9a-f]+)\s+")
35line = inputfile.readline()
36while line:
37 line = line.replace('\r\n','') #delete newline
38 m1 = r1.search(line)
39 if m1:
40 line = inputfile.readline()
41 line = line.replace('\r\n','') #delete newline
42 m2 = r2.search(line)
43 outputfile.write("0x" + m2.group(1) + " T " + m1.group(1) + "\n")
44 line = inputfile.readline()
45
46inputfile.close()
47outputfile.close()
48
49if TCPIP_API_TABLE != "":
50 cfg_tcpip_kernel_trb = srcdir + CFG_TCPIP_KERNEL_TRB
51 cfg_tcpip_api_table = srcdir + TCPIP_API_TABLE
52
53#
54# Execute cfg path 2
55#
56# make command
57cfg_command = cfg + " --pass 2 " + "--kernel " + CFG_KERNEL
58cfg_command += " " + cfg_includes
59if TCPIP_API_TABLE == "":
60 cfg_command += " -T " + cfg_kernel_trb
61else:
62 cfg_command += " -T " + cfg_tcpip_kernel_trb + ":tcpip"
63 cfg_command += " -T " + cfg_kernel_trb + ":kernel"
64
65print cfg_command
66
67# Execute
68try:
69 output = subprocess.check_output(cfg_command, stderr=subprocess.STDOUT,)
70except subprocess.CalledProcessError, e:
71 print "ERROR!! : ", e.output
72 sys.exit()
73
74output.replace('\r','')
75print output
76
77##
78## mov Os_Cfg_tmp.h Os_Cfg.h
79##
80#import filecmp
81#if not os.path.isfile(r'Os_Cfg.h'):
82# print "Rename Os_Cfg_tmp.h to Os_Cfg.h"
83# shutil.move("Os_Cfg_tmp.h", "Os_Cfg.h")
84#else:
85# print "compare Os_Cfg_tmp.h and Os_Cfg.h"
86# if not filecmp.cmp(r'Os_Cfg_tmp.h', r'Os_Cfg.h'):
87# print "Rename Os_Cfg_tmp.h to Os_Cfg.h"
88# shutil.move("Os_Cfg_tmp.h", "Os_Cfg.h")
89# else:
90# print "Delete Os_Cfg_tmp.h"
91# os.remove("Os_Cfg_tmp.h")
92
93#
94# Execute cfg path 3
95#
96# make command
97cfg_command = cfg + " --pass 2 -O " + "--kernel " + CFG_KERNEL
98cfg_command += " " + cfg_includes
99cfg_command += " --rom-image cfg1_out.srec --rom-symbol cfg1_out.syms"
100cfg_command += " -T " + cfg_offset_trb
101
102print cfg_command
103
104# Execute
105try:
106 output = subprocess.check_output(cfg_command, stderr=subprocess.STDOUT,)
107except subprocess.CalledProcessError, e:
108 print "ERROR!! : ", e.output
109 sys.exit()
110
111output.replace('\r','')
112print output
113
114#
115# convert map file
116#
117inputfile = open("offset.h")
118outputfile = open("offset.inc", 'w')
119
120outputfile.write("; offset.inc\n");
121outputfile.write("\n");
122
123r1 = re.compile("^#define\s+([0-9|a-z|A-Z|_]+)\s+(.+)\s*$")
124r2 = re.compile("^0x([0-9A-Fa-f]+)$");
125line = inputfile.readline()
126while line:
127 line = line.replace('\r\n','') #delete newline
128 m1 = r1.search(line)
129 if m1:
130 value = m1.group(2)
131 m2 = r2.search(value)
132 if m2:
133 value = "0" + m2.group(1) + "H"
134 line = " " + m1.group(1) + " .equ " + value
135 outputfile.write(line + "\n")
136 line = inputfile.readline()
137
138inputfile.close()
139outputfile.close()
Note: See TracBrowser for help on using the repository browser.