|
1 // |
|
2 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 // All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Nokia Corporation - initial contribution. |
|
11 // |
|
12 // Contributors: |
|
13 // |
|
14 // Description: |
|
15 // |
|
16 ////////////////////////////////////////////////////////////////////////////// |
|
17 // |
|
18 // This script configures the autoloader for full symbolic debugging. It is |
|
19 // designed to be used in conjunction with the board configuration system to |
|
20 // be found in configdialog.cmm. |
|
21 // |
|
22 ////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
24 print "=======================================================================" |
|
25 print "Generic symbol autoloader configuration script" |
|
26 |
|
27 global &_IS_BOOTLOADER |
|
28 global &_T32ROMDIR |
|
29 global &IsTextshell |
|
30 |
|
31 &IsTextshell=(0==1) |
|
32 |
|
33 if "&_IS_BOOTLOADER"=="" |
|
34 ( |
|
35 &_IS_BOOTLOADER=(0==1) |
|
36 ) |
|
37 |
|
38 ; Start from clean |
|
39 symbol.reset |
|
40 symbol.autoload.reset |
|
41 |
|
42 ; Add some special labels to various addresses so if an exception occurs it will me |
|
43 ; immediately obvious as to what caused it |
|
44 symbol.new.function VECTORS 0xFFFF0000++0x1C |
|
45 symbol.new.label RESET 0xFFFF0000 |
|
46 symbol.new.label UNDEF 0xFFFF0004 |
|
47 symbol.new.label SWI 0xFFFF0008 |
|
48 symbol.new.label PREFETCH_ABORT 0xFFFF000C |
|
49 symbol.new.label DATA_ABORT 0xFFFF0010 |
|
50 symbol.new.label IRQ 0xFFFF0018 |
|
51 symbol.new.label FIQ 0xFFFF001C |
|
52 |
|
53 ; Get the image filename |
|
54 &_DIALOG_PATH=os.env(T32ROMDIR) |
|
55 |
|
56 if "&_DIALOG_PATH"=="" |
|
57 ( |
|
58 if "&_T32ROMDIR"=="" |
|
59 ( |
|
60 &_DIALOG_PATH="*.IMG" |
|
61 ) |
|
62 else |
|
63 ( |
|
64 &_DIALOG_PATH="&_T32ROMDIR"+"\*.IMG" |
|
65 ) |
|
66 ) |
|
67 else |
|
68 ( |
|
69 &_DIALOG_PATH="&_DIALOG_PATH"+"\*.IMG" |
|
70 ) |
|
71 |
|
72 local &_SYMBOLICS_FILENAME |
|
73 &_SYMBOLICS_FILENAME="&RamImage" |
|
74 |
|
75 local &_SYMBOLICS_LOAD_ADDRESS |
|
76 &_SYMBOLICS_LOAD_ADDRESS="&RamAddr" |
|
77 |
|
78 if "&_SYMBOLICS_FILENAME"=="" |
|
79 ( |
|
80 print "Select EPOC image that is currently running:" |
|
81 |
|
82 dialog.file &_DIALOG_PATH |
|
83 entry &_SYMBOLICS_FILENAME |
|
84 |
|
85 if "&_SYMBOLICS_FILENAME"=="" |
|
86 ( |
|
87 ; disconnect from the board |
|
88 print "*** Aborted (no ROM image filename specified) ***" |
|
89 enddo |
|
90 ) |
|
91 ) |
|
92 |
|
93 ; Check for a logfile with the same path and stem as the ROM name and if found use that. Failing |
|
94 ; that, check for a logfile with the same path but called romfile.log and if found, use that |
|
95 &_LOGBASENAME=string.cut("&_SYMBOLICS_FILENAME",-string.len(os.file.extension(&_SYMBOLICS_FILENAME))) |
|
96 &_LOGFILENAME="&_LOGBASENAME"+".log" |
|
97 |
|
98 if !os.file("&_LOGFILENAME") |
|
99 ( |
|
100 &_LOGFILENAME=string.cut("&_SYMBOLICS_FILENAME",-string.len(os.file.name(&_SYMBOLICS_FILENAME))) |
|
101 &_LOGFILENAME="&_LOGFILENAME"+"rombuild.log" |
|
102 |
|
103 if !os.file("&_LOGFILENAME") |
|
104 ( |
|
105 print "*** Log file not found. Select logfile for this image ***" |
|
106 &_DIALOG_PATH="&_SYMBOLICS_FILENAME"+"\*.log" |
|
107 dialog.file &_DIALOG_PATH |
|
108 entry &_LOGFILENAME |
|
109 ) |
|
110 ) |
|
111 |
|
112 if os.file("&_LOGFILENAME") |
|
113 ( |
|
114 print "Using &_LOGFILENAME for symbols" |
|
115 ) |
|
116 else |
|
117 ( |
|
118 print "*** Aborted (no logfile name specified) ***" |
|
119 enddo |
|
120 ) |
|
121 |
|
122 ; It's possible that the script guesses a right logfilename but the user has let |
|
123 ; the log get out of date when compared to the image. Do a very quick compare on |
|
124 ; the timestamps - this will reject guessed filenames if the minute rolls over. |
|
125 local &_DATE_IMAGE |
|
126 local &_DATE_LOG |
|
127 |
|
128 &_DATE_IMAGE=string.cut(os.file.date(&_SYMBOLICS_FILENAME), -2) |
|
129 &_DATE_LOG=string.cut(os.file.date(&_LOGFILENAME), -2) |
|
130 |
|
131 if "&_DATE_IMAGE"!="&_DATE_LOG" |
|
132 ( |
|
133 print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
|
134 print "Would guess logfile was &_LOGFILENAME but not perfect time match" |
|
135 print "Date image: &_DATE_IMAGE" |
|
136 print "Date log: &_DATE_LOG" |
|
137 print "Select rombuild.log for this image:" |
|
138 print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
|
139 &_DIALOG_PATH="&_SYMBOLICS_FILENAME"+"\*.log" |
|
140 dialog.file &_DIALOG_PATH |
|
141 entry &_LOGFILENAME |
|
142 |
|
143 if "&_LOGFILENAME"=="" |
|
144 ( |
|
145 print "*** Aborted (no logfile name specified) ***" |
|
146 enddo |
|
147 ) |
|
148 |
|
149 if os.file("&_LOGFILENAME") |
|
150 ( |
|
151 print "Now using &_LOGFILENAME for symbols" |
|
152 ) |
|
153 else |
|
154 ( |
|
155 print "*** Aborted (no logfile name specified) ***" |
|
156 enddo |
|
157 ) |
|
158 ) |
|
159 |
|
160 ; parse the rombuild.log file to extract the rom checksum |
|
161 LOCAL &data &_BLANKS &_LOG_CHECKSUM |
|
162 &_BLANKS=0 |
|
163 |
|
164 OPEN #1 &_LOGFILENAME /Read |
|
165 REPEAT |
|
166 ( |
|
167 READ #1 %line &data |
|
168 ; Okay, this is because there isn't a way of the read returning EOF |
|
169 ; the easiest solution is to count the number of blank lines and if |
|
170 ; it crosses a threshold assume that the end was reached. |
|
171 if "&data"=="" |
|
172 ( |
|
173 &_BLANKS=&_BLANKS+1 |
|
174 if &_BLANKS>10 |
|
175 ( |
|
176 print "10 blank lines, assume EOF" |
|
177 goto endloop |
|
178 ) |
|
179 ) |
|
180 else |
|
181 ( |
|
182 &_BLANKS=0 |
|
183 ) |
|
184 |
|
185 if (string.scan("&data", "bootldr",0)!=-1) |
|
186 ( |
|
187 &_IS_BOOTLOADER=(1==1) |
|
188 ) |
|
189 |
|
190 if (string.scan("&data", "Checksum word:",0)!=-1) |
|
191 ( |
|
192 &_LOG_CHECKSUM=string.cut("&data", 25.) |
|
193 goto endloop |
|
194 ) |
|
195 ) |
|
196 endloop: |
|
197 CLOSE #1 |
|
198 |
|
199 if ("&_LOG_CHECKSUM"=="") |
|
200 ( |
|
201 print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
|
202 print "Can't get checksum from rombuild.log - aborting" |
|
203 print "Log: &_LOG_CHECKSUM" |
|
204 print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
|
205 enddo |
|
206 ) |
|
207 |
|
208 if ("&_LOG_CHECKSUM"!="") |
|
209 ( |
|
210 &_LOG_CHECKSUM="0x"+string.upr("&_LOG_CHECKSUM") |
|
211 ) |
|
212 |
|
213 ; Get the checksum from the board. Yes, duplicating two lines - it takes more |
|
214 ; lines of code to do the conditionals and variables required to record state |
|
215 ; and it looks very strange |
|
216 local &_ROM_CHECKSUM |
|
217 |
|
218 ; TODO - Temporary hack to get around NaviEngine problems |
|
219 if "&Platform"!="ne1_tb" |
|
220 ( |
|
221 if run() |
|
222 ( |
|
223 break |
|
224 &_ROM_CHECKSUM=&_SYMBOLICS_LOAD_ADDRESS+0xA8 |
|
225 &_ROM_CHECKSUM=data.long(ad:&_ROM_CHECKSUM) |
|
226 go |
|
227 ) |
|
228 else |
|
229 ( |
|
230 &_ROM_CHECKSUM=&_SYMBOLICS_LOAD_ADDRESS+0xA8 |
|
231 &_ROM_CHECKSUM=data.long(ad:&_ROM_CHECKSUM) |
|
232 ) |
|
233 |
|
234 if (&_ROM_CHECKSUM!=&_LOG_CHECKSUM) |
|
235 ( |
|
236 print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
|
237 print "Checksums don't match" |
|
238 print "Rom: &_ROM_CHECKSUM" |
|
239 print "Log: &_LOG_CHECKSUM" |
|
240 print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
|
241 ) |
|
242 ) |
|
243 |
|
244 ; Try and find the root of the source. This works relative to the "os" directory |
|
245 ; to take into account different source code layouts. It will work with substed |
|
246 ; and non substed drives, and with Perforce style and CBR style source layouts. |
|
247 ; |
|
248 ; The root is determined from the value of the fully qualified ROM name as setup |
|
249 ; in the &RamImage variable, as specified in the configdialog.cmm script. This is |
|
250 ; to take into account different source layouts and the fact that EPOCROOT may not |
|
251 ; be == \ |
|
252 |
|
253 local &epoc32 |
|
254 local &os |
|
255 |
|
256 ; Start by finding the "os" directory in the current qualified ROM name |
|
257 print "Scanning "+os.file.path(&_SYMBOLICS_FILENAME)+" for os source directory" |
|
258 &os=string.scan(os.file.path(&_SYMBOLICS_FILENAME),"os",0.) |
|
259 |
|
260 if (&os>=0x00) |
|
261 ( |
|
262 &_BASELOC=string.mid(os.file.path(&_SYMBOLICS_FILENAME),0,&os) |
|
263 |
|
264 if os.dir("&_BASELOC") |
|
265 ( |
|
266 &IsTextshell=(1==1) |
|
267 print "Using path &_BASELOC as a relative path to source" |
|
268 ) |
|
269 else |
|
270 ( |
|
271 &_BASELOC="" |
|
272 ) |
|
273 ) |
|
274 else |
|
275 ( |
|
276 ; Not found so assume we are using a CBR build and try for epoc32 |
|
277 print "Scanning "+os.file.path(&_SYMBOLICS_FILENAME)+" for epoc32 directory" |
|
278 &epoc32=string.scan(os.file.path(&_SYMBOLICS_FILENAME),"epoc32",0.) |
|
279 |
|
280 if (&epoc32>=0x00) |
|
281 ( |
|
282 &_BASELOC=string.mid(os.file.path(&_SYMBOLICS_FILENAME),0,&epoc32) |
|
283 |
|
284 if os.dir("&_BASELOC") |
|
285 ( |
|
286 print "Using path &_BASELOC as a relative path to source" |
|
287 ) |
|
288 else |
|
289 ( |
|
290 &_BASELOC="" |
|
291 ) |
|
292 ) |
|
293 ) |
|
294 |
|
295 if "&_BASELOC"=="" |
|
296 ( |
|
297 print "No os source path found, guessing it is one of the usual ones..." |
|
298 &_BASELOC="&driveletter\os" |
|
299 if os.dir("&_BASELOC") |
|
300 ( |
|
301 ) |
|
302 else |
|
303 ( |
|
304 &_BASELOC="&driveletter\sf\os" |
|
305 ) |
|
306 print "Using path &_BASELOC as a relative path to source" |
|
307 ) |
|
308 |
|
309 &_AUTOLOAD="/autoload" ; handles arm4 and armv5 |
|
310 |
|
311 ; Try to determine from the ROM name the CPU architecture is in use. If we can't then assume that it's |
|
312 ; the upcoming armv7 |
|
313 local &_ARCH |
|
314 |
|
315 &flexible="" |
|
316 |
|
317 if string.scan(string.lwr("&_SYMBOLICS_FILENAME"),"arm4",0)!=-1 |
|
318 ( |
|
319 &_ARCH="arm4" |
|
320 ) |
|
321 else if string.scan(string.lwr("&_SYMBOLICS_FILENAME"),"armv5smp",0)!=-1 |
|
322 ( |
|
323 &_ARCH="armv5smp" |
|
324 if ("&Platform"=="ne1_tb") |
|
325 ( |
|
326 print "Detected Flexible Memory Model for NaviEngine SMP image" |
|
327 &flexible="f" |
|
328 ) |
|
329 ) |
|
330 else if string.scan(string.lwr("&_SYMBOLICS_FILENAME"),"armv7",0)!=-1 |
|
331 ( |
|
332 &_ARCH="armv7" |
|
333 ) |
|
334 else |
|
335 ( |
|
336 &_ARCH="armv5" |
|
337 if ("&Platform"=="ne1_tb"&&string.scan(string.lwr("&_SYMBOLICS_FILENAME"),"fne1_tb",0)!=-1) |
|
338 ( |
|
339 print "Detected Flexible Memory Model for NaviEngine unicore image" |
|
340 &flexible="f" |
|
341 ) |
|
342 ) |
|
343 |
|
344 ; Setup the source paths as determined automatically and also as specified by the user |
|
345 do sourcepaths.cmm |
|
346 |
|
347 local &epocRoot |
|
348 if os.dir("&driveletter\epoc32") |
|
349 ( |
|
350 &epocRoot="&driveletter\" |
|
351 ) |
|
352 else |
|
353 ( |
|
354 &epocRoot="&_BASELOC" |
|
355 ) |
|
356 |
|
357 ; Determine the name of the bootstrap binary, using special handling if this is a bootloader image |
|
358 local &bootStrapFileName |
|
359 |
|
360 if &_IS_BOOTLOADER |
|
361 ( |
|
362 &bootStrapFileName="&epocRoot"+"epoc32\release\"+"&_ARCH"+"\_"+"&flexible&Platform"+"_bootloader_bootrom.bin" |
|
363 ) |
|
364 else |
|
365 ( |
|
366 &bootStrapFileName="&epocRoot"+"epoc32\release\"+"&_ARCH"+"\_"+"&flexible&Platform"+"_bootrom.bin" |
|
367 ) |
|
368 |
|
369 ; Determine whether to use SBSv1 or SBSv2 symbol file |
|
370 local &symfilename |
|
371 |
|
372 do checksymbols.cmm "&bootStrapFileName" |
|
373 if "&symfilename"!="" |
|
374 ( |
|
375 &bootStrapFileName="&symfilename" |
|
376 ) |
|
377 |
|
378 ; Scan rombuild log file for modules & addresses |
|
379 symbol.AutoLoad.LOADEPOC &_LOGFILENAME "do "+os.ppd()+"&_AUTOLOAD " |
|
380 symbol.AutoLoad.CHECKEPOC "do "+os.ppd()+"&_AUTOLOAD " ; define dynamic autoloader |
|
381 symbol.AutoLoad.CHECK OFF ; switch off automatic process detection |
|
382 |
|
383 ; If we are running a textshell image then we are probably a base engineer who has compile the image him |
|
384 ; or herself, so the kernel symbolics will be available. If so then load them now |
|
385 if &IsTextshell |
|
386 ( |
|
387 symbol.autoload.touch "*ekern.exe*" |
|
388 ) |
|
389 |
|
390 ; If the user has specified to load symbols for a particular module, load them now |
|
391 if "&AutoloadModule"!="" |
|
392 ( |
|
393 print "Autoloading symbols for &AutoloadModule" |
|
394 symbol.autoload.touch "&AutoloadModule" |
|
395 ) |
|
396 |
|
397 ; Breakpoint on kernel faults - do this before any other symbol files get loaded |
|
398 ; otherwise it could match on stub functions |
|
399 if (y.exist("Kern::Fault")) |
|
400 ( |
|
401 B.S Kern::Fault /P /ONCHIP |
|
402 ) |
|
403 |
|
404 ; Again, if we are running a textshell image then load the variant and bootstrap symbols |
|
405 if &IsTextshell |
|
406 ( |
|
407 symbol.AutoLoad.TOUCH "*ecust*" |
|
408 |
|
409 if os.file(&bootStrapFileName) |
|
410 ( |
|
411 print "Loading bootstrap symbolics for &bootStrapFileName" |
|
412 data.load.auto &bootStrapFileName &_SYMBOLICS_LOAD_ADDRESS /nocode /strippart 3 /noclear |
|
413 ) |
|
414 else |
|
415 ( |
|
416 print "*** Skipping bootstrap symbolics (can't find &bootStrapFileName) ***" |
|
417 ) |
|
418 ) |
|
419 |
|
420 symbol.cleanup |
|
421 enddo |