|
@@ -7,13 +7,150 @@
|
7
|
7
|
|
8
|
8
|
|
9
|
9
|
#include "main.h"
|
|
10
|
+#include <stdbool.h>
|
10
|
11
|
#include "MBIC_Bootloader.h"
|
11
|
12
|
|
|
13
|
+#define MARK_START_POSITION 0
|
|
14
|
+#define TYPE_START_POSITION 9
|
|
15
|
+#define FILE_TYPE_START_POSITION 10
|
|
16
|
+#define VERSION_START_POSITION 11
|
|
17
|
+#define FILENAME_START_POSITION 14
|
|
18
|
+#define CREATION_TIME_START_POSITION 55
|
|
19
|
+#define LENGTH_START_POSITION 61
|
|
20
|
+#define CRC_START_POSITION 65
|
|
21
|
+#define RESERVED_START_POSITION 69
|
|
22
|
+typedef struct{
|
|
23
|
+ uint16_t Length;
|
|
24
|
+ uint16_t Crcchk;
|
|
25
|
+ bool FileChk;
|
|
26
|
+}BootLoaderDataCheck_st;
|
12
|
27
|
|
13
|
|
-void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
|
14
|
28
|
|
|
29
|
+BootLoaderDataCheck_st MBIC_FileDataCheck(uint8_t* data){
|
|
30
|
+ BootLoaderDataCheck_st ret = {0,0,false};
|
|
31
|
+ int8_t MBIC_Mark[9] = "JT-NRDAS ";
|
|
32
|
+ int8_t MBIC_FileName1[] = "jhfs-mbic-nrdas-v";
|
|
33
|
+ int8_t MBIC_FileName2[] = "v00.00.01.mbc";
|
|
34
|
+ uint8_t MBIC_type = 0x20;
|
|
35
|
+ uint8_t MBIC_FileType = 0x00;
|
|
36
|
+ int i = 0;
|
|
37
|
+ /***
|
|
38
|
+ MARK Check
|
|
39
|
+ ***/
|
|
40
|
+ for(i = MARK_START_POSITION; i < TYPE_START_POSITION; i++){
|
|
41
|
+ if(MBIC_Mark[i] != data[i]){
|
|
42
|
+ printf("Data Diff \r\n");
|
|
43
|
+ return ret;
|
|
44
|
+ }else{
|
|
45
|
+ printf("MARK Data Success \r\n");
|
|
46
|
+ }
|
|
47
|
+ }
|
|
48
|
+ /***
|
|
49
|
+ TYPE Check
|
|
50
|
+ ***/
|
|
51
|
+ for(i = TYPE_START_POSITION; i < FILE_TYPE_START_POSITION; i++){
|
|
52
|
+ if(MBIC_type != data[i]){
|
|
53
|
+ printf("Data Diff \r\n");
|
|
54
|
+ return ret;
|
|
55
|
+ }
|
|
56
|
+ else
|
|
57
|
+ printf("Type Data Success \r\n");
|
|
58
|
+ }
|
|
59
|
+ /***
|
|
60
|
+ File Type Check
|
|
61
|
+ ***/
|
|
62
|
+ for(i = FILE_TYPE_START_POSITION; i < VERSION_START_POSITION; i++){
|
|
63
|
+ if(MBIC_FileType != data[i]){
|
|
64
|
+ printf("Data Diff \r\n");
|
|
65
|
+ return ret;
|
|
66
|
+ }
|
|
67
|
+ else
|
|
68
|
+ printf("File Type Data Success \r\n");
|
|
69
|
+ }
|
|
70
|
+ /***
|
|
71
|
+ Version Check
|
|
72
|
+ ***/
|
|
73
|
+ for(i = VERSION_START_POSITION; i < FILENAME_START_POSITION; i++){
|
|
74
|
+ printf("Version Data Success Version %x\r\n",data[i]);
|
|
75
|
+ }
|
|
76
|
+ /***
|
|
77
|
+ File Name Check
|
|
78
|
+ ***/
|
|
79
|
+ for(i = FILENAME_START_POSITION; i < 30; i++){
|
|
80
|
+ if(MBIC_FileName1[i-14] != data[i]){
|
|
81
|
+ printf("Data Diff \r\n");
|
|
82
|
+ printf("MBIC_FileName1[%d] : %x, data[%d] : %x\r\n",i - 14,MBIC_FileName1[i - 14],i,data[i]);
|
|
83
|
+ return ret;
|
|
84
|
+ }
|
|
85
|
+ else
|
|
86
|
+ printf("File Name Data Success %c\r\n",data[i]);
|
|
87
|
+ }
|
|
88
|
+ for(i = i; i < 43; i++){
|
|
89
|
+ if(MBIC_FileName2[i-30] != data[i]){
|
|
90
|
+ printf("Data Diff %c\r\n",data[i]);
|
|
91
|
+ printf("MBIC_FileName2[%d] : %x, data[%d] : %x\r\n",i - 30,MBIC_FileName2[i - 30],i,data[i]);
|
|
92
|
+ return ret;
|
|
93
|
+ }
|
|
94
|
+ else
|
|
95
|
+ printf("File Name Data Success %c\r\n",data[i]);
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+ for(i = i; i < 49; i++){
|
|
99
|
+ printf("Creation Success %x\r\n",data[i]);
|
|
100
|
+ }
|
|
101
|
+ for(i = i; i < 55; i++){
|
|
102
|
+ printf("Creation Success data[%d] : %x\r\n",i,data[i]);
|
|
103
|
+ }
|
|
104
|
+ printf(" %d",data[i++]);
|
|
105
|
+ printf(" -%02d",data[i++]);
|
|
106
|
+ printf(" -%02d",data[i++]);
|
|
107
|
+ printf(" -%02d",data[i++]);
|
|
108
|
+ printf(" -%02d",data[i++]);
|
|
109
|
+ printf(" -%02d\r\n",data[i++]);
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+ ret.Length = ((data[i++] << 8) & 0xFF00);
|
|
114
|
+ ret.Length += (data[i++]);
|
|
115
|
+ printf("data[%d] : %d\r\n",i - 1,ret.Length);
|
|
116
|
+ printf("data[%d] : %d\r\n",i - 1,ret.Length);
|
|
117
|
+
|
|
118
|
+ ret.Crcchk = ((data[i++] << 8) & 0xFF00);
|
|
119
|
+ ret.Crcchk += (data[i++]);
|
|
120
|
+
|
|
121
|
+ printf("CRC_H[%d] : %x\r\n",i,ret.Crcchk);
|
|
122
|
+ printf("CRC_L[%d] : %x\r\n",i,ret.Crcchk);
|
|
123
|
+
|
|
124
|
+ ret.FileChk = true;
|
|
125
|
+ return ret;
|
|
126
|
+}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
|
15
|
131
|
uint8_t datatype = data[MBIC_PAYLOADSTART];
|
16
|
132
|
|
|
133
|
+#if 0 // PYJ.2020.06.04_BEGIN --
|
|
134
|
+ uint8_t dataTest[1024] = {
|
|
135
|
+ 0x4A,0x54,0x2D,0x4E,0x52,0x44,0x41,0x53,0x20,0x20,0x00,0x00,
|
|
136
|
+ 0x00,0x01,0x6A,0x68,0x66,0x73,0x2D,0x6D,0x62,0x69,0x63,0x2D,
|
|
137
|
+ 0x6E,0x72,0x64,0x61,0x73,0x2D,0x76,0x30,0x30,0x2E,0x30,0x30,0x2E,
|
|
138
|
+ 0x30,0x31,0x2E,0x6D,0x62,0x63,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
|
139
|
+ 0x20,0x20,0x20,0x20,0x20,0x14,0x06,0x03,0x10,0x1F,0xC4,0x3C,0x49,
|
|
140
|
+ 0x42,0x98,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
141
|
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
142
|
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
143
|
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
144
|
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
|
145
|
+ };
|
|
146
|
+ MBIC_FileDataCheck(dataTest);
|
|
147
|
+
|
|
148
|
+#endif // PYJ.2020.06.04_END --
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+// printf("RX");
|
|
152
|
+// for(int i = 0; i < 128; i++)
|
|
153
|
+// printf("%c",*data++);
|
17
|
154
|
switch(datatype){
|
18
|
155
|
case MBIC_Notice_REQ:
|
19
|
156
|
|