Переглянути джерело

HFR 작업 내용 Download 완료 / Bank image 이름 업데이트

PYJ 5 роки тому
батько
коміт
5d1a07edfd

+ 7 - 4
Bluecell_Src/Bluecell_operate.c

@@ -3070,7 +3070,7 @@ typedef enum{
3070
         PrevMBIC_DL_ShutdownCount[i] = 0xFF;        
3070
         PrevMBIC_DL_ShutdownCount[i] = 0xFF;        
3071
     }
3071
     }
3072
 
3072
 
3073
-  printf("Type %x  Ready....\r\n",bluecell_Currdatastatus.Type);
3073
+//  printf("Type %x  Ready....\r\n",bluecell_Currdatastatus.Type);
3074
 
3074
 
3075
   //  printf("bluecell_Currdatastatus.Type : %02x \r\n",bluecell_Currdatastatus.Type);
3075
   //  printf("bluecell_Currdatastatus.Type : %02x \r\n",bluecell_Currdatastatus.Type);
3076
 #if 1 // PYJ.2020.06.17_BEGIN -- 
3076
 #if 1 // PYJ.2020.06.17_BEGIN -- 
@@ -3082,7 +3082,7 @@ typedef enum{
3082
     
3082
     
3083
     HAL_GPIO_WritePin(PATH_EN_UL1_GPIO_Port,PATH_EN_UL1_Pin,bluecell_Currdatastatus.ATT_UL1_PATH);   
3083
     HAL_GPIO_WritePin(PATH_EN_UL1_GPIO_Port,PATH_EN_UL1_Pin,bluecell_Currdatastatus.ATT_UL1_PATH);   
3084
     HAL_GPIO_WritePin(PATH_EN_UL2_GPIO_Port,PATH_EN_UL2_Pin,bluecell_Currdatastatus.ATT_UL2_PATH);   
3084
     HAL_GPIO_WritePin(PATH_EN_UL2_GPIO_Port,PATH_EN_UL2_Pin,bluecell_Currdatastatus.ATT_UL2_PATH);   
3085
-    printf("bluecell_Currdatastatus.ATT_UL2_PATH : %d \r\n",bluecell_Currdatastatus.ATT_UL2_PATH);
3085
+//    printf("bluecell_Currdatastatus.ATT_UL2_PATH : %d \r\n",bluecell_Currdatastatus.ATT_UL2_PATH);
3086
     HAL_GPIO_WritePin(PATH_EN_UL3_GPIO_Port,PATH_EN_UL3_Pin,bluecell_Currdatastatus.ATT_UL3_PATH);   
3086
     HAL_GPIO_WritePin(PATH_EN_UL3_GPIO_Port,PATH_EN_UL3_Pin,bluecell_Currdatastatus.ATT_UL3_PATH);   
3087
     HAL_GPIO_WritePin(PATH_EN_UL4_GPIO_Port,PATH_EN_UL4_Pin,bluecell_Currdatastatus.ATT_UL4_PATH);   
3087
     HAL_GPIO_WritePin(PATH_EN_UL4_GPIO_Port,PATH_EN_UL4_Pin,bluecell_Currdatastatus.ATT_UL4_PATH);   
3088
 #endif // PYJ.2020.06.17_END -- 
3088
 #endif // PYJ.2020.06.17_END -- 
@@ -3210,7 +3210,7 @@ uint32_t MBIC_DataSend(uint8_t* data){
3210
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION1;
3210
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION1;
3211
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION2;
3211
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION2;
3212
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION3;
3212
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION3;
3213
-    
3213
+//    printf("Version [3] : %x\r\n ",bluecell_Currdatastatus.CPUVERSION3);
3214
 
3214
 
3215
 
3215
 
3216
     /*CPU_Current_Bank*/
3216
     /*CPU_Current_Bank*/
@@ -3248,9 +3248,12 @@ uint32_t MBIC_DataSend(uint8_t* data){
3248
     data[MBIC_PAYLOADSTART + i++] = CPU_Bank1_Image_Name;
3248
     data[MBIC_PAYLOADSTART + i++] = CPU_Bank1_Image_Name;
3249
     data[MBIC_PAYLOADSTART + i++] = 32; // LENGTH
3249
     data[MBIC_PAYLOADSTART + i++] = 32; // LENGTH
3250
     Length += 32;  
3250
     Length += 32;  
3251
+    uint8_t* tmpstr = &bluecell_Currdatastatus.CPU_Bank1_Image_Name;
3251
     for(int a = 0; a < 32; a++){
3252
     for(int a = 0; a < 32; a++){
3252
         data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPU_Bank1_Image_Name[a];
3253
         data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPU_Bank1_Image_Name[a];
3254
+//        printf("%x ",tmpstr[a]);
3253
     }
3255
     }
3256
+//    printf("\r\n");
3254
 
3257
 
3255
     /*CPU_Bank2_Image_Version*/
3258
     /*CPU_Bank2_Image_Version*/
3256
     data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
3259
     data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
@@ -3325,7 +3328,7 @@ uint32_t MBIC_DataSend(uint8_t* data){
3325
     data[MBIC_PAYLOADSTART + i++] = 1; // LENGTH
3328
     data[MBIC_PAYLOADSTART + i++] = 1; // LENGTH
3326
     Length += 1;
3329
     Length += 1;
3327
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.Type;
3330
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.Type;
3328
-    printf(" bluecell_Currdatastatus.Type : %x \r\n", bluecell_Currdatastatus.Type);
3331
+//    printf(" bluecell_Currdatastatus.Type : %x \r\n", bluecell_Currdatastatus.Type);
3329
      /*PCB_Version*/
3332
      /*PCB_Version*/
3330
     data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
3333
     data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
3331
     data[MBIC_PAYLOADSTART + i++] = PCB_Version;
3334
     data[MBIC_PAYLOADSTART + i++] = PCB_Version;

+ 110 - 18
Bluecell_Src/MBIC_Bootloader.c

@@ -14,7 +14,7 @@
14
 #include "CRC.h"
14
 #include "CRC.h"
15
 #include "uart.h"
15
 #include "uart.h"
16
 
16
 
17
-extern __IO bool EraseInit;
17
+extern bool EraseInit;
18
 
18
 
19
 extern uint8_t Bank_Flash_write(uint8_t* data,uint32_t StartBankAddress);
19
 extern uint8_t Bank_Flash_write(uint8_t* data,uint32_t StartBankAddress);
20
 extern void MBIC_DataErase_Func(uint8_t bank_num);
20
 extern void MBIC_DataErase_Func(uint8_t bank_num);
@@ -211,14 +211,13 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
211
     static uint32_t Prev_Download_DataIndex = 0;    
211
     static uint32_t Prev_Download_DataIndex = 0;    
212
     uint32_t TotalFrame = 0;
212
     uint32_t TotalFrame = 0;
213
     uint32_t CurrFrame = 0;
213
     uint32_t CurrFrame = 0;
214
-    uint32_t PrevFrame = 0 ;
215
     static uint32_t prevFrame = 0xFF;
214
     static uint32_t prevFrame = 0xFF;
216
-    
215
+     uint8_t* tmpstr;
217
     uint16_t DataLength = 0;
216
     uint16_t DataLength = 0;
218
     uint16_t Crcret = 0;
217
     uint16_t Crcret = 0;
219
     uint16_t RecvCrc = 0;
218
     uint16_t RecvCrc = 0;
220
     uint32_t i = 0 ;
219
     uint32_t i = 0 ;
221
-    uint32_t FirmFile_Length  = 0;
220
+    int32_t FirmFile_Length  = 0;
222
     uint32_t  CurrApiAddress = 0,Bank1Address=0,Bank2Address = 0;
221
     uint32_t  CurrApiAddress = 0,Bank1Address=0,Bank2Address = 0;
223
     static uint8_t BankNum = 0;
222
     static uint8_t BankNum = 0;
224
     static bool CRCERR = false;
223
     static bool CRCERR = false;
@@ -249,14 +248,14 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
249
 //        printf("%c",*data++);
248
 //        printf("%c",*data++);
250
     switch(cmd){
249
     switch(cmd){
251
         case MBIC_Notice_REQ:
250
         case MBIC_Notice_REQ:
251
+            EraseInit = false;
252
             Download_Option = 0;
252
             Download_Option = 0;
253
             Curr_Download_DataIndex = 0;
253
             Curr_Download_DataIndex = 0;
254
             Prev_Download_DataIndex = 0;
254
             Prev_Download_DataIndex = 0;
255
-            
255
+            prevFrame = 0xFF;
256
             printf("MBIC DOWNLOAD REQUEST \r\n");
256
             printf("MBIC DOWNLOAD REQUEST \r\n");
257
             cmd = MBIC_Notice_RSP;
257
             cmd = MBIC_Notice_RSP;
258
             CRCERR = false;
258
             CRCERR = false;
259
-            EraseInit = false;
260
             /*TOTAL FRAME NUMBER*/
259
             /*TOTAL FRAME NUMBER*/
261
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 0];
260
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 0];
262
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 1];        
261
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 1];        
@@ -274,7 +273,11 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
274
             data[MBIC_PAYLOADSTART + index++] = 0;
273
             data[MBIC_PAYLOADSTART + index++] = 0;
275
             data[MBIC_PAYLOADSTART + index++] = 0;
274
             data[MBIC_PAYLOADSTART + index++] = 0;
276
             data[MBIC_PAYLOADSTART + index++] = 0;
275
             data[MBIC_PAYLOADSTART + index++] = 0;
277
-           
276
+              if(bluecell_Currdatastatus.CPU_Current_Bank == HFR_BANK1){
277
+                BankNum = HFR_BANK2;
278
+              }else{
279
+                BankNum = HFR_BANK1;
280
+              }           
278
 //            MBIC_DataBankWrite(1);
281
 //            MBIC_DataBankWrite(1);
279
             //if()
282
             //if()
280
 //            MBIC_DataErase_Func(bluecell_Currdatastatus.CPU_Bank_Select);
283
 //            MBIC_DataErase_Func(bluecell_Currdatastatus.CPU_Bank_Select);
@@ -319,18 +322,31 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
319
 #endif // PYJ.2020.06.24_END -- 
322
 #endif // PYJ.2020.06.24_END -- 
320
 //            printf("Data End\r\n");
323
 //            printf("Data End\r\n");
321
 //            Bank_Flash_write(data,FLASH_USER_BANK1_START_ADDR);
324
 //            Bank_Flash_write(data,FLASH_USER_BANK1_START_ADDR);
322
-              if(Currdata[MBIC_BOOT_VERSION + 3] == Bank1data[MBIC_BOOT_VERSION + 3]){
323
-                BankNum = HFR_BANK2;
325
+
326
+              if(prevFrame != CurrFrame){
327
+                MBIC_APIFLASH_Func(&data[MBIC_PAYLOADSTART + 12],1024,BankNum);
324
               }else{
328
               }else{
325
-                BankNum = HFR_BANK1;
329
+                if(MBIC_Address < FLASH_USER_BANK2_START_ADDR)
330
+                    MBIC_Address = FLASH_USER_BANK2_START_ADDR + (CurrFrame * 1024);
331
+                else
332
+                    MBIC_Address = FLASH_USER_BANK1_START_ADDR + (CurrFrame * 1024);
333
+                
334
+                printf("Frame Retry \r\n");
326
               }
335
               }
327
-              MBIC_APIFLASH_Func(&data[MBIC_PAYLOADSTART + 12],1024,BankNum);
328
-              printf("Bank1data[MBIC_BOOT_MARK] : %d \r\n",Bank2data[MBIC_BOOT_MARK]);
336
+#if 0 // PYJ.2020.06.29_BEGIN -- 
337
+              if(BankNum == HFR_BANK1){
338
+                  printf("Bank1data[MBIC_BOOT_MARK] : %d \r\n",Bank1data[MBIC_BOOT_MARK]);
339
+              }else{
340
+
341
+                  printf("Bank1data[MBIC_BOOT_MARK] : %d \r\n",Bank2data[MBIC_BOOT_MARK]);
342
+              }
343
+              
344
+#endif // PYJ.2020.06.29_END -- 
329
 //              if(BankNum == HFR_BANK1)
345
 //              if(BankNum == HFR_BANK1)
330
 //                  Crcret = CRC16_Generate(&Bank1data[MBIC_BOOT_MARK], TotalFrame);
346
 //                  Crcret = CRC16_Generate(&Bank1data[MBIC_BOOT_MARK], TotalFrame);
331
 //              else
347
 //              else
332
 //                Crcret = CRC16_Generate(&Bank2data[MBIC_BOOT_MARK], TotalFrame);
348
 //                Crcret = CRC16_Generate(&Bank2data[MBIC_BOOT_MARK], TotalFrame);
333
-                printf("CurrFrame : %d ,FirmFile_Length : %d \r\n",CurrFrame,TotalFrame);
349
+                printf("CurrFrame : %d ,FirmFile_Length : %d \r\n",CurrFrame,TotalFrame - 1);
334
                 printf("FILE CRC RET : %x \r\n",Crcret);              
350
                 printf("FILE CRC RET : %x \r\n",Crcret);              
335
 
351
 
336
 //            HAL_Delay(100);
352
 //            HAL_Delay(100);
@@ -339,14 +355,17 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
339
 
355
 
340
             break;
356
             break;
341
         case MBIC_Download_Confirm_REQ:
357
         case MBIC_Download_Confirm_REQ:
342
-            EraseInit = true;
358
+            
359
+            printf("MBIC_Download_Confirm_REQ \r\n");
343
             cmd = MBIC_Download_Confirm_RSP;
360
             cmd = MBIC_Download_Confirm_RSP;
344
             /*TOTAL FRAME NUMBER*/
361
             /*TOTAL FRAME NUMBER*/
362
+             
345
             if(BankNum == HFR_BANK1){
363
             if(BankNum == HFR_BANK1){
346
                 FirmFile_Length = (Bank1data[MBIC_BOOT_LENGTH + 0] << 24)
364
                 FirmFile_Length = (Bank1data[MBIC_BOOT_LENGTH + 0] << 24)
347
                                 | Bank1data[MBIC_BOOT_LENGTH + 1] << 16
365
                                 | Bank1data[MBIC_BOOT_LENGTH + 1] << 16
348
                                 | Bank1data[MBIC_BOOT_LENGTH + 2] << 8
366
                                 | Bank1data[MBIC_BOOT_LENGTH + 2] << 8
349
                                 | Bank1data[MBIC_BOOT_LENGTH + 3];
367
                                 | Bank1data[MBIC_BOOT_LENGTH + 3];
368
+                FirmFile_Length += 128;
350
                 Crcret = CRC16_Generate(&Bank1data[MBIC_BOOT_MARK], FirmFile_Length);
369
                 Crcret = CRC16_Generate(&Bank1data[MBIC_BOOT_MARK], FirmFile_Length);
351
                 printf("Bank 1 CRC Calc\r\n");                
370
                 printf("Bank 1 CRC Calc\r\n");                
352
             }
371
             }
@@ -354,13 +373,14 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
354
                  FirmFile_Length = (Bank2data[MBIC_BOOT_LENGTH + 0] << 24)
373
                  FirmFile_Length = (Bank2data[MBIC_BOOT_LENGTH + 0] << 24)
355
                                 | Bank2data[MBIC_BOOT_LENGTH + 1] << 16
374
                                 | Bank2data[MBIC_BOOT_LENGTH + 1] << 16
356
                                 | Bank2data[MBIC_BOOT_LENGTH + 2] << 8
375
                                 | Bank2data[MBIC_BOOT_LENGTH + 2] << 8
357
-                                | Bank2data[MBIC_BOOT_LENGTH + 3];           
358
-                Crcret = CRC16_Generate(&Bank2data[MBIC_BOOT_MARK], FirmFile_Length - 1);
376
+                                | Bank2data[MBIC_BOOT_LENGTH + 3];   
377
+                FirmFile_Length += 128;
378
+                Crcret = CRC16_Generate(&Bank2data[MBIC_BOOT_MARK], FirmFile_Length);
359
                 printf("Bank 2 CRC Calc\r\n");
379
                 printf("Bank 2 CRC Calc\r\n");
360
             }
380
             }
