zhangbo 3 gadi atpakaļ
vecāks
revīzija
fc0e5f2a29
38 mainītis faili ar 480 papildinājumiem un 842 dzēšanām
  1. BIN
      app/AuthLicense/authlicense
  2. 0 612
      app/AuthLicense/iflash.c
  3. 0 8
      app/AuthLicense/iflash.h
  4. BIN
      app/NCP81111_Config/ncp81111_cfg
  5. BIN
      app/UpdateFirmware/updateFW_app
  6. 22 28
      app/bmc/ipmb/IPMBIfc.c
  7. 0 1
      app/bmc/message.c
  8. 7 6
      app/bmc/msghndlr/MsgHndlrTask.c
  9. 2 0
      app/bmc/msghndlr/PDKCmds.c
  10. 137 0
      app/bmc/msghndlr/Storlead/Storlead.c
  11. 2 0
      app/bmc/msghndlr/Storlead/Storlead.h
  12. 2 0
      app/bmc/msghndlr/cmdselect.c
  13. 5 1
      app/bmc/readme.txt
  14. 6 16
      app/bmc/uds/UDSIfc.c
  15. 0 11
      app/common_include/com_BmcType.h
  16. 2 0
      app/common_include/com_IPMI_Storlead.h
  17. BIN
      app/driver/InternalFlash/iflash.ko
  18. 1 1
      app/driver/driver.h
  19. 7 7
      app/goahead-3.6.5/src/auth.c
  20. 1 1
      app/goahead-3.6.5/src/cJSON/cJSON.c
  21. 10 10
      app/goahead-3.6.5/src/goahead-mbedtls/goahead-mbedtls.c
  22. 4 4
      app/goahead-3.6.5/src/goahead.c
  23. 4 44
      app/goahead-3.6.5/src/goahead.h
  24. 15 15
      app/goahead-3.6.5/src/http.c
  25. 4 0
      app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h
  26. 108 0
      app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c
  27. 3 2
      app/goahead-3.6.5/src/libipmi/src/sensor_helpers.c
  28. 4 0
      app/goahead-3.6.5/src/libipmi/src/userinfo.c
  29. 8 8
      app/goahead-3.6.5/src/route.c
  30. 17 17
      app/goahead-3.6.5/src/runtime.c
  31. 4 4
      app/goahead-3.6.5/src/socket.c
  32. 6 6
      app/goahead-3.6.5/src/utils/gopass.c
  33. 70 18
      app/goahead-3.6.5/src/web_interface/src/config.c
  34. 15 11
      app/goahead-3.6.5/src/web_interface/src/fw_update.c
  35. 7 4
      app/goahead-3.6.5/src/web_interface/src/server_health.c
  36. 7 7
      app/hal_api/hal_spi_interface.c
  37. BIN
      app/i2c_scan/i2c-scan
  38. BIN
      app/test_app/test_app

BIN
app/AuthLicense/authlicense


+ 0 - 612
app/AuthLicense/iflash.c

