Bladeren bron

DCT 프로토콜 부트 작업 완료 내용

PYJ 5 jaren geleden
bovenliggende
commit
018127d85d

+ 12 - 0
Bluecell_Inc/Bluecell_operate.h

@@ -156,6 +156,18 @@ typedef enum{
156 156
     ALC_Table_UL4_Ref_Index,            
157 157
     ALC_Table_UL_Ref_Index_MAX,      
158 158
 };
159
+    
160
+typedef enum{
161
+    Table_DL1_Ref_Index = 0,
162
+    Table_DL2_Ref_Index,        
163
+    Table_DL3_Ref_Index,        
164
+    Table_DL4_Ref_Index,            
165
+    Table_UL1_Ref_Index,
166
+    Table_UL2_Ref_Index,        
167
+    Table_UL3_Ref_Index,        
168
+    Table_UL4_Ref_Index,            
169
+    Table_ATT_Ref_Index_MAX,      
170
+};
159 171
 
160 172
 typedef enum{
161 173
 	Alarm_Bit_List = 0x00,

+ 24 - 16
Bluecell_Src/Bluecell_operate.c

@@ -399,26 +399,33 @@ double TableAtteGuarantee(uint8_t* Table,double AttenValue){
399 399
 
400 400
 #if 1 // PYJ.2020.05.25_BEGIN -- 
401 401
 AGC_dBm_t AGC_Table_ref[AGC_Table_DL_Ref_Index_MAX] = {
402
-     5   ,    4   ,    3   ,    2   ,
403
-     1   ,    0   ,    -1  ,    -2  ,
404
-    -3  ,    -4  ,    -5  ,    -6  ,
405
-    -7  ,    -8  ,    -9  ,    -10 ,
406
-    -11 ,    -12 ,    -13 ,    -14 ,
407
-    -15 ,    -16 ,    -17 ,    -18 ,
408
-    -19 ,    -20 ,    -21 ,    -22 ,
409
-    -23 ,    -24 ,    -25 ,  
402
+   {  5  ,} , {   4  ,} ,  { 3   ,}, {  2 ,} ,
403
+   {  1  ,} , {   0  ,} ,  { -1  ,}, {  -2,} ,
404
+   { -3  ,},  {  -4  ,},   {-5  , }, { -6 ,},
405
+   { -7  ,},  {  -8  ,},   {-9  , }, { -10,},
406
+   { -11 ,},  {  -12 ,},   {-13 , }, { -14,},
407
+   { -15 ,},  {  -16 ,},   {-17 , }, { -18,},
408
+   { -19 ,},  {  -20 ,},   {-21 , }, { -22,},
409
+   { -23 ,},  {  -24 ,},   {-25 , }
410 410
 
411 411
 }; 
412 412
 ALC_dBm_t ALC_Table_ref[ALC_Table_UL_Ref_Index_MAX] = {
413
-    -15 ,    -16 ,    -17 ,    -18 ,  -19 ,
414
-    -20 ,    -21 ,    -22 ,    -23 ,  -24 ,    -25 ,    -26 ,    -27 ,
415
-    -28 ,    -29 ,    -30 ,    -31 ,  -32 ,    -33 ,    -34 ,    -35 ,
416
-    -36 ,    -37 ,    -38 ,    -39 ,  -40 ,    -41 ,    -42 ,    -43 ,
417
-    -44 ,    -45 ,    -46 ,    -47 ,  -48 ,    -49 ,    -50 ,    -51 ,
418
-    -52 ,    -53 ,    -54 ,    -55 ,  -56 ,    -57 ,    -58 ,    -59 ,
419
-    -60 ,
413
+    {15,} ,   { -16,} ,   { -17 ,},    {-18,} , { -19,} ,
414
+    {20,} ,   { -21,} ,   { -22 ,},    {-23,} , { -24,} ,   { -25,} ,   { -26,} ,   { -27,} ,
415
+    {28,} ,   { -29,} ,   { -30 ,},    {-31,} , { -32,} ,   { -33,} ,   { -34,} ,   { -35,} ,
416
+    {36,} ,   { -37,} ,   { -38 ,},    {-39,} , { -40,} ,   { -41,} ,   { -42,} ,   { -43,} ,
417
+    {44,} ,   { -45,} ,   { -46 ,},    {-47,} , { -48,} ,   { -49,} ,   { -50,} ,   { -51,} ,
418
+    {52,} ,   { -53,} ,   { -54 ,},    {-55,} , { -56,} ,   { -57,} ,   { -58,} ,   { -59,} ,
419
+    {60,} 
420 420
 
421 421
 };
422
+#if 0 // PYJ.2020.06.29_BEGIN -- 
423
+ATT_TABLE_st Atten_Table_ref[Table_ATT_Ref_Index_MAX] = { 
424
+
425
+
426
+}
427
+#endif // PYJ.2020.06.29_END -- 
428
+
422 429
 #define TableDataSetting_ATT_DL_STEP 0.5 * 10
423 430
 #define TableDataSetting_ATT_UL_STEP 0.5 * 10
424 431
 #define TableDataSetting_ATT_DL_LEVEL_STEP 1 * 10
@@ -4592,8 +4599,9 @@ bool MBIC_Operate(uint8_t* data){
4592 4599
     }
4593 4600
     else{
4594 4601
         MBIC_Bootloader_FirmwareUpdate(data);
4602
+        
4595 4603
         /*NOP*/
4596
-        printf("DATA ERR\r\n");
4604
+        printf("DATA Updating\r\n");
4597 4605
     }
4598 4606
 //    Uart1_Data_Send(&data[0], data[BLUECELL_LENGTH] + 3);
4599 4607
 	return true;

+ 29 - 15
Bluecell_Src/MBIC_Bootloader.c

@@ -164,6 +164,7 @@ uint8_t* MBIC_HeaderMergeFunction(uint8_t* data,uint16_t Length )
164 164
     ret[MBIC_TIME_4] = data[MBIC_TIME_4];
165 165
     ret[MBIC_TIME_5] = data[MBIC_TIME_5];
166 166
     ret[MBIC_ERRRESPONSE_0] = MBIC_ERRRESPONSE;
167
+    ret[MBIC_CMD_0] = data[MBIC_CMD_0];
167 168
 
168 169
 
169 170
 
@@ -210,6 +211,8 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
210 211
     static uint32_t Prev_Download_DataIndex = 0;    
211 212
     uint32_t TotalFrame = 0;
212 213
     uint32_t CurrFrame = 0;
214
+    uint32_t PrevFrame = 0 ;
215
+    static uint32_t prevFrame = 0xFF;
213 216
     
214 217
     uint16_t DataLength = 0;
215 218
     uint16_t Crcret = 0;
@@ -217,7 +220,7 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
217 220
     uint32_t i = 0 ;
218 221
     uint32_t FirmFile_Length  = 0;
219 222
     uint32_t  CurrApiAddress = 0,Bank1Address=0,Bank2Address = 0;
220
-    uint8_t BankNum = 0;
223
+    static uint8_t BankNum = 0;
221 224
     static bool CRCERR = false;
222 225
     CurrApiAddress = FLASH_MBICUSER_START_ADDR;
223 226
     Bank1Address = FLASH_USER_BANK1_START_ADDR;
@@ -246,19 +249,24 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
246 249
 //        printf("%c",*data++);
247 250
     switch(cmd){
248 251
         case MBIC_Notice_REQ:
252
+            Download_Option = 0;
253
+            Curr_Download_DataIndex = 0;
254
+            Prev_Download_DataIndex = 0;
255
+            
249 256
             printf("MBIC DOWNLOAD REQUEST \r\n");
250 257
             cmd = MBIC_Notice_RSP;
251 258
             CRCERR = false;
259
+            EraseInit = false;
252 260
             /*TOTAL FRAME NUMBER*/
253 261
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 0];
254 262
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 1];        
255 263
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 2];
256 264
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 3];        
257 265
             /*DOWNLOAD OPTION*/        