361
             RecvCrc = data[MBIC_PAYLOADSTART] << 8 | data[MBIC_PAYLOADSTART + 1];
381
             RecvCrc = data[MBIC_PAYLOADSTART] << 8 | data[MBIC_PAYLOADSTART + 1];
362
 
382
 
363
-            printf("FirmFile_Length : %x \r\n",FirmFile_Length);
383
+            printf("FirmFile_Length : %x \r\n",FirmFile_Length + 128);
364
             printf("FILE CRC RET : %x \r\n",Crcret);
384
             printf("FILE CRC RET : %x \r\n",Crcret);
365
         
385
         
366
             data[MBIC_PAYLOADSTART + index++] = ((Crcret & 0xFF00) >> 8);
386
             data[MBIC_PAYLOADSTART + index++] = ((Crcret & 0xFF00) >> 8);
@@ -383,18 +403,90 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
383
             data[MBIC_PAYLOADSTART + index++] = 0;
403
             data[MBIC_PAYLOADSTART + index++] = 0;
384
             data[MBIC_PAYLOADSTART + index++] = 0;
404
             data[MBIC_PAYLOADSTART + index++] = 0;
385
             data[MBIC_PAYLOADSTART + index++] = 0;
405
             data[MBIC_PAYLOADSTART + index++] = 0;