@@ -1,612 +0,0 @@
-
-#include "iflash.h"
-
-enum {RESET = 0, SET = !RESET};
-
-#define     __IO    volatile 
-
-/* Base address of the Flash sectors */ 
-#define ADDR_FLASH_SECTOR_0     ((uint32_t)0x08000000) /* Base address of Sector 0, 16 Kbytes   */
-#define ADDR_FLASH_SECTOR_1     ((uint32_t)0x08004000) /* Base address of Sector 1, 16 Kbytes   */
-#define ADDR_FLASH_SECTOR_2     ((uint32_t)0x08008000) /* Base address of Sector 2, 16 Kbytes   */
-#define ADDR_FLASH_SECTOR_3     ((uint32_t)0x0800C000) /* Base address of Sector 3, 16 Kbytes   */
-#define ADDR_FLASH_SECTOR_4     ((uint32_t)0x08010000) /* Base address of Sector 4, 64 Kbytes   */
-#define ADDR_FLASH_SECTOR_5     ((uint32_t)0x08020000) /* Base address of Sector 5, 128 Kbytes  */
-#define ADDR_FLASH_SECTOR_6     ((uint32_t)0x08040000) /* Base address of Sector 6, 128 Kbytes  */
-#define ADDR_FLASH_SECTOR_7     ((uint32_t)0x08060000) /* Base address of Sector 7, 128 Kbytes  */
-#define ADDR_FLASH_SECTOR_8     ((uint32_t)0x08080000) /* Base address of Sector 8, 128 Kbytes  */
-#define ADDR_FLASH_SECTOR_9     ((uint32_t)0x080A0000) /* Base address of Sector 9, 128 Kbytes  */
-#define ADDR_FLASH_SECTOR_10    ((uint32_t)0x080C0000) /* Base address of Sector 10, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_11    ((uint32_t)0x080E0000) /* Base address of Sector 11, 128 Kbytes */
-
-#define ADDR_FLASH_SECTOR_12     ((uint32_t)0x08100000) /* Base address of Sector 12, 16 Kbytes  */
-#define ADDR_FLASH_SECTOR_13     ((uint32_t)0x08104000) /* Base address of Sector 13, 16 Kbytes  */
-#define ADDR_FLASH_SECTOR_14     ((uint32_t)0x08108000) /* Base address of Sector 14, 16 Kbytes  */
-#define ADDR_FLASH_SECTOR_15     ((uint32_t)0x0810C000) /* Base address of Sector 15, 16 Kbytes  */
-#define ADDR_FLASH_SECTOR_16     ((uint32_t)0x08110000) /* Base address of Sector 16, 64 Kbytes  */
-#define ADDR_FLASH_SECTOR_17     ((uint32_t)0x08120000) /* Base address of Sector 17, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_18     ((uint32_t)0x08140000) /* Base address of Sector 18, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_19     ((uint32_t)0x08160000) /* Base address of Sector 19, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_20     ((uint32_t)0x08180000) /* Base address of Sector 20, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_21     ((uint32_t)0x081A0000) /* Base address of Sector 21, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_22     ((uint32_t)0x081C0000) /* Base address of Sector 22, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_23     ((uint32_t)0x081E0000) /* Base address of Sector 23, 128 Kbytes */
-
-#define SECTOR_MASK               ((uint32_t)0xFFFFFF07)
-
-
-/** @defgroup FLASH_Flags 
-  * @{
-  */ 
-#define FLASH_FLAG_EOP                 ((uint32_t)0x00000001)  /*!< FLASH End of Operation flag               */
-#define FLASH_FLAG_OPERR               ((uint32_t)0x00000002)  /*!< FLASH operation Error flag                */
-#define FLASH_FLAG_WRPERR              ((uint32_t)0x00000010)  /*!< FLASH Write protected error flag          */
-#define FLASH_FLAG_PGAERR              ((uint32_t)0x00000020)  /*!< FLASH Programming Alignment error flag    */
-#define FLASH_FLAG_PGPERR              ((uint32_t)0x00000040)  /*!< FLASH Programming Parallelism error flag  */
-#define FLASH_FLAG_PGSERR              ((uint32_t)0x00000080)  /*!< FLASH Programming Sequence error flag     */
-#define FLASH_FLAG_RDERR               ((uint32_t)0x00000100)  /*!< Read Protection error flag (PCROP)        */
-#define FLASH_FLAG_BSY                 ((uint32_t)0x00010000)  /*!< FLASH Busy flag                           */ 
-
-/** @defgroup FLASH_Sectors
-  * @{
-  */
-#define FLASH_Sector_0     ((uint16_t)0x0000) /*!< Sector Number 0   */
-#define FLASH_Sector_1     ((uint16_t)0x0008) /*!< Sector Number 1   */
-#define FLASH_Sector_2     ((uint16_t)0x0010) /*!< Sector Number 2   */
-#define FLASH_Sector_3     ((uint16_t)0x0018) /*!< Sector Number 3   */
-#define FLASH_Sector_4     ((uint16_t)0x0020) /*!< Sector Number 4   */
-#define FLASH_Sector_5     ((uint16_t)0x0028) /*!< Sector Number 5   */
-#define FLASH_Sector_6     ((uint16_t)0x0030) /*!< Sector Number 6   */
-#define FLASH_Sector_7     ((uint16_t)0x0038) /*!< Sector Number 7   */
-#define FLASH_Sector_8     ((uint16_t)0x0040) /*!< Sector Number 8   */
-#define FLASH_Sector_9     ((uint16_t)0x0048) /*!< Sector Number 9   */
-#define FLASH_Sector_10    ((uint16_t)0x0050) /*!< Sector Number 10  */
-#define FLASH_Sector_11    ((uint16_t)0x0058) /*!< Sector Number 11  */
-#define FLASH_Sector_12    ((uint16_t)0x0080) /*!< Sector Number 12  */
-#define FLASH_Sector_13    ((uint16_t)0x0088) /*!< Sector Number 13  */
-#define FLASH_Sector_14    ((uint16_t)0x0090) /*!< Sector Number 14  */
-#define FLASH_Sector_15    ((uint16_t)0x0098) /*!< Sector Number 15  */
-#define FLASH_Sector_16    ((uint16_t)0x00A0) /*!< Sector Number 16  */
-#define FLASH_Sector_17    ((uint16_t)0x00A8) /*!< Sector Number 17  */
-#define FLASH_Sector_18    ((uint16_t)0x00B0) /*!< Sector Number 18  */
-#define FLASH_Sector_19    ((uint16_t)0x00B8) /*!< Sector Number 19  */
-#define FLASH_Sector_20    ((uint16_t)0x00C0) /*!< Sector Number 20  */
-#define FLASH_Sector_21    ((uint16_t)0x00C8) /*!< Sector Number 21  */
-#define FLASH_Sector_22    ((uint16_t)0x00D0) /*!< Sector Number 22  */
-#define FLASH_Sector_23    ((uint16_t)0x00D8) /*!< Sector Number 23  */
-
-/** 
-  * @brief FLASH Status  
-  */ 
-typedef enum
-{ 
-  FLASH_BUSY = 1,
-  FLASH_ERROR_RD,
-  FLASH_ERROR_PGS,
-  FLASH_ERROR_PGP,
-  FLASH_ERROR_PGA,
-  FLASH_ERROR_WRP,
-  FLASH_ERROR_PROGRAM,
-  FLASH_ERROR_OPERATION,
-  FLASH_COMPLETE
-}FLASH_Status;
-
-
-/** @defgroup FLASH_Voltage_Range 
-  * @{
-  */ 
-#define VoltageRange_1        ((uint8_t)0x00)  /*!< Device operating range: 1.8V to 2.1V */
-#define VoltageRange_2        ((uint8_t)0x01)  /*!<Device operating range: 2.1V to 2.7V */
-#define VoltageRange_3        ((uint8_t)0x02)  /*!<Device operating range: 2.7V to 3.6V */
-#define VoltageRange_4        ((uint8_t)0x03)  /*!<Device operating range: 2.7V to 3.6V + External Vpp */
-
-/** @defgroup FLASH_Program_Parallelism   
-  * @{
-  */
-#define FLASH_PSIZE_BYTE           ((uint32_t)0x00000000)
-#define FLASH_PSIZE_HALF_WORD      ((uint32_t)0x00000100)
-#define FLASH_PSIZE_WORD           ((uint32_t)0x00000200)
-#define FLASH_PSIZE_DOUBLE_WORD    ((uint32_t)0x00000300)
-#define CR_PSIZE_MASK              ((uint32_t)0xFFFFFCFF)
-
-#define PERIPH_BASE           ((uint32_t)0x40000000) 
-#define AHB1PERIPH_BASE       (PERIPH_BASE + 0x00020000)
-#define FLASH_R_BASE          (AHB1PERIPH_BASE + 0x3C00)
-
-/** @defgroup FLASH_Keys 
-  * @{
-  */ 
-
-#define FLASH_KEY1               ((uint32_t)0x45670123)
-#define FLASH_KEY2               ((uint32_t)0xCDEF89AB)
-
-
-typedef struct
-{
-  __IO uint32_t ACR;      /*!< FLASH access control register,   Address offset: 0x00 */
-  __IO uint32_t KEYR;     /*!< FLASH key register,              Address offset: 0x04 */
-  __IO uint32_t OPTKEYR;  /*!< FLASH option key register,       Address offset: 0x08 */
-  __IO uint32_t SR;       /*!< FLASH status register,           Address offset: 0x0C */
-  __IO uint32_t CR;       /*!< FLASH control register,          Address offset: 0x10 */
-  __IO uint32_t OPTCR;    /*!< FLASH option control register ,  Address offset: 0x14 */
-  __IO uint32_t OPTCR1;   /*!< FLASH option control register 1, Address offset: 0x18 */
-} FLASH_TypeDef;
-
-
-
-#define FLASH               ((FLASH_TypeDef *) FLASH_R_BASE)
-
-/*******************  Bits definition for FLASH_CR register  ******************/
-#define FLASH_CR_PG                          ((uint32_t)0x00000001)
-#define FLASH_CR_SER                         ((uint32_t)0x00000002)
-#define FLASH_CR_STRT                        ((uint32_t)0x00010000)
-#define FLASH_CR_LOCK                        ((uint32_t)0x80000000)
-
-
-
-static uint32_t GetSector(uint32_t Address);
-void FLASH_Unlock(void);
-FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange);
-FLASH_Status FLASH_WaitForLastOperation(void);
-FLASH_Status FLASH_GetStatus(void);
-FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
-FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
-FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data);
-void FLASH_Lock(void);
-
-
-
-
-
-/*准备写入的测试数据*/
-#define DATA_32                 ((uint32_t)0x13246578)
-#define BUFLENGTH 32
-uint32_t wrbuf[BUFLENGTH] = {0xabcdef12};  
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-/* 要擦除内部FLASH的起始地址(含) */
-#define FLASH_USER_START_ADDR   ADDR_FLASH_SECTOR_7   
-/* 要擦除内部FLASH的结束地址(不含) */
-#define FLASH_USER_END_ADDR     ADDR_FLASH_SECTOR_8  
-
-
-// /**
-//   * @brief  InternalFlash_Test,对内部FLASH进行读写测试
-//   * @param  None
-//   * @retval None
-//   */
-// int InternalFlash_Test(void)
-// {
-// 	/*要擦除的起始扇区(包含)及结束扇区(不包含),如8-12,表示擦除8、9、10、11扇区*/
-// 	uint32_t uwStartSector = 0;
-// 	uint32_t uwEndSector = 0;
-	
-// 	uint32_t uwAddress = 0;
-// 	uint32_t uwSectorCounter = 0;
-
-// 	// __IO uint32_t uwData32 = 0;
-// 	__IO uint32_t uwMemoryProgramStatus = 0;
-
-// 	int i = 0;
-	
-//   /* FLASH 解锁 ********************************/
-//   /* 使能访问FLASH控制寄存器 */
-//   FLASH_Unlock();
-    
-//   /* 擦除用户区域 (用户区域指程序本身没有使用的空间,可以自定义)**/
-//   /* 清除各种FLASH的标志位 */  
-// //  FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | 
-// //                  FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); 
-    
-//     *((volatile uint32_t *)0x40023c0C) = (((uint32_t)0x00000001) | ((uint32_t)0x00000002) | ((uint32_t)0x00000010) | \
-//                                         ((uint32_t)0x00000020) | ((uint32_t)0x00000040) | ((uint32_t)0x00000080));
-    
-
-
-// 	uwStartSector = GetSector(FLASH_USER_START_ADDR);
-// 	uwEndSector = GetSector(FLASH_USER_END_ADDR);
-
-//   /* 开始擦除操作 */
-//   uwSectorCounter = uwStartSector;
-//   while (uwSectorCounter <= uwEndSector) 
-//   {
-//      // VoltageRange_3 以“字”的大小进行操作  
-//     if (FLASH_EraseSector(uwSectorCounter, VoltageRange_3) != FLASH_COMPLETE)
-//     { 
-//       /*擦除出错,返回,实际应用中可加入处理 */
-// 			return -1;
-//     }
-//     /* 计数器指向下一个扇区 */
-//     if (uwSectorCounter == FLASH_Sector_11)
-//     {
-//       uwSectorCounter += 40;
-//     } 
-//     else 
-//     {
-//       uwSectorCounter += 8;
-//     }
-//   }
-
-//   /* 以“字节”的大小为单位写入数据 ********************************/
-//   uwAddress = FLASH_USER_START_ADDR;
-
-
-//   for (i=0;i < BUFLENGTH;i++)
-//   {
-//     uint32_t rr = 0x12345600;//wrbuf[i];
-//     if (FLASH_ProgramWord(uwAddress, rr) == FLASH_COMPLETE)
-//     {
-//       uwAddress = uwAddress + 4;
-//     }
-//     else
-//     { 
-//       /*写入出错,返回,实际应用中可加入处理 */
-// 			break;
-//     }
-//   }
-	
-
-//   /* 给FLASH上锁,防止内容被篡改*/
-//   FLASH_Lock(); 
-
-// }
-
-
-int WriteLicensetoFlash(uint8_t *license )
-{
-    int index=0;
-    uint32_t eraseSector = 0;
-    uint32_t address = ADDR_FLASH_SECTOR_6;
-    uint32_t *ptr = (uint32_t*)license;
-    FLASH_Unlock();
-  /* 清除各种FLASH的标志位 */  
-    *((volatile uint32_t *)0x40023c0C) = (((uint32_t)0x00000001) | ((uint32_t)0x00000002) | ((uint32_t)0x00000010) | \
-                                        ((uint32_t)0x00000020) | ((uint32_t)0x00000040) | ((uint32_t)0x00000080));
-    
-    eraseSector = GetSector(ADDR_FLASH_SECTOR_6);
-    if(FLASH_EraseSector(eraseSector, VoltageRange_3) != FLASH_COMPLETE)
-    {
-      printf("Erase Flash sector 7 failed!\n");
-      FLASH_Lock();
-      return -1;
-    }
-
-    for(index=0;index<32;index++)
-    {
-      FLASH_ProgramWord(address, (uint32_t)0x11223344);
-      address += 4;
-      ptr++;
-    }
-
-    FLASH_Lock(); 
-}
-
-/**
-  * @brief  根据输入的地址给出它所在的sector
-  *					例如:
-						uwStartSector = GetSector(FLASH_USER_START_ADDR);
-						uwEndSector = GetSector(FLASH_USER_END_ADDR);	
-  * @param  Address:地址
-  * @retval 地址所在的sector
-  */
-static uint32_t GetSector(uint32_t Address)
-{
-  uint32_t sector = 0;
-  
-  if((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0))
-  {
-    sector = FLASH_Sector_0;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1))
-  {
-    sector = FLASH_Sector_1;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2))
-  {
-    sector = FLASH_Sector_2;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3))
-  {
-    sector = FLASH_Sector_3;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4))
-  {
-    sector = FLASH_Sector_4;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5))
-  {
-    sector = FLASH_Sector_5;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6))
-  {
-    sector = FLASH_Sector_6;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7))
-  {
-    sector = FLASH_Sector_7;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8))
-  {
-    sector = FLASH_Sector_8;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9))
-  {
-    sector = FLASH_Sector_9;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10))
-  {
-    sector = FLASH_Sector_10;  
-  }
-  
-
-  else if((Address < ADDR_FLASH_SECTOR_12) && (Address >= ADDR_FLASH_SECTOR_11))
-  {
-    sector = FLASH_Sector_11;  
-  }
-
-  else if((Address < ADDR_FLASH_SECTOR_13) && (Address >= ADDR_FLASH_SECTOR_12))
-  {
-    sector = FLASH_Sector_12;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_14) && (Address >= ADDR_FLASH_SECTOR_13))
-  {
-    sector = FLASH_Sector_13;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_15) && (Address >= ADDR_FLASH_SECTOR_14))
-  {
-    sector = FLASH_Sector_14;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_16) && (Address >= ADDR_FLASH_SECTOR_15))
-  {
-    sector = FLASH_Sector_15;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_17) && (Address >= ADDR_FLASH_SECTOR_16))
-  {
-    sector = FLASH_Sector_16;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_18) && (Address >= ADDR_FLASH_SECTOR_17))
-  {
-    sector = FLASH_Sector_17;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_19) && (Address >= ADDR_FLASH_SECTOR_18))
-  {
-    sector = FLASH_Sector_18;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_20) && (Address >= ADDR_FLASH_SECTOR_19))
-  {
-    sector = FLASH_Sector_19;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_21) && (Address >= ADDR_FLASH_SECTOR_20))
-  {
-    sector = FLASH_Sector_20;  
-  } 
-  else if((Address < ADDR_FLASH_SECTOR_22) && (Address >= ADDR_FLASH_SECTOR_21))
-  {
-    sector = FLASH_Sector_21;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_23) && (Address >= ADDR_FLASH_SECTOR_22))
-  {
-    sector = FLASH_Sector_22;  
-  }
-  else/*(Address < FLASH_END_ADDR) && (Address >= ADDR_FLASH_SECTOR_23))*/
-  {
-    sector = FLASH_Sector_23;  
-  }
-  return sector;
-}
-
-void FLASH_Unlock(void)
-{
-  if((FLASH->CR & FLASH_CR_LOCK) != RESET)
-  {
-    /* Authorize the FLASH Registers access */
-    FLASH->KEYR = FLASH_KEY1;
-    FLASH->KEYR = FLASH_KEY2;
-  }  
-}
-
-FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange)
-{
-  uint32_t tmp_psize = 0x0;
-  FLASH_Status status = FLASH_COMPLETE;
-
-//  /* Check the parameters */
-//  assert_param(IS_FLASH_SECTOR(FLASH_Sector));
-//  assert_param(IS_VOLTAGERANGE(VoltageRange));
-  
-  if(VoltageRange == VoltageRange_1)
-  {
-     tmp_psize = FLASH_PSIZE_BYTE;
-  }
-  else if(VoltageRange == VoltageRange_2)
-  {
-    tmp_psize = FLASH_PSIZE_HALF_WORD;
-  }
-  else if(VoltageRange == VoltageRange_3)
-  {
-    tmp_psize = FLASH_PSIZE_WORD;
-  }
-  else
-  {
-    tmp_psize = FLASH_PSIZE_DOUBLE_WORD;
-  }
-  /* Wait for last operation to be completed */
-  status = FLASH_WaitForLastOperation();
-  
-  if(status == FLASH_COMPLETE)
-  { 
-    /* if the previous operation is completed, proceed to erase the sector */
-    FLASH->CR &= CR_PSIZE_MASK;
-    FLASH->CR |= tmp_psize;
-    FLASH->CR &= SECTOR_MASK;
-    FLASH->CR |= FLASH_CR_SER | FLASH_Sector;
-    FLASH->CR |= FLASH_CR_STRT;
-    
-    /* Wait for last operation to be completed */
-    status = FLASH_WaitForLastOperation();
-    
-    /* if the erase operation is completed, disable the SER Bit */
-    FLASH->CR &= (~FLASH_CR_SER);
-    FLASH->CR &= SECTOR_MASK; 
-  }
-  /* Return the Erase Status */
-  return status;
-}
-
-
-FLASH_Status FLASH_WaitForLastOperation(void)
-{ 
-  __IO FLASH_Status status = FLASH_COMPLETE;
-   
-  /* Check for the FLASH Status */
-  status = FLASH_GetStatus();
-
-  /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
-     Even if the FLASH operation fails, the BUSY flag will be reset and an error
-     flag will be set */
-  while(status == FLASH_BUSY)
-  {
-    status = FLASH_GetStatus();
-  }
-  /* Return the operation status */
-  return status;
-}
-
-FLASH_Status FLASH_GetStatus(void)
-{
-  FLASH_Status flashstatus = FLASH_COMPLETE;
-  
-  if((FLASH->SR & FLASH_FLAG_BSY) == FLASH_FLAG_BSY) 
-  {
-    flashstatus = FLASH_BUSY;
-  }
-  else 
-  {  
-    if((FLASH->SR & FLASH_FLAG_WRPERR) != (uint32_t)0x00)
-    { 
-      flashstatus = FLASH_ERROR_WRP;
-    }
-    else
-    {
-      if((FLASH->SR & FLASH_FLAG_RDERR) != (uint32_t)0x00)
-      { 
-        flashstatus = FLASH_ERROR_RD;
-      } 
-      else 
-      {
-        if((FLASH->SR & (uint32_t)0xE0) != (uint32_t)0x00)
-        {
-          flashstatus = FLASH_ERROR_PROGRAM; 
-        }
-        else
-        {
-          if((FLASH->SR & FLASH_FLAG_OPERR) != (uint32_t)0x00)
-          {
-            flashstatus = FLASH_ERROR_OPERATION;
-          }
-          else
-          {
-            flashstatus = FLASH_COMPLETE;
-          }
-        }
-      }
-    }
-  }
-  /* Return the FLASH Status */
-  return flashstatus;
-}
-
-FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data)
-{
-//  FLASH_Status status = FLASH_COMPLETE;
-
-//  /* Check the parameters */
-//  assert_param(IS_FLASH_ADDRESS(Address));
-
-  /* Wait for last operation to be completed */
-  // status = FLASH_WaitForLastOperation();
-  
-  // if(status == FLASH_COMPLETE)
-  // {
-    /* if the previous operation is completed, proceed to program the new data */
-    FLASH->CR &= CR_PSIZE_MASK;
-    FLASH->CR |= FLASH_PSIZE_WORD;
-    FLASH->CR |= FLASH_CR_PG;
-  
-    *(__IO uint32_t*)Address = Data;
-        
-  //   /* Wait for last operation to be completed */
-  //   status = FLASH_WaitForLastOperation();
-
-  //   /* if the program operation is completed, disable the PG Bit */
-  //   FLASH->CR &= (~FLASH_CR_PG);
-  // } 
-  /* Return the Program Status */
-  return 0;
-}
-
-FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
-{
-  FLASH_Status status = FLASH_COMPLETE;
-
-  // /* Check the parameters */
-  // assert_param(IS_FLASH_ADDRESS(Address));
-
-  /* Wait for last operation to be completed */
-  status = FLASH_WaitForLastOperation();
-  
-  if(status == FLASH_COMPLETE)
-  {
-    /* if the previous operation is completed, proceed to program the new data */
-    FLASH->CR &= CR_PSIZE_MASK;
-    FLASH->CR |= FLASH_PSIZE_HALF_WORD;
-    FLASH->CR |= FLASH_CR_PG;
-  
-    *(__IO uint16_t*)Address = Data;
-        
-    /* Wait for last operation to be completed */
-    status = FLASH_WaitForLastOperation();
-
-    /* if the program operation is completed, disable the PG Bit */
-    FLASH->CR &= (~FLASH_CR_PG);
-  } 
-  /* Return the Program Status */
-  return status;
-}
-
-FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data)
-{
-  FLASH_Status status = FLASH_COMPLETE;
-
-  // /* Check the parameters */
-  // assert_param(IS_FLASH_ADDRESS(Address));
-
-  /* Wait for last operation to be completed */
-  status = FLASH_WaitForLastOperation();
-  
-  if(status == FLASH_COMPLETE)
-  {
-    /* if the previous operation is completed, proceed to program the new data */
-    FLASH->CR &= CR_PSIZE_MASK;
-    FLASH->CR |= FLASH_PSIZE_BYTE;
-    FLASH->CR |= FLASH_CR_PG;
-  
-    *(__IO uint8_t*)Address = Data;
-        
-    /* Wait for last operation to be completed */
-    status = FLASH_WaitForLastOperation();
-
-    /* if the program operation is completed, disable the PG Bit */
-    FLASH->CR &= (~FLASH_CR_PG);
-  } 
-
-  /* Return the Program Status */
-  return status;
-}
-
-void FLASH_Lock(void)
-{
-  /* Set the LOCK Bit to lock the FLASH Registers access */
-  FLASH->CR |= FLASH_CR_LOCK;
-}

