-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
44 lines (34 loc) · 1.09 KB
/
Program.cs
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
using System;
using System.IO;
namespace STM32Programmer
{
internal class Program
{
public static int Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("HELP: \nPass path to bin file as argument");
Console.WriteLine("Example: STM32Programmer C:\\file.bin");
return 0;
}
if (!Utils.CheckFile(args[0]))
return 1;
// Startup CRC tests
CRC.SanityCheck();
Bootloader bootloader = new Bootloader();
if (!bootloader.Echo())
return 1;
FileStream file = File.OpenRead(args[0]);
if(!bootloader.SetFirmwareSize((uint)file.Length))
return 1;
if (!bootloader.UpdateFirmware(args[0]))
return 1;
if (!bootloader.VerifyChecksum(file))
return 1;
// TODO: jump to app after prompt
//Console.WriteLine("Are you jump to the application now? ()")
return 0;
}
}
}