406
+//         if(BankNum == HFR_BANK1){
407
+//            bluecell_Currdatastatus.CPUVERSION1 = Bank1data[MBIC_BOOT_VERSION];
408
+//            bluecell_Currdatastatus.CPUVERSION2 = Bank1data[MBIC_BOOT_VERSION + 1];
409
+//            bluecell_Currdatastatus.CPUVERSION3 = Bank1data[MBIC_BOOT_VERSION + 2];          
410
+//              printf("Bank1data[MBIC_BOOT_VERSION] : %d \r\n",Bank1data[MBIC_BOOT_VERSION + 2]);
411
+//          }else{
412
+//              bluecell_Currdatastatus.CPUVERSION1 = Bank2data[MBIC_BOOT_VERSION];
413
+//              bluecell_Currdatastatus.CPUVERSION2 = Bank2data[MBIC_BOOT_VERSION + 1];
414
+//              bluecell_Currdatastatus.CPUVERSION3 = Bank2data[MBIC_BOOT_VERSION + 2]; 
415
+//              printf("Bank2data[MBIC_BOOT_VERSION] : %d \r\n",Bank2data[MBIC_BOOT_VERSION + 2]);
416
+//          }   
417
+          bluecell_Currdatastatus.CPU_Bank1_Image_Version1 = Bank1data[MBIC_BOOT_VERSION];
418
+          bluecell_Currdatastatus.CPU_Bank1_Image_Version2 = Bank1data[MBIC_BOOT_VERSION + 1];
419
+          bluecell_Currdatastatus.CPU_Bank1_Image_Version3 = Bank1data[MBIC_BOOT_VERSION + 2];
420
+
421
+            bluecell_Currdatastatus.CPU_Bank2_Image_Version1 = Bank2data[MBIC_BOOT_VERSION];
422
+            bluecell_Currdatastatus.CPU_Bank2_Image_Version2 = Bank2data[MBIC_BOOT_VERSION + 1];
423
+            bluecell_Currdatastatus.CPU_Bank2_Image_Version3 = Bank2data[MBIC_BOOT_VERSION + 2];
424
+            
425
+             bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime1 = Bank1data[MBIC_BOOT_CREATION_TIME];
426
+            bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime2 = Bank1data[MBIC_BOOT_CREATION_TIME + 1];
427
+            bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime3 = Bank1data[MBIC_BOOT_CREATION_TIME + 2];         
428
+            bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime4 = Bank1data[MBIC_BOOT_CREATION_TIME + 3];         
429
+            bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime5 = Bank1data[MBIC_BOOT_CREATION_TIME + 4];         
430
+            bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime6 = Bank1data[MBIC_BOOT_CREATION_TIME + 5];   
386
 
