@libs-scripts-mep/grav-fw-pvi 3.1.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/grav-fw-pvi.js +67 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Biblioteca que auxilia na gravação de microcontroladores por linha de comando
|
|
|
4
4
|
|
|
5
5
|
## Instalando
|
|
6
6
|
|
|
7
|
+
> ### ⚠️ Compatibilidade PVI: [>= v4.8.0.0](https://git.inova.ind.br/Inova/PVI/releases/tag/4.8.0.0-beta0)
|
|
8
|
+
|
|
7
9
|
Abra o terminal, e na pasta do script, execute:
|
|
8
10
|
|
|
9
11
|
```
|
package/grav-fw-pvi.js
CHANGED
|
@@ -7,7 +7,7 @@ export default class GravaFW {
|
|
|
7
7
|
* @param {String} dirFirm
|
|
8
8
|
* @param {String} dirOpt
|
|
9
9
|
* @param {Object} objArguments
|
|
10
|
-
* @param {Number} timeOut
|
|
10
|
+
* @param {Number} [timeOut=5000]
|
|
11
11
|
* @returns
|
|
12
12
|
*
|
|
13
13
|
* # Exemplos
|
|
@@ -33,6 +33,7 @@ export default class GravaFW {
|
|
|
33
33
|
if (dirFirm != null && dirOpt != null) { validationMsg = `Verify OPTION BYTE succeeds` }
|
|
34
34
|
else if (dirFirm != null) { validationMsg = `Verifying PROGRAM MEMORY succeeds` }
|
|
35
35
|
else if (dirOpt != null) { validationMsg = `Verify OPTION BYTE succeeds` }
|
|
36
|
+
else { validationMsg = "error" }
|
|
36
37
|
|
|
37
38
|
let ObjWriteSTM8 = await defineWriteSTM8(dirFirm, dirOpt, objArguments)
|
|
38
39
|
|
|
@@ -88,7 +89,7 @@ export default class GravaFW {
|
|
|
88
89
|
resolve({ success: false, msg: `Nenhum diretório de firmware ou option byte informado` })
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
FWLink.runInstructionS("EXEC", [
|
|
92
|
+
FWLink.runInstructionS("EXEC", [`${FWLink.runInstructionS("GETRESOURCESPATH", [])}\\stvp\\STVP_CmdLine.exe`, ObjWriteSTM8.commandLineArguments, "true", "true"])
|
|
92
93
|
|
|
93
94
|
})
|
|
94
95
|
|
|
@@ -143,14 +144,13 @@ export default class GravaFW {
|
|
|
143
144
|
/**
|
|
144
145
|
*
|
|
145
146
|
* @param {String} dirProject
|
|
146
|
-
* @param {Number} timeOut
|
|
147
|
+
* @param {Number} [timeOut=5000]
|
|
147
148
|
* @returns
|
|
148
149
|
*
|
|
149
150
|
* # Exemplos
|
|
150
151
|
*
|
|
151
152
|
* ```js
|
|
152
153
|
* const programPath = "I:/script_repo/fw_repo/fw_v1_0.2.rpj"
|
|
153
|
-
* const optionPath = "I:/script_repo/fw_repo/opt.hex"
|
|
154
154
|
* const writeFirmware = await GravaFW.Renesas(programPath)
|
|
155
155
|
* ```
|
|
156
156
|
*
|
|
@@ -209,7 +209,7 @@ export default class GravaFW {
|
|
|
209
209
|
|
|
210
210
|
}, "sniffer.exec")
|
|
211
211
|
|
|
212
|
-
FWLink.runInstructionS("EXEC", [`${FWLink.runInstructionS("
|
|
212
|
+
FWLink.runInstructionS("EXEC", [`${FWLink.runInstructionS("GETRESOURCESPATH", [])}/Renesas/RFPV3.Console.exe`, dirProject, "true", "true"])
|
|
213
213
|
|
|
214
214
|
let timeOutGravacao = setTimeout(() => {
|
|
215
215
|
|
|
@@ -225,48 +225,84 @@ export default class GravaFW {
|
|
|
225
225
|
})
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
|
|
228
229
|
/**
|
|
229
|
-
* Realiza gravacao nos microcontroladores Nuvoton atraves do PVI, via JLink command line
|
|
230
|
+
* Realiza gravacao nos microcontroladores Nuvoton atraves do PVI, via JLink command line.
|
|
231
|
+
*
|
|
230
232
|
* @param {string} dirProject caminho do firmware
|
|
231
|
-
* @param {string}
|
|
233
|
+
* @param {string} nameFile nome para o arquivo de comandos JLink que ficará na pasta 'C:/Temp/', sujestão: código effective
|
|
232
234
|
* @param {string} device modelo do micrcontrolador
|
|
233
|
-
* @param {number}
|
|
235
|
+
* @param {number} [speed=4000] velocidade de gravação
|
|
236
|
+
* @param {number} [timeOut=5000] tempo máximo de gravação
|
|
237
|
+
* @returns {Promise<{success: boolean, msg: string}>} - resultado da gravação
|
|
238
|
+
*
|
|
239
|
+
* # Exemplos
|
|
240
|
+
*
|
|
241
|
+
* ```js
|
|
242
|
+
* const programPath = "I:/script_repo/fw_repo/fw_v1_0.2.hex"
|
|
243
|
+
* const codigo_effective = "1234"
|
|
244
|
+
* const device = "STM32C031K6"
|
|
245
|
+
* const writeFirmware = await GravaFW.JLink_v7(programPath, codigo_effective, device)
|
|
246
|
+
* ```
|
|
247
|
+
*
|
|
248
|
+
* # Retorno
|
|
249
|
+
*
|
|
250
|
+
* ```js
|
|
251
|
+
* { success: Boolean, msg: String }
|
|
252
|
+
* ```
|
|
234
253
|
*/
|
|
235
|
-
static async JLink_v7(dirProject = null,
|
|
254
|
+
static async JLink_v7(dirProject = null, nameFile, device, speed = 4000, timeOut = 5000) {
|
|
236
255
|
|
|
237
|
-
|
|
256
|
+
return new Promise((resolve) => {
|
|
257
|
+
let logGravacao = ""
|
|
238
258
|
|
|
239
|
-
|
|
259
|
+
const id = FWLink.PVIEventObserver.add((msg, param) => {
|
|
240
260
|
|
|
241
|
-
|
|
242
|
-
|
|
261
|
+
console.log(`%cLog Program: ${param[0]}`, ' color: #B0E0E6')
|
|
262
|
+
logGravacao = logGravacao + param[0]
|
|
243
263
|
|
|
244
|
-
|
|
264
|
+
if (param == "Script processing completed.") {
|
|
245
265
|
|
|
246
|
-
|
|
266
|
+
FWLink.PVIEventObserver.remove(id)
|
|
247
267
|
|
|
248
|
-
|
|
268
|
+
if (logGravacao.includes('Program & Verify speed')) {
|
|
249
269
|
|
|
250
|
-
|
|
251
|
-
|
|
270
|
+
clearTimeout(timeOutGravacao)
|
|
271
|
+
resolve({ success: true, msg: dirProject })
|
|
252
272
|
|
|
253
|
-
|
|
273
|
+
} else if (logGravacao.includes(`Cannot connect to target.`)) {
|
|
254
274
|
|
|
255
|
-
|
|
256
|
-
|
|
275
|
+
clearTimeout(timeOutGravacao)
|
|
276
|
+
resolve({ success: false, msg: `Cannot connect to target.` })
|
|
257
277
|
|
|
258
|
-
|
|
278
|
+
}
|
|
259
279
|
|
|
260
|
-
|
|
261
|
-
|
|
280
|
+
}
|
|
281
|
+
}, "sniffer.exec")
|
|
262
282
|
|
|
263
|
-
|
|
283
|
+
const commandFile = commandJlink(nameFile, speed, dirProject)
|
|
284
|
+
FWLink.runInstructionS("EXEC", [`${FWLink.runInstructionS("GETPVIPATH", [])}\\Plugins\\JLINK7\\JLink.exe`, `-device ${device} -CommandFile ${commandFile}`, "true", "true"])
|
|
264
285
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
286
|
+
let timeOutGravacao = setTimeout(() => {
|
|
287
|
+
FWLink.PVIEventObserver.remove(id)
|
|
288
|
+
resolve({ success: false, msg: `Falha na gravação, verifique a conexão USB do gravador.` })
|
|
289
|
+
}, timeOut)
|
|
290
|
+
})
|
|
269
291
|
|
|
292
|
+
function commandJlink(nameFile, speed, dirProject) {
|
|
293
|
+
if (FWLink.runInstructionS("vfs.directoryexists", [`C:/Temp/`]) == '1') {
|
|
294
|
+
if (FWLink.runInstructionS("vfs.fileexists", [`C:/Temp/${nameFile}.txt`]) == '1') {
|
|
295
|
+
FWLink.runInstructionS("EXEC", ["cmd.exe", `/c (echo si 1 & echo speed ${speed} & echo r & echo h & echo erase & echo loadfile ${dirProject} & echo exit) > C:/Temp/${nameFile}.txt`, true, true])
|
|
296
|
+
return `C:/Temp/${nameFile}.txt`
|
|
297
|
+
} else {
|
|
298
|
+
FWLink.runInstructionS("EXEC", ["cmd.exe", `/c (echo texto invalido) > C:/Temp/${nameFile}.txt`, true, true])
|
|
299
|
+
return commandJlink(nameFile, speed, dirProject)
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
FWLink.runInstructionS("vfs.createdirectory", [`C:/Temp/`])
|
|
303
|
+
return commandJlink(nameFile, speed, dirProject)
|
|
304
|
+
}
|
|
305
|
+
}
|
|
270
306
|
}
|
|
271
307
|
|
|
272
308
|
|
|
@@ -364,4 +400,6 @@ export default class GravaFW {
|
|
|
364
400
|
})
|
|
365
401
|
}
|
|
366
402
|
|
|
403
|
+
static { window.GravaFW = GravaFW }
|
|
404
|
+
|
|
367
405
|
}
|