+ 0 - 8
app/AuthLicense/iflash.h

@@ -1,8 +0,0 @@
-#ifndef __IFLASH_H__
-#define __IFLASH_H__
-#include <stdio.h>
-#include <stdint.h>
-
-int WriteLicensetoFlash(uint8_t *license );
-
-#endif /* __IFLASH_H__ */

BIN
app/NCP81111_Config/ncp81111_cfg


BIN
app/UpdateFirmware/updateFW_app


+ 22 - 28
app/bmc/ipmb/IPMBIfc.c

@@ -167,32 +167,29 @@ void *IPMBIfcTask(void *Param)
         switch(RcvMsgPkt.Param)
 		{
 			case PARAM_REQUEST:
-                //printf("---> IPMBIfcTask/PARAM_REQUEST\n");
 				ProcessIPMBReq (&RcvMsgPkt);
 				break;
 			case PARAM_BRIDGE:
-                //printf("---> IPMBIfcTask/PARAM_BRIDGE, channel: %d\n", RcvMsgPkt.Channel);
-                
                 /* Send the response */
                 if(RcvMsgPkt.Channel == PRIMARY_IPMB_CHANNEL)
                 {
                     RetVal = stm32_i2c_master_write(gFd_Primary, RcvMsgPkt.Data[0], &RcvMsgPkt.Data[1], RcvMsgPkt.Size-1);
-                    printf("PriTx: ");
+                    //printf("PriTx: ");
                 }
                 else if(RcvMsgPkt.Channel == SECONDARY_IPMB_CHANNEL)
                 {
                     RetVal = stm32_i2c_master_write(gFd_Secondary, RcvMsgPkt.Data[0], &RcvMsgPkt.Data[1], RcvMsgPkt.Size-1);
-                    printf("SecTx: ");
+                    //printf("SecTx: ");
                 }
                 else
                 {
                     printf("IPMBIfc.c: IPMB channel error. %#x\r\n", RcvMsgPkt.Channel);
                 }
 
-                int i;
-                for(i=0;i<RcvMsgPkt.Size;i++)
-                    printf("%02x ", RcvMsgPkt.Data[i]);
-                printf("\n");
+                // int i;
+                // for(i=0;i<RcvMsgPkt.Size;i++)
+                //     printf("%02x ", RcvMsgPkt.Data[i]);
+                // printf("\n");
 
                 if (RetVal < 0)
                 {
@@ -306,31 +303,31 @@ ProcessIPMBReq ( MsgPkt_T* pReq)
         return;
     }
 
-   
+    //usleep(2000);
     /* Send the response */
 	if(pReq->Channel == PRIMARY_IPMB_CHANNEL)
 	{
         pthread_mutex_lock(&primary_mutex);
 		RetVal = stm32_i2c_master_write(gFd_Primary, ResPkt.Data[0], &ResPkt.Data[1], ResPkt.Size-1);
         pthread_mutex_unlock(&primary_mutex);
-        printf("PriTx: ");
+        //printf("PriTx: ");
 	}
 	else if(pReq->Channel == SECONDARY_IPMB_CHANNEL)
 	{
         pthread_mutex_lock(&secondary_mutex);
 		RetVal = stm32_i2c_master_write(gFd_Secondary, ResPkt.Data[0], &ResPkt.Data[1], ResPkt.Size-1);
         pthread_mutex_unlock(&secondary_mutex);
-        printf("SecTx: ");
+        //printf("SecTx: ");
 	}
 	else
 	{
 		printf("IPMBIfc.c: IPMB channel error. %#x\r\n", pReq->Channel);
 	}
 
-    int i;
-    for(i=0;i<ResPkt.Size;i++)
-        printf("%02x ", ResPkt.Data[i]);
-    printf("\n");
+    // int i;
+    // for(i=0;i<ResPkt.Size;i++)
+    //     printf("%02x ", ResPkt.Data[i]);
+    // printf("\n");
 	
     if (0 != RetVal)
     {
@@ -471,16 +468,6 @@ static void* RecvIPMBPkt (void *Param)
             IPMBReqPkt.Param    = PARAM_REQUEST;
             IPMBReqPkt.Size     = retval + 1;       /* +1 to include BMC Slave address */
 
-            int cnt;
-            if(0 == ipmbSelect)
-                printf("\nPriRx: ");
-            else
-                printf("\nSecRx: ");
-
-            for(cnt=0;cnt < IPMBReqPkt.Size; cnt++)
-                printf("%02x ", IPMBReqPkt.Data[cnt]);
-            printf("\n");
-
             /* Post the IPMB Request message to IPMBIfc Queue */
             if(ipmbSelect == 0)
             {
@@ -497,9 +484,16 @@ static void* RecvIPMBPkt (void *Param)
                 }
             }
 
-        }
+            // int cnt;
+            // if(0 == ipmbSelect)
+            //     printf("\nPriRx: ");
+            // else
+            //     printf("\nSecRx: ");
 
-       
+            // for(cnt=0;cnt < IPMBReqPkt.Size; cnt++)
+            //     printf("%02x ", IPMBReqPkt.Data[cnt]);
+            // printf("\n");
+        }
 	}
     return (void*)-1;
 }

+ 0 - 1
app/bmc/message.c

@@ -35,7 +35,6 @@ PostMsg (int fd, MsgPkt_T* pMsgPkt)
         return -1;
     }             
 
-    //printf("---> PostMsg ok, fd = %d\n", fd);
     return 0;
 }
 

+ 7 - 6
app/bmc/msghndlr/MsgHndlrTask.c

@@ -271,7 +271,13 @@ ValidateMsgHdr (MsgPkt_T* pReq)
 				 }
 						
 				 /* Post the data to Destination Interface queue */
-//				 printf("===> ValidateMsgHdr post message to %d\n", Queuefd);
+				 //printf("Post2UDS %d: \n", Queuefd);
+				 // int i;
+				 // for(i=0;i<pReq->Size;i++)
+				 // {
+				 // 	printf("%02x ", pReq->Data[i]);
+				 // }
+				 // printf("\n");
 				 PostMsg (Queuefd, pReq);
 
 				 m_PendingBridgedResTbl[PBTbl][SeqNum].Used = FALSE;