431
 
432
+            
433
+             bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime1 = Bank2data[MBIC_BOOT_CREATION_TIME];
434
+            bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime2 = Bank2data[MBIC_BOOT_CREATION_TIME + 1];
435
+            bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime3 = Bank2data[MBIC_BOOT_CREATION_TIME + 2];         
436
+            bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime4 = Bank2data[MBIC_BOOT_CREATION_TIME + 3];         
437
+            bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime5 = Bank2data[MBIC_BOOT_CREATION_TIME + 4];         
438
+            bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime6 = Bank2data[MBIC_BOOT_CREATION_TIME + 5];   
439
+            tmpstr = &bluecell_Currdatastatus.CPU_Bank1_Image_Name;
440
+            for(int i = 0 ; i< 41; i++){
441
+                if(i < 32)
442
+                tmpstr[i] = Bank1data[MBIC_BOOT_FILENAME + i];
443
+                else
444
+                 tmpstr[i] = 0x20;
445
+                printf("%x",tmpstr[i]);
446
+            }  
447
+            tmpstr = &bluecell_Currdatastatus.CPU_Bank2_Image_Name;
448
+            for(int i = 0 ; i< 41; i++){
449
+                if(i < 32)
450
+                tmpstr[i] = Bank2data[MBIC_BOOT_FILENAME + i];
451
+                else
452
+                 tmpstr[i] = 0x20;
453
+
454
+                printf("%x",tmpstr[i]);
455
+            }               
456
+            printf("Curr Version : %02x.%02x.%02x \r\n",bluecell_Currdatastatus.CPUVERSION1,bluecell_Currdatastatus.CPUVERSION2,bluecell_Currdatastatus.CPUVERSION3);
457
+            printf("Bank1data Version : %02x.%02x.%02x \r\n", Bank1data[MBIC_BOOT_VERSION + 0], Bank1data[MBIC_BOOT_VERSION + 1], Bank1data[MBIC_BOOT_VERSION + 2]);
458
+            printf("Bank2data Version : %02x.%02x.%02x \r\n", Bank2data[MBIC_BOOT_VERSION + 0], Bank2data[MBIC_BOOT_VERSION + 1], Bank2data[MBIC_BOOT_VERSION + 2]);            
459
+        
387
         break;
460
         break;
388
         case MBIC_Complete_Notice_REQ_REQ:
461
         case MBIC_Complete_Notice_REQ_REQ:
462
+            printf("MBIC_Complete_Notice_REQ_REQ \r\n");
389
             cmd = MBIC_Complete_Notice_RSP;
463
             cmd = MBIC_Complete_Notice_RSP;
390
             if(CRCERR == false){
464
             if(CRCERR == false){
391
                 data[MBIC_PAYLOADSTART + index++] = 1;  
465
                 data[MBIC_PAYLOADSTART + index++] = 1;  
392
             }else{
466
             }else{
393
                 data[MBIC_PAYLOADSTART + index++] = 0;  
467
                 data[MBIC_PAYLOADSTART + index++] = 0;  
394
             }
468
             }
395
-                data[MBIC_PAYLOADSTART + index++] = 1;              
469
+                data[MBIC_PAYLOADSTART + index++] = 1;    
470
+
471
+
472
+//          if(BankNum == HFR_BANK1){
473
+//            bluecell_Currdatastatus.CPUVERSION1 = Bank1data[MBIC_BOOT_VERSION];
474
+//            bluecell_Currdatastatus.CPUVERSION2 = Bank1data[MBIC_BOOT_VERSION + 1];
475
+//            bluecell_Currdatastatus.CPUVERSION3 = Bank1data[MBIC_BOOT_VERSION + 2];          
476
+//              printf("Bank1data[MBIC_BOOT_VERSION] : %d \r\n",Bank1data[MBIC_BOOT_VERSION]);
477
+//          }else{
478
+//              bluecell_Currdatastatus.CPUVERSION1 = Bank2data[MBIC_BOOT_VERSION];
479
+//              bluecell_Currdatastatus.CPUVERSION2 = Bank2data[MBIC_BOOT_VERSION + 1];
480
+//              bluecell_Currdatastatus.CPUVERSION3 = Bank2data[MBIC_BOOT_VERSION + 2]; 
481
+//
482
+//              printf("Bank1data[MBIC_BOOT_VERSION] : %d \r\n",Bank2data[MBIC_BOOT_VERSION]);
483
+//          }   
484
+            printf("Curr Version : %02x.%02x.%02x \r\n",bluecell_Currdatastatus.CPUVERSION1,bluecell_Currdatastatus.CPUVERSION2,bluecell_Currdatastatus.CPUVERSION3);
485
+            printf("Bank1data Version : %02x.%02x.%02x \r\n", Bank1data[MBIC_BOOT_VERSION + 0], Bank1data[MBIC_BOOT_VERSION + 1], Bank1data[MBIC_BOOT_VERSION + 2]);
486
+            printf("Bank2data Version : %02x.%02x.%02x \r\n", Bank2data[MBIC_BOOT_VERSION + 0], Bank2data[MBIC_BOOT_VERSION + 1], Bank2data[MBIC_BOOT_VERSION + 2]);
396
             break;
487
             break;
397
         case MBIC_Reboot_Notice_REQ:
488
         case MBIC_Reboot_Notice_REQ:
489
+            printf("MBIC_Reboot_Notice_REQ\r\n");
398
             cmd = MBIC_Reboot_Notice_RSP;
490
             cmd = MBIC_Reboot_Notice_RSP;
399
             /*TOTAL FRAME NUMBER*/
491
             /*TOTAL FRAME NUMBER*/
400
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 0];
492
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 0];

+ 5 - 5
Bluecell_Src/eeprom.c

@@ -90,10 +90,10 @@ void EEPROM_M24C08_Init(void){
90
     uint8_t* tmpdata;
90
     uint8_t* tmpdata;
91
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_DET_DL4_TABLE_ADDRESDS,&Det_UL1.Table_Det_15_dBm_H,sizeof(DET_TABLEUL_st) );
91
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_DET_DL4_TABLE_ADDRESDS,&Det_UL1.Table_Det_15_dBm_H,sizeof(DET_TABLEUL_st) );
92
     tmpdata = &Det_UL1.Table_Det_15_dBm_H;
92
     tmpdata = &Det_UL1.Table_Det_15_dBm_H;
93
-    for(int i =0; i < sizeof(DET_TABLEUL_st) ; i++){
94
-        printf("[%d]%f \r\n",i,(tmpdata[i * 2] << 8 | tmpdata[i*2+1])*0.001);
95
-    }
96
-    printf("");
93
+//    for(int i =0; i < sizeof(DET_TABLEUL_st) ; i++){
94
+//        printf("[%d]%f \r\n",i,(tmpdata[i * 2] << 8 | tmpdata[i*2+1])*0.001);
95
+//    }
96
+//    printf("");
97
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_DET_UL1_TABLE_ADDRESDS,&Det_UL2.Table_Det_15_dBm_H,sizeof(DET_TABLEUL_st) );
97
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_DET_UL1_TABLE_ADDRESDS,&Det_UL2.Table_Det_15_dBm_H,sizeof(DET_TABLEUL_st) );
98
 //    data = &Det_UL2.Table_Det_15_dBm_H;
98
 //    data = &Det_UL2.Table_Det_15_dBm_H;
99
 //    for(int i = 0; i < sizeof(DET_TABLEUL_st) ; i ++ ){
99
 //    for(int i = 0; i < sizeof(DET_TABLEUL_st) ; i ++ ){
@@ -384,7 +384,7 @@ HAL_StatusTypeDef EEPROM_M24C08_write(uint8_t devid,uint16_t Address,uint8_t* da
384
           HAL_Delay(20);
384
           HAL_Delay(20);
385
         }
385
         }
386
     }
386
     }
387
-    printf("EEPROM WRITE\r\n");
387
+//    printf("EEPROM WRITE\r\n");
388
 
388
 
389
 #endif // PYJ.2020.04.25_END -- 
389
 #endif // PYJ.2020.04.25_END -- 
390
     return ret;
390
     return ret;

+ 50 - 72
Bluecell_Src/flash.c

@@ -74,14 +74,14 @@ void Flash_InitRead() // ?占쏙옙湲고븿?占쏙옙
74
     bluecell_Currdatastatus.CPUVERSION1 = Currdata[MBIC_BOOT_VERSION + 0];
74
     bluecell_Currdatastatus.CPUVERSION1 = Currdata[MBIC_BOOT_VERSION + 0];
75
     bluecell_Currdatastatus.CPUVERSION2 = Currdata[MBIC_BOOT_VERSION + 1];
75
     bluecell_Currdatastatus.CPUVERSION2 = Currdata[MBIC_BOOT_VERSION + 1];
76
     bluecell_Currdatastatus.CPUVERSION3 = Currdata[MBIC_BOOT_VERSION + 2];
76
     bluecell_Currdatastatus.CPUVERSION3 = Currdata[MBIC_BOOT_VERSION + 2];
77
+    for(int i =0; i < 3; i++)
78
+        printf("Bank1data[MBIC_BOOT_VERSION] : %d \r\n",Bank1data[MBIC_BOOT_VERSION + i]);
77
     
79
     
78
-    if(bluecell_Currdatastatus.CPUVERSION1 == Bank1data[MBIC_BOOT_VERSION + 0]
79
-    &&bluecell_Currdatastatus.CPUVERSION1 == Bank1data[MBIC_BOOT_VERSION + 1]
80
-    &&bluecell_Currdatastatus.CPUVERSION1 == Bank1data[MBIC_BOOT_VERSION + 2]){
80
+    if(bluecell_Currdatastatus.CPUVERSION3  == Bank1data[MBIC_BOOT_VERSION + 2]){
81
         bluecell_Currdatastatus.CPU_Current_Bank = HFR_BANK1_SEL;
81
         bluecell_Currdatastatus.CPU_Current_Bank = HFR_BANK1_SEL;
82
-    }else if(bluecell_Currdatastatus.CPUVERSION1 == Bank2data[MBIC_BOOT_VERSION + 0]
83
-    &&bluecell_Currdatastatus.CPUVERSION1 == Bank2data[MBIC_BOOT_VERSION + 1]
84
-    &&bluecell_Currdatastatus.CPUVERSION1 == Bank2data[MBIC_BOOT_VERSION + 2]){
82
+    }
83
+    else 
84
+    {
85
         bluecell_Currdatastatus.CPU_Current_Bank = HFR_BANK2_SEL;
85
         bluecell_Currdatastatus.CPU_Current_Bank = HFR_BANK2_SEL;
86
     }
86
     }
87
     printf("Curr Version : %02x.%02x.%02x \r\n",bluecell_Currdatastatus.CPUVERSION1,bluecell_Currdatastatus.CPUVERSION2,bluecell_Currdatastatus.CPUVERSION3);
87
     printf("Curr Version : %02x.%02x.%02x \r\n",bluecell_Currdatastatus.CPUVERSION1,bluecell_Currdatastatus.CPUVERSION2,bluecell_Currdatastatus.CPUVERSION3);
@@ -91,17 +91,32 @@ void Flash_InitRead() // ?占쏙옙湲고븿?占쏙옙
91
 
91
 
92
     
92
     
93
     printf("BANK1 IMAGE NAME : ");
93
     printf("BANK1 IMAGE NAME : ");
94
-    for(int i = 0 ; i< 32; i++){
95
-        pdata[i] = Bank1data[MBIC_BOOT_FILENAME + i];
96
-        printf("%c",pdata[i]);
94
+    pdata = & bluecell_Currdatastatus.CPU_Bank1_Image_Name;
95
+    for(int i = 0 ; i< 41; i++){
96
+        if(i < 32){
97
+            pdata[i] = Bank1data[MBIC_BOOT_FILENAME + i];
98
+            printf("%c",pdata[i]);
99
+        }
100
+        else{
101
+         pdata[i] = 0x20;
102
+        }
103
+
97
     }
104
     }