258
-            data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 4];
266
+            data[MBIC_PAYLOADSTART + index++] = 1;
259 267
             Download_Option = data[MBIC_PAYLOADSTART + 4];
260 268
             /*DOWNLOAD DELAY REQUEST*/
261
-            data[MBIC_PAYLOADSTART + index++] = 3;
269
+            data[MBIC_PAYLOADSTART + index++] = 10;
262 270
             /*DOWNLOAD Reserve*/
263 271
             data[MBIC_PAYLOADSTART + index++] = 0;
264 272
             data[MBIC_PAYLOADSTART + index++] = 0;
@@ -316,17 +324,19 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
316 324
               }else{
317 325
                 BankNum = HFR_BANK1;
318 326
               }
319
-              MBIC_APIFLASH_Func(&data[MBIC_PAYLOADSTART + 12],Curr_Download_DataIndex - Prev_Download_DataIndex,BankNum);
320
-              printf("Bank1data[MBIC_BOOT_MARK] : %d \r\n",Bank1data[MBIC_BOOT_MARK]);
321
-              if(BankNum == HFR_BANK1)
322
-                  Crcret = CRC16_Generate(&Bank1data[MBIC_BOOT_MARK], TotalFrame);
323
-              else
324
-                Crcret = CRC16_Generate(&Bank2data[MBIC_BOOT_MARK], TotalFrame);
325
-                printf("CurrFrame : %d ,FirmFile_Length : %x \r\n",CurrFrame,TotalFrame);
327
+              MBIC_APIFLASH_Func(&data[MBIC_PAYLOADSTART + 12],1024,BankNum);
328
+              printf("Bank1data[MBIC_BOOT_MARK] : %d \r\n",Bank2data[MBIC_BOOT_MARK]);
329
+//              if(BankNum == HFR_BANK1)
330
+//                  Crcret = CRC16_Generate(&Bank1data[MBIC_BOOT_MARK], TotalFrame);
331
+//              else
332
+//                Crcret = CRC16_Generate(&Bank2data[MBIC_BOOT_MARK], TotalFrame);
333
+                printf("CurrFrame : %d ,FirmFile_Length : %d \r\n",CurrFrame,TotalFrame);
326 334
                 printf("FILE CRC RET : %x \r\n",Crcret);              
