-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFRM_9s12xeq384_DFlash_EEE_ed2.blr
235 lines (201 loc) · 5.6 KB
/
FRM_9s12xeq384_DFlash_EEE_ed2.blr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
Menu
&Âåðñèÿ ñîôòà,version,5,F1
EndMenu
Editor
{
(Caption="D_FLASH";size=32768;mode=8;bytes=16)
(Caption="EEE";size=4096;mode=8;bytes=16)
}
Window(caption=""; width=300; height=150; align=h)
{
Text(caption="new Vin"; name=text_0000; left=380; top=50; width=175; items="hello world,Òâîþ Ìàòü!")
Button(caption="Make EEE"; left=5; top=20; width=100; height=25; proc=button_make_eee_0184)
Button(caption="Cheñk D_Flash"; left=5; top=50; width=100; height=25; proc=button_check_dflash_0252)
Button(caption="Get_Vin"; left=340; top=90; width=100; height=25; proc=button_get_vin_0162)
Button(caption="Set_Vin"; left=450; top=90; width=100; height=25; proc=button_set_vin_0046)
List(caption="Help "; name=list_0B42; left=180; top=20; width=100; value=0; items="--Help--","help_script","about_9s12XEx","about_FRM3"; proc=list_help_0310)
Label(caption="Vin : "; name=label_0001; left=340; top=29; width=0; value=0)
Label(caption=" "; name=label_0002; left=365; top=29; width=0; value=0)
Group(caption="FRM3 DFlash->EEE "; left=10; top=95; width=270; height=50)
{
Label(caption="© by megaServis (2017)"; name=label_0003; left=65; top=29; width=0; value=0)
}
}
$HOST
#define MEM_DFLASH_SIZE 32768
#define MEM_EEE_SIZE 4096
emem dflash=0;
emem eee=1;
string str0, str1;
proc version(){
var i;
i = SW_VERSION;
mbox("Âåðñèÿ ñîôòà " +#i.i, 0);
}
proc prc_001F(offset, length){
var i;
for(i = 0; i < length; i++) {
eee[offset+i] = str1[i];
}
}
proc button_set_vin_0046(){
var v0, temp;
str1 = text_0000;
v0 = len(str1);
if(v0 != 17) {
if(WINDOW = 0) ShowWindow;
print(" Vin äîëæåí ñîäåðæàòü 17 ñèìâîëîâ!");
}
if(v0 != 17) {
temp = mbox(" Vin äîëæåí ñîäåðæàòü 17 ñèìâîëîâ! Do you confirm set new VIN?", 1);
if(temp = 0){
print("\nSet new VIN canceled by user.");
return;
}
prc_001F(0x0FD3, 17);
if(WINDOW = 0) ShowWindow;
print("\n new VIN writed to EEE bufer");
print("\n new VIN:" + str1);
return;
}
if(v0 = 17) {
temp = mbox("set new VIN?", 1);
if(temp = 0) {
print("\nSet new VIN canceled by user.");
return;
}
prc_001F(0x0FD3, 17);
if(WINDOW = 0) ShowWindow;
print("\n new VIN writed to EEE bufer");
print("\n new VIN: " + str1);
}
}
proc prc_0127(a0, a1){
var i, temp;
str0 = "";
for(i = 0; i < a1; i++) {
temp = eee[a0+i];
str0 = str0 + #c.temp;
}
}
proc button_get_vin_0162(){
prc_0127(0x0FD3, 17);
label_0002 = str0;
}
proc button_make_eee_0184(){
var i, v1, v2, v3, v4, j;
v3 = 0xB800;
j = 0;
v4 = 0;
if(WINDOW = 0) ShowWindow;
print("\n Separating records of ÅÅÅ...");
print("\n Partition of DataFlash mast be:");
print("\n DFPART==0x0000 (0Kb (0 *128 words) user Dataflesh)");
print("\n ERPART==0x0010 (4Kb (16*128 words) emulated eeprom)");
PBPOS = 0;
PBMAX = MEM_EEE_SIZE/2;
while(j < MEM_EEE_SIZE/2) {
for(i = 0; i < MEM_DFLASH_SIZE; i = i+4) {
v1 = dflash[i];
v2 = dflash[i+1];
v1 = v1 << 8;
v2 = v2 | v1;
if(v2 = v3+j) {
v1 = dflash[i+2];
v2 = dflash[i+3];
eee[j*2] = v1;
eee[j*2+1] = v2;
i = 0;
v4 = v4 + 2;
break;
}
}
j = j +1;
PBPOS = j;
}
print("\n GoTovo");
button_get_vin_0162();
}
proc button_check_dflash_0252(){
var i, v1, v2, v3, v4, j;
v3 = 0xB800;
j = 0;
v4 = 0;
if(WINDOW = 0) ShowWindow;
while(j < 1) {
for(i = 0; i < MEM_DFLASH_SIZE; i = i + 4) {
v1 = dflash[i];
v2 = dflash[i+1];
v1 = v1 << 8;
v2 = v2 | v1;
if(v2 = v3+j) {
v4 = 85;
v1 = dflash[i + 2];
v2 = dflash[i + 3];
v1 = v1 << 8;
v2 = v2 | v1;
if(v2 = 0xDEAD) {
print("\nÏîõîæ íà íîðìàëüíûé D_flash, âñå íå ïðîâåðÿë, íî");
print("\nïåðâûå çàïèñè ÅÅÅ è àòðèáóòû ñåêòîðîâ D_flash â íîðìå");
break;
} else {
print("\nFàéë ìîæíî âûáðîñèòü!");
}
break;
}
}
j += 1;
}
if(v4=0) {
print("\nDas is niht DataFlash!");
return;
}
print("\nÃîòîâî");
}
proc list_help_0310(){
if(list_0B42=0) {
if(WINDOW)
CloseWindow;
}
if(list_0B42 = 1) {
if(WINDOW = 0) ShowWindow;
print("\n 1 -çàãðóçèòå, ñ÷èòàííûé ïîäõîäÿùèì ïðîãåðîì,");
print("\n ôàéë DataFlash *.bin â D_Flash ðåäàêòîð");
print("\n 2 - íàæìèòå Make EEE, äîæäèòåñü çàâåðøåíèÿ ïðîöåäóðû");
print("\n (àêòèâíûé D_Flash ðåäàêòîð) ");
print("\n 3 - ñîõðàíèòå ñîäåðæèìîå ðåäàêòîðà ÅÅÅ â ôàéë .bin ");
print("\n Good Luck! ");
}
if(list_0B42 = 2) {
if(WINDOW = 0) ShowWindow;
print("\n (9s12xeq384) ");
print("\n Please see Freescale application note AN3490");
}
if(list_0B42 = 3) {
if(WINDOW = 0) ShowWindow;
print("\n (FRM3) ");
print("\n MCU: mc9s12xeq384mag 3M25J qfp144");
print("\n  áëî÷êå ñëåòàåò ðàçäåëåíèå Dflash, ïðè ýòîì áëîê íå äèàãíîñòèòñÿ,");
print("\n íå ðàáîòàþò ôàðû, ïîâîðîòíèêè è ò.ä.. Íî ïðè ýòîì ïîÿâëÿåòñÿ");
print("\n âîçìîõíîñòü ÷èòàòü âñå 32kÁ Dflash, à ñïîìîùüþ äàííîé ïðîãðàììêè");
print("\n <ñîáðàòü> îáëàñòü ýìóëÿöèè ååïðîì ");
print("\n Ïîýòîìó, äëÿ ðåìîíòà äîñòàòî÷íî: ïðî÷èòàòü Dflash, sobrat ÅÅÅ,");
print("\n ðàçäåëèòü Dflash (Full Partition) è çàïèñàòü ÅÅÅ ");
print("\n Âñå! áëî÷åê ñíîâà æèâîé è <ðîäíîé> äëÿ äàííîé ìàøèíû ");
print("\n Äëÿ ðàçíûõ ïðîãåðîâ èíòåðôåéñ ïîëçîâàòåëÿ ðàçíèòñÿ, íî â öåëîì");
print("\n ñöåíàðèé òàêîâ:");
print("\n * ");
print("\n 1 - read dataFlash safe it *.bin format and make EEE");
print("\n 2 - read partition (usually 0xFFFF 0xFFFF)");
print("\n change to 0x0000 0x0010 value and write it");
print("\n 3 - open EEE area load stored EEE file and write it");
print("\n *");
print("\n * ");
print("\n Mast be OK. Good luk!!!");
}
}
$DEVICE
byte unused[291];
proc unused_000() {
return(RANDOM);
}