@@ -601,11 +607,6 @@ void RespondSendMessage ( MsgPkt_T* pReq, uint8_t Status)
 		 (pIPMIReqHdr->Cmd               == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.Cmd) &&
 		 (pIPMIReqHdr->ResAddr           == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.ResAddr)  )
 	{
-		//printf("---> RespondSendMessage/ m_PendingBridgedResTbl: PBTbl: %d, SeqNum %d, log222\n", PBTbl, SeqNum);
-		// int i;
-		// for(i=0;i<6;i++)
-		// 	printf("%#x ", ((uint8_t*)&m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.IPMIMsgHdr)[i]);
-		// printf("\n");
 		uint32_t tcnt = 0;
 		while(m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk == 0)
 		{

+ 2 - 0
app/bmc/msghndlr/PDKCmds.c

@@ -347,6 +347,8 @@ const CmdHndlrMap_T g_Storlead_CmdHndlr [] =
     { CMD_GET_BLADE_INFO,      PRIV_USER,      Storlead_GetBladeInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_SENSOR_NAME,      PRIV_USER,      Storlead_GetSensorName,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_CURRUNTIME,      PRIV_USER,      Storlead_GetCurRunTime,         0xff,  0xAAAA  ,0xFFFF},    
+    { CMD_SAVE_CONFIG,      PRIV_USER,      Storlead_SaveConfig,         0xff,  0xAAAA  ,0xFFFF},    
+    { CMD_RESTORE_CONFIG,      PRIV_USER,      Storlead_RestoreConfig,         0xff,  0xAAAA  ,0xFFFF},        
      { 0x00,                     0x00,           0x00,                 0x00, 0x0000  ,  0x0000},
 };
 

+ 137 - 0
app/bmc/msghndlr/Storlead/Storlead.c

@@ -8,6 +8,9 @@
 #include "com_IPMI_SDRRecord.h"
 #include "SDR.h"
 #include "SELRecord.h"
+#include "driver.h"
+#include "fcntl.h"
+#include "Api.h"
 
 int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 {
@@ -491,7 +494,9 @@ int Storlead_RestoreFactorSettings(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     int i;
     pRes[0] = CC_NORMAL;
     //擦除Flash   IpmiConfig
+    pthread_mutex_lock(&Flash_Mutex);
     sf_sector_erase(5, CONFIG_FLASH_START);
+    pthread_mutex_unlock(&Flash_Mutex);
 
     return 1;
 }
@@ -627,4 +632,136 @@ int Storlead_GetCurRunTime(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     pRes[3] = (g_BMCInfo.BootValidMinutes>>16)&0xff;
     pRes[4] = (g_BMCInfo.BootValidMinutes>>24)&0xff;
     return 5;
+}
+
+int Storlead_SaveConfig(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    pRes[0] = CC_NORMAL;
+    int i;
+    iflash_t iflash_arg;
+    int ret = 0;
+    int fd = open("/dev/iflash", O_RDWR);
+    ret = ioctl(fd, IFLASH_UNLOCK, NULL);
+    if(ret != 0)
+    {
+        printf("error: ret = %d\n", ret);
+    }
+
+    iflash_arg.sector = 8;
+    ret = ioctl(fd, IFLASH_ERASESECTOR, &iflash_arg);
+    if(ret != 0)
+    {
+        printf("error: ret = %d\n", ret);
+    }
+
+    /**** IpmiConfig + user info + FRU + SDR ****/
+    //IpmiConfig    4KB
+    iflash_arg.address = 0x08080000;
+    iflash_arg.len = sizeof(IPMIConfig_T);  //最大256字节
+    memcpy(iflash_arg.data, &g_BMCInfo.IpmiConfig, sizeof(IPMIConfig_T));
+    ret = ioctl(fd, IFLASH_WRITEBYTE, &iflash_arg);
+    if(ret != 0)
+    {
+        printf("error: ret = %d\n", ret);
+    }
+    //user info     4KB
+    uint8_t usrinfolen = 50;//sizeof(UserInfo_T);
+    for(i=0;i<MAX_USER_NUM;i++)
+    {
+        iflash_arg.address = 0x08081000 + usrinfolen*i;//sizeof(UserInfo_T)*i;
+        iflash_arg.len = usrinfolen;//sizeof(UserInfo_T);  //最大256字节
+        memcpy(iflash_arg.data, &(g_BMCInfo.UserInfoTbl[i]), usrinfolen);
+        ret = ioctl(fd, IFLASH_WRITEBYTE, &iflash_arg);
+        if(ret != 0)
+        {
+            printf("error: ret = %d\n", ret);
+        }
+    }    
+    //FRU           4KB
+    iflash_arg.address = 0x08082000;
+    iflash_arg.len = sizeof(OemFRUData_T);  //最大256字节
+    memcpy(iflash_arg.data, &g_BMCInfo.FRU, sizeof(OemFRUData_T));
+    ret = ioctl(fd, IFLASH_WRITEBYTE, &iflash_arg);
+    if(ret != 0)
+    {
+        printf("error: ret = %d\n", ret);
+    }
+    //SDR           4KB
+    uint32_t    sdrSize =
+        sizeof(SDRRepository_T) + sizeof(HdrMgmtCtrlrDevLocator_T) + sizeof(HdrFullSensorRec_T)*SENSOR_NUMBERS;     
+    uint32_t    writebytes = 0;
+    while(sdrSize>0)
+    {   
+        iflash_arg.address = 0x08083000 + writebytes;
+        if(sdrSize > 256)
+        {            
+            iflash_arg.len = 256;  //最大256字节                                
+            memcpy(iflash_arg.data, g_BMCInfo.pSDR+writebytes, 256);
+            // printf("L1: ");
+            // for(i=0;i<iflash_arg.len;i++)
+            //     printf("%02x ", iflash_arg.data[i]);
+            // printf("\n"); 
+            writebytes += 256;
+            sdrSize -= 256;
+        }
+        else
+        {
+            iflash_arg.len = sdrSize;  //最大256字节                        
+            memcpy(iflash_arg.data, g_BMCInfo.pSDR+writebytes, sdrSize);
+            // printf("L2: ");
+            // for(i=0;i<iflash_arg.len;i++)
+            //     printf("%02x ", iflash_arg.data[i]);
+            // printf("\n"); 
+            writebytes += sdrSize;
+            sdrSize = 0;
+        }
+        
+        ret = ioctl(fd, IFLASH_WRITEBYTE, &iflash_arg);
+        if(ret != 0)
+        {
+            printf("error: ret = %d\n", ret);
+        }
+    }
+
+    ret = ioctl(fd, IFLASH_LOCK, NULL);
+    if(ret != 0)
+    {
+        printf("error: ret = %d\n", ret);
+    }
+    
+    close(fd);
+
+    return 1;
+}
+
+int Storlead_RestoreConfig(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    pRes[0] = CC_NORMAL;    
+    int i;
+    /**** IpmiConfig + user info + FRU + SDR ****/
+    //IpmiConfig    4KB
+    memcpy(&g_BMCInfo.IpmiConfig, (uint8_t*)0x08080000, sizeof(IPMIConfig_T));
+    FlushIPMIToFlash();
+    //user info     4KB
+    uint8_t usrinfolen = 50;
+    for(i=0;i<MAX_USER_NUM;i++)
+    {
+        memcpy(&(g_BMCInfo.UserInfoTbl[i]), (uint8_t*)0x08081000 + usrinfolen*i, sizeof(UserInfo_T));
+    }
+    FlushUserInfoTbl();
+    //FRU           4KB
+    memcpy(&g_BMCInfo.FRU, (uint8_t*)0x08082000, sizeof(OemFRUData_T));
+    FlushFRUToFlash();
+    //SDR           4KB
+    uint32_t    sdrSize =
+        sizeof(SDRRepository_T) + sizeof(HdrMgmtCtrlrDevLocator_T) + 
+        sizeof(HdrFullSensorRec_T)*SENSOR_NUMBERS;     
+    memcpy(g_BMCInfo.pSDR, (uint8_t*)0x08083000, sdrSize);
+    // printf("read: ");
+    // for(i=0;i<sdrSize;i++)
+    //     printf("%02x ", ((uint8_t*)0x08083000)[i]);
+    // printf("\n"); 
+    FlushSDRToFlash();
+        
+    return 1;
 }

+ 2 - 0
app/bmc/msghndlr/Storlead/Storlead.h

@@ -16,3 +16,5 @@ int Storlead_SetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetBladeInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetSensorName(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetCurRunTime(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_SaveConfig(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_RestoreConfig(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);

+ 2 - 0
app/bmc/msghndlr/cmdselect.c

@@ -811,6 +811,8 @@ const NetFnCmds_T g_Storlead [] =
 	{ CMD_GET_BLADE_INFO          ,ENABLED},	
 	{ CMD_GET_SENSOR_NAME          ,ENABLED},	
 	{ CMD_GET_CURRUNTIME          ,ENABLED},	
+	{ CMD_SAVE_CONFIG          ,ENABLED},	
+	{ CMD_RESTORE_CONFIG          ,ENABLED},		
 	{0,				0		},
 };
 

+ 5 - 1
app/bmc/readme.txt

@@ -20,4 +20,8 @@
 5. 	机箱内所有刀片的IPMB地址在dashboard.c里定义,在goahead.h里声明。
 	机箱内所有刀片的IPMB地址在main.c里定义,在main.h里声明。
 
-6. 机箱管理使能改由前端网页控制,默认是打开的。网页在下发获取机箱信息的时候多下发一个参数,机箱管理是否使能。
+6. 机箱管理使能改由前端网页控制,默认是打开的。网页在下发获取机箱信息的时候多下发一个参数,机箱管理是否使能。
+
+7. GD32F450内部flash:
+		Sector 6 放License											0x08060000~0x0807ffff 128KB
+		Sector 7 放配置信息,IpmiConfig + user info + FRU + SDR 		0x08080000~0x0809ffff 128KB

+ 6 - 16
app/bmc/uds/UDSIfc.c

@@ -38,29 +38,15 @@
 #include "main.h"
 
 /*Function Prototypes*/
-//void CloseUDSSocket(int Socket );
 static int ProcessUDSReq(MsgPkt_T *pReq );
 int InitUnixDomainSocket(void);
 void *RecvUDSPkt(void *pArg);
-//int AddUDSSocket (int Socket,uint8_t IsLoopBackSocket, uint8_t IsFixedSocket );
-//int RemoveUDSSocket (int Socket );
 int ReadUDSData(MsgPkt_T *MsgPkt,int Socket );
 int SendUDSPkt (MsgPkt_T *pRes );
-//int SetUDSFd(fd_set *newfd,int *maximum );
 int FillUDSResponsePacket(MsgPkt_T *pReq, MsgPkt_T *pRes,uint8_t UDSCompletionCode );
-//static int UpdateUDSTimeout (void);
-//static void*  UDSTimer (void *pArg);
-//int AddUDSInfo(MsgPkt_T *pUDSReq,MsgPkt_T *pUDSRes );
-//uint8_t RemoveUDSSession(SOCKET Socket );
-//int CheckReservedCmd(uint8_t Cmd);
 void *UDSIfcTask(void* pArg);
 static void ProcessUDSBridgeMsg (  MsgPkt_T* pReq );
 
-// static uint8_t ReservedCmd[]={
-//                       CMD_GET_DEV_ID,
-//                       CMD_GET_USER_NAME,
-//                       CMD_SET_USER_PASSWORD};
-
 int gUDSSocket;
 int gFdUdsIfc, gFdUdsRes;
 
@@ -139,10 +125,10 @@ void *UDSIfcTask(void* pArg)
             continue;
         }
     
+        //printf("UDSIfc GetMsg!\n");
         switch(Req.Param)
         {
             case UDS_SMB_PARAM:
-//                printf("---> UDS get request Message\n");
                 ProcessUDSReq(&Req);
                 break;
             case BRIDGING_REQUEST:
@@ -225,7 +211,7 @@ void *RecvUDSPkt(void *pArg)
 
     while(TRUE)
     {
-        Timeout.tv_sec  =   SESSION_TIMEOUT; 
+        Timeout.tv_sec  =  365*24*60*60;//SESSION_TIMEOUT; 
         Timeout.tv_usec  =   0; 
 
         FD_ZERO(&fds);
@@ -240,11 +226,13 @@ void *RecvUDSPkt(void *pArg)
         RetVal = select (max, &fds, NULL, NULL, &Timeout);
         if (UDS_FAILURE == RetVal)
         {
+            printf("UDS Recv failed!\n");
             continue;
         }
         if (UDS_SUCCESS == RetVal)
         {
             /* Its due to timeout - continue */
+            printf("UDS Recv timeout!\n");
             continue;
         }
         
@@ -372,6 +360,7 @@ static int ProcessUDSReq(MsgPkt_T *pReq )
     memset(&pRes,0,sizeof(MsgPkt_T));
     if (UDS_SUCCESS != GetMsg (gFdUdsRes, &pRes, (DEFAULT_TIMEOUT>2)?(DEFAULT_TIMEOUT-2):1))
     {
+        printf("UDS GetMsg timeout!\n");
         return UDS_FAILURE;
     }
 
@@ -402,6 +391,7 @@ int SendUDSPkt (MsgPkt_T *pRes)
     // for(i=0;i<pRes->Size;i++)
     //     printf("%#x ", pRes->Data[i]);
     // printf("\n");
+    //printf("Send UDS!\n");
     /* Send the UDS response packet */
      if(UDS_FAILURE == send(pRes->Socket,pRes->Data,pRes->Size,MSG_NOSIGNAL))
      {

+ 0 - 11
app/common_include/com_BmcType.h

@@ -260,21 +260,10 @@ typedef struct
 **/
 typedef struct
 {
-//    uint32_t  ID;
     uint8_t   UserId;
     uint8_t   UserName [MAX_USERNAME_LEN];
     uint8_t   UserPassword [MAX_PASSWORD_LEN];
-//    uint8_t   MaxPasswordSize;                /**< Maximum password size                  */
-//  uint8_t   ChannelAccess;                /** reserve,Call back, Link Auth, Ipmi Msg, Priv[3:0]. **/
-//    uint8_t   UserShell;                      /**< user shell type                        */      
-//    uint8_t   UserEMailID [EMAIL_ADDR_SIZE];  /**< Email-ID registered for the user       */
-//    uint8_t   MaxSession;                     /**< max No of session allowed for User.    */
-//    uint8_t   CurrentSession;                 /**< No Current session for the User.       */
     uint8_t    UserStatus;                  /**< User Enabled/Disabled Status.          */
-//    uint32_t    FixedUser:1;                  /**< Is this user name fixed                */
-//    uint8_t  EmailFormat[EMAIL_FORMAT_SIZE]; /** Email Alert format                       */
-//    uint32_t  ExtendedPrivilege;                       /** User Enhanced Privilege Flags           */
-//    uint8_t   UserPasswdConfigured;           /*  Flag to allow default Empty Password  */
 }   UserInfo_T;
 
 

+ 2 - 0
app/common_include/com_IPMI_Storlead.h

@@ -14,6 +14,8 @@
 #define CMD_GET_BLADE_INFO		0xE
 #define CMD_GET_SENSOR_NAME		0xF
 #define CMD_GET_CURRUNTIME		0x10
+#define CMD_SAVE_CONFIG			0x11
+#define CMD_RESTORE_CONFIG		0x12
 
 
 #endif /* __COM_IPMI_STORLEAD_H__ */

BIN
app/driver/InternalFlash/iflash.ko


+ 1 - 1
app/driver/driver.h

@@ -151,7 +151,7 @@ typedef struct {
 	uint8_t  sector;
 	uint32_t address;
 	uint32_t len;
-	uint8_t  data[256];
+	uint8_t  data[260];
 } iflash_t;
 
 #endif /* __DRIVER_H__ */

+ 7 - 7
app/goahead-3.6.5/src/auth.c

@@ -210,7 +210,7 @@ PUBLIC int websWriteAuthFile(char *path)
 
     tempFile = websTempFile(NULL, NULL);
     if ((fp = fopen(tempFile, "w" FILE_TEXT)) == 0) {
-        error("Cannot open %s", tempFile);
+        printf("Cannot open %s", tempFile);
         wfree(tempFile);
         return -1;
     }
@@ -237,7 +237,7 @@ PUBLIC int websWriteAuthFile(char *path)
     fclose(fp);
     unlink(path);
     if (rename(tempFile, path) < 0) {
-        error("Cannot create new %s", path);
+        printf("Cannot create new %s", path);
         wfree(tempFile);
         return -1;
     }
@@ -269,11 +269,11 @@ WebsUser *websAddUser(char *username, char *password, char *roles)  //jimbo todo
     WebsUser    *user;
 
     if (!username) {
-        error("User is missing name");
+        printf("User is missing name");
         return 0;
     }
     if (websLookupUser(username)) {
-        error("User %s already exists", username);
+        printf("User %s already exists", username);
         /* Already exists */
         return 0;
     }
@@ -361,7 +361,7 @@ static void computeAbilities(WebsHash abilities, char *role, int depth)
     assert(depth >= 0);
 
     if (depth > 20) {
-        error("Recursive ability definition for %s", role);
+        printf("Recursive ability definition for %s", role);
         return;
     }
     if (roles >= 0) {
@@ -423,11 +423,11 @@ WebsRole *websAddRole(char *name, WebsHash abilities)
     WebsRole    *rp;
 
     if (!name) {
-        error("Role is missing name");
+        printf("Role is missing name");
         return 0;
     }
     if (hashLookup(roles, name)) {
-        error("Role %s already exists", name);
+        printf("Role %s already exists", name);
         /* Already exists */
         return 0;
     }

+ 1 - 1
app/goahead-3.6.5/src/cJSON/cJSON.c

@@ -37,7 +37,7 @@ static const char *ep;
 
 void jimboTestcJson(void)
 {
-	error("---> This is jimbo test cJSON.c\n");
+	printf("---> This is jimbo test cJSON.c\n");
 }
 
 const char *cJSON_GetErrorPtr(void) {return ep;}

+ 10 - 10
app/goahead-3.6.5/src/goahead-mbedtls/goahead-mbedtls.c

@@ -284,11 +284,11 @@ static int mbedHandshake(Webs *wp)
     if (rc < 0) {
         if (rc == MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED && 
                 (ME_GOAHEAD_SSL_KEY[0] == '\0' || ME_GOAHEAD_SSL_CERTIFICATE[0] == '\0')) {
-            error("Missing required certificate and key");
+            printf("Missing required certificate and key");
         } else {
             char ebuf[256];
             mbedtls_strerror(-rc, ebuf, sizeof(ebuf));
-            error("%s: error -0x%x", ebuf, -rc);
+            printf("%s: error -0x%x", ebuf, -rc);
         }
         sp->flags |= SOCKET_EOF;
         errno = EPROTO;
@@ -458,7 +458,7 @@ static int *getCipherSuite(char *ciphers, int *len)
     for (i = 0; (cipher = stok(next, ":, \t", &next)) != 0; ) {
         replaceHyphen(cipher, '_', '-');
         if ((code = mbedtls_ssl_get_ciphersuite_id(cipher)) <= 0) {
-            error("Unsupported cipher \"%s\"", cipher);
+            printf("Unsupported cipher \"%s\"", cipher);
             continue;
         }
         result[i++] = code;
@@ -477,7 +477,7 @@ static int parseCert(mbedtls_x509_crt *cert, char *path)
     ssize   len;
 
     if ((buf = websReadWholeFile(path)) == 0) {
-        error("Unable to read certificate %s", path); 
+        printf("Unable to read certificate %s", path); 
         return -1;
     }
     len = slen(buf);
@@ -487,7 +487,7 @@ static int parseCert(mbedtls_x509_crt *cert, char *path)
     }
     if (mbedtls_x509_crt_parse(cert, (uchar*) buf, len) != 0) {
         memset(buf, 0, len);
-        error("Unable to parse certificate %s", path); 
+        printf("Unable to parse certificate %s", path); 
         return -1;
     }
     memset(buf, 0, len);
@@ -502,7 +502,7 @@ static int parseKey(mbedtls_pk_context *key, char *path)
     ssize   len;
 
     if ((buf = websReadWholeFile(path)) == 0) {
-        error("Unable to read key %s", path); 
+        printf("Unable to read key %s", path); 
         return -1;
     }
     len = slen(buf);
@@ -511,7 +511,7 @@ static int parseKey(mbedtls_pk_context *key, char *path)
     }
     if (mbedtls_pk_parse_key(key, (uchar*) buf, len, NULL, 0) != 0) {
         memset(buf, 0, len);
-        error("Unable to parse key %s", path); 
+        printf("Unable to parse key %s", path); 
         return -1;
     }
     memset(buf, 0, len);
@@ -526,7 +526,7 @@ static int parseCrl(mbedtls_x509_crl *crl, char *path)
     ssize   len;
 
     if ((buf = websReadWholeFile(path)) == 0) {
-        error("Unable to read crl %s", path); 
+        printf("Unable to read crl %s", path); 
         return -1;
     }
     len = slen(buf);
@@ -535,7 +535,7 @@ static int parseCrl(mbedtls_x509_crl *crl, char *path)
     }
     if (mbedtls_x509_crl_parse(crl, (uchar*) buf, len) != 0) {
         memset(buf, 0, len);
-        error("Unable to parse crl %s", path); 
+        printf("Unable to parse crl %s", path); 
         return -1;
     }
     memset(buf, 0, len);
@@ -565,7 +565,7 @@ static void merror(int rc, char *fmt, ...)
 
     va_start(ap, fmt);
     mbedtls_strerror(-rc, ebuf, sizeof(ebuf));
-    error("mbedtls", "mbedtls error: 0x%x %s %s", rc, sfmtv(fmt, ap), ebuf);
+    printf("mbedtls", "mbedtls error: 0x%x %s %s", rc, sfmtv(fmt, ap), ebuf);
     va_end(ap);
 }
 

+ 4 - 4
app/goahead-3.6.5/src/goahead.c

@@ -96,7 +96,7 @@ MAIN(goahead, int argc, char **argv, char **envp)
             if (argind >= argc) usage();
             home = argv[++argind];
             if (chdir(home) < 0) {
-                error("Cannot change directory to %s", home);
+                printf("Cannot change directory to %s", home);
                 exit(-1);
             }
         } else if (smatch(argp, "--log") || smatch(argp, "-l")) {
@@ -128,12 +128,12 @@ MAIN(goahead, int argc, char **argv, char **envp)
     }
     initPlatform(); //注册信号
     if (websOpen(documents, route) < 0) {
-        error("Cannot initialize server. Exiting.");
+        printf("Cannot initialize server. Exiting.");
         return -1;
     }
 #if ME_GOAHEAD_AUTH
     if (websLoad(auth) < 0) {
-        error("Cannot load %s", auth);
+        printf("Cannot load %s", auth);
         return -1;
     }
 #endif
@@ -239,7 +239,7 @@ websDefineAction("web_RestoreConfig", web_RestoreConfig);
     if (websGetBackground()) {
         printf("---> daemon\n");
         if (daemon(0, 0) < 0) {
-            error("Cannot run as daemon");
+            printf("Cannot run as daemon");
             return -1;
         }
     }

+ 4 - 44
app/goahead-3.6.5/src/goahead.h

@@ -170,46 +170,6 @@ PUBLIC_DATA int logLevel;
 #define WEBS_RAW_MSG        0x200       /**< Raw message output */
 #define WEBS_TRACE_MSG      0x400       /**< Originated from trace */
 
-
-// #if ME_GOAHEAD_TRACING && ME_GOAHEAD_LOGGING
-//     #if ME_COMPILER_HAS_MACRO_VARARGS
-//       #define trace(l, ...) if (((l) & WEBS_LEVEL_MASK) <= websGetLogLevel()) { traceProc(l, __VA_ARGS__); } else {}
-//     #else
-//         inline void trace(int level, cchar *fmt, ...) {
-//             WebsLogHandler logHandler = logGetHandler();
-//             if ((level & WEBS_LEVEL_MASK) <= logLevel && logHandler) {
-//                 va_list args; va_start(args, fmt);
-//                 char *message = sfmtv((char*) fmt, args);
-//                 logHandler(level | WEBS_TRACE_MSG, message);
-//                 wfree(message);
-//                 va_end(args);
-//             }
-//         }
-//     #endif
-// #else
-//     #define trace(l, ...) if (1) ; else {}
-// #endif
-
-// #if ME_GOAHEAD_LOGGING
-//     #if ME_COMPILER_HAS_MACRO_VARARGS
-//         #define logmsg(l, ...) if ((l) <= logLevel) { logmsgProc(l, __VA_ARGS__); } else {}
-//     #else
-//         inline void logmsg(int level, cchar *fmt, ...) {
-//             WebsLogHandler logHandler = logGetHandler();
-//             if ((level & WEBS_LEVEL_MASK) <= logLevel && logHandler) {
-//                 va_list args; va_start(args, fmt);
-//                 char *message = sfmtv((char*) fmt, args);
-//                 logHandler(level | WEBS_TRACE_MSG, message);
-//                 wfree(message);
-//                 va_end(args);
-//             }
-//         }
-//     #endif
-// #else
-//     #define logmsg(l, ...) if (1) ; else {}
-// #endif
-
-
 #if DOXYGEN
 #undef assert
 /**
@@ -248,7 +208,7 @@ typedef void (*WebsLogHandler)(int level, char *msg);
     @return Zero if successful
     @stability Stable
 */
-PUBLIC void error(char *fmt, ...);
+//PUBLIC void error(char *fmt, ...);
 
 /**
     Open the log logging module
@@ -330,12 +290,12 @@ PUBLIC void traceProc(int level, char *fmt, ...);
 
 #else /*! ME_GOAHEAD_LOGGING */
     #define assert(C) if (1) ; else {}
-    #define error(l, ...) if (1) ; else {}
-    #define trace(l, ...) if (1) ; else {}
+    //#define error(l, ...) if (1) ; else {}
+    //#define trace(l, ...) if (1) ; else {}
     #define logOpen() if (1) ; else {}
     #define logClose() if (1) ; else {}
     #define websGetLogLevel() 0
-    #define logmsg(l, ...) if (1) ; else {}
+    //#define logmsg(l, ...) if (1) ; else {}
     #define logSetPath(p) if (1) ; else {}
 #endif
 

+ 15 - 15
app/goahead-3.6.5/src/http.c

@@ -280,7 +280,7 @@ PUBLIC int websOpen(char *documents, char *routeFile)
 
 #if ME_GOAHEAD_ACCESS_LOG && !ME_ROM
     if ((accessFd = open(accessLog, O_CREAT | O_TRUNC | O_APPEND | O_WRONLY, 0666)) < 0) {
-        error("Cannot open access log %s", accessLog);
+        printf("Cannot open access log %s", accessLog);
         return -1;
     }
     /* Some platforms don't implement O_APPEND (VXWORKS) */
@@ -440,7 +440,7 @@ static void termWebs(Webs *wp, int reuse)
         wp->putfd = -1;
         assert(wp->putname && wp->filename);
         if (rename(wp->putname, wp->filename) < 0) {
-            error("Cannot rename PUT file from %s to %s", wp->putname, wp->filename);
+            printf("Cannot rename PUT file from %s to %s", wp->putname, wp->filename);
         }
     }
 #endif
@@ -687,7 +687,7 @@ PUBLIC int websAccept(int sid, char *ipaddr, int port, int listenSid)
      */
     len = sizeof(ifAddr);
     if (getsockname(socketPtr(sid)->sock, (struct sockaddr*) &ifAddr, (Socklen*) &len) < 0) {
-        error("Cannot get sockname");
+        printf("Cannot get sockname");
         return -1;
     }
     socketAddress((struct sockaddr*) &ifAddr, (int) len, wp->ifaddr, sizeof(wp->ifaddr), NULL);
@@ -714,7 +714,7 @@ PUBLIC int websAccept(int sid, char *ipaddr, int port, int listenSid)
         wp->flags |= WEBS_SECURE;
         //printf( "Upgrade connection to TLS");
         if (sslUpgrade(wp) < 0) {
-            error("Cannot upgrade to TLS");
+            printf("Cannot upgrade to TLS");
             return -1;
         }
     }
@@ -938,7 +938,7 @@ static bool parseIncoming(Webs *wp)
         wfree(wp->putname);
         wp->putname = websTempFile(ME_GOAHEAD_PUT_DIR, "put");
         if ((wp->putfd = open(wp->putname, O_BINARY | O_WRONLY | O_CREAT | O_BINARY, 0644)) < 0) {
-            error("Cannot create PUT filename %s", wp->putname);
+            printf("Cannot create PUT filename %s", wp->putname);
             websError(wp, HTTP_CODE_INTERNAL_SERVER_ERROR, "Cannot create the put URI");
             wfree(wp->putname);
             return 1;
@@ -991,7 +991,7 @@ static void parseFirstLine(Webs *wp)
      */
     host = path = port = query = ext = NULL;
     if (websUrlParse(url, &buf, NULL, &host, &port, &path, &ext, NULL, &query) < 0) {
-        error("Cannot parse URL: %s", url);
+        printf("Cannot parse URL: %s", url);
         websError(wp, HTTP_CODE_BAD_REQUEST | WEBS_CLOSE | WEBS_NOLOG, "Bad URL");
         return;
     }
@@ -1810,7 +1810,7 @@ PUBLIC int websWriteHeader(Webs *wp, char *key, char *fmt, ...)
     if (fmt) {
         va_start(vargs, fmt);
         if ((buf = sfmtv(fmt, vargs)) == 0) {
-            error("websWrite lost data, buffer overflow");
+            printf("websWrite lost data, buffer overflow");
             return -1;
         }
         va_end(vargs);
@@ -1950,7 +1950,7 @@ PUBLIC ssize websWrite(Webs *wp, char *fmt, ...)
     buf = NULL;
     rc = 0;
     if ((buf = sfmtv(fmt, vargs)) == 0) {
-        error("websWrite lost data, buffer overflow");
+        printf("websWrite lost data, buffer overflow");
     }
     va_end(vargs);
     assert(buf);
@@ -2365,7 +2365,7 @@ static int get_local_ip(const char *eth_inf, char *ip)
     sd = socket(AF_INET, SOCK_DGRAM, 0);
     if (-1 == sd)
     {
-        error("socket error: %s\n", strerror(errno));
+        printf("socket error: %s\n", strerror(errno));
         return -1;
     }
 
@@ -2375,7 +2375,7 @@ static int get_local_ip(const char *eth_inf, char *ip)
     // if error: No such device
     if (ioctl(sd, SIOCGIFADDR, &ifr) < 0)
     {
-        error("ioctl error: %s\n", strerror(errno));
+        printf("ioctl error: %s\n", strerror(errno));
         close(sd);
         return -1;
     }
@@ -2523,7 +2523,7 @@ PUBLIC bool websValidUriChars(char *uri)
     }
     pos = strspn(uri, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=%");
     if (pos < slen(uri)) {
-        error("Bad character in URI at \"%s\"", &uri[pos]);
+        printf("Bad character in URI at \"%s\"", &uri[pos]);
         return 0;
     }
     return 1;
@@ -3069,7 +3069,7 @@ WebsSession *websGetSession(Webs *wp, int create)
                 return 0;
             }
             if (sessionCount > ME_GOAHEAD_LIMIT_SESSION_COUNT) {
-                error("Too many sessions %d/%d", sessionCount, ME_GOAHEAD_LIMIT_SESSION_COUNT);
+                printf("Too many sessions %d/%d", sessionCount, ME_GOAHEAD_LIMIT_SESSION_COUNT);
                 wfree(id);
                 return 0;
             }
@@ -3251,11 +3251,11 @@ PUBLIC int websServer(char *endpoint, char *documents)
     int     finished = 0;
 
     if (websOpen(documents, "route.txt") < 0) {
-        error("Cannot initialize server. Exiting.");
+        printf("Cannot initialize server. Exiting.");
         return -1;
     }
     if (websLoad("auth.txt") < 0) {
-        error("Cannot load auth.txt");
+        printf("Cannot load auth.txt");
         return -1;
     }
     if (websListen(endpoint) < 0) {
@@ -3295,7 +3295,7 @@ static void setFileLimits()
     } else {
         r.rlim_cur = r.rlim_max = limit;
         if (setrlimit(RLIMIT_NOFILE, &r) < 0) {
-            error("Cannot set file limit to %d", limit);
+            printf("Cannot set file limit to %d", limit);
         }
     }
     getrlimit(RLIMIT_NOFILE, &r);

+ 4 - 0
app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h

@@ -119,5 +119,9 @@ int IPMI_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_numb
 int IPMC_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint16_t offset, uint16_t length, uint8_t *history_buf, int timeout);
 uint16_t	IPMI_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint32_t *minutes,int timeout);
 uint16_t	IPMC_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint32_t *minutes,int timeout);
