Skip to content

Commit 53c65ea

Browse files
author
QuantAsylum
committed
Release 1.5
Signed-off-by: QuantAsylum <git@quantasylum.com>
1 parent 2dbd665 commit 53c65ea

File tree

17 files changed

+3520
-103
lines changed

17 files changed

+3520
-103
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*.ico
66
*.png
77
Exclude.txt
8+
Setup*/
9+
MSP430 Workspace - Copy*/
810

911
#
1012
# Visual Studio

Application/QA350/QA350/Bootloader.cs

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,47 @@ static class Bootloader
2929

3030
static public void EnterBootloader()
3131
{
32+
const string bootstrapFile = "RAM_BSL.00.07.08.38.bsl";
33+
3234
OpenFileDialog ofd = new OpenFileDialog();
33-
ofd.Filter = "Text Files|*.txt";
35+
ofd.Filter = "Boot Files|*.boot";
3436
ofd.Title = "Enter flash file";
3537
ofd.CheckFileExists = true;
38+
ofd.FileName = "QA350.boot";
39+
ofd.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
3640

3741
if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
3842
return;
3943

44+
// Make sure boottloader is valid
45+
if (VerifyValidBootloader(ofd.FileName) == false)
46+
{
47+
MessageBox.Show("This doesn't appear to be a valid bootloader file. Reflash will be aborted.");
48+
return;
49+
}
50+
51+
// Make sure the bootloader boostrap exists
52+
if (File.Exists(bootstrapFile) == false)
53+
{
54+
MessageBox.Show("The bootstrap file is missing. Reflash will be aborted.");
55+
return;
56+
}
57+
58+
if (VerifyValidBootstrap(bootstrapFile) == false)
59+
{
60+
MessageBox.Show("This doesn't appear to be a valid bootsrap file. Reflash will be aborted.");
61+
return;
62+
}
63+
4064
// Tell the device to enter BSL if we're already connected
4165
if (Hardware.IsConnected && Hardware.USBSendData(new byte[] { 0xFF, 0x00 }))
4266
{
4367
Thread.Sleep(4000);
4468
}
4569

46-
47-
// Now reconnect with BL
70+
// Now reconnect with BL. Do not enter this section of code if
71+
// everything you need isn't verified. Becuase failure inside here
72+
// probably means a bricked device.
4873
try
4974
{
5075
Hardware.OpenBSL();
@@ -53,8 +78,10 @@ static public void EnterBootloader()
5378
SubmitPassword(); // This might fail and perform mass erase
5479
SubmitPassword(); // This will always succeed and perform mass erase
5580

81+
// Once we are mass-erased, then the bootloader will always run at start
82+
5683
// Load ram-based BSL
57-
WriteFlash("RAM_BSL.00.07.08.38.txt", true);
84+
WriteFlash(bootstrapFile, true);
5885

5986
// Run ram-based BSL
6087
SetPC(0x2504);
@@ -74,6 +101,7 @@ static public void EnterBootloader()
74101
catch (Exception ex)
75102
{
76103
Debug.WriteLine("Exception during update: " + ex.Message);
104+
MessageBox.Show("An exception occured during reflash: " + ex.Message);
77105
}
78106
}
79107

@@ -150,6 +178,26 @@ static void MassErase()
150178

151179
}
152180

181+
static bool VerifyValidBootstrap(string fileName)
182+
{
183+
string[] lines = File.ReadAllLines(fileName);
184+
185+
if (lines[0] == "@2500" && lines[lines.Length - 1] == "q")
186+
return true;
187+
else
188+
return false;
189+
}
190+
191+
static bool VerifyValidBootloader(string fileName)
192+
{
193+
string[] lines = File.ReadAllLines(fileName);
194+
195+
if (lines[0] == "@4400" && lines[lines.Length-1] == "q")
196+
return true;
197+
else
198+
return false;
199+
}
200+
153201
/// <summary>
154202
/// Parses the specified ram-based bootloader file (provided by TI) and sends
155203
/// it down to the MSP430, and then execute the ram-based file. This is needed

Application/QA350/QA350/Constants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ class Constants
1111
static public string DataFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\QuantAsylum\QA350\";
1212
static public string CalibrationFile = DataFilePath + "CalibrationData.xml";
1313
static public string SettingsFile = DataFilePath + "QA350Settings.xml";
14+
15+
static public double Version = 1.5;
16+
17+
static public Int32 RequiredFwVersion = 6;
1418
}
1519
}

Application/QA350/QA350/DlgEditStats.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Application/QA350/QA350/DlgEditStats.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public DlgEditStats(Settings settings) : this()
4242
numericUpDown4.Value = Convert.ToDecimal(AppSettings.HistoBinInUV);
4343
numericUpDown5.Value = Convert.ToDecimal(AppSettings.HistoBinInMV);
4444

45-
numericUpDown6.Value = Convert.ToDecimal(AppSettings.BinCount);
45+
numericUpDown6.Value = Convert.ToDecimal(AppSettings.SampleHistory);
4646

4747
}
4848

@@ -72,7 +72,7 @@ private void button4_Click(object sender, EventArgs e)
7272
AppSettings.HistoBinInUV = Convert.ToInt32(numericUpDown4.Value);
7373
AppSettings.HistoBinInMV = Convert.ToInt32(numericUpDown5.Value);
7474

75-
AppSettings.BinCount = Convert.ToInt32(numericUpDown6.Value);
75+
AppSettings.SampleHistory = Convert.ToInt32(numericUpDown6.Value);
7676

7777
Close();
7878
}

0 commit comments

Comments
 (0)