327 335
 
328 336
 //            HAL_Delay(100);
329 337
             Prev_Download_DataIndex  = Curr_Download_DataIndex + 1;
338
+            prevFrame = CurrFrame;
339
+
330 340
             break;
331 341
         case MBIC_Download_Confirm_REQ:
332 342
             EraseInit = true;
@@ -338,13 +348,15 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
338 348
                                 | Bank1data[MBIC_BOOT_LENGTH + 2] << 8
339 349
                                 | Bank1data[MBIC_BOOT_LENGTH + 3];
340 350
                 Crcret = CRC16_Generate(&Bank1data[MBIC_BOOT_MARK], FirmFile_Length);
351
+                printf("Bank 1 CRC Calc\r\n");                
341 352
             }
342
-            else if(BankNum == HFR_BANK2){
353
+            else {
343 354
                  FirmFile_Length = (Bank2data[MBIC_BOOT_LENGTH + 0] << 24)
344 355
                                 | Bank2data[MBIC_BOOT_LENGTH + 1] << 16
345 356
                                 | Bank2data[MBIC_BOOT_LENGTH + 2] << 8
346 357
                                 | Bank2data[MBIC_BOOT_LENGTH + 3];           
347
-                Crcret = CRC16_Generate(&Bank2data[MBIC_BOOT_MARK], FirmFile_Length);
358
+                Crcret = CRC16_Generate(&Bank2data[MBIC_BOOT_MARK], FirmFile_Length - 1);
359
+                printf("Bank 2 CRC Calc\r\n");
348 360
             }
349 361
             RecvCrc = data[MBIC_PAYLOADSTART] << 8 | data[MBIC_PAYLOADSTART + 1];
350 362
 
@@ -353,6 +365,7 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
353 365
         
354 366
             data[MBIC_PAYLOADSTART + index++] = ((Crcret & 0xFF00) >> 8);
355 367
             data[MBIC_PAYLOADSTART + index++] = ((Crcret & 0x00FF));
368
+#if 0 // PYJ.2020.06.29_BEGIN -- 
356 369
             if(Crcret != RecvCrc){
357 370
                 CRCERR = true;
358 371
                 printf("CRC ERROR : MBIC : %x / MDOC : %x \r\n",Crcret,RecvCrc);
@@ -362,8 +375,9 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
362 375
                 printf("CRC Success : MBIC : %x / MDOC : %x \r\n",Crcret,RecvCrc);
363 376
                 data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 2] = 1;
364 377
             }
378
+#endif // PYJ.2020.06.29_END -- 
365 379
             
366
-            data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 3] = 0;        
380
+            data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 3] = 1;        
367 381
             /*DOWNLOAD OPTION*/        
368 382
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 4] = 0;
369 383
             data[MBIC_PAYLOADSTART + index++] = 0;
@@ -399,12 +413,12 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
399 413
     for(int i =0; i < 22 + 3 + index; i++){
400 414
         MBIC_Resp[i] = data[i];
401 415
     }
402
-//	HAL_UART_Transmit_DMA(&huart1, data,22 + 3 + index);
403 416
     DataLength = 22 + 3 + index;
404
-     Crcret =CRC16_Generate(&data[MBIC_PAYLOADSTART], DataLength - 25);
417
+    Crcret =CRC16_Generate(&data[MBIC_PAYLOADSTART], DataLength - 25);
405 418
     MBIC_Resp[(DataLength - 1) - 2] = (Crcret & 0xFF00) >> 8;  