+uint16_t	IPMI_SaveConfig( IPMI20_UDS_SESSION_T *pUDSSession,int timeout);
+uint16_t	IPMC_SaveConfig( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,int timeout);
+uint16_t	IPMI_RestoreConfig( IPMI20_UDS_SESSION_T *pUDSSession,int timeout);
+uint16_t	IPMC_RestoreConfig( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,int timeout);
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 

+ 108 - 0
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -615,4 +615,112 @@ uint16_t	IPMC_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr
     *minutes = (Res[10]<<24) | (Res[9]<<16) | (Res[8]<<8) | Res[7];
         
     return 0;
+}
+
+uint16_t	IPMI_SaveConfig( IPMI20_UDS_SESSION_T *pUDSSession,int timeout)
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    uint8_t 		Res[10];
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+					    NETFNLUN_IPMI_STORLEAD, CMD_SAVE_CONFIG,
+					    NULL, 0 ,
+					    Res, &dwResLen,
+					    timeout);
+    if((wRet != 0) || (Res[0] != 0))
+    {
+    	printf("IPMI_SaveConfig failed! ccode = %d\n", Res[0]);
+    	return -1;
+    }
+    printf("IPMI_SaveConfig successful!\n");
+    return 0;
+}
+
+uint16_t	IPMC_SaveConfig( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,int timeout)
+{
+
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50];
+	uint32_t	dwResLen;
+	
+
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_SAVE_CONFIG;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
+    if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("---> IPMC_SaveConfig failed! ccode = %d\n", Res[6]);
+		return -1;
+	}
+    printf("IPMC_SaveConfig successful!\n");
+    return 0;
+}
+
+uint16_t	IPMI_RestoreConfig( IPMI20_UDS_SESSION_T *pUDSSession,int timeout)
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    uint8_t 		Res[10];
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+					    NETFNLUN_IPMI_STORLEAD, CMD_RESTORE_CONFIG,
+					    NULL, 0 ,
+					    Res, &dwResLen,
+					    timeout);
+    if((wRet != 0) || (Res[0] != 0))
+    {
+    	printf("IPMI_RestoreConfig failed! ccode = %d\n", Res[0]);
+    	return -1;
+    }
+    printf("IPMI_RestoreConfig successful!\n");
+    return 0;
+}
+
+uint16_t	IPMC_RestoreConfig( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,int timeout)
+{
+
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50];
+	uint32_t	dwResLen;
+	
+
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_RESTORE_CONFIG;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
+    if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("IPMC_RestoreConfig failed! ccode = %d\n", Res[6]);
+		return -1;
+	}
+	printf("IPMC_RestoreConfig successful!\n");
+    return 0;
 }