98
     printf("\r\n");
105
     printf("\r\n");
99
 
106
 
100
     
107
     
101
     pdata = & bluecell_Currdatastatus.CPU_Bank2_Image_Name;
108
     pdata = & bluecell_Currdatastatus.CPU_Bank2_Image_Name;
102
     printf("BANK2 IMAGE NAME : ");
109
     printf("BANK2 IMAGE NAME : ");
103
-    for(int i = 0 ; i< 32; i++){
104
-        pdata[i] = Bank2data[MBIC_BOOT_FILENAME + i];  
110
+    for(int i = 0 ; i< 41; i++){
111
+        if(i < 32){
112
+            pdata[i] = Bank2data[MBIC_BOOT_FILENAME + i];
113
+            printf("%c",pdata[i]);
114
+        }
115
+        else{
116
+         pdata[i] = 0x20;
117
+        }
118
+
119
+
105
         printf("%c",pdata[i]);
120
         printf("%c",pdata[i]);
106
     }
121
     }
107
     printf("\r\n");
122
     printf("\r\n");
@@ -275,7 +290,7 @@ uint8_t Bank_Flash_write(uint8_t* data,uint32_t StartBankAddress) // ?占쏙옙
275
 }
290
 }
276
 #endif // PYJ.2020.06.24_END -- 
291
 #endif // PYJ.2020.06.24_END -- 
277
 #define DATA_32                 ((uint32_t)0x33333333)
292
 #define DATA_32                 ((uint32_t)0x33333333)
278
-__IO bool EraseInit = false;
293
+bool EraseInit = false;
279
 
294
 
280
 #if 0 // PYJ.2020.06.24_BEGIN -- 
295
 #if 0 // PYJ.2020.06.24_BEGIN -- 
281
 void MBIC_APIFLASH_test(uint8_t* data,uint32_t size){
296
 void MBIC_APIFLASH_test(uint8_t* data,uint32_t size){
@@ -418,6 +433,7 @@ void MBIC_DataErase_Func(uint8_t bank_num){
418
     static uint32_t PAGEError = 0;
433
     static uint32_t PAGEError = 0;
419
 
434
 
420
     if(EraseInit == false){
435
     if(EraseInit == false){
436
+        HAL_FLASH_Unlock();
421
 #if 0 // PYJ.2020.06.24_BEGIN -- 
437
 #if 0 // PYJ.2020.06.24_BEGIN -- 
422
         EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
438
         EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
423
         EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
439
         EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
@@ -474,6 +490,19 @@ void MBIC_DataErase_Func(uint8_t bank_num){
474
         }
490
         }
475
         EraseInit = true;
491
         EraseInit = true;
476
         printf("Erase End\r\n");
492
         printf("Erase End\r\n");
493
+         HAL_FLASH_Lock();
494
+    }
495
+    if(MBIC_Address == 0){
496
+        if(bluecell_Currdatastatus.CPU_Current_Bank == HFR_BANK1){
497
+            bank_num = HFR_BANK2;
498
+            MBIC_Address = FLASH_USER_BANK2_START_ADDR;
499
+            printf("Curr Bank BANK 1 I will download Bank2 \r\n");
500
+        }
501
+        else{
502
+            bank_num = HFR_BANK1;
503
+            MBIC_Address = FLASH_USER_BANK1_START_ADDR;
504
+            printf("Curr Bank BANK 2 I will download Bank1 \r\n");
505
+        }        
477
     }
506
     }
478
 
507
 
479
 }
508
 }
