123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- var ForReading = 1;
- var ForWriting = 2;
- var fPopMask = "znp-popmask.txt";
- function get_popmask() {
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- if (fso.FileExists(fPopMask)) {
- var fin = fso.OpenTextFile(fPopMask, ForReading);
- var mask = fin.Read(4);
- fin.Close();
- return (mask);
- }
- return "0000";
- }
- function set_popmask(mask) {
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var fout = fso.CreateTextFile(fPopMask, true);
- fout.WriteLine(mask);
- fout.WriteLine("The first byte of this file is a bit mask that forces the ZNP post processing");
- fout.WriteLine("to run popless for the corresponding build types.");
- fout.WriteLine("The bit mask is updated when the 'Cancel' button is pressed on a pop-up");
- fout.WriteLine("Simply delete this file to get all pop-ups back.");
- fout.Close();
- }
- function popup(idx, fName, pName) {
- var popmask = get_popmask();
-
- if (popmask.substr(idx, 1) != 0) {
- return;
- }
- var WshShell = WScript.CreateObject("WScript.Shell");
- var msg = "The output file can be found here:\n" + pName + fName;
- switch (idx) {
- case 1:
- msg += "\nThe .hex image is intended to be programmed and verified by a tool such as\
- \nthe TI SmartRF Programmer.";
- break;
- case 2:
- msg += "\nThe .bin image is intended to be programmed and verified by a tool that implements\
- \nthe SBL protocol such as the SBDemo.exe.\
- \nNOTE: The SBL must already be programmed into the target device, usually by having\
- \n already programmed the CC253xZNP-Prod.hex with a programming tool.";
- break;
- case 3:
- msg += "\nThe .hex image is intended to be programmed and verified by a tool such as the TI SmartRF Programmer.\
- \nNOTE: The checksum and shadow are forced to be equal, so external verification is crucial.";
- break;
- }
-
- var BtnCode = WshShell.Popup(msg, 30, fName + " is in the dev!", 1 + 64);
-
- if (BtnCode == 2) {
- var newmask = popmask.substring(0, idx) + 1 + popmask.substring(idx+1, 3);
- set_popmask(newmask);
- }
- }
- {
- var buildName = WScript.Arguments(0);
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var pZNP = fso.GetFile("znp.js");
- var fOut = buildName.substring(0, 6) + "ZNP" + buildName.substring(6, 11);
- var pOut = pZNP.Path.substr(0, pZNP.Path.length-12) + "dev";
- var pIn = pZNP.Path.substr(0, pZNP.Path.length-12) + buildName + "\\Exe\\";
- var fIn, fSBL;
- var buildType;
- var tgtType;
- if (!fso.FolderExists(pOut)) {
- fso.CreateFolder(pOut);
- }
- pOut += "\\";
- switch (buildName.substr(7)) {
- case "Debug":
- WScript.Quit(0);
- break;
- case "TestHex":
- buildType = 1;
- fOut += ".hex";
- break;
- case "ProdSBL":
- fIn = buildName.substring(0, 6) + ".sim"
- fOut += ".bin";
- buildType = 2;
- break;
- case "ProdHex":
- fIn = buildName.substring(0, 6) + ".a51"
- fOut += ".hex";
- buildType = 3;
- break;
- default:
-
- if ((buildName.substr(6, 3) == "Rel") || (buildName.substr(6, 3) == "-MK"))
- {
- pOut = pZNP.Path.substr(0, pZNP.Path.length-12) + "bin\\";
- fIn = buildName.substring(0, 9) + ".a51"
- if (buildName.substr(6, 3) == "Rel")
- {
- fOut = buildName.substring(0, 6) + "ZNP" + buildName.substr(9) + ".hex";
- }
- else
- {
- fOut = buildName.substring(0, 6) + "-MK" + buildName.substr(9) + ".hex";
- }
- buildType = 3;
- }
- else
- {
- WScript.Quit(0);
- }
- break;
- }
- switch (buildName.substr(5, 1)) {
- case "0":
- tgtType = 0;
- if (buildName.substr(6, 3) == "-MK")
- {
- fSBL = pZNP.Path.substr(0, pZNP.Path.length-12) + "bin\\CC2530-MK-SB.hex";
- }
- else
- {
- fSBL = pZNP.Path.substr(0, pZNP.Path.length-12) + "bin\\CC2530ZNP-SB.hex";
- }
- break;
- case "1":
- tgtType = 1;
- fSBL = pZNP.Path.substr(0, pZNP.Path.length-12) + "bin\\CC2531SB.hex";
- break;
- }
- switch (buildType) {
- case 1:
- fso.CopyFile(pIn+fOut, pOut+fOut, true);
- break;
- case 2:
- fso.CopyFile(pIn+fIn, "tmp.sim", true);
- var WshShell = new ActiveXObject("WScript.Shell");
-
- WshShell.Run("sim2bin.exe tmp.sim tmp.bin", 8, true);
- fso.CopyFile("tmp.bin", pOut+fOut, true);
- fso.DeleteFile("tmp.bin");
- fso.DeleteFile("tmp.sim");
- break;
- case 3:
- var fin = fso.OpenTextFile(fSBL, ForReading)
- var fout = fso.CreateTextFile(pOut+fOut, true);
- var line = new Array(3);
- var rIdx = 2;
- var wIdx = 0;
-
- line[0] = fin.ReadLine();
- line[1] = fin.ReadLine();
- while (1)
- {
- fout.WriteLine(line[wIdx]);
- line[rIdx] = fin.ReadLine();
- if (fin.AtEndOfStream)
- {
- break;
- }
- rIdx = (rIdx+1) % 3;
- wIdx = (wIdx+1) % 3;
- }
- fin.Close();
- fin = fso.OpenTextFile(pIn+fIn, ForReading)
- fin.ReadLine();
- while (!fin.AtEndOfStream)
- {
- var s = fin.ReadLine();
- fout.WriteLine(s);
- }
- fin.Close();
- fout.Close();
- break;
- }
- popup(buildType, fOut, pOut);
- }
|