+ 3 - 2
app/goahead-3.6.5/src/libipmi/src/sensor_helpers.c

@@ -1048,7 +1048,7 @@ unsigned char sdr_convert_sensor_value_to_raw(FullSensorRec_T   *sdr_record, dou
     k1 = tos(sdr_record->R_B_Exp & 0x0f, 4);
     k2 = tos((sdr_record->R_B_Exp & 0xf0) >> 4, 4);
 
-    printf("---> m: %d, b: %d, k1: %d, k2: %d\n", m, b, k1, k2);
+    printf("---> m: %d, b: %d, k1: %d, k2: %d, val: %0.3f\n", m, b, k1, k2, val);
     
     /* only works for analog sensors */
     if (sdr_record->Units1 >> 6 > 2)
@@ -1075,7 +1075,7 @@ unsigned char sdr_convert_sensor_value_to_raw(FullSensorRec_T   *sdr_record, dou
         result += -0.5;
     }
     tmp = (int)result;
-    printf("---> result: %f, tmp = %d,", result, tmp);
+    printf("---> result: %f, int = %d,", result, tmp);
 
     if (((sdr_record->Units1 & 0xC0) == 0x80) || ((sdr_record->Units1 & 0xC0) == 0x40))    //signed
     {
@@ -1085,6 +1085,7 @@ unsigned char sdr_convert_sensor_value_to_raw(FullSensorRec_T   *sdr_record, dou
     else
     {
         if(tmp > 255)   tmp = 255;
+        if(tmp < 0) tmp = 0;
     }
     retVal = (unsigned char)tmp;
     printf(" retVal = %#x\n", retVal);

+ 4 - 0
app/goahead-3.6.5/src/libipmi/src/userinfo.c

@@ -6,13 +6,17 @@
 
 int FlushUserInfoTbl(void)
 {
+	pthread_mutex_lock(&Flash_Mutex);
 	sf_sector_erase(5, USERTBL_FLASH_ADDR);
 	sf_write(5, USERTBL_FLASH_ADDR, (uint8_t*)UserInfoTbl, sizeof(UserInfo_T)*MAX_USER_NUM);
+	pthread_mutex_unlock(&Flash_Mutex);
 	return 0;
 }
 
 int UpdateUserInfoTble(void)
 {
+	pthread_mutex_lock(&Flash_Mutex);
 	sf_read(5, USERTBL_FLASH_ADDR, (uint8_t*)UserInfoTbl, sizeof(UserInfo_T)*MAX_USER_NUM);
+	pthread_mutex_unlock(&Flash_Mutex);
 	return 0;
 }

+ 8 - 8
app/goahead-3.6.5/src/route.c

@@ -129,7 +129,7 @@ PUBLIC void websRouteRequest(Webs *wp)
         }
     }
     if (wp->routeCount >= WEBS_MAX_ROUTE) {
-        error("Route loop for %s", wp->url);
+        printf("Route loop for %s", wp->url);
     }
     websError(wp, HTTP_CODE_NOT_FOUND, "Cannot find suitable route for request.");
     assert(wp->route == 0);
@@ -287,7 +287,7 @@ WebsRoute *websAddRoute(char *uri, char *handler, int pos)
     WebsKey     *key;
 
     if (uri == 0 || *uri == '\0') {
-        error("Route has bad URI");
+        printf("Route has bad URI");
         return 0;
     }
     if ((route = walloc(sizeof(WebsRoute))) == 0) {
@@ -301,7 +301,7 @@ WebsRoute *websAddRoute(char *uri, char *handler, int pos)
         handler = "file";
     }
     if ((key = hashLookup(handlers, handler)) == 0) {
-        error("Cannot find route handler %s", handler);
+        printf("Cannot find route handler %s", handler);
         wfree(route->prefix);
         wfree(route);
         return 0;
@@ -346,7 +346,7 @@ static void growRoutes()
     if (routeCount >= routeMax) {
         routeMax += 16;
         if ((routes = wrealloc(routes, sizeof(WebsRoute*) * routeMax)) == 0) {
-            error("Cannot grow routes");
+            printf("Cannot grow routes");
         }
     }
 }
@@ -508,7 +508,7 @@ PUBLIC int websLoad(char *path)
 
     rc = 0;
     if ((buf = websReadWholeFile(path)) == 0) {
-        error("Cannot open config file %s", path);
+        printf("Cannot open config file %s", path);
         return -1;
     }
     for (line = stok(buf, "\r\n", &token); line; line = stok(NULL, "\r\n", &token)) {
@@ -551,7 +551,7 @@ PUBLIC int websLoad(char *path)
                 } else if (smatch(key, "uri")) {
                     uri = value;
                 } else {
-                    error("Bad route keyword %s", key);
+                    printf("Bad route keyword %s", key);
                     continue;
                 }
             }