@@ -520,40 +549,8 @@ uint8_t MBIC_APIFLASH_Func(uint8_t* data,uint32_t size,uint8_t bank_num){
520
       (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
549
       (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
521
     
550
     
522
     /* Fill EraseInit structure*/
551
     /* Fill EraseInit structure*/
523
-#if 0 // PYJ.2020.06.24_BEGIN -- 
552
+#if 0 // PYJ.2020.06.29_BEGIN -- 
524
     if(EraseInit == false){
553
     if(EraseInit == false){
525
-        EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
526
-        EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
527
-        EraseInitStruct.NbPages     = ((FLASH_USER_BANK1_START_ADDR + ((uint32_t)0xFFFF)) - FLASH_USER_BANK1_START_ADDR) / FLASH_PAGE_SIZE;
528
-        printf("Erase Start\r\n");
529
-        if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK)
530
-        {
531
-          /*
532
-            Error occurred while page erase.
533
-            User can add here some code to deal with this error.
534
-            PAGEError will contain the faulty page and then to know the code error on this page,
535
-            user can call function 'HAL_FLASH_GetError()'
536
-          */
537
-          /* Infinite loop */
538
-          while (1)
539
-          {
540
-            /* Make LED2 blink (100ms on, 2s off) to indicate error in Erase operation */
541
-            printf("HAL_FLASHEx_Erase Error\r\n");
542
-            HAL_Delay(2000);
543
-          }
544
-        }
545
-        EraseInit = true;
546
-        printf("Erase End\r\n");
547
-    }
548
-#else
549
-    if(EraseInit == false){
550
-#if 0 // PYJ.2020.06.24_BEGIN -- 
551
-        EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
552
-        EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
553
-        printf("PageAddress : %x \r\n",FLASH_USER_BANK1_START_ADDR);
554
-//        EraseInitStruct.NbPages     = ((FLASH_USER_BANK1_START_ADDR + ((uint32_t)0xFFFF)) - FLASH_USER_BANK1_START_ADDR) / FLASH_PAGE_SIZE;
555
-        EraseInitStruct.NbPages     = (FLASH_USER_BANK1_START_ADDR - ((uint32_t)0xFFFF)) / FLASH_PAGE_SIZE;
556
-#else
557
     ret = bluecell_Currdatastatus.CPU_Current_Bank;
554
     ret = bluecell_Currdatastatus.CPU_Current_Bank;
558
     if(bank_num == HFR_AUTO_SEL){
555
     if(bank_num == HFR_AUTO_SEL){
559
         if(ret == HFR_BANK2)
556
         if(ret == HFR_BANK2)
@@ -585,7 +582,6 @@ uint8_t MBIC_APIFLASH_Func(uint8_t* data,uint32_t size,uint8_t bank_num){
585
         printf("I will download Bank1 \r\n");        
582
         printf("I will download Bank1 \r\n");        
586
         printf("Erase BANK 1 \r\n");        
583
         printf("Erase BANK 1 \r\n");        
587
     }
584
     }
588
-#endif // PYJ.2020.06.24_END -- 
589
         printf("NbPages : %x \r\n",EraseInitStruct.NbPages );
585
         printf("NbPages : %x \r\n",EraseInitStruct.NbPages );
590
         printf("EraseInitStruct.PageAddress : %x \r\n",EraseInitStruct.PageAddress);
586
         printf("EraseInitStruct.PageAddress : %x \r\n",EraseInitStruct.PageAddress);
591
 
587
 
@@ -609,38 +605,21 @@ uint8_t MBIC_APIFLASH_Func(uint8_t* data,uint32_t size,uint8_t bank_num){
609
         EraseInit = true;
605
         EraseInit = true;
610
         printf("Erase End\r\n");
606
         printf("Erase End\r\n");
611
     }
607
     }
608
+#endif // PYJ.2020.06.29_END -- 
612
 
609
 
613
-#endif // PYJ.2020.06.24_END -- 
614
     /* Program the user Flash area word by word
610
     /* Program the user Flash area word by word
615
       (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
611
       (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
616
     
612
     
617
 //    MBIC_Address = FLASH_USER_BANK1_START_ADDR;
613
 //    MBIC_Address = FLASH_USER_BANK1_START_ADDR;
618
     printf("HAL_FLASH_Program Start\r\n");
614
     printf("HAL_FLASH_Program Start\r\n");
619
     DownloadIndex += size;
615
     DownloadIndex += size;
620
-#if 0 // PYJ.2020.06.24_BEGIN -- 
621
-    while (MBIC_Address <= ((FLASH_USER_BANK1_START_ADDR + DownloadIndex)))
622
-    {
623
-      writedata = data[dataindex + 0] ;
624
-      writedata += data[dataindex + 1] << 8 ;
625
-      writedata += data[dataindex + 2] << 16;
626
-      writedata += data[dataindex + 3] << 24;      
627
-      if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, MBIC_Address,writedata) == HAL_OK)
628
-      {
629
-        MBIC_Address +=  4;
630
-        dataindex  += 4;
631
-      }
632
-      else
633
-      {
634
-        /* Error occurred while writing data in Flash memory.
635
-           User can add here some code to deal with this error */
636
-        while (1)
637
-        {
638
-          printf("HAL_FLASH_Program Error\r\n");
639
-        }
640
-      }
641
-    }
642
-#else   
643
      printf("MBIC_Address : %x \r\n",MBIC_Address);
616
      printf("MBIC_Address : %x \r\n",MBIC_Address);
617
+     if(MBIC_Address == 0){
618
+        if(bank_num == HFR_BANK1)
619
+            MBIC_Address = FLASH_USER_BANK1_START_ADDR;
620
+        else
621
+           MBIC_Address = FLASH_USER_BANK2_START_ADDR;
622
+     }
644
      for(int downindex = 0; downindex < size; downindex+=4)
623
      for(int downindex = 0; downindex < size; downindex+=4)
645
      {
624
      {
646
        writedata = data[downindex + 0] ;
625
        writedata = data[downindex + 0] ;
@@ -658,8 +637,7 @@ uint8_t MBIC_APIFLASH_Func(uint8_t* data,uint32_t size,uint8_t bank_num){
658
        }
637
        }
659
      }
638
      }
660
 
639
 
661
-#endif // PYJ.2020.06.24_END -- 
662
-     printf("HAL_FLASH_Program END\r\n");
640
+     printf("HAL_FLASH_Program END   %x \r\n",MBIC_Address);
663
     /* Lock the Flash to disable the flash control register access (recommended
641
     /* Lock the Flash to disable the flash control register access (recommended
664
        to protect the FLASH memory against possible unwanted operation) *********/
642
        to protect the FLASH memory against possible unwanted operation) *********/
665
     HAL_FLASH_Lock();
643
     HAL_FLASH_Lock();

+ 5 - 5
Bluecell_Src/uart.c

@@ -100,7 +100,7 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
100
 //        printf("data cnt zero !!!  \r\n");
100
 //        printf("data cnt zero !!!  \r\n");
101
         //RF_Ctrl_Main(&uart_buf[Header]);
101
         //RF_Ctrl_Main(&uart_buf[Header]);
102
 //        HAL_UART_Transmit(dst, &temp_buf[BLUECELL_HEADER00], 11, 3000);
102
 //        HAL_UART_Transmit(dst, &temp_buf[BLUECELL_HEADER00], 11, 3000);
103
-#if 1// PYJ.2019.07.15_BEGIN --
103
+#if 0// PYJ.2019.07.15_BEGIN --
104
             printf("\r\n[RX]");
104
             printf("\r\n[RX]");
