Browse Source

Boot Loader Index 추가 / Bank 이름 추가 / Flash Config 추가 / Cpu 버전 표시하도록 수정 / AGC / ALC 알람 / DL Shutdown 알람 표시하도록 수정 / Flash Write 함수 추가 /

Uart Tx 프린트 추가 /  Flash init 에서 버전 정보 이미지이름 날짜 가져오도록 수정
PYJ 5 years ago
parent
commit
16011e0515

+ 38 - 0
Bluecell_Inc/Bluecell_operate.h

@@ -46,6 +46,20 @@ ETX
46 46
  *
47 47
  *
48 48
  */
49
+ 
50
+
51
+
52
+#define ANSI_COLOR_RED     "\x1b[31m"
53
+#define ANSI_COLOR_GREEN   "\x1b[32m"
54
+#define ANSI_COLOR_YELLOW  "\x1b[33m"
55
+#define ANSI_COLOR_BLUE    "\x1b[34m"
56
+#define ANSI_COLOR_MAGENTA "\x1b[35m"
57
+#define ANSI_COLOR_CYAN    "\x1b[36m"
58
+#define ANSI_COLOR_RESET   "\x1b[0m" "\r\n"    
59
+
60
+#define MBIC_BANK1_NUM 1
61
+#define MBIC_BANK1_NUM 2
62
+
49 63
 typedef enum{
50 64
 	AllDataReq = 0,      // -> Response 80
51 65
 	DataCtrlReq,		 // -> Response 81
@@ -695,6 +709,30 @@ typedef struct{
695 709
     uint8_t bluecell_User_UL3_H;  uint8_t bluecell_User_UL3_L;
696 710
     uint8_t bluecell_User_UL4_H;  uint8_t bluecell_User_UL4_L;
697 711
 }USER_ATTEN_st;
712
+typedef enum{
713
+    MBIC_BOOT_MARK  =     0,
714
+    MBIC_BOOT_TYPE   =    9   ,
715
+    MBIC_BOOT_FILE_TYPE=      10,
716
+    MBIC_BOOT_VERSION  = 11,
717
+    MBIC_BOOT_FILENAME  =      14,
718
+    MBIC_BOOT_CREATION_TIME=     55,
719
+    MBIC_BOOT_LENGTH = 61,
720
+    MBIC_BOOT_CRC     =65,
721
+    MBIC_BOOT_RESERVED =       69,
722
+
723
+}HFR_BootLoader_Index_;
724
+typedef enum{
725
+    HFR_BANK1 = 1,
726
+    HFR_BANK2 = 2,
727
+    HFR_FACTORY = 3,    
728
+
729
+}HFR_BootBankIndex_;
730
+typedef enum{
731
+    HFR_BANK1_SEL = 1,
732
+    HFR_BANK2_SEL = 2,
733
+    HFR_AUTO_SEL = 3,    
734
+
735
+}HFR_BootSelIndex_;
698 736
 
699 737
 typedef struct{
700 738
     uint8_t bluecell_header;

+ 12 - 0
Bluecell_Inc/flash.h

@@ -11,13 +11,25 @@
11 11
 #include "main.h"
12 12
 #include "CRC.h"
13 13
 
14
+#define FLASH_USER_BANK_NUM ((uint32_t)0x08005000) - 150
15
+
16
+#define FLASH_MBICUSER_START_ADDR (uint32_t)((0x08005000) - 128)
17
+#define FLASH_MBICUSER_END_ADDR FLASH_MBICUSER_START_ADDR + ((uint32_t)0xFFFF)
18
+
19
+
14 20
 #define FLASH_USER_START_ADDR ((uint32_t)0x08005000)
15 21
 #define FLASH_USER_END_ADDR     FLASH_USER_START_ADDR + ((uint32_t)0x000FFFF)   /* End @ of user Flash area */
16 22
 #define APPLICATION_ADDRESS     (uint32_t)0x08005000      /* Start user code address: ADDR_FLASH_PAGE_8 */
23
+#define BOOTLOADER_ADDRESS     (uint32_t)0x08000000      /* Start user code address: ADDR_FLASH_PAGE_8 */
24
+
17 25
 
18 26
 
19 27
 #define FLASH_USER_BANK1_START_ADDR ((uint32_t)0x08025000)
28
+#define FLASH_USER_BANK1_END_ADDR FLASH_USER_BANK1_START_ADDR + ((uint32_t)0x1FFFF)   /* End @ of user Flash area */
29
+
20 30
 #define FLASH_USER_BANK2_START_ADDR ((uint32_t)0x08045000)
31
+#define FLASH_USER_BANK2_END_ADDR FLASH_USER_BANK2_START_ADDR + ((uint32_t)0x2FFFF)
32
+
21 33
 
22 34
 
23 35
 

+ 86 - 40
Bluecell_Src/Bluecell_operate.c

@@ -11,16 +11,6 @@
11 11
 
12 12
 
13 13
 
14
-#define CPU_VERSION0 0
15
-#define CPU_VERSION1 0
16
-#define CPU_VERSION2 3
17
-#define ANSI_COLOR_RED     "\x1b[31m"
18
-#define ANSI_COLOR_GREEN   "\x1b[32m"
19
-#define ANSI_COLOR_YELLOW  "\x1b[33m"
20
-#define ANSI_COLOR_BLUE    "\x1b[34m"
21
-#define ANSI_COLOR_MAGENTA "\x1b[35m"
22
-#define ANSI_COLOR_CYAN    "\x1b[36m"
23
-#define ANSI_COLOR_RESET   "\x1b[0m" "\r\n"    
24 14
 
25 15
 
26 16
 
@@ -35,6 +25,8 @@ extern void Uart1_Data_Send(uint8_t* data,uint16_t size);
35 25
 extern HAL_StatusTypeDef EEPROM_M24C08_Zerowrite(uint8_t devid,uint16_t Address);
36 26
 extern uint8_t Chksum_Create(uint8_t *data);
37 27
 extern uint16_t CRC16_Generate(uint8_t* buf_ptr, int len);
28
+extern void MBIC_APIFLASH_Func(uint8_t* data,uint32_t size);
29
+
38 30
 /***************************************************************************************/
39 31
 /*                                  Extern Valuable                                    */
40 32
 /***************************************************************************************/
@@ -112,6 +104,7 @@ uint16_t ADC1Ret[4];
112 104
 bool UL_ALC_GainAttenSet[ALC_Alarm_UL_Index_MAX] = {false,};
113 105
 int16_t ALC_Level_Save[ALC_Alarm_UL_Index_MAX] = {0,};
114 106
 bool Initialize = false;
107
+bool AGC_AlarmSet[AGC_Alarm_DL_Index_MAX] = {0,};
115 108
 
116 109
 uint16_t ADC3Ret[5];
117 110
 
@@ -148,6 +141,9 @@ BLUESTATUS_st bluecell_Currdatastatus;
148 141
 BLUESTATUS_st bluecell_Prevdatastatus;
149 142
 int16_t DL_AGC_StartAtten[AGC_Alarm_DL_Index_MAX] = {0,};
150 143
 int16_t DL_PrevIwillgiveAtten[AGC_Alarm_DL_Index_MAX] = {0,};
144
+bool DL_PathUserHandl[4] = {0,};
145
+bool UL_PathUserHandl[4] = {0,};
146
+
151 147
 
152 148
 
153 149
 #if 0 // PYJ.2020.05.21_BEGIN -- 
@@ -2540,9 +2536,6 @@ typedef enum{
2540 2536
     MBIC Request List 
2541 2537
     Turn off all paths at boot
2542 2538
  */
2543
-   bluecell_Currdatastatus.CPUVERSION1 = CPU_VERSION0;
2544
-   bluecell_Currdatastatus.CPUVERSION2 = CPU_VERSION1;
2545
-   bluecell_Currdatastatus.CPUVERSION3 = CPU_VERSION2;
2546 2539
    
2547 2540
    bluecell_Currdatastatus.Type =  HAL_GPIO_ReadPin(UNIT_ID0_GPIO_Port,UNIT_ID0_Pin);
2548 2541
    bluecell_Currdatastatus.Type +=  HAL_GPIO_ReadPin(UNIT_ID1_GPIO_Port,UNIT_ID1_Pin) << 1;
@@ -2670,9 +2663,12 @@ uint32_t MBIC_DataSend(uint8_t* data){
2670 2663
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_MASK5 = 0xFF;
2671 2664
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_TEMP_HIGH;
2672 2665
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_DLI_Level;
2673
-    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN;
2666
+    data[MBIC_PAYLOADSTART + i++] = (bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm & 0xF0 )
2667
+                                  | (bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN & 0x0F);
2668
+    
2674 2669
     data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_ULO_Level;
2675
-    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm;
2670
+    data[MBIC_PAYLOADSTART + i++] = (bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm & 0xF0)
2671
+                                    |(bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN & 0x0F);
2676 2672
     
2677 2673
     /*ALARM BIT MASK*/
2678 2674
     data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
@@ -2706,9 +2702,9 @@ uint32_t MBIC_DataSend(uint8_t* data){
2706 2702
     data[MBIC_PAYLOADSTART + i++] = CPU_Version;
2707 2703
     Length += 3;
2708 2704
     data[MBIC_PAYLOADSTART + i++] = 3; // LENGTH
2709
-    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION1 = CPU_VERSION0;
2710
-    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION2 = CPU_VERSION1;
2711
-    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION3 = CPU_VERSION2;
2705
+    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION1;
2706
+    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION2;
2707
+    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION3;
2712 2708
     
2713 2709
 
2714 2710
 
@@ -3495,10 +3491,25 @@ bool MBIC_Operate(uint8_t* data){
3495 3491
                 break;
3496 3492
             case  CPU_Bank_Select_Reboot_by               :
3497 3493
                 bluecell_Currdatastatus.CPU_Bank_Select = data[MBIC_PAYLOADSTART + 3]; 
3498
-
3494
+                if(bluecell_Currdatastatus.CPU_Bank_Select == HFR_AUTO_SEL){
3495
+                    printf("Curr Bank : %d \r\n",bluecell_Currdatastatus.CPU_Current_Bank);
3496
+                    if(bluecell_Currdatastatus.CPU_Current_Bank == HFR_BANK1_SEL){
3497
+                        bluecell_Currdatastatus.CPU_Current_Bank = HFR_BANK2_SEL;
3498
+                    }else{
3499
+                        bluecell_Currdatastatus.CPU_Current_Bank = HFR_BANK1_SEL;
3500
+                    }
3501
+                }
3502
+                Bluecell_StructCpy(&DataWrite[0],&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st));
3503
+                EEPROM_M24C08_write(EEPROM_M24C08_ID ,(EEPROM_WINDOW_STATUS_ADDRESDS),&DataWrite[0],sizeof(BLUESTATUS_st));
3504
+                EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_WINDOW_STATUS_ADDRESDS,&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st) );
3505
+                printf("bluecell_Currdatastatus.CPU_Bank_Select : %d \r\n",bluecell_Currdatastatus.CPU_Bank_Select);
3506
+                printf("I will Booting Bank : %d \r\n",bluecell_Currdatastatus.CPU_Current_Bank);
3507
+                NVIC_SystemReset();
3499 3508
                 break;
3500 3509
             case  SW_Reset                                :
3510
+                printf("SoftWare Reset Start \r\n");
3501 3511
                 bluecell_Currdatastatus.S_W_Reset = data[MBIC_PAYLOADSTART + 3]; 
3512
+                NVIC_SystemReset();
3502 3513
                 break;
3503 3514
             case  Factory_Set_Initialization              :
3504 3515
                 bluecell_Currdatastatus.Factory_Set_Initialization = data[MBIC_PAYLOADSTART + 3]; 
@@ -3524,10 +3535,12 @@ bool MBIC_Operate(uint8_t* data){
3524 3535
                 bluecell_Prevdatastatus.DLI_Shutdown_Retry_Count1 = 0xFF;
3525 3536
                 if(data[MBIC_PAYLOADSTART + 3]==0){
3526 3537
                     HAL_GPIO_WritePin(PATH_EN_DL1_GPIO_Port,PATH_EN_DL1_Pin,GPIO_PIN_RESET);//CLOCK        
3538
+                    DL_PathUserHandl[0] = true;
3527 3539
                 }
3528 3540
                 else{
3529 3541
                     bluecell_Prevdatastatus.ATT_DL1_H = 0xFF;
3530 3542
                     bluecell_Prevdatastatus.ATT_DL1_L =0xFF;
3543
+                    DL_PathUserHandl[0] = false;                    
3531 3544
                     HAL_GPIO_WritePin(PATH_EN_DL1_GPIO_Port,PATH_EN_DL1_Pin,GPIO_PIN_SET);//CLOCK
3532 3545
                 }                
3533 3546
                 CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
@@ -3538,10 +3551,12 @@ bool MBIC_Operate(uint8_t* data){
3538 3551
                 bluecell_Prevdatastatus.DLI_Shutdown_Retry_Count2 = 0xFF;
3539 3552
                if(data[MBIC_PAYLOADSTART + 3]==0){
3540 3553
                    HAL_GPIO_WritePin(PATH_EN_DL2_GPIO_Port,PATH_EN_DL2_Pin,GPIO_PIN_RESET);//CLOCK        
3554
+                   DL_PathUserHandl[1] = true;
3541 3555
                }
3542 3556
                else{
3543 3557
                     bluecell_Prevdatastatus.ATT_DL2_H = 0xFF;
3544 3558
                     bluecell_Prevdatastatus.ATT_DL2_L = 0xFF;
3559
+                    DL_PathUserHandl[1] = false;                   
3545 3560
                    HAL_GPIO_WritePin(PATH_EN_DL2_GPIO_Port,PATH_EN_DL2_Pin,GPIO_PIN_SET);//CLOCK
3546 3561
                }
3547 3562
                 CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
@@ -3553,10 +3568,12 @@ bool MBIC_Operate(uint8_t* data){
3553 3568
                 bluecell_Prevdatastatus.DLI_Shutdown_Retry_Count3 = 0xFF;
3554 3569
                 if(data[MBIC_PAYLOADSTART + 3]==0){
3555 3570
                     HAL_GPIO_WritePin(PATH_EN_DL3_GPIO_Port,PATH_EN_DL3_Pin,GPIO_PIN_RESET);//CLOCK        
3571
+                    DL_PathUserHandl[2] = true;                
3556 3572
                 }
3557 3573
                 else{
3558 3574
                     bluecell_Prevdatastatus.ATT_DL3_H = 0xFF;
3559 3575
                     bluecell_Prevdatastatus.ATT_DL3_L = 0xFF;
3576
+                    DL_PathUserHandl[2] = false;    
3560 3577
                     HAL_GPIO_WritePin(PATH_EN_DL3_GPIO_Port,PATH_EN_DL3_Pin,GPIO_PIN_SET);//CLOCK
3561 3578
                 }
3562 3579
                 CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
@@ -3568,10 +3585,12 @@ bool MBIC_Operate(uint8_t* data){
3568 3585
                 bluecell_Prevdatastatus.DLI_Shutdown_Retry_Count4 = 0xFF;
3569 3586
                 if(data[MBIC_PAYLOADSTART + 3]==0){
3570 3587
                     HAL_GPIO_WritePin(PATH_EN_DL4_GPIO_Port,PATH_EN_DL4_Pin,GPIO_PIN_RESET);//CLOCK        
3588
+                    DL_PathUserHandl[3] = true;                                
3571 3589
                 }
3572 3590
                 else{
3573 3591
                     bluecell_Prevdatastatus.ATT_DL4_H =0xFF;
3574 3592
                     bluecell_Prevdatastatus.ATT_DL4_L = 0xFF;
3593
+                    DL_PathUserHandl[3] = false;                    
3575 3594
                     HAL_GPIO_WritePin(PATH_EN_DL4_GPIO_Port,PATH_EN_DL4_Pin,GPIO_PIN_SET);//CLOCK
3576 3595
                 }
3577 3596
                 CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
@@ -3651,6 +3670,12 @@ bool MBIC_Operate(uint8_t* data){
3651 3670
             case  DLI_AGC_ON_OFF                   :
3652 3671
                 /*AGC multi apply*/
3653 3672
                 bluecell_Currdatastatus.DLI_AGC_ON_OFF = data[MBIC_PAYLOADSTART + 3];
3673
+                if( bluecell_Currdatastatus.DLI_AGC_ON_OFF == false){
3674
+                    AGC_AlarmSet[AGC_Alarm_DL1_Index] = false;
3675
+                    AGC_AlarmSet[AGC_Alarm_DL2_Index] = false;
3676
+                    AGC_AlarmSet[AGC_Alarm_DL3_Index] = false;
3677
+                    AGC_AlarmSet[AGC_Alarm_DL4_Index] = false;
3678
+                }
3654 3679
                 DL_AGC_StartAtten[AGC_Alarm_DL1_Index] 
3655 3680
                     = bluecell_Currdatastatus.ATT_DL1_H << 8 | bluecell_Currdatastatus.ATT_DL1_L;
3656 3681
                 DL_AGC_StartAtten[AGC_Alarm_DL2_Index] 
@@ -4021,7 +4046,7 @@ bool MBIC_Operate(uint8_t* data){
4021 4046
 
4022 4047
     }
4023 4048
     else{
4024
-//        MBIC_Bootloader_FirmwareUpdate();
4049
+        MBIC_Bootloader_FirmwareUpdate(data);
4025 4050
         /*NOP*/
4026 4051
         printf("DATA ERR\r\n");
4027 4052
     }
@@ -4059,7 +4084,7 @@ void DascendigFunc(uint16_t* data,uint32_t size ){
4059 4084
   int temp;
4060 4085
   for(int i = 0 ; i < size - 1 ; i ++) {
4061 4086
       for(int j = i+1 ; j < size ; j ++) {
4062
-          if(data[i] < data[j]) {
4087
+	  if(data[i] < data[j]) {
4063 4088
               temp = data[j];
4064 4089
               data[j] = data[i];
4065 4090
               data[i] = temp;
@@ -5309,7 +5334,7 @@ void ALC_Function(){ //DL
5309 5334
 //            }
5310 5335
             bluecell_Currdatastatus.ULO_Level1_H = ((int16_t)ResultData & 0xFF00) >> 8;
5311 5336
             bluecell_Currdatastatus.ULO_Level1_L = ((int16_t)ResultData & 0x00FF);
5312
-#if 1 // PYJ.2020.06.20_BEGIN -- 
5337
+#if 0 // PYJ.2020.06.20_BEGIN -- 
5313 5338
             printf("============ALC_OFF======START================\r\n");
5314 5339
             printf("Current UL ADC VALUE : %f \r\n",ret);
5315 5340
             printf("ResdBm : UL1 : %f \r\n",ResdBm);
@@ -5411,7 +5436,7 @@ int8_t AGC_Calc(int8_t threshold,int8_t CurrDet){
5411 5436
     return Attenret;
5412 5437
 }
5413 5438
 
5414
-bool AGC_AlarmSet[AGC_Alarm_DL_Index_MAX] = {0,};
5439
+
5415 5440
 //bool AGC_AlarmTimerSet[AGC_Alarm_DL_Index_MAX] = {false,};
5416 5441
 void AGC_Alarm_Check(uint8_t Path_Index,double AGC_Det,uint8_t* AGC_Table,uint16_t CurrAtten){
5417 5442
     double TableAdc = 0;
@@ -5431,7 +5456,7 @@ void AGC_Alarm_Check(uint8_t Path_Index,double AGC_Det,uint8_t* AGC_Table,uint16
5431 5456
     
5432 5457
 
5433 5458
     if(AGC_Det > TableAdc + step){/*Alarm Enable*/
5434
-        AGC_AlarmSet[Path_Index] = true; /*Alarm Check val*/
5459
+//        AGC_AlarmSet[Path_Index] = true; /*Alarm Check val*/
5435 5460
 //        AGC_AlarmTimerSet[Path_Index] = false;/*Alarm Timer Setting Val*/
5436 5461
 //        AGCAlarmTimerCnt[Path_Index] = 0;/*Alarm Time Cnt Val*/
5437 5462
 //        printf("AGC ALARM ON %d \r\n",Path_Index + 1);
@@ -5443,7 +5468,7 @@ void AGC_Alarm_Check(uint8_t Path_Index,double AGC_Det,uint8_t* AGC_Table,uint16
5443 5468
 //            AGCAlarmTimerCnt[Path_Index] = 0;
5444 5469
 //        }
5445 5470
 //        if(AGCAlarmTimerCnt[Path_Index] > 3000){
5446
-            AGC_AlarmSet[Path_Index] = false;
5471
+//            AGC_AlarmSet[Path_Index] = false;
5447 5472
 //        }
5448 5473
     }
5449 5474
 
@@ -5472,6 +5497,7 @@ void AGC_Function(){//DL
5472 5497
         
5473 5498
 
5474 5499
         if(bluecell_Currdatastatus.DLI_AGC_ON_OFF == true){
5500
+            
5475 5501
             Limitdata = (( bluecell_Currdatastatus.DLI_AGC_Threshold_H << 8) & 0xFF00) ;
5476 5502
             Limitdata +=  bluecell_Currdatastatus.DLI_AGC_Threshold_L ;
5477 5503
             Limitdata /= 10; 
@@ -5482,7 +5508,14 @@ void AGC_Function(){//DL
5482 5508
         DL_Curr_Atten[AGC_Alarm_DL3_Index] = 
5483 5509
             bluecell_Currdatastatus.ATT_DL3_H  << 8 | bluecell_Currdatastatus.ATT_DL3_L;        
5484 5510
         DL_Curr_Atten[AGC_Alarm_DL4_Index] = 
5485
-            bluecell_Currdatastatus.ATT_DL4_H  << 8 | bluecell_Currdatastatus.ATT_DL4_L;            
5511
+            bluecell_Currdatastatus.ATT_DL4_H  << 8 | bluecell_Currdatastatus.ATT_DL4_L; 
5512
+        for(int k = 0; k < AGC_Alarm_DL_Index_MAX; k++){
5513
+            if((DL_Curr_Atten[AGC_Alarm_DL1_Index+i] / 10) <= -15   ){
5514
+                AGC_AlarmSet[AGC_Alarm_DL1_Index+i] = true;
5515
+            }else{
5516
+                AGC_AlarmSet[AGC_Alarm_DL1_Index+i] = false;
5517
+            }
5518
+        }
5486 5519
 #if 0 // PYJ.2020.06.23_BEGIN -- 
5487 5520
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL1_INDEX].DET_DL_0;
5488 5521
             ret  = bluecell_Currdatastatus.DLI_P1_Level1_H << 8;
@@ -5703,7 +5736,7 @@ void AGC_Function(){//DL
5703 5736
             Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,Det_DL2.Table_Length * 2,AGC_Table));
5704 5737
             bluecell_Currdatastatus.DLI_Level1_H = (Levelret & 0xFF00) >> 8;
5705 5738
             bluecell_Currdatastatus.DLI_Level1_L = (Levelret & 0x00FF);
5706
-#if 1 // PYJ.2020.06.20_BEGIN -- 
5739
+#if 0 // PYJ.2020.06.20_BEGIN -- 
5707 5740
             printf("========AGC OFF==========START================\r\n");
5708 5741
             printf(ANSI_COLOR_YELLOW"Current DL1 ADC VALUE : %f \r\n"ANSI_COLOR_RESET,ret);
5709 5742
             printf("AGC_Table[%d] : %d\r\n",i,AGC_Table[i]);
@@ -6137,7 +6170,8 @@ void DLI_ShutdownAlarmCheck()
6137 6170
         /***************************************************************************************************************/  
6138 6171
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index] < 3
6139 6172
             && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index] != MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index])
6140
-            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
6173
+            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC
6174
+            && DL_PathUserHandl[DET_Alarm_DL1_Shutdown_Index] == false){
6141 6175
             HAL_GPIO_WritePin(PATH_EN_DL1_GPIO_Port,PATH_EN_DL1_Pin,GPIO_PIN_SET);//CLOCK
6142 6176
             bluecell_Currdatastatus.ATT_DL1_PATH = true;            
6143 6177
             bluecell_Prevdatastatus.ATT_DL1_H = 0xFF;
@@ -6146,7 +6180,8 @@ void DLI_ShutdownAlarmCheck()
6146 6180
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
6147 6181
         }
6148 6182
         else if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index] == 3
6149
-            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index] >= MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC){
6183
+            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index] >= MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC
6184
+            && DL_PathUserHandl[DET_Alarm_DL1_Shutdown_Index] == false){
6150 6185
             HAL_GPIO_WritePin(PATH_EN_DL1_GPIO_Port,PATH_EN_DL1_Pin,GPIO_PIN_SET);//CLOCK
6151 6186
             bluecell_Currdatastatus.ATT_DL1_PATH = true;            
6152 6187
             bluecell_Prevdatastatus.ATT_DL1_H = 0xFF;
@@ -6180,7 +6215,8 @@ void DLI_ShutdownAlarmCheck()
6180 6215
         /***************************************************************************************************************/  
6181 6216
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index] < 3
6182 6217
             && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index] != MBIC_DL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index])
6183
-            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL2_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
6218
+            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL2_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC
6219
+            && DL_PathUserHandl[DET_Alarm_DL2_Shutdown_Index] == false){
6184 6220
             HAL_GPIO_WritePin(PATH_EN_DL2_GPIO_Port,PATH_EN_DL2_Pin,GPIO_PIN_SET);//CLOCK
6185 6221
             bluecell_Currdatastatus.ATT_DL2_PATH = true;            
6186 6222
             bluecell_Prevdatastatus.ATT_DL2_H = 0xFF;
@@ -6190,7 +6226,8 @@ void DLI_ShutdownAlarmCheck()
6190 6226
             printf("DL SHUTDOWN RECOVERY OPERATE PATH ON\r\n");
6191 6227
         }
6192 6228
         else if(MBIC_DL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index] == 3
6193
-            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL2_Shutdown_Index] >= MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC){
6229
+            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL2_Shutdown_Index] >= MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC
6230
+            && DL_PathUserHandl[DET_Alarm_DL2_Shutdown_Index] == false){
6194 6231
             HAL_GPIO_WritePin(PATH_EN_DL2_GPIO_Port,PATH_EN_DL2_Pin,GPIO_PIN_SET);//CLOCK
6195 6232
             bluecell_Currdatastatus.ATT_DL2_PATH = true;            
6196 6233
             bluecell_Prevdatastatus.ATT_DL2_H = 0xFF;
@@ -6227,7 +6264,8 @@ void DLI_ShutdownAlarmCheck()
6227 6264
         /***************************************************************************************************************/  
6228 6265
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index] < 3
6229 6266
             && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index] != MBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index])