@@ -577,7 +577,7 @@ PUBLIC int websLoad(char *path)
                 } else if (smatch(key, "roles")) {
                     roles = value;
                 } else {
-                    error("Bad user keyword %s", key);
+                    printf("Bad user keyword %s", key);
                     continue;
                 }
             }
@@ -603,7 +603,7 @@ PUBLIC int websLoad(char *path)
             }
 #endif
         } else {
-            error("Unknown route keyword %s", kind);
+            printf("Unknown route keyword %s", kind);
             rc = -1;
             break;
         }

+ 17 - 17
app/goahead-3.6.5/src/runtime.c

@@ -977,20 +977,20 @@ static void defaultLogHandler(int flags, char *buf)
 }
 
 
-PUBLIC void error(char *fmt, ...)
-{
-    va_list     args;
-    char        *message;
-
-    if (!logHandler) {
-        return;
-    }
-    va_start(args, fmt);
-    message = sfmtv(fmt, args);
-    va_end(args);
-    logHandler(WEBS_ERROR_MSG, message);
-    wfree(message);
-}
+// PUBLIC void error(char *fmt, ...)
+// {
+//     va_list     args;
+//     char        *message;
+
+//     if (!logHandler) {
+//         return;
+//     }
+//     va_start(args, fmt);
+//     message = sfmtv(fmt, args);
+//     va_end(args);
+//     logHandler(WEBS_ERROR_MSG, message);
+//     wfree(message);
+// }
 
 
 PUBLIC void assertError(WEBS_ARGS_DEC, char *fmt, ...)
@@ -1750,7 +1750,7 @@ PUBLIC void bufAdjustEnd(WebsBuf *bp, ssize size)
         Flush the queue if the endp pointer is corrupted via a bad size
      */
     if (bp->endp >= bp->endbuf) {
-        error("Bad end pointer");
+        printf("Bad end pointer");
         bufFlush(bp);
     }
 }
@@ -1774,7 +1774,7 @@ PUBLIC void bufAdjustStart(WebsBuf *bp, ssize size)
         Flush the queue if the servp pointer is corrupted via a bad size
      */
     if (bp->servp >= bp->endbuf) {
-        error("Bad serv pointer");
+        printf("Bad serv pointer");
         bufFlush(bp);
     }
 }
@@ -1844,7 +1844,7 @@ PUBLIC bool bufGrow(WebsBuf *bp, ssize room)
     if (room == 0) {
         if (bp->maxsize >= 0 && bp->buflen >= bp->maxsize) {
 #if BLD_DEBUG
-            error("Cannot grow buf. Needed %d, max %d", room, bp->maxsize);
+            printf("Cannot grow buf. Needed %d, max %d", room, bp->maxsize);
 #endif
             return 0;
         }

+ 4 - 4
app/goahead-3.6.5/src/socket.c

@@ -138,19 +138,19 @@ PUBLIC int socketListen(char *ip, int port, SocketAccept accept, int flags)
     enable = 1;
 #if ME_UNIX_LIKE || VXWORKS
     if (setsockopt(sp->sock, SOL_SOCKET, SO_REUSEADDR, (char*) &enable, sizeof(enable)) != 0) {
-        error("Cannot set reuseaddr, errno %d", errno);
+        printf("Cannot set reuseaddr, errno %d", errno);
     }
 #if defined(SO_REUSEPORT) && KEEP
     /*
         This permits multiple servers listening on the same endpoint
      */
     if (setsockopt(sp->sock, SOL_SOCKET, SO_REUSEPORT, (char*) &enable, sizeof(enable)) != 0) {
-        error("Cannot set reuseport, errno %d", errno);
+        printf("Cannot set reuseport, errno %d", errno);
     }
 #endif
 #elif ME_WIN_LIKE && defined(SO_EXCLUSIVEADDRUSE)
     if (setsockopt(sp->sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*) &enable, sizeof(enable)) != 0) {
-        error("Cannot set exclusiveaddruse, errno %d", WSAGetLastError());
+        printf("Cannot set exclusiveaddruse, errno %d", WSAGetLastError());
     }
 #endif
 
@@ -170,7 +170,7 @@ PUBLIC int socketListen(char *ip, int port, SocketAccept accept, int flags)
     }
 #endif
     if (bind(sp->sock, (struct sockaddr*) &addr, addrlen) == SOCKET_ERROR) {
-        error("Cannot bind to address %s:%d, errno %d", ip ? ip : "*", port, errno);
+        printf("Cannot bind to address %s:%d, errno %d", ip ? ip : "*", port, errno);
         socketFree(sid);
         return -1;
     }

+ 6 - 6
app/goahead-3.6.5/src/utils/gopass.c

@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
                 } else {
                     cipher = argv[i];
                     if (!smatch(cipher, "md5") && !smatch(cipher, "blowfish")) {
-                        error("Unknown cipher \"%s\". Use \"md5\" or \"blowfish\".", cipher);
+                        printf("Unknown cipher \"%s\". Use \"md5\" or \"blowfish\".", cipher);
                     }
                     break;
                 }
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
             exit(2);
         }
         if (access(authFile, W_OK) < 0) {
-            error("Cannot write to %s", authFile);
+            printf("Cannot write to %s", authFile);
             exit(4);
         }
     }
@@ -151,7 +151,7 @@ static int writeAuthFile(char *path)
 
     tempFile = websTempFile(NULL, "gp");
     if ((fp = fopen(tempFile, "w" FILE_TEXT)) == 0) {
-        error("Cannot open %s", tempFile);
+        printf("Cannot open %s", tempFile);
         return -1;
     }
     fprintf(fp, "#\n#   %s - Authorization data\n#\n\n", basename(path));
@@ -179,7 +179,7 @@ static int writeAuthFile(char *path)
     fclose(fp);
     unlink(path);
     if (rename(tempFile, path) < 0) {
-        error("Cannot create new %s", path);
+        printf("Cannot create new %s", path);
         return -1;
     }
     return 0;
@@ -195,7 +195,7 @@ static char *getPassword()
     if (smatch(password, confirm)) {
         return password;
     }
-    error("Password not verified");
+    printf("Password not verified");
     return 0;
 }
 