105
             for(int i = 0; i < cnt; i++){
105
             for(int i = 0; i < cnt; i++){
106
                 printf("%02x ",uart_buf[i]);
106
                 printf("%02x ",uart_buf[i]);
@@ -153,9 +153,9 @@ void Uart1_Data_Send(uint8_t* data,uint16_t size){
153
   //HAL_UART_Transmit_IT(&hTerminal, &data[0],size);
153
   //HAL_UART_Transmit_IT(&hTerminal, &data[0],size);
154
 //    printf("data[278] : %x \r\n",data[278]);
154
 //    printf("data[278] : %x \r\n",data[278]);
155
 ////    HAL_Delay(1);   
155
 ////    HAL_Delay(1);   
156
-//    printf("\r\n [TX] : {");
157
-//    for(int i = 0; i< size; i++)
158
-//        printf(",0x%02x ",data[i]);
156
+    printf("\r\n [TX] : ");
157
+    for(int i = 0; i< size; i++)
158
+        printf("%02x ",data[i]);
159
 //    printf("};\r\n\tCOUNT : %d \r\n",size);
159
 //    printf("};\r\n\tCOUNT : %d \r\n",size);
160
 //    printf("\r\n");
160
 //    printf("\r\n");
161
 //    printf("\r\n [TX] : {");
161
 //    printf("\r\n [TX] : {");
@@ -164,7 +164,7 @@ void Uart1_Data_Send(uint8_t* data,uint16_t size){
164
 //        data[i] = 0;
164
 //        data[i] = 0;
165
 //    }
165
 //    }
166
 //    printf("};\r\n\tCOUNT : %d \r\n",size);
166
 //    printf("};\r\n\tCOUNT : %d \r\n",size);
167
-//    printf("\r\n");
167
+    printf("\r\n");
168
     
168
     
169
 }
169
 }
170
 
170
 

+ 1 - 1
STM32F103ZET_JDASMBIC.elf.launch

@@ -57,5 +57,5 @@
57
 </listAttribute>
57
 </listAttribute>
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;"/>
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
 <stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
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,data"/>
60
+<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="uart_buf,0x08005000,0x8005000,Bank2data,data,Currdata,Currdata[MBIC_BOOT_VERSION + 2],Bank1data"/>
61
 </launchConfiguration>
61
 </launchConfiguration>

+ 40 - 15
Src/main.c

@@ -28,6 +28,7 @@
28
 #include "uart.h"
28
 #include "uart.h"
29
 #include "Bluecell_operate.h"
29
 #include "Bluecell_operate.h"
30
 #include "eeprom.h"
30
 #include "eeprom.h"
31
+#include "flash.h"
31
 /* USER CODE END Includes */
32
 /* USER CODE END Includes */
32
 
33
 
33
 /* Private typedef -----------------------------------------------------------*/
34
 /* Private typedef -----------------------------------------------------------*/
@@ -279,20 +280,43 @@ extern const uint16_t crc16_tab[256];
279
 
280
 
280
 
281
 
281
   setbuf(stdout, NULL);
282
   setbuf(stdout, NULL);
282
-//  uint32_t CrcLength = 
283
-//    ((data2[MBIC_BOOT_LENGTH] << 24 ) 
284
-//    | data2[MBIC_BOOT_LENGTH + 1]<<16 
285
-//    | data2[MBIC_BOOT_LENGTH + 2]<<8   
286
-//    | data2[MBIC_BOOT_LENGTH + 3]);
287
-//  printf("CRC LENGTH : %d,CRC LENGTH : %X \r\n",CrcLength,CrcLength):
288
-//  uint16_t crcret = CRC16_Generate2(&data2[MBIC_PAYLOADSTART], CrcLength);
289
-//    
290
-//  printf("CRC : %x \r\n",data2[MBIC_BOOT_CRC + 0]);
291
-//  printf("data2 : %X size %d \r\n",crcret,CrcLength );  
292
-//      while(1);
293
-#if 1 // PYJ.2020.06.24_BEGIN -- 
294
-//  DataWriteTest();
295
-//    while(1);
283
+   uint32_t  CurrApiAddress = 0,Bank1Address=0,Bank2Address = 0;
284
+        int32_t CrcLength = 0;
285
+        
286
+        
287
+        
288
+        CurrApiAddress = FLASH_MBICUSER_START_ADDR;
289
+           Bank1Address = FLASH_USER_BANK1_START_ADDR;
290
+           Bank2Address = FLASH_USER_BANK2_START_ADDR;
291
+        
292
+           uint8_t* Currdata = (uint8_t*)CurrApiAddress;
293
+           uint8_t* Bank1data = (uint8_t*)Bank1Address;
294
+           uint8_t* Bank2data = (uint8_t*)Bank2Address;
295
+        
296
+        uint16_t crcret = 0;
297
+        
298
+        CrcLength=
299
+        ((Bank1data[MBIC_BOOT_LENGTH] << 24 ) 
300
+        | Bank1data[MBIC_BOOT_LENGTH + 1]<<16 
301
+        | Bank1data[MBIC_BOOT_LENGTH + 2]<<8   
302
+        | Bank1data[MBIC_BOOT_LENGTH + 3]);    
303
+
304
+        if(CrcLength > 0)
305
+            crcret = CRC16_Generate(Bank1data, CrcLength + 128);
306
+        CrcLength += 128;
307
+        printf("Bank 1 Crc ret : %x  Length : %x :  %d \r\n",crcret ,CrcLength,CrcLength);
308
+        
309
+        CrcLength=
310
+        ((Bank2data[MBIC_BOOT_LENGTH] << 24 ) 
311
+        | Bank2data[MBIC_BOOT_LENGTH + 1]<<16 
312
+        | Bank2data[MBIC_BOOT_LENGTH + 2]<<8   
313
+        | Bank2data[MBIC_BOOT_LENGTH + 3]);  
314
+        printf("address : %x \r\n",Bank2data[0]);
315
+        
316
+        printf("Bank 2 Crc ret : %x  Length : %x :  %d  \r\n", crcret,CrcLength,CrcLength );
317
+        CrcLength += 128;
318
+         crcret = CRC16_Generate(Bank2data, CrcLength );
319
+        printf("Bank 2 Crc ret : %x  Length : %x :  %d  \r\n", crcret,CrcLength,CrcLength );
296
 
320
 
297
   PE43711_PinInit();
321
   PE43711_PinInit();
298
   EEPROM_M24C08_Init();
322
   EEPROM_M24C08_Init();
@@ -305,7 +329,7 @@ extern const uint16_t crc16_tab[256];
305
   Booting_LedInit();
329
   Booting_LedInit();
306
   Booting_LED_Check();
330
   Booting_LED_Check();
307
   InitUartQueue(&TerminalQueue);
331
   InitUartQueue(&TerminalQueue);
308
-#endif // PYJ.2020.06.24_END -- 
332
+
309
 #if 0 // PYJ.2020.04.22_BEGIN -- 
333
 #if 0 // PYJ.2020.04.22_BEGIN -- 
310
   EEPROM_M24C08_write(0xA0,0,i2cTestData,1);
334
   EEPROM_M24C08_write(0xA0,0,i2cTestData,1);
311
   printf("i2c Test Data1 %d\r\n",i2ctest[0]);
335
   printf("i2c Test Data1 %d\r\n",i2ctest[0]);
@@ -334,6 +358,7 @@ extern const uint16_t crc16_tab[256];
334
 
358
 
335
 //      while(1);
359
 //      while(1);
336
 #if 1 // PYJ.2020.05.06_BEGIN --
360
 #if 1 // PYJ.2020.05.06_BEGIN --
361
+     
337
       printf("****************************************\r\n");
362
       printf("****************************************\r\n");
338
       printf("MBIC Project\r\n");
363
       printf("MBIC Project\r\n");
339
       printf("Build at %s %s\r\n", __DATE__, __TIME__);
364
       printf("Build at %s %s\r\n", __DATE__, __TIME__);