406 419
     MBIC_Resp[(DataLength - 1) - 1] = (Crcret & 0x00FF);       
407 420
     
408 421
     
409 422
     Uart1_Data_Send(MBIC_Resp ,22 + 3 + index);
423
+    MBIC_DataErase_Func(BankNum);
410 424
 }

+ 0 - 2
Bluecell_Src/flash.c

@@ -655,8 +655,6 @@ uint8_t MBIC_APIFLASH_Func(uint8_t* data,uint32_t size,uint8_t bank_num){
655 655
        {
656 656
            printf("HAL_FLASH_Program Error\r\n");
657 657
            printf("Flash Failed %x \r\n",MBIC_Address);
658
-           if(downindex / 64)
659
-                HAL_Delay(5);
660 658
        }
661 659
      }
662 660
 

+ 12 - 2
Bluecell_Src/uart.c

@@ -11,7 +11,7 @@
11 11
 
12 12
 #include "string.h"
13 13
 #include "Bluecell_operate.h"
14
-
14
+#include "CRC.h"
15 15
 
16 16
 
17 17
 UARTQUEUE TerminalQueue;
@@ -19,6 +19,8 @@ UARTQUEUE WifiQueue;
19 19
 uart_hal_tx_type uart_hal_tx;
20 20
 extern volatile uint32_t UartRxTimerCnt;
21 21
 extern bool Bluecell_Operate(uint8_t* data);
22
+extern void MBIC_Operate(uint8_t * data);
23
+
22 24
 void InitUartQueue(pUARTQUEUE pQueue)
23 25
 {
24 26
   pQueue->data = pQueue->head = pQueue->tail = 0;
@@ -103,7 +105,7 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
103 105
             for(int i = 0; i < cnt; i++){
104 106
                 printf("%02x ",uart_buf[i]);
105 107
             }
106
-            printf("                       CNT : %d \r\n",cnt);
108
+            printf(ANSI_COLOR_GREEN"\r\n CNT : %d \r\n"ANSI_COLOR_RESET,cnt);
107 109
 #endif // PYJ.2019.07.15_END --
108 110
             if(uart_buf[0] == 0xbe){
109 111
                 Length = uart_buf[BLUECELL_LENGTH_H] << 8  |  uart_buf[BLUECELL_LENGTH_L] ;
@@ -144,6 +146,7 @@ void Uart_Check(void){
144 146
 
145 147
 void Uart1_Data_Send(uint8_t* data,uint16_t size){
146 148
 //    HAL_UART_Transmit(&hTerminal, &data[0],size,0xFFFF);
149
+//    HAL_UART_Transmit(&hTerminal, &data[0],size,0xFFFF);
147 150
 //    HAL_UART_Transmit(&hTest, &data[0],size,0xFFFF);
148 151
       HAL_UART_Transmit_DMA(&hTerminal, &data[0],size);
149 152
 
@@ -155,6 +158,13 @@ void Uart1_Data_Send(uint8_t* data,uint16_t size){
155 158
 //        printf(",0x%02x ",data[i]);
156 159
 //    printf("};\r\n\tCOUNT : %d \r\n",size);
157 160
 //    printf("\r\n");
161
+//    printf("\r\n [TX] : {");
162
+//    for(int i = 0; i< size; i++){
163
+//        printf(",%02x ",data[i]);
164
+//        data[i] = 0;
165
+//    }
166
+//    printf("};\r\n\tCOUNT : %d \r\n",size);
167
+//    printf("\r\n");
158 168
     
159 169
 }
160 170
 

+ 1 - 1
STM32F103ZET_JDASMBIC.elf.launch

@@ -57,5 +57,5 @@
57 57
 </listAttribute>
58 58
 <stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;&#13;&#10;"/>
59 59
 <stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
60
-<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="uart_buf,0x08005000,0x8005000,Bank2data"/>
60
+<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="uart_buf,0x08005000,0x8005000,Bank2data,data"/>
61 61
 </launchConfiguration>

+ 1 - 1
STM32F103ZE_FLASH.ld

@@ -62,7 +62,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
62 62
 MEMORY
63 63
 {
64 64
 RAM (xrw)      : ORIGIN = 0x20002800, LENGTH = 54K
65
-FLASH (rx)      : ORIGIN = 0x8008000, LENGTH = 512K - 20K
65
+FLASH (rx)      : ORIGIN = 0x8008000, LENGTH = 512K - 32K
66 66
 }
67 67
 
68 68
 /* Define output sections */