@@ -257,7 +257,7 @@ static char *getpass(char *prompt)
 
 static void printUsage()
 {
-    error("usage: gopass [--cipher cipher] [--file path] [--password password] realm user roles...\n"
+    printf("usage: gopass [--cipher cipher] [--file path] [--password password] realm user roles...\n"
         "Options:\n"
         "    --cipher md5|blowfish Select the encryption cipher. Defaults to md5\n"
         "    --file filename       Modify the password file\n"

+ 70 - 18
app/goahead-3.6.5/src/web_interface/src/config.c

@@ -47,13 +47,15 @@ void restoreFactorySettings(Webs *wp){
     {
         wRet = IPMC_ResetBMC(&UDSSession, target_addr,DEFAULT_TIMEOUT);
     }
+    LIBIPMI_CloseSession(&UDSSession );
+
 	if(wRet != 0)
 	{
 		websError(wp, 404, "Reset BMC fail!");
+        return;
 	}
 
-	//Close session
-    LIBIPMI_CloseSession(&UDSSession );
+    
 
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
@@ -96,14 +98,15 @@ void web_ResetBMC(Webs *wp){
     {
         wRet = IPMC_ResetBMC(&UDSSession, target_addr, DEFAULT_TIMEOUT);
     }
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
+
+
 	if(wRet != 0)
 	{
 		websError(wp, 404, "Reset BMC fail!");
+        return;
 	}
-
-	//Close session
-    LIBIPMI_CloseSession(&UDSSession );
-
 	
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
@@ -154,7 +157,9 @@ void web_GetLanInfo(Webs *wp){
         wRet = IPMICMD_GetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
         if(wRet != 0)
         {
+            LIBIPMI_CloseSession(&UDSSession );
             websError(wp, 404, "Get Lan Info fail!");
+            return;
         }
     }
     else
@@ -223,6 +228,7 @@ void web_SetLanInfo(Webs *wp){
     LanInfo_T   LanInfo;
     uint8_t index = 0;
     uint8_t target_addr;
+    uint8_t isSave = 0;
     
     char *EthName = websGetVar(wp, "eth", NULL);    //eth0
     char *strMode = websGetVar(wp, "mode", NULL);   //static DHCP
@@ -233,7 +239,14 @@ void web_SetLanInfo(Webs *wp){
     char *strGw = websGetVar(wp, "defaultgw", NULL);        //192.168.0.1
     char *strSave = websGetVar(wp, "isSave", NULL);         //0 or 1
 
-    int  isSave = atoi(strSave);
+    if( strcmp(strSave, "true") == 0)
+    {
+        isSave = 1;
+    }
+    else
+    {
+        isSave = 0;
+    }
 
     if(strlen(EthName) > 20)
     {
@@ -281,12 +294,6 @@ void web_SetLanInfo(Webs *wp){
         LanInfo.MACAddr[3] = mac2hex(strMac, 3);
         LanInfo.MACAddr[4] = mac2hex(strMac, 4);
         LanInfo.MACAddr[5] = mac2hex(strMac, 5);
-
-        //isSave 只能是0和1这两个值。
-        if(isSave != 1)
-        {
-            isSave = 0;
-        }
         
         //Create session
         LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
@@ -294,7 +301,9 @@ void web_SetLanInfo(Webs *wp){
         wRet = IPMICMD_SetLanInfo(&UDSSession, index, isSave, &LanInfo, DEFAULT_TIMEOUT);
         if(wRet != 0)
         {
+            LIBIPMI_CloseSession(&UDSSession );
             websError(wp, 404, "Reset BMC fail!");
+            return;
         }
 
         //Close session
@@ -346,7 +355,9 @@ void web_GetRunTime(Webs *wp){
         wRet = IPMI_GetPOH( &UDSSession, &min_per_cnt, &counts,DEFAULT_TIMEOUT);
         if(wRet != 0)
         {
+            LIBIPMI_CloseSession(&UDSSession );
             websError(wp, 404, "web_GetRunTime failed!");
+            return;
         }        
     }
     else
@@ -354,7 +365,9 @@ void web_GetRunTime(Webs *wp){
         wRet = IPMC_GetPOH( &UDSSession, target_addr, &min_per_cnt, &counts, DEFAULT_TIMEOUT);
         if(wRet != 0)
         {
+            LIBIPMI_CloseSession(&UDSSession );
             websError(wp, 404, "web_GetRunTime failed!");
+            return;
         }
     }
     totalhours = counts*min_per_cnt/60;  //hours
@@ -368,7 +381,9 @@ void web_GetRunTime(Webs *wp){
         wRet = IPMI_GetCurRunTime( &UDSSession, &totalsMinutes, DEFAULT_TIMEOUT);
         if(wRet != 0)
         {
+            LIBIPMI_CloseSession(&UDSSession );
             websError(wp, 404, "web_GetRunTime failed!");
+            return;
         }        
     }
     else
@@ -376,7 +391,9 @@ void web_GetRunTime(Webs *wp){
         wRet = IPMC_GetCurRunTime( &UDSSession, target_addr, &totalsMinutes, DEFAULT_TIMEOUT);
         if(wRet != 0)
         {
+            LIBIPMI_CloseSession(&UDSSession );
             websError(wp, 404, "web_GetRunTime failed!");
+            return;
         }
     }
     days = totalsMinutes/(24*60);
@@ -449,9 +466,7 @@ void web_SetModIdentifyOn(Webs *wp){
     }
 
     printf("---> identify on Sec = %d\n", identifySec);
-
-    
-    
+   
     //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
@@ -555,7 +570,27 @@ void web_SaveConfig(Webs *wp){
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
     uint8_t target_addr;
-    uint8_t identifySec = 0;
+
+    
+
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMI_SaveConfig(&UDSSession, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_SaveConfig(&UDSSession, target_addr, DEFAULT_TIMEOUT);
+    }
+    LIBIPMI_CloseSession(&UDSSession );
+    
+    if(wRet != 0)
+    {
+        websError(wp, 404, "Save config failed!");
+        return;
+    }
+
 
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
@@ -583,7 +618,24 @@ void web_RestoreConfig(Webs *wp){
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
     uint8_t target_addr;
-    uint8_t identifySec = 0;
+
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMI_RestoreConfig(&UDSSession, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_RestoreConfig(&UDSSession, target_addr, DEFAULT_TIMEOUT);
+    }
+    LIBIPMI_CloseSession(&UDSSession );
+    
+    if(wRet != 0)
+    {
+        websError(wp, 404, "Save config failed!");
+        return;
+    }
 
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();

+ 15 - 11
app/goahead-3.6.5/src/web_interface/src/fw_update.c

@@ -27,7 +27,6 @@ static uint8_t target_addr;
 */
 void prepareDevice(Webs *wp)
 {
-//    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];
     if(target_addr == 0x20)
     {
@@ -79,25 +78,30 @@ void uploadFirmware(Webs *wp)
     char            *upfile;
 
 //    wp->index = TEST_INDEX;
+    printf("index %d, target_addr %#x\n", wp->index, target_addr);
     target_addr = gIPMBAddr[wp->index];
-    if(target_addr == 0x20)
+    //if(target_addr == 0x20)
     {
         if (scaselessmatch(wp->method, "POST")) {
             for (s = hashFirst(wp->files); s; s = hashNext(wp->files, s)) {
                 up = s->content.value.symbol;
                 upfile = sfmt("%s/tmp/%s", websGetDocuments(), "tmp.uImage");
                 if (rename(up->filename, upfile) < 0) {
-                    error("Cannot rename uploaded file: %s to %s, errno %d", up->filename, upfile, errno);
+                    printf("Cannot rename uploaded file: %s to %s, errno %d", up->filename, upfile, errno);
+                }
+                else
+                {
+                    printf("Rename uploaded file: %s to %s", up->filename, upfile);  
                 }
                 wfree(upfile);
             }
-          
         }
     }
-    else
-    {
-        //Do nothing
-    }
+    // else
+    // {
+    //     //Do nothing
+    // }
+
 
     
     cJSON * root =  cJSON_CreateObject();
@@ -134,7 +138,7 @@ void updateFlash(Webs *wp)
 
 //    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];
-    //printf("wp->index %d, target_addr %#x\n", wp->index, target_addr);
+    printf("wp->index %d, target_addr %#x\n", wp->index, target_addr);
     if(target_addr == 0x20)
     {
         //Call updateFW_app
@@ -243,14 +247,14 @@ void getEraseStatus(Webs *wp)
         if(NULL == fp)
         {
             printf("Open Erase.log failed!\n");
-            websError(wp, 200, "Open Erase.log failed!");
+            websError(wp, HTTP_CODE_NO_CONTENT, "Open Erase.log failed!");
             return;
         }
 
         if(NULL == fgets(EraseStr, 13, fp))
         {
             printf("Read Erase.log failed!\n");
-            websError(wp, 200, "Read Erase.log failed!");
+            websError(wp, HTTP_CODE_NO_CONTENT, "Read Erase.log failed!");
             fclose(fp);
             return;
         }

+ 7 - 4
app/goahead-3.6.5/src/web_interface/src/server_health.c

@@ -33,9 +33,7 @@ void setThreshold(Webs *wp){
     int   SensorNumber = atoi(strSensorNumber);
     uint8_t target_addr;
 
-    // printf(" %s, %s %s %s, %s %s %s = %d, %f %f %f %f %f %f \n", strSensorNumber, strUNC, strUC, strUNR, strLNC, strLC, 
-    // 	strLNR,  SensorNumber, UNC, UC, UNR, LNC, LC, LNR );
-
+    
     uint8_t  *data_buffer = (uint8_t*)walloc(255);
     FullSensorRec_T	*sdr_record = (FullSensorRec_T*) data_buffer;
     uint32_t data_buff_size = 255;//sizeof(data_buffer);
@@ -84,7 +82,12 @@ void setThreshold(Webs *wp){
     pReqSetSensorThreshold->LowerNonCritical = sdr_convert_sensor_value_to_raw(sdr_record, LNC);
     pReqSetSensorThreshold->LowerCritical = sdr_convert_sensor_value_to_raw(sdr_record, LC);
     pReqSetSensorThreshold->LowerNonRecoverable = sdr_convert_sensor_value_to_raw(sdr_record, LNR);
-    
+    printf("SensorNumber\t| UNC\t| UC\t| UNR\t| LNC\t| LC\t| LNR\n");
+    printf("    %s      \t| %s\t| %s\t| %s\t| %s\t| %s\t| %s\n", strSensorNumber, strUNC, strUC, strUNR, strLNC, strLC, strLNR );
+    printf("    %d      \t|%0.3f\t|%0.3f\t|%0.3f\t|%0.3f\t|%0.3f\t|%0.3f \n", SensorNumber, UNC, UC, UNR, LNC, LC, LNR );
+    printf("    %d      \t| %02x \t| %02x\t| %02x \t| %02x \t| %02x\t| %02x \n", SensorNumber, 
+        pReqSetSensorThreshold->UpperNonCritical,pReqSetSensorThreshold->UpperCritical,pReqSetSensorThreshold->UpperNonRecoverable,
+        pReqSetSensorThreshold->LowerNonCritical,pReqSetSensorThreshold->LowerCritical,pReqSetSensorThreshold->LowerNonRecoverable);
     if(target_addr == 0x20)
     {
         wRet = IPMICMD_SetSensorThreshold( &UDSSession, pReqSetSensorThreshold, pResSetSensorThreshold, DEFAULT_TIMEOUT);

+ 7 - 7
app/hal_api/hal_spi_interface.c

@@ -48,7 +48,7 @@ int stm32_spi_master_write(uint8_t spi, uint8_t *pBuf, uint32_t size)
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	{
-		printf("Open %s failed!\n", dev_name);
+		printf("%s %d: Open %s failed!\n", __FILE__, __LINE__, dev_name);
 	}
 
 	// //NSS low
@@ -106,7 +106,7 @@ int stm32_spi_master_read(uint8_t spi, uint8_t *pBuf, uint32_t size)
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	{
-		printf("Open %s failed!\n", DEV_NAME);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, DEV_NAME);
 	}
 	
 	spi_arg.Size = size;
@@ -158,7 +158,7 @@ int stm32_spi_master_write_read(uint8_t spi, uint8_t *txBuf, uint32_t txSize, ui
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	{
-		printf("Open %s failed!\n", DEV_NAME);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, DEV_NAME);
 	}
 
 	//Tx
@@ -276,7 +276,7 @@ int sf_sector_erase(uint8_t spi, uint32_t offset)
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	{
-		printf("Open %s failed!\n", dev_name);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, dev_name);
 	}
 
 	//Write Enable
@@ -359,7 +359,7 @@ int sf_chip_erase(uint8_t spi)
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	{
-		printf("Open %s failed!\n", dev_name);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, dev_name);
 	}
 
 	//Write Enable
@@ -505,7 +505,7 @@ int sf_write(uint8_t spi, uint32_t offset, uint8_t *buf, uint32_t size)
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	{
-		printf("Open %s failed!\n", dev_name);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, dev_name);
 	}
 
 	
@@ -657,7 +657,7 @@ int sf_read(uint8_t spi, uint32_t offset, uint8_t *buf, uint32_t size)
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	{
-		printf("Open %s failed!\n", dev_name);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, dev_name);
 	}
 		
 	remain = size;

BIN
app/i2c_scan/i2c-scan


BIN
app/test_app/test_app