|
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 // Generic ROM image loading script with automatic attaching and symbol loading. |
|
19 // This is designed to be used in conjunction with the board configuration |
|
20 // system to be found in configdialog.cmm. |
|
21 // |
|
22 ////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
24 print "=======================================================================" |
|
25 print "Generic ROM image loading script" |
|
26 |
|
27 ; Declare the global variables used by the system and read the current config into them |
|
28 do globals.cmm |
|
29 |
|
30 ; Special check so that people do not try to download images to the h6 or labrador, which is not supported |
|
31 if ("&Platform"=="34xx_sdp"||"&Platform"=="34xx_lab") |
|
32 ( |
|
33 dialog.ok "Image downloading not supported for &Platform" |
|
34 enddo |
|
35 ) |
|
36 |
|
37 if "&RamImage"=="" |
|
38 ( |
|
39 print "No image selected" |
|
40 enddo |
|
41 ) |
|
42 |
|
43 ; Attach to the board and reset its hardware completely |
|
44 do init.cmm |
|
45 |
|
46 ; Clean up some image specific details |
|
47 task.reset |
|
48 mmu.reset |
|
49 |
|
50 ; Detected from image file |
|
51 &fileName="&RamImage" |
|
52 &fileSize=os.file.size(&fileName) |
|
53 &fileDate=os.file.date(&fileName) |
|
54 |
|
55 print "=========================================================" |
|
56 print "Filename: &fileName" |
|
57 print "Date: &fileDate" |
|
58 print "Size: &fileSize" |
|
59 print "RAM addr: &RamAddr" |
|
60 print "=========================================================" |
|
61 |
|
62 ; Load first few bytes of the image into ram and see whether it has a header on the front |
|
63 data.load.binary "&fileName" &RamAddr++0x200 |
|
64 &firstWord=(data.long(sd:&RamAddr)) |
|
65 &skipHeader="false" |
|
66 |
|
67 if ((&firstWord)==0x434F5045) |
|
68 ( |
|
69 print "File has EPOC Image header (will skip it)" |
|
70 &skipHeader="true" |
|
71 ) |
|
72 else |
|
73 ( |
|
74 print "No EPOC header present on file &fileName" |
|
75 ) |
|
76 |
|
77 print "Started download: " CLOCK.TIME() |
|
78 |
|
79 ; Turbo mode will disable cpu checks after each system speed memory access |
|
80 if ("&SystemOptionTurbo"!="") |
|
81 ( |
|
82 sys.option turbo &SystemOptionTurbo |
|
83 ) |
|
84 |
|
85 ; Udate the screen |
|
86 screen |
|
87 |
|
88 if "&skipHeader"=="true" |
|
89 ( |
|
90 data.load.binary "&fileName" &RamAddr /SKIP 100 |
|
91 ) |
|
92 else |
|
93 ( |
|
94 data.load.binary "&fileName" &RamAddr |
|
95 ) |
|
96 |
|
97 if os.file("&PlatformsDir\&Platform\postload.cmm") |
|
98 ( |
|
99 do &PlatformsDir\&Platform\postload.cmm |
|
100 ) |
|
101 |
|
102 sys.option turbo off |
|
103 |
|
104 print "Finished load: " CLOCK.TIME() |
|
105 |
|
106 ; Set all CPUs to point at the entrypoint of the ROM, stored in RamAddr |
|
107 ¤tCPU=&NumberOfCpus-1 |
|
108 print "Setting PC of &NumberOfCpus CPU core(s) to &RamAddr" |
|
109 |
|
110 while ¤tCPU>=0 |
|
111 ( |
|
112 ; Only change the current core if there is more than one or it will cause an error |
|
113 if &NumberOfCpus>1 |
|
114 core ¤tCPU |
|
115 |
|
116 ; Now set the PC address for the current core |
|
117 register.set PC &RamAddr |
|
118 ¤tCPU=¤tCPU-1 |
|
119 ) |
|
120 |
|
121 ; How do we decide whether this is a debug image or not? if we check for a 'D' |
|
122 ; in the filename it could match on anything whilst if we match on *D.IMG we'll |
|
123 ; get most of the debug images but not all of them... |
|
124 if string.scan(string.lwr("&fileName"),"techview.img",0)==-1 |
|
125 ( |
|
126 ; Logic doesn't work for Techview |
|
127 if string.scan(string.lwr("&fileName"),"d.img",0)==-1 |
|
128 ( |
|
129 ; .SYM files are not normally produced for UREl builds, but we might have a .SYMBOL |
|
130 ; file that we can pull in. See if there is a .symbol file matching the filename. |
|
131 &_SYMBOLBASENAME=string.cut("&fileName",-string.len(os.file.extension(&fileName))) |
|
132 &_SYMBOLFILENAME="&_SYMBOLBASENAME"+".symbol" |
|
133 if os.file("&_SYMBOLFILENAME") |
|
134 ( |
|
135 ; This was recently added by Lauterbach so it is not in all versions of the software |
|
136 data.load.symbian "&_SYMBOLFILENAME" &RamAddr /nocode |
|
137 print "UREL image, .symbol file loaded, finished everything: " CLOCK.TIME() |
|
138 ENDDO |
|
139 ) |
|
140 |
|
141 print "UREL image, no .symbol file, finished everything: " CLOCK.TIME() |
|
142 enddo |
|
143 ) |
|
144 ) |
|
145 |
|
146 ; Switch the windows in to showing source (if available) rather than mixed |
|
147 mode.hll |
|
148 |
|
149 ; Sase disassemble method on symbol data rather than CPU access mode |
|
150 sys.OPTION DISMODE AUTO |
|
151 |
|
152 do symbolics.cmm |
|
153 |
|
154 enddo |