Sfoglia il codice sorgente

iFlash Write Buf added

zhangbo 3 anni fa
parent
commit
d01a02c78d
4 ha cambiato i file con 64 aggiunte e 35 eliminazioni
  1. BIN
      app/bmc/bmc_app
  2. 16 8
      app/bmc/iflash.c
  3. 1 1
      app/bmc/iflash.h
  4. 47 26
      app/bmc/main.c

BIN
app/bmc/bmc_app


+ 16 - 8
app/bmc/iflash.c

@@ -159,9 +159,8 @@ void FLASH_Lock(void);
 
 
 /*准备写入的测试数据*/
-#define DATA_32                 ((uint32_t)0x13246578)
-#define BUFLENGTH 32
-uint32_t wrbuf[BUFLENGTH] = {0xabcdef12};  
+
+
 
 /* Exported types ------------------------------------------------------------*/
 /* Exported constants --------------------------------------------------------*/
@@ -176,7 +175,7 @@ uint32_t wrbuf[BUFLENGTH] = {0xabcdef12};
   * @param  None
   * @retval None
   */
-int InternalFlash_Test(void)
+int InternalFlash_WriteBuf(const uint8_t* data, uint32_t length)
 {
 	/*要擦除的起始扇区(包含)及结束扇区(不包含),如8-12,表示擦除8、9、10、11扇区*/
 	uint32_t uwStartSector = 0;
@@ -187,8 +186,16 @@ int InternalFlash_Test(void)
 
 	// __IO uint32_t uwData32 = 0;
 	__IO uint32_t uwMemoryProgramStatus = 0;
+  __IO uint32_t rr=0;
+
+  uint8_t* pbuf = data;
+  //pbuf = (uint8_t*)malloc(length*sizeof(uint8_t));
+
+
+
+	static uint32_t i = 0;
+
 
-	int i = 0;
 	
   /* FLASH 解锁 ********************************/
   /* 使能访问FLASH控制寄存器 */
@@ -232,11 +239,12 @@ int InternalFlash_Test(void)
   uwAddress = FLASH_USER_START_ADDR;
 
 
-  for (i=0;i < BUFLENGTH;i++)
+  for (i=0;i < length;i++)
   {
-    if (FLASH_ProgramWord(uwAddress, DATA_32) == FLASH_COMPLETE)
+    rr = pbuf[i];
+    if (FLASH_ProgramByte(uwAddress, rr) == FLASH_COMPLETE)
     {
-      uwAddress = uwAddress + 4;
+      uwAddress = uwAddress + 1;
     }
     else
     { 

+ 1 - 1
app/bmc/iflash.h

@@ -3,6 +3,6 @@
 #include <stdio.h>
 #include <stdint.h>
 
-//int InternalFlash_Test(void);
+int InternalFlash_WriteBuf(const uint8_t* const data, uint32_t length);
 
 #endif /* __IFLASH_H__ */

+ 47 - 26
app/bmc/main.c

@@ -77,35 +77,56 @@ BladeStatus_T gBladeStatus[BLADE_NUMBERS] = {
 static int tmp_fd;
 void main(void)
 {
-// 	if(0 != cm_Auth_Encrp_Init(1, 1, TRUE))
-// 	{
-// 		printf("Initialize AT88SC0104C failed!\n");
-// 		sleep(1);
-// 		return;
-// 	}
-// 	printf("cm_Auth_Encrp_Init ok\n");
 
-// #if 0
-// 	if(0 != cm_Auth_Encrp_Personal(1, 1))
-// 	{
-// 		printf("Personal AT88SC0104C failed!\n");
-// 		sleep(1);
-// 		return ;
-// 	}
-// #endif
+	unsigned char license[128]={0};
+	int i = 0;
+	for (i = 0; i<128; i++){
+		license[i] = i;
+	} 
+
+
+	InternalFlash_WriteBuf(license, 128);
+
+	unsigned char * pfls = 0;
+	unsigned int addrs = 0x08060000;
+	
+	for (i = 0; i<128; i++){
+
+		pfls = (unsigned char*)addrs;
+
+		printf("%x:%x  \n", addrs, *pfls);
+		addrs++;
+	}
 
-// 	if(0 != test_cryptomem())
-// 	{
-// 		while(1)
-// 		{
-// 			printf("Illegal Board!\n");
-// 			sleep(3);
-// 		}
-// 	}
 
-	//检查软件授权
-	if(CheckLicense() != 0)
-		exit(0);
+	printf("\n\n");
+
+
+	if(0 != cm_Auth_Encrp_Init(1, 1, TRUE))
+	{
+		printf("Initialize AT88SC0104C failed!\n");
+		sleep(1);
+		return;
+	}
+	printf("cm_Auth_Encrp_Init ok\n");
+
+#if 0
+	if(0 != cm_Auth_Encrp_Personal(1, 1))
+	{
+		printf("Personal AT88SC0104C failed!\n");
+		sleep(1);
+		return ;
+	}
+#endif
+
+	if(0 != test_cryptomem())
+	{
+		while(1)
+		{
+			printf("Illegal Board!\n");
+			sleep(3);
+		}
+	}
 
 	PlatformInit();
 	Init_IPMI_FRU_SDR_SEL();