6230
-            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL3_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
6267
+            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL3_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC
6268
+            && DL_PathUserHandl[DET_Alarm_DL3_Shutdown_Index] == true){
6231 6269
             HAL_GPIO_WritePin(PATH_EN_DL3_GPIO_Port,PATH_EN_DL3_Pin,GPIO_PIN_SET);//CLOCK
6232 6270
             bluecell_Currdatastatus.ATT_DL3_PATH = true;            
6233 6271
             bluecell_Prevdatastatus.ATT_DL3_H = 0xFF;
@@ -6236,7 +6274,8 @@ void DLI_ShutdownAlarmCheck()
6236 6274
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
6237 6275
         }
6238 6276
         else if(MBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index] == 3
6239
-            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL3_Shutdown_Index] >= MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC){
6277
+            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL3_Shutdown_Index] >= MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC
6278
+            && DL_PathUserHandl[DET_Alarm_DL3_Shutdown_Index] == true){
6240 6279
             HAL_GPIO_WritePin(PATH_EN_DL3_GPIO_Port,PATH_EN_DL3_Pin,GPIO_PIN_SET);//CLOCK
6241 6280
             bluecell_Currdatastatus.ATT_DL3_PATH = true;            
6242 6281
             bluecell_Prevdatastatus.ATT_DL3_H = 0xFF;
@@ -6271,7 +6310,8 @@ void DLI_ShutdownAlarmCheck()
6271 6310
         /***************************************************************************************************************/  
6272 6311
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] < 3
6273 6312
             && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] != MBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index])
6274
-            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL4_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
6313
+            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL4_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC
6314
+            && DL_PathUserHandl[DET_Alarm_DL4_Shutdown_Index] == true){
6275 6315
             HAL_GPIO_WritePin(PATH_EN_DL4_GPIO_Port,PATH_EN_DL4_Pin,GPIO_PIN_SET);//CLOCK
6276 6316
             bluecell_Currdatastatus.ATT_DL4_PATH = true;            
6277 6317
             bluecell_Prevdatastatus.ATT_DL4_H = 0xFF;
@@ -6280,7 +6320,8 @@ void DLI_ShutdownAlarmCheck()
6280 6320
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
6281 6321
         }
6282 6322
         else if(MBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] == 3
6283
-            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL4_Shutdown_Index] >= MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC){
6323
+            && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL4_Shutdown_Index] >= MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC
6324
+            && DL_PathUserHandl[DET_Alarm_DL4_Shutdown_Index] == true){
6284 6325
             HAL_GPIO_WritePin(PATH_EN_DL4_GPIO_Port,PATH_EN_DL4_Pin,GPIO_PIN_SET);//CLOCK
6285 6326
             bluecell_Currdatastatus.ATT_DL4_PATH = true;            
6286 6327
             bluecell_Prevdatastatus.ATT_DL4_H = 0xFF;
@@ -6756,9 +6797,10 @@ void DLI_AGCAlarmCheck(){
6756 6797
 //    }
6757 6798
 
6758 6799
     if(bluecell_Currdatastatus.DLI_AGC_ON_OFF == true){
6800
+//        printf("bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm : %x \r\n",bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm);
6759 6801
         if(AGC_AlarmSet[AGC_Alarm_DL1_Index] == true
6760 6802
          &&AGC_On_AlarmTimerCnt[AGC_Alarm_DL1_Index] >= MBIC_ON_MAINTAIN_SEC){
6761
-            printf("ALARM_AGC_P1 OCCUR\r\n");
6803
+//            printf("ALARM_AGC_P1 OCCUR\r\n");
6762 6804
             bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm |= ALARM_AGC_P1;
6763 6805
             bluecell_Currdatastatus.DLI_AGC_Alarm1       = true;
6764 6806
         }else{
@@ -6769,7 +6811,7 @@ void DLI_AGCAlarmCheck(){
6769 6811
         }
6770 6812
         if(AGC_AlarmSet[AGC_Alarm_DL2_Index] == true
6771 6813
          &&AGC_On_AlarmTimerCnt[AGC_Alarm_DL2_Index] >= MBIC_ON_MAINTAIN_SEC){
6772
-            printf("ALARM_AGC_P2 OCCUR\r\n");
6814
+//            printf("ALARM_AGC_P2 OCCUR\r\n");
6773 6815
             bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm |= ALARM_AGC_P2;
6774 6816
             bluecell_Currdatastatus.DLI_AGC_Alarm2       = true;
6775 6817
         }else{
@@ -6780,7 +6822,7 @@ void DLI_AGCAlarmCheck(){
6780 6822
         }
6781 6823
         if(AGC_AlarmSet[AGC_Alarm_DL3_Index] == true
6782 6824
          &&AGC_On_AlarmTimerCnt[AGC_Alarm_DL3_Index] >= MBIC_ON_MAINTAIN_SEC){
6783
-            printf("ALARM_AGC_P3 OCCUR\r\n");
6825
+//            printf("ALARM_AGC_P3 OCCUR\r\n");
6784 6826
             bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm |= ALARM_AGC_P3;
6785 6827
             bluecell_Currdatastatus.DLI_AGC_Alarm3       = true;
6786 6828
         }else{
@@ -6791,7 +6833,7 @@ void DLI_AGCAlarmCheck(){
6791 6833
         }
6792 6834
         if(AGC_AlarmSet[AGC_Alarm_DL3_Index] == true
6793 6835
          &&AGC_On_AlarmTimerCnt[AGC_Alarm_DL3_Index] >= MBIC_ON_MAINTAIN_SEC){
6794
-            printf("ALARM_AGC_P4 OCCUR\r\n");
6836
+//            printf("ALARM_AGC_P4 OCCUR\r\n");
6795 6837
             bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm |= ALARM_AGC_P4;
6796 6838
             bluecell_Currdatastatus.DLI_AGC_Alarm4       = true;
6797 6839
         }else{
@@ -6801,6 +6843,10 @@ void DLI_AGCAlarmCheck(){
6801 6843
             }
6802 6844
         }        
6803 6845
     }
6846
+    else{
6847
+        bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm = 0;
6848
+        bluecell_Currdatastatus.DLI_AGC_Alarm4       = false;            
6849
+    }
6804 6850
 }
6805 6851
 void Temp_HighAlarmCheck(){
6806 6852
     //double temp = 0;
@@ -6816,7 +6862,7 @@ void Temp_HighAlarmCheck(){
6816 6862
             if(bluecell_Currdatastatus.Temp_High_Threshold - 2 >= (bluecell_Currdatastatus.DET_TEMP )){
6817 6863
                 bluecell_Currdatastatus.Temp_High_Alarm = false;        
6818 6864
                 if( Alarm_Temp_TimerOffCnt > MBIC_OFF_MAINTAIN_SEC){
6819
-                    printf("1 Alarm TEMP OFF Curr : %d  Limit : %d \r\n",(bluecell_Currdatastatus.DET_TEMP ),bluecell_Currdatastatus.Temp_High_Threshold);
6865
+//                    printf("1 Alarm TEMP OFF Curr : %d  Limit : %d \r\n",(bluecell_Currdatastatus.DET_TEMP ),bluecell_Currdatastatus.Temp_High_Threshold);
6820 6866
                     bluecell_Currdatastatus.ALARM_TEMP_HIGH &= ~ENVIRONMENT_TEMPHIGH;
6821 6867
                 }
6822 6868
             }

+ 21 - 7
Bluecell_Src/MBIC_Bootloader.c

@@ -17,6 +17,9 @@
17 17
 extern __IO bool EraseInit;
18 18
 
19 19
 extern uint8_t Bank_Flash_write(uint8_t* data,uint32_t StartBankAddress);
20
+extern void MBIC_DataErase_Func(uint8_t bank_num);
21
+extern void MBIC_APIFLASH_Func(uint8_t* data,uint32_t size);
22
+extern void MBIC_DataBankWrite(uint8_t BankNum);
20 23
 
21 24
 
22 25
 
@@ -26,7 +29,7 @@ BootLoaderDataCheck_st MBIC_FileDataCheck(uint8_t* data){
26 29
   BootLoaderDataCheck_st ret = {0,0,false};
27 30
   int8_t MBIC_Mark[9] = "JT-NRDAS ";
28 31
   int8_t MBIC_FileName1[] = "jhfs-mbic-nrdas-v";
29
-  int8_t MBIC_FileName2[] = "v00.00.01.mbc";
32
+  int8_t MBIC_FileName2[] = "v00.00.04.mbc";
30 33
   uint8_t MBIC_type = 0x20;
31 34
   uint8_t MBIC_FileType = 0x00;
32 35
   int i = 0;
@@ -196,7 +199,8 @@ uint8_t* MBIC_HeaderMergeFunction(uint8_t* data,uint16_t Length )
196 199
 
197 200
     return data;
198 201
 }
199
-
202
+extern uint32_t MBIC_Address;
203
+uint8_t MBIC_Resp[2048];
200 204
 void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
201 205
     uint8_t MBIC_DownLoadData[0xFFFF];
202 206
     uint8_t cmd = data[MBIC_CMD_0];
@@ -230,6 +234,7 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
230 234
 //        printf("%c",*data++);
231 235
     switch(cmd){
232 236
         case MBIC_Notice_REQ:
237
+            printf("MBIC DOWNLOAD REQUEST \r\n");
233 238
             cmd = MBIC_Notice_RSP;
234 239
             /*TOTAL FRAME NUMBER*/
235 240
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 0];
@@ -247,7 +252,11 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
247 252
             data[MBIC_PAYLOADSTART + index++] = 0;
248 253
             data[MBIC_PAYLOADSTART + index++] = 0;
249 254
             data[MBIC_PAYLOADSTART + index++] = 0;
250
-            data[MBIC_PAYLOADSTART + index++] = 0;      
255
+            data[MBIC_PAYLOADSTART + index++] = 0;
256
+           
257
+//            MBIC_DataBankWrite(1);
258
+            //if()
259
+            MBIC_DataErase_Func(bluecell_Currdatastatus.CPU_Bank_Select);
251 260
 //            printf("ccc\r\n");
252 261
         break;
253 262
         case MBIC_Download_DATA_REQ:
@@ -276,12 +285,15 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
276 285
             data[MBIC_PAYLOADSTART + index++] = 0;
277 286
             data[MBIC_PAYLOADSTART + index++] = 0;
278 287
             data[MBIC_PAYLOADSTART + index++] = 0;
288
+#if 0 // PYJ.2020.06.24_BEGIN -- 
279 289
             for(i = 0; i < Curr_Download_DataIndex - Prev_Download_DataIndex; i++){
280
-                    MBIC_DownLoadData[i] = data[MBIC_PAYLOADSTART + 12 +i];
290
+                    MBIC_DownLoadData[i] = ;
281 291
 //                    printf("%02x ",MBIC_DownLoadData[i]);
282 292
             }
293
+#endif // PYJ.2020.06.24_END -- 
283 294
 //            printf("Data End\r\n");
284
-            Bank_Flash_write(data,FLASH_USER_BANK1_START_ADDR);
295
+//            Bank_Flash_write(data,FLASH_USER_BANK1_START_ADDR);
296
+              MBIC_APIFLASH_Func(&data[MBIC_PAYLOADSTART + 12],Curr_Download_DataIndex - Prev_Download_DataIndex);
285 297
 //            HAL_Delay(100);
286 298
             Prev_Download_DataIndex  = Curr_Download_DataIndex + 1;
287 299
             break;
@@ -352,8 +364,10 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
352 364
     data[MBIC_CMD_0] = cmd;
353 365
     
354 366
     data = MBIC_HeaderMergeFunction(data,index); // reponse
367
+    for(int i =0; i < 22 + 3 + index; i++){
368
+        MBIC_Resp[i] = data[i];
369
+    }
355 370
 //	HAL_UART_Transmit_DMA(&huart1, data,22 + 3 + index);
356
-
357 371
     
358
-    Uart1_Data_Send(data ,22 + 3 + index);
372
+    Uart1_Data_Send(MBIC_Resp ,22 + 3 + index);
359 373
 }

+ 317 - 14
Bluecell_Src/flash.c

@@ -6,9 +6,11 @@
6 6
  */
7 7
 #include "flash.h"
8 8
 #include "MBIC_Bootloader.h"
9
+#include "bluecell_operate.h"
9 10
 uint8_t flashinit = 0;
10 11
 uint32_t Address = FLASH_USER_START_ADDR;
11 12
 volatile static uint32_t UserAddress;
13
+uint32_t MBIC_Address;
12 14
 
13 15
 typedef void (*fptr)(void);
14 16
 fptr jump_to_app;
@@ -27,14 +29,107 @@ void Jump_App(void){
27 29
 
28 30
 
29 31
 
30
-void Flash_InitRead(void) // ?占쏙옙湲고븿?占쏙옙
32
+void Flash_InitRead() // ?占쏙옙湲고븿?占쏙옙
31 33
 {
32
-    uint32_t  Address = 0;
33
-    Address = FLASH_USER_BANK1_START_ADDR;
34
-    for(uint32_t i = 0; i < 300; i++ ){
35
-        printf("%08x : %02X \n",Address ,*(uint8_t*)Address);
34
+    uint32_t  CurrApiAddress = 0,Bank1Address=0,Bank2Address = 0;
35
+    uint32_t i = 0;
36
+    uint8_t ret = 0;
37
+    CurrApiAddress = FLASH_MBICUSER_START_ADDR;
38
+    Bank1Address = FLASH_USER_BANK1_START_ADDR;
39
+    Bank2Address = FLASH_USER_BANK2_START_ADDR;
40
+    
41
+    uint8_t* Currdata = (uint8_t*)CurrApiAddress;
42
+    uint8_t* Bank1data = (uint8_t*)Bank1Address;
43
+    uint8_t* Bank2data = (uint8_t*)Bank2Address;
44
+
45
+    
46
+    
47
+    printf("Flash Init \r\n");
48
+    for(int i = 0; i < 6; i++){
49
+        if(Currdata[MBIC_BOOT_CREATION_TIME + i] != Bank1data[MBIC_BOOT_CREATION_TIME + i]){
50
+            ret = HFR_BANK2;
51
+            printf("MBIC BANK2 Booting \r\n");
52
+            break;
53
+        }else{
54
+            ret = HFR_BANK1;
55
+        }
56
+    }
57
+    uint8_t* pdata;
58
+    bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime1 = Bank1data[MBIC_BOOT_CREATION_TIME + 0];
59
+    bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime2 = Bank1data[MBIC_BOOT_CREATION_TIME + 1];
60
+    bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime3 = Bank1data[MBIC_BOOT_CREATION_TIME + 2];
61
+    bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime4 = Bank1data[MBIC_BOOT_CREATION_TIME + 3];
62
+    bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime5 = Bank1data[MBIC_BOOT_CREATION_TIME + 4];
63
+    bluecell_Currdatastatus.CPU_Bank1_Image_BuildTime6 = Bank1data[MBIC_BOOT_CREATION_TIME + 5];
64
+
65
+    bluecell_Currdatastatus.CPU_Bank1_Image_Version1 = Bank1data[MBIC_BOOT_VERSION + 0];
66
+    bluecell_Currdatastatus.CPU_Bank1_Image_Version2 = Bank1data[MBIC_BOOT_VERSION + 1];
67
+    bluecell_Currdatastatus.CPU_Bank1_Image_Version3 = Bank1data[MBIC_BOOT_VERSION + 2];
68
+
69
+    pdata = &bluecell_Currdatastatus.CPU_Bank1_Image_Name;
70
+    printf("BANK1 IMAGE NAME : ");
71
+    for(int i = 0 ; i< 32; i++){
72
+        pdata[i] = Bank1data[MBIC_BOOT_FILENAME + i];
73
+        printf("%c",pdata[i]);
74
+    }
75
+    printf("\r\n");
76
+
77
+
78
+    bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime1 = Bank2data[MBIC_BOOT_CREATION_TIME + 0];
79
+    bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime2 = Bank2data[MBIC_BOOT_CREATION_TIME + 1];
80
+    bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime3 = Bank2data[MBIC_BOOT_CREATION_TIME + 2];
81
+    bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime4 = Bank2data[MBIC_BOOT_CREATION_TIME + 3];
82
+    bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime5 = Bank2data[MBIC_BOOT_CREATION_TIME + 4];
83
+    bluecell_Currdatastatus.CPU_Bank2_Image_BuildTime6 = Bank2data[MBIC_BOOT_CREATION_TIME + 5];
84
+
85
+    bluecell_Currdatastatus.CPU_Bank2_Image_Version1 = Bank2data[MBIC_BOOT_VERSION + 0];
86
+    bluecell_Currdatastatus.CPU_Bank2_Image_Version2 = Bank2data[MBIC_BOOT_VERSION + 1];
87
+    bluecell_Currdatastatus.CPU_Bank2_Image_Version3 = Bank2data[MBIC_BOOT_VERSION + 2];
88
+
89
+    pdata = & bluecell_Currdatastatus.CPU_Bank2_Image_Name;
90
+    printf("BANK2 IMAGE NAME : ");
91
+    for(int i = 0 ; i< 32; i++){
92
+        pdata[i] = Bank2data[MBIC_BOOT_FILENAME + i];  
93
+        printf("%c",pdata[i]);
94
+    }
95
+    printf("\r\n");
96
+
97
+    bluecell_Currdatastatus.CPUVERSION1 = Currdata[MBIC_BOOT_VERSION + 0];
98
+    bluecell_Currdatastatus.CPUVERSION2 = Currdata[MBIC_BOOT_VERSION + 1];
99
+    bluecell_Currdatastatus.CPUVERSION3 = Currdata[MBIC_BOOT_VERSION + 2];
100
+    
101
+
102
+
103
+    
104
+
105
+    printf("20%d Y / %d M / %d D / %d H / %d M / %d S  \r\n",
106
+        Currdata[MBIC_BOOT_CREATION_TIME + 0],
107
+        Currdata[MBIC_BOOT_CREATION_TIME + 1],
108
+        Currdata[MBIC_BOOT_CREATION_TIME + 2],
109
+        Currdata[MBIC_BOOT_CREATION_TIME + 3],
110
+        Currdata[MBIC_BOOT_CREATION_TIME + 4],
111
+        Currdata[MBIC_BOOT_CREATION_TIME + 5]        
112
+    );
113
+    bluecell_Currdatastatus.CPU_Current_Bank = ret;
114
+    
115
+    printf("MBIC BANK %d Booting \r\n",bluecell_Currdatastatus.CPU_Current_Bank);    
116
+
117
+    
118
+#if 0 // PYJ.2020.06.25_BEGIN -- 
119
+    for(i = 0; i < 128; i++ ){
120
+        printf("Address : %08x Value :  %02X \r\n",data+i  ,data[i]);
121
+
122
+    }
123
+#endif // PYJ.2020.06.25_END -- 
124
+    
125
+
126
+#if 0 // PYJ.2020.06.25_BEGIN -- 
127
+    for(i = 0; i < size; i++ ){
128
+        printf("Address : %08x Value :  %02X \r\n",Address ,*(uint8_t*)Address);
36 129
         Address++;
37 130
     }
131
+    Address -= i;
132
+#endif // PYJ.2020.06.25_END -- 
38 133
 #if 0 // PYJ.2019.03.27_BEGIN -- 
39 134
     for(uint32_t i = 0; i < 13848; i++ ){
40 135
         printf("%08x : %02X \n",Address ,*(uint8_t*)Address);
@@ -63,14 +158,12 @@ uint8_t Flash_Data_Write(uint8_t* data){
63 158
     Curr_Download_DataIndex += data[MBIC_PAYLOADSTART + 5] << 16;
64 159
     Curr_Download_DataIndex += data[MBIC_PAYLOADSTART + 6] << 8;            
65 160
     Curr_Download_DataIndex += data[MBIC_PAYLOADSTART + 7];      
66
-
67 161
 //    data[MBIC_PAYLOADSTART + 12 +i];
68
-   
69 162
     returntoFirst:
70 163
     for(i= 0; i <= Curr_Download_DataIndex - Prev_Download_DataIndex; i+=2){
71 164
         Firmdata  = ((data[MBIC_PAYLOADSTART + 12 +i]) & 0x00FF);
72 165
         Firmdata  += ((data[MBIC_PAYLOADSTART + 12 +i + 1] << 8) & 0xFF00);
73
-        if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,UserAddress ,   (uint16_t)Firmdata) != HAL_OK)
166
+        if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD,UserAddress ,   (uint16_t)Firmdata) != HAL_OK)
74 167
         {
75 168
             printf("HAL NOT OK \n");
76 169
             ret = 1;
@@ -78,7 +171,7 @@ uint8_t Flash_Data_Write(uint8_t* data){
78 171
             if(Errcnt == 0xFF)
79 172
                 return;
80 173
             
81
-            Errcnt++;
174
+//            Errcnt++;
82 175
             goto returntoFirst;
83 176
         }else{
84 177
             Errcnt = 0; //Err Cnt Init;
@@ -129,6 +222,7 @@ uint8_t API_Flash_Data_Write(uint8_t* data){
129 222
 
130 223
 
131 224
 
225
+#if 1 // PYJ.2020.06.24_BEGIN -- 
132 226
 uint8_t Bank_Flash_write(uint8_t* data,uint32_t StartBankAddress) // ?占쏙옙湲고븿?占쏙옙
133 227
 {
134 228
 
@@ -139,6 +233,7 @@ uint8_t Bank_Flash_write(uint8_t* data,uint32_t StartBankAddress) // ?占쏙옙
139 233
 
140 234
 
141 235
     HAL_FLASH_Unlock(); // lock ??占�?
236
+#if 0 // PYJ.2020.06.24_BEGIN -- 
142 237
     if(flashinit == 0){
143 238
         
144 239
         flashinit= 1;
@@ -170,19 +265,23 @@ uint8_t Bank_Flash_write(uint8_t* data,uint32_t StartBankAddress) // ?占쏙옙
170 265
             printf("Erase Failed \r\n");
171 266
         }
172 267
     }
268
+#endif // PYJ.2020.06.24_END -- 
173 269
     ret = Flash_Data_Write(&data[MBIC_PREAMBLE_0]);
174 270
     HAL_FLASH_Lock(); // lock ?占쏙옙洹멸린
175 271
     return ret;
176 272
 }
273
+#endif // PYJ.2020.06.24_END -- 
177 274
 #define DATA_32                 ((uint32_t)0x33333333)
178 275
 __IO bool EraseInit = false;
179 276
 
277
+#if 0 // PYJ.2020.06.24_BEGIN -- 
180 278
 void MBIC_APIFLASH_test(uint8_t* data,uint32_t size){
181 279
     static FLASH_EraseInitTypeDef EraseInitStruct;
182 280
     static uint32_t Address = 0, PAGEError = 0;
183
-        
281
+    
184 282
     static __IO uint32_t data32 = 0 , MemoryProgramStatus = 0;
185
-
283
+    int dataindex = 0;
284
+    uint32_t writedata = 0;
186 285
     HAL_FLASH_Unlock();
187 286
     
188 287
     /* Erase the user Flash area
@@ -192,7 +291,7 @@ void MBIC_APIFLASH_test(uint8_t* data,uint32_t size){
192 291
     if(EraseInit == false){
193 292
         EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
194 293
         EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
195
-        EraseInitStruct.NbPages     = ((FLASH_USER_BANK1_START_ADDR + ((uint32_t)0x000FFFF)) - FLASH_USER_BANK1_START_ADDR) / FLASH_PAGE_SIZE;
294
+        EraseInitStruct.NbPages     = ((FLASH_USER_BANK1_START_ADDR + ((uint32_t)0xFFFF)) - FLASH_USER_BANK1_START_ADDR) / FLASH_PAGE_SIZE;
196 295
         printf("Erase Start\r\n");
197 296
         if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK)
198 297
         {
@@ -219,11 +318,16 @@ void MBIC_APIFLASH_test(uint8_t* data,uint32_t size){
219 318
     
220 319
     Address = FLASH_USER_BANK1_START_ADDR;
221 320
     printf("HAL_FLASH_Program Start\r\n");
222
-    while (Address < ((FLASH_USER_BANK1_START_ADDR + 12)))
321
+    while (Address < ((FLASH_USER_BANK1_START_ADDR + size)))
223 322
     {
224
-      if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, Address, DATA_32) == HAL_OK)
323
+      writedata = data[dataindex + 0] ;
324
+      writedata += data[dataindex + 1] << 8 ;
325
+      writedata += data[dataindex + 2] << 16;
326
+      writedata += data[dataindex + 3] << 24;      
327
+      if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, Address,writedata) == HAL_OK)
225 328
       {
226 329
         Address = Address + 4;
330
+        dataindex  += 4;
227 331
       }
228 332
       else
229 333
       {
@@ -277,4 +381,203 @@ void MBIC_APIFLASH_test(uint8_t* data,uint32_t size){
277 381
 
278 382
 
279 383
 }
384
+#else
385
+
386
+void MBIC_DataBankWrite(uint8_t BankNum){
387
+    static FLASH_EraseInitTypeDef EraseInitStruct;
388
+    static uint32_t PAGEError = 0;
389
+
390
+    EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
391
+    EraseInitStruct.PageAddress = FLASH_USER_BANK_NUM;
392
+    EraseInitStruct.NbPages     = ((FLASH_USER_BANK_NUM + ((uint32_t)1)) - FLASH_USER_BANK_NUM) / FLASH_PAGE_SIZE;
393
+    printf("Erase Start BANK NUM\r\n");
394
+    if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK)
395
+    {
396
+      while (1)
397
+      {
398
+        HAL_Delay(2000);
399
+      }
400
+    }
401
+    printf("Erase End\r\n");
402
+    HAL_FLASH_Unlock();
403
+        if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, FLASH_USER_BANK_NUM,BankNum) == HAL_OK)
404
+        {
405
+            printf("Bank%d Write Success \r\n",BankNum);
406
+        }else{
407
+            printf("Bank%d Write Failed \r\n",BankNum);
408
+        }
409
+    HAL_FLASH_Lock();
410
+
411
+}
412
+
413
+void MBIC_DataErase_Func(uint8_t bank_num){
414
+    static FLASH_EraseInitTypeDef EraseInitStruct;
415
+    static uint32_t PAGEError = 0;
416
+
417
+    if(EraseInit == false){
418
+#if 0 // PYJ.2020.06.24_BEGIN -- 
419
+        EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
420
+        EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
421
+        printf("PageAddress : %x \r\n",FLASH_USER_BANK1_START_ADDR);
422
+//        EraseInitStruct.NbPages     = ((FLASH_USER_BANK1_START_ADDR + ((uint32_t)0xFFFF)) - FLASH_USER_BANK1_START_ADDR) / FLASH_PAGE_SIZE;
423
+        EraseInitStruct.NbPages     = (FLASH_USER_BANK1_START_ADDR - ((uint32_t)0xFFFF)) / FLASH_PAGE_SIZE;
424
+#else
425
+    if(bank_num == HFR_AUTO_SEL){
426
+        if(bluecell_Currdatastatus.CPU_Current_Bank == HFR_BANK1){
427
+            bank_num = HFR_BANK2;
428
+            printf("Curr Bank BANK 1 I will download Bank2 \r\n");
429
+        }
430
+        else{
431
+            bank_num = HFR_BANK1;
432
+            printf("Curr Bank BANK 2 I will download Bank1 \r\n");
433
+        }
434
+    }
435
+
436
+    if(bank_num == HFR_BANK2){
437
+        EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
438
+        EraseInitStruct.PageAddress = FLASH_USER_BANK2_START_ADDR;
439
+        EraseInitStruct.NbPages     = (FLASH_USER_BANK2_END_ADDR - FLASH_USER_BANK2_START_ADDR) / FLASH_PAGE_SIZE;
440
+        MBIC_Address = FLASH_USER_BANK2_START_ADDR;
441
+        printf("I will download Bank2 \r\n");
442
+        printf("Erase BANK 2 \r\n");
443
+    }else{
444
+        EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
445
+        EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
446
+        EraseInitStruct.NbPages     = (FLASH_USER_BANK1_END_ADDR - FLASH_USER_BANK1_START_ADDR) / FLASH_PAGE_SIZE;
447
+        MBIC_Address = FLASH_USER_BANK1_START_ADDR;
448
+        printf("I will download Bank1 \r\n");        
449
+        printf("Erase BANK 1 \r\n");        
450
+    }
451
+        EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
452
+        EraseInitStruct.PageAddress = FLASH_USER_BANK2_START_ADDR;
453
+        EraseInitStruct.NbPages     = (FLASH_USER_BANK2_END_ADDR - FLASH_USER_BANK2_START_ADDR) / FLASH_PAGE_SIZE;
454
+        MBIC_Address = FLASH_USER_BANK2_START_ADDR;    
455
+#endif // PYJ.2020.06.24_END -- 
456
+        printf("NbPages : %x \r\n",EraseInitStruct.NbPages );
457
+
458
+        printf("Erase Start\r\n");
459
+        if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK)
460
+        {
461
+          /*
462
+            Error occurred while page erase.
463
+            User can add here some code to deal with this error.
464
+            PAGEError will contain the faulty page and then to know the code error on this page,
465
+            user can call function 'HAL_FLASH_GetError()'
466
+          */
467
+          /* Infinite loop */
468
+          while (1)
469
+          {
470
+            /* Make LED2 blink (100ms on, 2s off) to indicate error in Erase operation */
471
+            printf("HAL_FLASHEx_Erase Error\r\n");
472
+            HAL_Delay(2000);
473
+          }
474
+        }
475
+        EraseInit = true;
476
+        printf("Erase End\r\n");
477
+    }
478
+
479
+}
480
+
481
+
482
+void MBIC_APIFLASH_Func(uint8_t* data,uint32_t size){
483
+
484
+    static uint32_t PAGEError = 0;
485
+    static uint32_t DownloadIndex;
486
+    static __IO uint32_t data32 = 0 , MemoryProgramStatus = 0;
487
+    int dataindex = 0;
488
+    uint32_t writedata = 0;
489
+    HAL_FLASH_Unlock();
490
+    
491
+    /* Erase the user Flash area
492
+      (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
493
+    
494
+    /* Fill EraseInit structure*/
495
+#if 0 // PYJ.2020.06.24_BEGIN -- 
496
+    if(EraseInit == false){
497
+        EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
498
+        EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
499
+        EraseInitStruct.NbPages     = ((FLASH_USER_BANK1_START_ADDR + ((uint32_t)0xFFFF)) - FLASH_USER_BANK1_START_ADDR) / FLASH_PAGE_SIZE;
500
+        printf("Erase Start\r\n");
501
+        if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK)
502
+        {
503
+          /*
504
+            Error occurred while page erase.
505
+            User can add here some code to deal with this error.
506
+            PAGEError will contain the faulty page and then to know the code error on this page,
507
+            user can call function 'HAL_FLASH_GetError()'
508
+          */
509
+          /* Infinite loop */
510
+          while (1)
511
+          {
512
+            /* Make LED2 blink (100ms on, 2s off) to indicate error in Erase operation */
513
+            printf("HAL_FLASHEx_Erase Error\r\n");
514
+            HAL_Delay(2000);
515
+          }
516
+        }
517
+        EraseInit = true;
518
+        printf("Erase End\r\n");
519
+    }
520
+#endif // PYJ.2020.06.24_END -- 
521
+    /* Program the user Flash area word by word
522
+      (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
523
+    
524
+//    MBIC_Address = FLASH_USER_BANK1_START_ADDR;
525
+    printf("HAL_FLASH_Program Start\r\n");
526
+    DownloadIndex += size;
527
+#if 0 // PYJ.2020.06.24_BEGIN -- 
528
+    while (MBIC_Address <= ((FLASH_USER_BANK1_START_ADDR + DownloadIndex)))
529
+    {
530
+      writedata = data[dataindex + 0] ;
531
+      writedata += data[dataindex + 1] << 8 ;
532
+      writedata += data[dataindex + 2] << 16;
533
+      writedata += data[dataindex + 3] << 24;      
534
+      if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, MBIC_Address,writedata) == HAL_OK)
535
+      {
536
+        MBIC_Address +=  4;
537
+        dataindex  += 4;
538
+      }
539
+      else
540
+      {
541
+        /* Error occurred while writing data in Flash memory.
542
+           User can add here some code to deal with this error */
543
+        while (1)
544
+        {
545
+          printf("HAL_FLASH_Program Error\r\n");
546
+        }
547
+      }
548
+    }
549
+#else   
550
+     printf("MBIC_Address : %x \r\n",MBIC_Address);
551
+     for(int downindex = 0; downindex < size; downindex+=4)
552
+     {
553
+       writedata = data[downindex + 0] ;
554
+       writedata += data[downindex + 1] << 8 ;
555
+       writedata += data[downindex + 2] << 16;
556
+       writedata += data[downindex + 3] << 24;      
557
+       if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, MBIC_Address,writedata) == HAL_OK)
558
+       {
559
+         MBIC_Address +=  4;
560
+       }
561
+       else
562
+       {
563
+         while (1)
564
+         {
565
+           printf("HAL_FLASH_Program Error\r\n");
566
+         }
567
+       }
568
+     }
569
+
570
+#endif // PYJ.2020.06.24_END -- 
571
+     printf("HAL_FLASH_Program END\r\n");
572
+    /* Lock the Flash to disable the flash control register access (recommended
573
+       to protect the FLASH memory against possible unwanted operation) *********/
574
+    HAL_FLASH_Lock();
575
+    
576
+    /* Check if the programmed data is OK
577
+        MemoryProgramStatus = 0: data programmed correctly
578
+        MemoryProgramStatus != 0: number of words not programmed correctly ******/
579
+}
580
+    
581
+
582
+#endif // PYJ.2020.06.24_END -- 
280 583
 

+ 8 - 6
Bluecell_Src/uart.c

@@ -140,14 +140,16 @@ void Uart_Check(void){
140 140
 
141 141
 void Uart1_Data_Send(uint8_t* data,uint16_t size){
142 142
     HAL_UART_Transmit(&hTerminal, &data[0],size,0xFFFF);
143
+//      HAL_UART_Transmit_DMA(&hTerminal, &data[0],size);
144
+
143 145
   //HAL_UART_Transmit_IT(&hTerminal, &data[0],size);
144 146
 //    printf("data[278] : %x \r\n",data[278]);
145
-//    HAL_Delay(1);   
146
-//    printf("\r\n [TX] : ");
147
-//    for(int i = 0; i< size; i++)
148
-//        printf("%02x ",data[i]);
149
-//    printf("\r\n\tCOUNT : %d \r\n",size);
150
-//    printf("\r\n");
147
+    HAL_Delay(1);   
148
+    printf("\r\n [TX] : ");
149
+    for(int i = 0; i< size; i++)
150
+        printf("%02x ",data[i]);
151
+    printf("\r\n\tCOUNT : %d \r\n",size);
152
+    printf("\r\n");
151 153
     
152 154
 }
153 155
 

+ 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"/>
60
+<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="uart_buf,0x08005000,0x8005000"/>
61 61
 </launchConfiguration>

+ 21 - 6
Src/main.c

@@ -345,6 +345,7 @@ extern void ALC_Function();
345 345
 extern void Boot_LED_Toggle(void);
346 346
 extern void ADC_Check(void);
347 347
 extern void Booting_LED_Check(void);
348
+uint8_t MBICTest_Firmdata[8]  = {1,2,3,4,5,6,7,8};
348 349
 
349 350
 /* USER CODE END 0 */
350 351
 
@@ -352,6 +353,7 @@ extern void Booting_LED_Check(void);
352 353
   * @brief  The application entry point.
353 354
   * @retval int
354 355
   */
356
+
355 357
 int main(void)  {
356 358
   /* USER CODE BEGIN 1 */
357 359
 
@@ -396,24 +398,24 @@ int main(void)  {
396 398
 
397 399
 
398 400
   setbuf(stdout, NULL);
401
+#if 1 // PYJ.2020.06.24_BEGIN -- 
399 402
   PE43711_PinInit();
400 403
   EEPROM_M24C08_Init();
404
+  Flash_InitRead();
405
+
401 406
 
402 407
 
403
-//  MBIC_APIFLASH_test();
404
-  //Flash_InitRead();
405 408
 
406 409
   Booting_LedInit();
407 410
   Booting_LED_Check();
408 411
   InitUartQueue(&TerminalQueue);
412
+#endif // PYJ.2020.06.24_END -- 
409 413
 #if 0 // PYJ.2020.04.22_BEGIN -- 
410 414
   EEPROM_M24C08_write(0xA0,0,i2cTestData,1);
411 415
   printf("i2c Test Data1 %d\r\n",i2ctest[0]);
412 416
   EEPROM_M24C08_Read(0xA0,0x00,i2ctest,2);
413 417
   printf("i2c Test Data2 %d\r\n",i2ctest[0]);
414 418
   printf("i2c Test Data2 %d\r\n",i2ctest[1]);
415
-#endif // PYJ.2020.04.22_END -- 
416
-
417 419
   /* USER CODE END 2 */
418 420
 
419 421
   /* Infinite loop */
@@ -427,15 +429,28 @@ int main(void)  {
427 429
 //  rrrrrr = ((CRC16_Generate(&retdate[0], 10)));  
428 430
 //  printf("CRC : %x \r\n",rrrrrr);
429 431
 //  Bluecell_DataInit();
430
-//  Bluecell_AttenInitialize();
432
+//  Bluecell_AttenInitialize();  
433
+#endif // PYJ.2020.04.22_END -- 
434
+
435
+
431 436
 #if 1 // PYJ.2020.05.06_BEGIN -- 
432 437
       printf("****************************************\r\n");
433 438
       printf("MBIC Project\r\n");
434 439
       printf("Build at %s %s\r\n", __DATE__, __TIME__);
435 440
       printf("Copyright (c) 2020. BLUECELL\r\n");
436 441
       printf("****************************************\r\n");
437
-#endif // PYJ.2020.05.06_END --   
442
+#endif // PYJ.2020.05.06_END --  
443
+#if 0 // PYJ.2020.06.24_BEGIN --
444
+  
445
+  MBIC_APIFLASH_test(&MBICTest_Firmdata[0],sizeof(MBICTest_Firmdata));
446
+  Flash_InitRead(8);
447
+
448
+  printf("Bootloader Test File \r\n");
449
+  while(1);
450
+#endif // PYJ.2020.06.24_END -- 
451
+  //NVIC_SystemReset();
438 452
 
453
+//  
439 454
   while (1)
440 455
   {
441 456
 //	  HAL_GPIO_TogglePin(GPIOG,GPIO_PIN_14);