🦄 Sync 2026-04-24 02:45:08

This commit is contained in:
github-actions[bot] committed 2026-04-24 02:45:08 +08:00
1 parent ff176861b1
commit acf702ebcc
180 files changed
+4684 -28638

No files matched your search

-40
View File
@@ -1,40 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=cp210x-cfg
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=https://github.com/iuncuim/cp210x-cfg.git
PKG_SOURCE_DATE:=2023-05-18
PKG_SOURCE_VERSION:=bf968c49c7cf004ebfba72f7deb0ba88330e1652
PKG_MIRROR_HASH:=skip
include $(INCLUDE_DIR)/package.mk
define Package/cp210x-cfg
SECTION:=utils
CATEGORY:=Utilities
TITLE:=CLI utility for programming CP210x USB<->UART bridges
DEPENDS:=+libusb-1.0
endef
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
TARGET_LDFLAGS += -L$(STAGING_DIR)/usr/lib
define Package/cp210x-cfg/description
CLI utility for programming CP210x USB<->UART bridges
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/cp210x-cfg/install
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cp210x-cfg $(1)/sbin/
endef
$(eval $(call BuildPackage,cp210x-cfg))
-36
View File
@@ -1,36 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fbfdownloader
PKG_VERSION:=4.9.0.7
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/fbfdownloader
include $(INCLUDE_DIR)/package.mk
define Package/fbfdownloader
SECTION:=utils
CATEGORY:=Utilities
DEPENDS+= +libpthread
TITLE:=Firmware flash tool for ASR based modems
endef
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
TARGET_LDFLAGS += -L$(STAGING_DIR)/usr/lib
define Package/fbfdownloader/description
This package contains utility for sim check manage.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/fbfdownloader/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/fbfdownloader_cross $(1)/usr/bin
endef
$(eval $(call BuildPackage,fbfdownloader))
-432
View File
@@ -1,432 +0,0 @@
//
//////////////////////////////////////////////////////////////////////
#pragma once
#pragma warning ( disable : 4100 ) // Disable warning messages: unreferenced formal parameter
#pragma warning ( disable : 4189 ) // Disable warning messages: local variable is initialized but not referenced
#include "Macrodef.h"
//#include "BLFProperty.h"
#include "EnumVal.h"
#define MAX_FILE_LENGTH 1024
#define SECTOR_UNIT 512
#define EMMC_ERASE_UNIT (512*1024) // 512K
#define NAND_ERASE_UNIT (128*1024) // 128K
#define NOR_ERASE_UNIT (64*1024) // 64K
#define READ_BLOCK_SIZE 0x800000 //8M
//different partitions of EMMC
#define PRIBOOT_PARTITION 1
#define RECVBOOT_PARTITION 2
#define RPMB_PARTITION 3
/* general commands */
#define DLCMD_DO_ERASE_ALL_FLASH (1)
#define DLCMD_DO_UPLOAD_DATA (2)
#define DLCMD_RESETBBT (4)
#define DLCMD_DO_ERASE_ALL_ONLY (16)
const static TCHAR* FBF_IDNAME = _T("FBFD");
const static TCHAR* DKB_IDNAME = _T("DKBI");
const static TCHAR* OBM_IDNAME = _T("OBMI");
const static TCHAR* WTM_IDNAME = _T("WTMI");
const static TCHAR* TZI_IDNAME = _T("TZII");
const static TCHAR* ROMC_IDNAME = _T("ROMC");
const static TCHAR* FBF_IMAGE_TYPE = _T("FBF");
const static TCHAR* pszDKB_TIM_HEADER_NAME = _T("DKB_ntimheader.bin");
const static TCHAR* pszDKB_TRUST_TIM_HEADER_NAME = _T("DKB_timheader.bin");
const static TCHAR* pszDKB_DUMMY_BIN = _T("DKB_dummy.bin");
const static TCHAR* pszFBF_NTIM_HEADER_NAME = _T("FBF_Ntimheader.bin");
const static TCHAR* pszFBF_TRUST_TIM_HEADER_NAME = _T("FBF_timheader.bin");
const static TCHAR* pszDKB_FILE_NAME = _T("Dkb.bin");
const static TCHAR* pszPREFERENCES = _T("Preferences");
const static TCHAR* pszRUN_TIME_DLG = _T("Run-Time Dialog");
const static TCHAR* pszTIM_CFG = _T("TIM_Configuration");
const static TCHAR* pszBLF_VERSION_PRO = _T("BLF_Version");
const static TCHAR* pszBLF_VERSION_NUMBER = _T("V2.0.0");
const static TCHAR* pszBLF_VERSION_NUMBER_SECTOR_FLASH = _T("V2.1.0");
const static TCHAR* pszBLF_VERSION_NUMBER_SECTOR_FLASH_WITH_DTIMPPSETTING = _T("V2.2.0");
const static TCHAR* pszBLF_VERSION_NAND_NOR_FLASH = _T("V3.0.0");
const static TCHAR* pszBLF_VERSION = _T("Blf_Version_Number");
const static TCHAR* pszRESET_BBT = _T("Reset_BBT");
const static TCHAR* pszFBF_SECTOR_SIZE = _T("FBF_Sector_Size");
const static TCHAR* pszDATA_PAGE_SIZE = _T("Data_Area_Size" );
const static TCHAR* pszSPARE_AREA_SIZE = _T("Spare_Area_Size" );
const static TCHAR* pszNAND_BLOCK_SIZE = _T("Flash_Block_Size");
const static TCHAR* pszMAX_OTA_IAMGE_SIZE = _T("Max_OTA_Image_Size");
const static TCHAR* pszOTA_IAMGE_SPLIT_SIZE = _T("OTA_Image_Split_Size");
const static TCHAR* pszFLASH_FAMILY_PRO = _T("Flash_Family" );
const static TCHAR* pszSKIP_BLOCK_NUMBER = _T("Skip_Blocks_Number");
const static TCHAR* pszERASE_ALL_FLASH = _T("Erase_All_Flash");
const static TCHAR* pszBOOTOPTION_AFTER_FLASH = _T("UE_Boot_Option");
const static TCHAR* pszPROCESSOR_TYPE = _T("Processor_Type");
const static TCHAR* pszBOOT_FLASH_SIG = _T("Boot_Flash_Signature");
const static TCHAR* pszTRUSTED = _T("Trusted");
const static TCHAR* pszVERSION = _T("Version");
const static TCHAR* pszISSUDT = _T("Issue_Date");
const static TCHAR* pszOEMUID = _T("OEM_UniqueID");
const static TCHAR* pszSIZE_OF_IMG = _T("Number_of_Images");
const static TCHAR* pszSIZE_OF_EMMCTYPE = _T("Number_of_EMMCTypes");
const static TCHAR* pszSIZE_OF_RSV = _T("Size_of_Reserved_in_bytes");
const static TCHAR* pszNUM_OF_KEYS = _T("Number_of_Keys");
const static TCHAR* pszEXT_RSV_DATA = _T("[Extended_Reserved_Data]");
const static TCHAR* pszRSV_DATA = _T("[Reserved_Data]");
const static TCHAR* pszEND_RSV_DATA = _T("End_Reserved_Data");
const static TCHAR* pszFBF_SPLIT_SIZE_SETTING = _T("Max_FBF_Split_Size");
const static TCHAR* pszUPLOAD_MAX_SIZE_SETTING = _T("Max_Upload_Split_Size" );
const static TCHAR* pszWTM_FL_SIGTURE = _T("WTM_Save_State_Flash_Signature");
const static TCHAR* pszWTM_FL_EN_ADDR = _T("WTM_Save_State_Flash_Entry_Address");
const static TCHAR* pszWTM_BK_EN_ADDR = _T("WTM_Save_State_BackUp_Entry_Address");
const static TCHAR* pszAUTH_PATH = _T("Authentication Path");
const static TCHAR* pszST_ADDR = _T("Start_Address");
const static TCHAR* pszIMG_LIST = _T("Image_List");
const static TCHAR* pszENBL = _T("Enable");
const static TCHAR* pszTIM_INCLUDED = _T("Tim_Included");
const static TCHAR* pszPATH = _T("Path");
const static TCHAR* pszFL_ENTRY_ADDR = _T("Flash_Entry_Address");
const static TCHAR* pszLOAD_ADDR = _T("Load_Address");
const static TCHAR* pszSIZE_OF_IMGTOCRC = _T("Size_To_CRC_in_bytes");
const static TCHAR* pszSIZE_OF_IMGTOHASH = _T("Image_Size_To_Hash_in_bytes");
const static TCHAR* pszSIZE_OF_ERASE = _T("Erase_Size");
const static TCHAR* pszPARTITION = _T("Partition_Number");
const static TCHAR* pszIMGID_NAME = _T("ID_Name");
const static TCHAR* pszIMGID = _T("Image_ID");
const static TCHAR* pszNTIMGID = _T("Next_Image_ID");
const static TCHAR* pszHASH_ALGT_ID = _T("Hash_Algorithm_ID");
const static TCHAR* pszOFST = _T("Offset");
const static TCHAR* pszTYPE = _T("Type");
const static TCHAR* pszFLASH_PROP = _T("Flash_Properties");
const static TCHAR* pszFLASH_OPTIONS = _T("Flash_Options");
const static TCHAR* pszUE_OPTIONS = _T("UE_Options");
const static TCHAR* pszNONE_ERASESIZE = _T("");
const static TCHAR* pszSPARE_SIZE = _T("Spare_Area_Size");
const static TCHAR* pszDATA_SIZE = _T("Data_Area_Size");
const static TCHAR* pszFLASHNANDID = _T("Flash_NandID");
const static TCHAR* pszJTAG_TRUSTED = _T("JTAG TRUSTED");
const static TCHAR* pszJTAG_TIM = _T("TIM Path");
const static TCHAR* pszJTAG_KEY = _T("KEY Path");
const static TCHAR* pszPACKAGE_SIZE = _T("Package_Size");
const static TCHAR* pszERASE_ONLY_OPTION = _T("EraseOnly_Option");
const static TCHAR* pszERASE_ONLY_NUM = _T("Total_Eraseonly_Areas");
const static TCHAR* pszERASE_ONLY_START_ADD = _T("Eraseonly_Area_FlashStartAddress");
const static TCHAR* pszERASE_ONLY_SIZE = _T("Eraseonly_Area_Size");
const static TCHAR* pszERASE_ONLY_PARTITION = _T("Eraseonly_Area_Partition");
//Add support for trusted mode
const static TCHAR* pszDIGITAL_SIGNATURE_DATA = _T("Digital_Signature_Data");
const static TCHAR* pszEND_DIGITAL_SIGNATURE_DATA = _T("End_Digital_Signature_Data");
const static TCHAR* pszKEYS_DATA = _T("Keys_Data");
const static TCHAR* pszDSA_ALGORITHM = _T("DSA_Algorithm");
const static TCHAR* pszHASHALG_ID = _T("Hash_Algorithm_ID");
const static TCHAR* pszENCRYPT_ALGID = _T("Encrypt_Algorithm_ID");
const static TCHAR* pszKEY_ID = _T("Key_ID");
const static TCHAR* pszMODULUS_SIZE = _T("Modulus_Size_in_bytes");
const static TCHAR* pszKEY_SIZE = _T("Key_Size_in_bits");
const static TCHAR* pszPUBLIC_KEY_SIZE = _T("Public_Key_Size_in_bytes");
const static TCHAR* pszRSA_PUBLIC_EXP = _T("RSA_Public_Exponent");
const static TCHAR* pszEND_RSA_PUBLIC_EXP = _T("End_RSA_Public_Exponent");
const static TCHAR* pszRSA_SYS_MODULUS = _T("RSA_System_Modulus");
const static TCHAR* pszEND_RSA_SYS_MODULUS = _T("End_RSA_System_Modulus");
const static TCHAR* pszRSA_PRIVATE_KEY = _T("RSA_Private_Key");
const static TCHAR* pszEND_RSA_PRIVATE_KEY = _T("End_RSA_Private_Key");
const static TCHAR* pszECDSA_PUBLIC_KEY_COMX = _T("ECDSA_Public_Key_CompX");
const static TCHAR* pszEND_ECDSA_PUBLIC_KEY_COMX = _T("End_ECDSA_Public_Key_CompX");
const static TCHAR* pszECDSA_PUBLIC_KEY_COMY = _T("ECDSA_Public_Key_CompY");
const static TCHAR* pszEND_ECDSA_PUBLIC_KEY_COMY = _T("End_ECDSA_Public_Key_CompY");
const static TCHAR* pszECDSA_PRIVATE_KEY = _T("ECDSA_Private_Key");
const static TCHAR* pszEND_ECDSA_PRIVATE_KEY = _T("End_ECDSA_Private_Key");
const static TCHAR* pszEND_EXT_RSV_DATA = _T("End_Extended_Reserved_Data");
const static TCHAR* pszCLK_ENABLE = _T("Clock_Enable");
const static TCHAR* pszEND_CLK_ENABLE = _T("End_Clock_Enable");
const static TCHAR* pszDDR_GEO = _T("DDR_Geometry");
const static TCHAR* pszEND_DDR_GEO = _T("End_DDR_Geometry");
const static TCHAR* pszDDR_TIMING = _T("DDR_Timing");
const static TCHAR* pszEND_DDR_TIMING = _T("End_DDR_Timing");
const static TCHAR* pszDDR_CUSTOM = _T("DDR_Custom");
const static TCHAR* pszEND_DDR_CUSTOM = _T("End_DDR_Custom");
const static TCHAR* pszFREQ = _T("Frequency");
const static TCHAR* pszEND_FREQ = _T("End_Frequency");
const static TCHAR* pszVOL = _T("Voltages");
const static TCHAR* pszEND_VOL = _T("End_Voltages");
const static TCHAR* pszCFG_MEM_CTRL = _T("Configure_Memory_Control");
const static TCHAR* pszEND_CFG_MEM_CTRL = _T("End_Configure_Memory_Control");
const static TCHAR* pszTRUST_Z = _T("Trust_Zone");
const static TCHAR* pszEND_TRUST_Z = _T("End_Trust_Zone");
const static TCHAR* pszTRUST_Z_RE = _T("Trust_Zone_Regid");
const static TCHAR* pszEND_TRUST_Z_RE = _T("End_Trus_Zone_Regid");
const static TCHAR* pszOPDIV = _T("OpDiv");
const static TCHAR* pszEND_OPDIV = _T("End_OpDiv");
const static TCHAR* pszOPMOD = _T("OpMode");
const static TCHAR* pszEND_OPMOD = _T("End_OpMode");
const static TCHAR* pszERDVEC = _T("ErdVec");
const static TCHAR* pszEND_ERDVEC = _T("End_ErdVec");
const static TCHAR* pszTR069_INFO = _T("TRFU");
const static TCHAR* pszTR069_ENABLED = _T("Enabled");
const static TCHAR* pszTR069_FLASH_ADDR = _T("Flash_Address");
const static TCHAR* pszTR069_MAGIC = _T("Magic");
const static TCHAR* pszTR069_INFO_END = _T("End_TRFU");
const static TCHAR* pszFOTA_INFO = _T("OTAI");
const static TCHAR* pszFOTA_ENABLED = _T("Enabled");
const static TCHAR* pszFOTA_FLASH_ADDR = _T("Flash_Address");
const static TCHAR* pszFOTA_MAGIC = _T("Magic");
const static TCHAR* pszFOTA_INFO_END = _T("End_OTAI");
const static TCHAR* pszDDR_TYPE_BEGIN = _T("DTYP");
const static TCHAR* pszDDR_TYPE_VALUE = _T("DDR_Type");
const static TCHAR* pszDDR_TYPE_END = _T("End_DTYP");
const static TCHAR* pszDDR_BYTE_SELECT_BEGIN = _T("DDBS");
const static TCHAR* pszDDR_BYTE_SELECT = _T("DDR_Byte_Select");
const static TCHAR* pszDDR_BYTE_SELECT_END = _T("End_DDBS");
//LTG LWG SELECT PACKAGE
const static TCHAR* pszLTG_LWG_SELECT_BEGIN = _T("LTWS");
const static TCHAR* pszLTG_LWG_SELECT_VALUE = _T("LTG_LWG_Select");
const static TCHAR* pszLTG_LWG_SELECT_END = _T("End_LTWS");
const static TCHAR* pszCUSTOMER_TRANSFER_INFO = _T("CITA_CUMIZED_INFO_TRANSFER_TOAP_ID");
const static TCHAR* pszCUSTOMER_TRANSFER_INFO_END = _T("End_CITA_CUMIZED_INFO_TRANSFER_TOAP_ID");
const static TCHAR* pszBBMIDTYPE = _T("BBMT");
const static TCHAR* pszBBMIDTYPE_END = _T("End_BBMT");
const static TCHAR* pszFLASHGEOPKGID = _T("FGPI");
const static TCHAR* pszFLASHGEOPKGID_END = _T("End_FGPI");
const static TCHAR* pszBBCS_BEGIN = _T("BBCS");
const static TCHAR* pszBBCS_VALUE = _T("Enabled");
const static TCHAR* pszBBCS_END = _T("End_BBCS");
const static TCHAR* pszCRCS_BEGIN = _T("CRCS");
const static TCHAR* pszCRCS_VALUE = _T("Enabled");
const static TCHAR* pszCRCS_END = _T("End_CRCS");
// Added by ZQQ to support DTIM 2012-03-28
const static TCHAR* pszDTIM_KEYS_DATA = _T("DTIM_Keys_Data");
const static TCHAR* pszEND_DTIM_KEYS_DATA = _T("End_DTIM_Keys_Data");
const static TCHAR* pszPRODUCTION_MODE = _T("ProductionMode");
const static TCHAR* pszDDR_FLASH_MCP_MAP = _T("DDR_Flash_Mcp_Map");
const static TCHAR* pszEND_DDR_FLASH_MCP_MAP = _T("End_DDR_Flash_Mcp_Map");
// definition for PXA92x
//Added by zqq 2012-2-3
const static TCHAR* pszPXA92x_TIM_CFG = _T("TIM Configuration");
const static TCHAR* pszPXA92x_SKIP_BLOCK_CFG = _T("Skip Block Configuration");
const static TCHAR* pszPXA92x_TRUSTED = _T("Trusted");
const static TCHAR* pszPXA92x_TOTAL_SKIPBLOCK = _T("Total Skip Block Numbers");
const static TCHAR* pszPXA92x_SKIP_BLOCK_NUMBER = _T("Skip Block Number");
const static TCHAR* pszPXA92x_ERASE_ALL_FLASH = _T("Erase All Flash");
const static TCHAR* pszPXA92x_FLASHER_ADRES = _T("FlasherLoadAddress");
const static TCHAR* pszPXA92x_VERSION = _T("Version");
const static TCHAR* pszPXA92x_ISSUDT = _T("Issue Date");
const static TCHAR* pszPXA92x_OEMUID = _T("OEM UniqueID");
const static TCHAR* pszPXA92x_PROCESSOR_TYPE = _T("Processor Type");
const static TCHAR* pszPXA92x_BOOT_FLASH_SIG = _T("Boot Flash Signature");
const static TCHAR* pszPXA92x_SIZE_OF_IMG = _T("Number of Images");
const static TCHAR* pszPXA92x_SIZE_OF_RSV = _T("Size of Reserved in bytes");
const static TCHAR* pszPXA92x_NUM_OF_KEYS = _T("Number of Keys");
const static TCHAR* pszPXA92x_EXT_RSV_DATA = _T("Extended Reserved Data");
const static TCHAR* pszPXA92x_END_EXT_RSV_DATA = _T("End Extended Reserved Data");
const static TCHAR* pszPXA92x_RSV_DATA = _T("[Reserved Data]");
const static TCHAR* pszPXA92x_END_RSV_DATA = _T("End Reserved Data");
const static TCHAR* pszPXA92x_WTM_FL_SIGTURE = _T("WTM Save State Flash Signature");
const static TCHAR* pszPXA92x_WTM_FL_EN_ADDR = _T("WTM Save State Flash Entry Address");
const static TCHAR* pszPXA92x_WTM_BK_EN_ADDR = _T("WTM Save State BackUp Entry Address");
const static TCHAR* pszPXA92x_FL_PATH = _T("Flasher Path");
const static TCHAR* pszPXA92x_AUTH_PATH = _T("Authentication Path");
const static TCHAR* pszPXA92x_JTAG_TIM_PATH = _T("Jtag TIM File Path");
const static TCHAR* pszPXA92x_ST_ADDR = _T("Start Address");
const static TCHAR* pszPXA92x_IMEI_PATH = _T("IMEI File Path");
const static TCHAR* pszPXA92x_MEP_PATH = _T("MEP File Path");
const static TCHAR* pszPXA92x_IMG_LIST = _T("Image List");
const static TCHAR* pszPXA92x_ENBL = _T("Enable");
const static TCHAR* pszPXA92x_PATH = _T("Path");
const static TCHAR* pszPXA92x_FL_ENTRY_ADDR = _T("Flash Entry Address");
const static TCHAR* pszPXA92x_LOAD_ADDR = _T("Load Address");
const static TCHAR* pszPXA92x_SIZE_OF_IMGTOCRC = _T("Image Size To CRC in bytes");
const static TCHAR* pszPXA92x_SIZE_OF_IMGTOHASH = _T("Image Size To Hash in bytes");
const static TCHAR* pszPXA92x_SIZE_OF_ERASE = _T("Erase Size");
const static TCHAR* pszPXA92x_PARTITION = _T("Partition Number");
const static TCHAR* pszPXA92x_IMGID_NAME = _T("ID Name");
const static TCHAR* pszPXA92x_IMGID = _T("Image ID");
const static TCHAR* pszPXA92x_NTIMGID = _T("Next Image ID");
const static TCHAR* pszPXA92x_HASH_ALGT_ID = _T("Hash Algorithm ID");
const static TCHAR* pszPXA92x_OFST = _T("Offset");
const static TCHAR* pszPXA92x_TYPE = _T("Type");
const static TCHAR* pszPXA92x_OLD_FLASHER = _T("Flasher Property");
const static TCHAR* pszPXA92x_FLASH_PROP = _T("Flash Properties");
const static TCHAR* pszPXA92x_CFG_FILE_PATH = _T("Flash Configuration File Path");
const static TCHAR* pszPXA92x_TAVOR_PROP = _T("Tavor Flasher Properties");
const static TCHAR* pszPXA92x_NONE_ERASESIZE = _T("");
const static TCHAR* pszPXA92x_SPARE_SIZE = _T("Spare Area Size");
const static TCHAR* pszPXA92x_DATA_SIZE = _T("Data Area Size");
const static TCHAR* pszPXA92x_JTAG_TRUSTED = _T("JTAG TRUSTED");
const static TCHAR* pszPXA92x_JTAG_TIM = _T("TIM Path");
const static TCHAR* pszPXA92x_JTAG_KEY = _T("KEY Path");
const static TCHAR* pszPXA92x_ERASE_ALL = _T("Erase All");
const static TCHAR* pszPXA92x_END_ERASE_ALL = _T("End Erase All");
const static TCHAR* pszPXA92x_CLK_ENABLE = _T("Clock Enable");
const static TCHAR* pszPXA92x_END_CLK_ENABLE = _T("End Clock Enable");
const static TCHAR* pszPXA92x_DDR_GEO = _T("DDR Geometry");
const static TCHAR* pszPXA92x_END_DDR_GEO = _T("End DDR Geometry");
const static TCHAR* pszPXA92x_DDR_TIMING = _T("DDR Timing");
const static TCHAR* pszPXA92x_END_DDR_TIMING = _T("End DDR Timing");
const static TCHAR* pszPXA92x_DDR_CUSTOM = _T("DDR Custom");
const static TCHAR* pszPXA92x_END_DDR_CUSTOM = _T("End DDR Custom");
const static TCHAR* pszPXA92x_FREQ = _T("Frequency");
const static TCHAR* pszPXA92x_END_FREQ = _T("End Frequency");
const static TCHAR* pszPXA92x_VOL = _T("Voltages");
const static TCHAR* pszPXA92x_END_VOL = _T("End Voltages");
const static TCHAR* pszPXA92x_CFG_MEM_CTRL = _T("Configure Memory Control");
const static TCHAR* pszPXA92x_END_CFG_MEM_CTRL = _T("End Configure Memory Control");
const static TCHAR* pszPXA92x_TRUST_Z = _T("Trust Zone");
const static TCHAR* pszPXA92x_END_TRUST_Z = _T("End Trust Zone");
const static TCHAR* pszPXA92x_TRUST_Z_RE = _T("Trust Zone Regid");
const static TCHAR* pszPXA92x_END_TRUST_Z_RE = _T("End Trust Zone Regid");
const static TCHAR* pszPXA92x_OPDIV = _T("OpDiv");
const static TCHAR* pszPXA92x_END_OPDIV = _T("End OpDiv");
const static TCHAR* pszPXA92x_OPMOD = _T("OpMode");
const static TCHAR* pszPXA92x_END_OPMOD = _T("End OpMode");
const static TCHAR* pszPXA92x_ERDVEC = _T("ErdVec");
const static TCHAR* pszPXA92x_END_ERDVEC = _T("End ErdVec");
const static TCHAR* pszPXA92x_DEVICE_USB_MAP = _T("DEVICE_USBPORT_MAP");
const static TCHAR* pszPXA92x_DEVICE_USBPORT_NUMBER = _T("MAX Device USB Port Number");
const static TCHAR* pszPXA92x_DEVICE_USB_PORT = _T("Device USB Port");
const static TCHAR* pszPXA92x_ERASE_ONLY = _T("Erase only Area");
const static TCHAR* pszPXA92x_ERASE_ONLY_NUM = _T("Erase Area Num");
const static TCHAR* pszPXA92x_ERASE_ONLY_START_ADD = _T("Erase Flash Start Address");
const static TCHAR* pszPXA92x_ERASE_ONLY_LENGTH = _T("Erase Length");
const static TCHAR* pszPXA92x_ERASE_ONLY_PARTITION = _T("Erase Area Partition");
const static TCHAR* pszPXA92x_DEV_HEADER_0 = _T("DEV_HEADER_0");
const static TCHAR* pszPXA92x_BLOCK_SIZE_NAME = _T("Block_Size_0");
const static TCHAR* pszPXA92x_FLASHFAMLIY = _T("FlashFamily");
const static TCHAR* pszPXA92x_FLASHINI = _T("INTEL_FLASHER_INPUT_FILE");
const static TCHAR* pszPXA92x_FLASH_BLOCKS = _T("Number_of_Blocks_0");
const static TCHAR* pszUPLOAD_PROPERTY = _T("Upload_Property");
const static TCHAR* pszMAX_UPLOAD_SIZE = _T("Max_Upload_Size");
const static TCHAR* pszUPLOADAREA_NUM = _T("Upload_Area_Nums");
const static TCHAR* pszUPLOAD_RESETUE = _T("ResetUE_AfterUpload");
const static TCHAR* pszUPLOAD_TIMEDELAY_RESET = _T("Reset_DelayTime");
const static TCHAR* pszUPLOADAREA_LIST = _T("Upload_Areas_List");
const static TCHAR* pszUPLOADAREA_TYPE = _T("Area_Type");
const static TCHAR* pszUPLOADAREA_SUBTYPE = _T("Area_SubType");
const static TCHAR* pszUPLOADAREA_OFFSET = _T("Area_Offset");
const static TCHAR* pszUPLOADAREA_DATATSIZE = _T("Area_DataSize");
const static TCHAR* pszUPLOADAREA_PARTITION = _T("Area_Partition");
const static TCHAR* pszUPLOADAREA_SPAREAREA = _T("Area_UploadWithSpareArea");
const static TCHAR* pszUPLOADAREA_SAVEFILE = _T("Area_UploadData_SaveFile");
const static TCHAR* pszBLFVERSION = _T("Blf_Version");
const static TCHAR* pszFlashFamily = _T("Flash_Family");
const static TCHAR* pszPlatFormType = _T("PlatForm_Type");
const static TCHAR* pszEMMCIMAGEPROPERTY = _T("EMMC_Images_list_Property");
const static TCHAR* pszEMMCIMGIDNUM = _T("ImageID_num");
const static TCHAR* pszEMMCTYPECFG = _T("EmmcType");
//mutliple Nand size
const static TCHAR* pszNAND_SIGNATURE_NUMBER = _T("Nand_Signature_Number");
const static TCHAR* pszNAND_IMAGE_PROPERTY = _T("Nand_Images_list_Property");
const static TCHAR* pszNANDSIGN = _T("NandSign");
const static TCHAR* pszNANDSIGN_VALUE = _T("NandSign_Value");
const static TCHAR* pszNANDSIGN_NANDIDNUMBER = _T("NandSign_NandIdNumber");
const static TCHAR* pszNANDID = _T("NandId");
const static TCHAR* pszNANDSIZE = _T("NandSize");
const static TCHAR* pszIMAGENUMBER = _T("ImageNumber");
//#define pszNAND_SIGNATURE_NUMBER _T("NAND_Signature_Number")
//#define pszNAND_IMAGE_PROPERTY _T("NAND_Images_list_Property")
//#define pszNANDSIGN _T("NandSign")
//#define pszNANDSIGN_VALUE _T("NandSign_Value")
//#define pszNANDSIGN_NANDIDNUMBER _T("NandSign_NandIdNumber")
//#define pszNANDID _T("NandId")
//#define pszNANDSIZE _T("NandSize")
//#define pszIMAGENUMBER _T("ImageNumber")
#define MAX_DDR_VENDOR_NUM 34
#define MAX_DDR_SIZE_NUM 20
struct stDdrVendorIdNameMap{
unsigned int nDdrVendorID;
TCHAR strDdrVendorName[128];
};
static const struct stDdrVendorIdNameMap vendorDdrPidNameMap[MAX_DDR_VENDOR_NUM]={
{0x01,_T("SAMSUNG")},
{0x02,_T("QIMONDA")},
{0x03,_T("ELPIDA")},
{0x04,_T("ETRON")},
{0x05,_T("NANYA")},
{0x06,_T("HYNIX")},
{0x07,_T("MOSEL")},
{0x08,_T("WINBOND")},
{0x09,_T("ESMT")},
{0x0A,_T("RESERVED")},
{0x0B,_T("SPANSION")},
{0x0C,_T("SST")},
{0x0D,_T("ZMOS")},
{0x0E,_T("INTEL")},
{0x0F,_T("NUMONYX")},
{0x10,_T("MICRON")},
{0x11,_T("TOSHIBA")},
{0x12,_T("FIDELIX")},
{0x13,_T("ReservedVendor1")},
{0x14,_T("ReservedVendor2")},
{0x15,_T("ReservedVendor3")},
{0x16,_T("ReservedVendor4")},
{0x17,_T("ReservedVendor5")},
{0x18,_T("ReservedVendor6")},
{0x19,_T("ReservedVendor7")},
{0x1A,_T("ReservedVendor8")},
{0x1B,_T("ReservedVendor9")},
{0x1C,_T("JSC")},
{0x1D,_T("ReservedVendor11")},
{0x1E,_T("ReservedVendor12")},
{0xF8,_T("Fidelix")},
{0xFD,_T("ESMT2")},
{0xFE,_T("Numonyx")},
{0xFF,_T("Micron")},
};
#define RESERVED_DDR_FOR_SMALLMEMORY 0x300000 /* Reserved 3MB DDR Size for OBM on platform Nezha and Nezha2 */
#define RESERVED_DDR_FOR_LARGEMEMORY 0x1E00000 /* Reserved 30MB DDR Size for OBM */
#define UNIT_GB 0x40000000
-353
View File
@@ -1,353 +0,0 @@
#include "CommonFun.h"
#include "BinFileWtp.h"
#include <endian.h>
#define BINFILE _T("BinFile.bin")
BOOL BinFileWtp_OpenBinFile(struct CBinFileWtp *me, const TCHAR *strOpenMode)
{
if (me->m_fBinFile)
BinFileWtp_CloseBinFIle(me);
me->m_fBinFile = _tfopen((const TCHAR *)me->m_strBinFilePath, strOpenMode);
if (NULL == me->m_fBinFile)
{
printf("Open BinFile.bin Failed!\n");
return FALSE;
}
else
{
printf("Open BinFile.bin Successed!\n");
return TRUE;
}
}
UINT32 BinFileWtp_ReadBinFile(struct CBinFileWtp *me, void *buffer, size_t size, size_t count, const TCHAR *pszBinFile)
{
UINT32 ret = 0;
UINT32 uRemain = 0;
UINT32 uRPos = 0;
khiter_t kfs, kfp;
kfs = kh_get(str2fs, me->m_mapFile2Struct, pszBinFile);
if (kfs == kh_end(me->m_mapFile2Struct))
return ret;
uRemain = size * count;
kfp = kh_get(str2n, me->m_mapFile2PointPos, pszBinFile);
uRPos = kh_value(me->m_mapFile2PointPos, kfp);
if (0 == kh_value(me->m_mapFile2Struct, kfs).Head2 && 0 == kh_value(me->m_mapFile2Struct, kfs).Mid1 && 0 == kh_value(me->m_mapFile2Struct, kfs).Mid2 && 0 == kh_value(me->m_mapFile2Struct, kfs).Tail1)
{
fseek(me->m_fBinFile, uRPos, SEEK_SET);
ret = fread(buffer, size, count, me->m_fBinFile);
kh_value(me->m_mapFile2PointPos, kfp) += size * count;
}
else //分段读取情况
{
fseek(me->m_fBinFile, uRPos, SEEK_SET);
if (uRPos >= kh_value(me->m_mapFile2Struct, kfs).Head1 && uRPos < kh_value(me->m_mapFile2Struct, kfs).Head2)
{
if (uRemain < kh_value(me->m_mapFile2Struct, kfs).Head2 - uRPos)
{
ret += fread(buffer, sizeof(BYTE), uRemain, me->m_fBinFile);
kh_value(me->m_mapFile2PointPos, kfp) += uRemain;
uRemain = 0;
}
else
{
ret += fread(buffer, sizeof(BYTE), kh_value(me->m_mapFile2Struct, kfs).Head2 - uRPos, me->m_fBinFile);
uRemain -= (kh_value(me->m_mapFile2Struct, kfs).Head2 - uRPos);
buffer = (void *)((char *)buffer + kh_value(me->m_mapFile2Struct, kfs).Head2 - uRPos);
uRPos = kh_value(me->m_mapFile2Struct, kfs).Mid1;
kh_value(me->m_mapFile2PointPos, kfp) = uRPos;
fseek(me->m_fBinFile, uRPos, SEEK_SET);
}
}
if (uRPos >= kh_value(me->m_mapFile2Struct, kfs).Mid1 && uRPos < kh_value(me->m_mapFile2Struct, kfs).Mid2)
{
if (uRemain < kh_value(me->m_mapFile2Struct, kfs).Mid2 - uRPos)
{
ret += fread(buffer, sizeof(BYTE), uRemain, me->m_fBinFile);
uRPos += uRemain;
kh_value(me->m_mapFile2PointPos, kfp) = uRPos;
uRemain = 0;
}
else
{
ret += fread(buffer, sizeof(BYTE), kh_value(me->m_mapFile2Struct, kfs).Mid2 - uRPos, me->m_fBinFile);
uRemain -= (kh_value(me->m_mapFile2Struct, kfs).Mid2 - uRPos);
buffer = (void *)((char *)buffer + kh_value(me->m_mapFile2Struct, kfs).Mid2 - uRPos);
uRPos = kh_value(me->m_mapFile2Struct, kfs).Tail1;
kh_value(me->m_mapFile2PointPos, kfp) = uRPos;
fseek(me->m_fBinFile, uRPos, SEEK_SET);
}
}
if (uRPos >= kh_value(me->m_mapFile2Struct, kfs).Tail1 && uRPos < kh_value(me->m_mapFile2Struct, kfs).Tail2)
{
ret += fread(buffer, sizeof(BYTE), uRemain, me->m_fBinFile);
kh_value(me->m_mapFile2PointPos, kfp) += uRemain;
uRemain = 0;
}
}
return ret;
}
int BinFileWtp_FseekBin(struct CBinFileWtp *me, const TCHAR *pszBinFile, long _Offset, int _Origin)
{
int ret;
khint_t kfs, kfp;
kfp = kh_get(str2n, me->m_mapFile2PointPos, pszBinFile);
kfs = kh_get(str2fs, me->m_mapFile2Struct, pszBinFile);
if (kfp == kh_end(me->m_mapFile2PointPos) || kfs == kh_end(me->m_mapFile2Struct))
return -1;
if (SEEK_SET == _Origin)
{
ret = fseek(me->m_fBinFile, kh_value(me->m_mapFile2Struct, kfs).Head1 + _Offset, SEEK_SET);
kh_value(me->m_mapFile2PointPos, kfp) = kh_value(me->m_mapFile2Struct, kfs).Head1 + _Offset;
}
else if (SEEK_END == _Origin)
{
ret = fseek(me->m_fBinFile, kh_value(me->m_mapFile2Struct, kfs).Tail2 + _Offset, SEEK_SET);
kh_value(me->m_mapFile2PointPos, kfp) = kh_value(me->m_mapFile2Struct, kfs).Tail2 + _Offset;
}
else
{
fseek(me->m_fBinFile, kh_value(me->m_mapFile2PointPos, kfp) + _Offset, SEEK_SET);
}
return ret;
}
UINT32 BinFileWtp_GetFileSize(struct CBinFileWtp *me, const TCHAR *pszBinFile)
{
khiter_t kfs;
kfs = kh_get(str2fs, me->m_mapFile2Struct, pszBinFile);
if (kh_end(me->m_mapFile2Struct) == kfs)
return 0;
else
{
return kh_value(me->m_mapFile2Struct, kfs).Head2 - kh_value(me->m_mapFile2Struct, kfs).Head1 + kh_value(me->m_mapFile2Struct, kfs).Mid2 - kh_value(me->m_mapFile2Struct, kfs).Mid1 + kh_value(me->m_mapFile2Struct, kfs).Tail2 - kh_value(me->m_mapFile2Struct, kfs).Tail1;
}
}
void BinFileWtp_CloseBinFIle(struct CBinFileWtp *me)
{
if (NULL != me->m_fBinFile)
{
fclose(me->m_fBinFile);
me->m_fBinFile = NULL;
}
}
void BinFileWtp_FreshBinOffset(struct CBinFileWtp *me)
{
fseek(me->m_fBinFile, 0, SEEK_END);
me->m_uFileOffset = ftell(me->m_fBinFile);
}
void BinFileWtp_ResetPara(struct CBinFileWtp *me)
{
me->m_bHaveInitForFbfDown = FALSE;
me->m_uFileOffset = 0;
me->m_fBinFile = NULL;
if (me->m_mapFile2PointPos)
kh_destroy(str2n, me->m_mapFile2PointPos);
if (me->m_mapFile2Struct)
kh_destroy(str2fs, me->m_mapFile2Struct);
me->m_mapFile2PointPos = kh_init(str2n);
me->m_mapFile2Struct = kh_init(str2fs);
}
void BinFileWtp_InitRead(struct CBinFileWtp *me)
{
khiter_t kfs, kfp;
int ret;
for (kfs = kh_begin(me->m_mapFile2Struct); kfs != kh_end(me->m_mapFile2Struct); ++kfs)
if (kh_exist(me->m_mapFile2Struct, kfs))
{
kfp = kh_put(str2n, me->m_mapFile2PointPos, kh_key(me->m_mapFile2Struct, kfs), &ret);
kh_value(me->m_mapFile2PointPos, kfp) = kh_value(me->m_mapFile2Struct, kfs).Head1;
}
}
void BinFileWtp_InitParameter(struct CBinFileWtp *me)
{
TCHAR buffer[1024];
khiter_t kfp, kfs;
char *pstr;
int ret;
if (me->m_bHaveInitForFbfDown)
return;
BinFileWtp_ResetPara(me);
#if !defined(LINUX)
memset(me->m_strBinFilePath, 0x00, sizeof(me->m_strBinFilePath));
tsnprintf(me->m_strBinFilePath, sizeof(me->m_strBinFilePath), _T("%s\\temp\\%s"), (pstr = GetAppPath().s), BINFILE);
free(pstr);
#else
memset(me->m_strBinFilePath, 0x00, sizeof(me->m_strBinFilePath));
tsnprintf(me->m_strBinFilePath, sizeof(me->m_strBinFilePath), _T("%s/temp/%s"), (pstr = GetAppPath().s), BINFILE);
free(pstr);
#endif
UINT32 uValue;
BinFileWtp_OpenBinFile(me, _T("rb"));
fseek(me->m_fBinFile, -1L * sizeof(UINT32), SEEK_END);
//读FBF文件最后的偏移,之后的为map信息
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
printf("Read from File Value is %x\n", uValue);
uValue = le32toh(uValue);
printf("After Convert Value is %x\n", uValue);
fseek(me->m_fBinFile, uValue, SEEK_SET);
//读map size
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
unsigned int i = uValue;
while (i)
{
i--;
memset(buffer, 0, sizeof(buffer));
//读路径文件长度
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
//读路径文件
uValue = le32toh(uValue);
fread(buffer, 1, uValue, me->m_fBinFile);
kfs = kh_put(str2fs, me->m_mapFile2Struct, buffer, &ret);
kfp = kh_put(str2n, me->m_mapFile2PointPos, buffer, &ret);
//读Head1
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Head1 = uValue;
kh_value(me->m_mapFile2PointPos, kfp) = uValue;
//读Head2
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Head2 = uValue;
//读Mid1
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Mid1 = uValue;
//读Mid2
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Mid2 = uValue;
//读Tail1
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Tail1 = uValue;
//读Tail2
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Tail2 = uValue;
}
}
BOOL BinFileWtp_InitParameter2(struct CBinFileWtp *me, const TCHAR *pBinFilePath, struct StringList *pFbfList)
{
TCHAR buffer[1024];
int ret, nPosBuf;
khiter_t kfp, kfs;
if (me->m_bHaveInitForFbfDown)
return TRUE;
BinFileWtp_ResetPara(me);
me->m_bHaveInitForFbfDown = TRUE;
#if !defined(LINUX)
memset(me->m_strBinFilePath, 0x00, sizeof(me->m_strBinFilePath));
tsnprintf(me->m_strBinFilePath, sizeof(me->m_strBinFilePath), _T("%s"), pBinFilePath);
#else
memset(me->m_strBinFilePath, 0x00, sizeof(me->m_strBinFilePath));
tsnprintf(me->m_strBinFilePath, sizeof(me->m_strBinFilePath), _T("%s"), pBinFilePath);
#endif
UINT32 uValue = 0;
if (FALSE == BinFileWtp_OpenBinFile(me, _T("rb")))
{
return FALSE;
}
fseek(me->m_fBinFile, -1L * sizeof(UINT32), SEEK_END);
//读FBF文件最后的偏移,之后的为map信息
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
printf("Read from File Value is %x\n", uValue);
uValue = le32toh(uValue);
printf("Convert Value is %x\n", uValue);
fseek(me->m_fBinFile, uValue, SEEK_SET);
printf("Offset of Map is %u\n", uValue);
//读map size
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
printf("Size of Map is %u\n", uValue);
unsigned int i = uValue;
while (i)
{
i--;
memset(buffer, 0, sizeof(buffer));
//读路径文件长度
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
//读路径文件
fread(buffer, 1, uValue, me->m_fBinFile);
#ifndef UNICODE
nPosBuf = 0;
for (int j = 0; j < uValue; j++)
{
if (buffer[j] != 0)
{
buffer[nPosBuf] = buffer[j];
++nPosBuf;
}
buffer[nPosBuf] = 0;
}
#endif
const char *buf2 = strdup(buffer);
printf("Find image name:%s\n", buf2);
kfp = kh_put(str2n, me->m_mapFile2PointPos, buf2, &ret);
kfs = kh_put(str2fs, me->m_mapFile2Struct, buf2, &ret);
//读Head1
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Head1 = uValue;
kh_value(me->m_mapFile2PointPos, kfp) = uValue;
//读Head2
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Head2 = uValue;
//读Mid1
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Mid1 = uValue;
//读Mid2
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Mid2 = uValue;
//读Tail1
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Tail1 = uValue;
//读Tail2
fread(&uValue, sizeof(UINT32), 1, me->m_fBinFile);
uValue = le32toh(uValue);
kh_value(me->m_mapFile2Struct, kfs).Tail2 = uValue;
pFbfList->strL[pFbfList->nSize++] = buf2;
}
return TRUE;
}
BOOL BinFileWtp_IsFileExist(struct CBinFileWtp *me, const TCHAR *pFileName)
{
khiter_t k;
k = kh_get(str2fs, me->m_mapFile2Struct, pFileName);
if (k == kh_end(me->m_mapFile2Struct))
return FALSE;
else
return TRUE;
}
void BinFileWtp_DelMe(struct CBinFileWtp *me)
{
khiter_t k;
for (k = kh_begin(me->m_mapFile2PointPos); k != kh_end(me->m_mapFile2PointPos); ++k)
if (kh_exist(me->m_mapFile2PointPos, k))
{
free((void *)kh_key(me->m_mapFile2PointPos, k));
}
}
-51
View File
@@ -1,51 +0,0 @@
#pragma once
#include "Macrodef.h"
#include "ApplicationINI.h"
#include "ParaDefine.h"
#include <fcntl.h>
#include <sys/types.h>
#include "khash.h"
#include "klist.h"
typedef struct _FileStruct
{
UINT32 Head1, Head2;
UINT32 Mid1, Mid2;
UINT32 Tail1, Tail2;
} FileStruct;
KHASH_MAP_INIT_STR(str2n,UINT32)
KHASH_MAP_INIT_STR(str2fs,FileStruct)
#define BINFILE _T("BinFile.bin")
typedef khash_t(str2n) *t_FilePathWriteOffsetMap;
typedef khash_t(str2fs)* t_FileNameFileStructMap;
BOOL BinFileWtp_OpenBinFile(struct CBinFileWtp *me,const TCHAR* strOpenMode);
UINT32 BinFileWtp_ReadBinFile(struct CBinFileWtp *me,void *buffer, size_t size, size_t count, const TCHAR* pszBinFile);
int BinFileWtp_FseekBin(struct CBinFileWtp *me,const TCHAR* pszBinFile,long _Offset,int _Origin);
BOOL BinFileWtp_IsFileExist(struct CBinFileWtp *me,const TCHAR *pFileName);
UINT32 BinFileWtp_GetFileSize(struct CBinFileWtp *me,const TCHAR* pszBinFile);
BOOL BinFileWtp_InitParameter2(struct CBinFileWtp *me,const TCHAR *pBinFilePath, struct StringList*);
void BinFileWtp_InitParameter(struct CBinFileWtp *me);
void BinFileWtp_CloseBinFIle(struct CBinFileWtp *me);
void BinFileWtp_FreshBinOffset(struct CBinFileWtp *me);
void BinFileWtp_ResetPara(struct CBinFileWtp *me);
void BinFileWtp_InitRead(struct CBinFileWtp *me);
void BinFileWtp_DelMe(struct CBinFileWtp *me);
struct CBinFileWtp
{
FILE* m_fBinFile;
t_FileNameFileStructMap m_mapFile2Struct;
t_FilePathWriteOffsetMap m_mapFile2PointPos;//文件指针位置 相对起始
UINT32 m_uFileOffset;//Bin文件总偏移
TCHAR m_strBinFilePath[MAX_FILE_LENGTH];
BOOL m_bHaveInitForFbfDown;
};
extern struct CBinFileWtp gBinFileWtp;
-710
View File
@@ -1,710 +0,0 @@
#include "BulkDevNonDrv_Linux.h"
#define MAX_RETRIES 5
int BulkDevNonDrv_check(void *_desc, int nLen, unsigned int type, int size)
{
unsigned char *desc = (unsigned char *)_desc;
if(nLen < size) return 0;
if(desc[0] < size) return 0;
if(desc[0] > nLen) return 0;
if(desc[1] != type) return 0;
return 1;
}
int BulkDevNonDrv_badname(const char *name)
{
while(*name)
{
if(!isdigit(*name++))
return 1;
}
return 0;
}
int BulkDevNonDrv_OpenDev(USB_HANDLE *usb)
{
char DevDesc[1024];
int bRet = 0;
int hDevHandle = 0;
int nLen = 0;
int PipeIn = -1;
int PipeOut = -1;
int ifc_id = -1;
#ifdef __ANDROID__
chmod(usb->DevName,0777);
#endif
#if 0
char szBuffer[MAX_FILE_LENGTH];
memset(szBuffer,0,sizeof(Tchar)*MAX_FILE_LENGTH);
snprintf(szBuffer,sizeof(szBuffer),("su -c \"chmod -R 777 /dev/bus/usb/\""));
int r = system(szBuffer);
if(r!=0) {
printf("Could not grant permissions to USB\n");
}
#endif
if((hDevHandle = open(usb->DevName, O_RDWR)) >= 0)
{
#if PRINTLOG
printf("Open dev OK\n");
#endif
system("echo ---open usb OK--- > /dev/kmsg");
nLen = read(hDevHandle, DevDesc, sizeof(DevDesc));
if( BulkDevNonDrv_GetPipeOfDev(DevDesc, nLen, &PipeIn, &PipeOut, &ifc_id) )
{
//printf("GetPipeOfWTPTP OK!\n");
nLen = ioctl(hDevHandle, USBDEVFS_CLAIMINTERFACE, &ifc_id);
if(nLen == 0)
{
#if PRINTLOG
printf("Check ifc_id OK!\n");
#endif
system("echo ---claim usb OK--- > /dev/kmsg");
bRet = 1;
usb->nPipeIn = PipeIn;
usb->nPipeOut = PipeOut;
usb->hDevHandle = hDevHandle;
#if PRINTLOG
printf("DevName is %s, PipeIn is %d, PipeOut is %d, hDevHandle is 0x%X\n", usb->DevName, usb->nPipeIn, usb->nPipeOut, usb->hDevHandle);
#endif
}
else
{
system("echo ---claim usb FAIL--- > /dev/kmsg");
#if PRINTLOG
printf("Check ifc_id fail! nLen: %d, errno(%d): %s\n", nLen, errno, strerror(errno));
#endif
close(hDevHandle);
}
}
#if PRINTLOG
else
printf("GetPipeOfWTPTP fail!\n");
#endif
}
else
{
system("echo ---open usb FAIL--- > /dev/kmsg");
#if PRINTLOG
printf("Open dev fail, hDevHandle=0x%X\n", hDevHandle);
#endif
}
return bRet;
}
int BulkDevNonDrv_CloseDev(USB_HANDLE *usb)
{
int hDevHandle;
hDevHandle = usb->hDevHandle;
if(hDevHandle >= 0)
{
close(hDevHandle);
#if PRINTLOG
printf("WTPTP dev: %s was closed!\n", usb->DevName);
#endif
memset(usb->DevName, 0, 256);
usb->hDevHandle = -1;
usb->nPipeIn = -1;
usb->nPipeOut = -1;
return 1;
}
return 0;
}
int BulkDevNonDrv_WaitDev()
{
struct sockaddr_nl client;
struct timeval tv;
int CppLive, rcvlen, ret;
fd_set fds;
int buffersize = 2048;
CppLive = socket(AF_NETLINK, SOCK_RAW, NETLINK_KOBJECT_UEVENT);
memset(&client, 0, sizeof(client));
client.nl_family = AF_NETLINK;
client.nl_pid = getpid();
client.nl_groups = 1;
setsockopt(CppLive, SOL_SOCKET, SO_RCVBUF, &buffersize, sizeof(buffersize));
bind(CppLive, (struct sockaddr*)&client, sizeof(client));
//while(1)
{
char buff[2048] = {0};
FD_ZERO(&fds);
FD_SET(CppLive, &fds);
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
ret = select(CppLive+1, &fds, NULL, NULL, &tv);
//if(ret<0)
// continue;
//if(!(ret>0 && FD_ISSET(CppLive, &fds)))
// continue;
rcvlen = recv(CppLive, &buff, sizeof(buff), 0);
if(rcvlen>0)
{
for(int nIndex=0; nIndex<rcvlen; nIndex++)
{
if( '\0' == *(buff+nIndex) )
buff[nIndex] = '\n';
}
#if PRINTLOG
printf("%s\n", buff);
#endif
//break;
}
}
close(CppLive);
return 0;
}
int BulkDevNonDrv_FindAllSupportedDevices(PUSB_HANDLE hUSBArray[])
{
char *base = "/dev/bus/usb";
/*For AsiaTelco MIPS design, use proc dir*/
//char *base = "/proc/bus/usb";
char busname[64], devname[64];
//char tmpBuffer[1024];
char *DevDesc = (char *)malloc(1024);
char *OrigiPtr = DevDesc;
DIR *busdir, *devdir;
struct dirent *de;
struct usb_device_descriptor *dev;
struct usb_config_descriptor *cfg;
struct usb_interface_descriptor *ifc;
USB_IFC_INFO info;
int bRet = 0;
int hDevHandle = 0;
int nDevNameLen = 0;
int bAdd = 0;
int nIndex = 0;
memset(busname, 0, sizeof(busname));
memset(devname, 0, sizeof(devname));
memset(DevDesc, 0, sizeof(DevDesc));
busdir = opendir(base);
if(0 == busdir)
return 0;
while( de = readdir(busdir) )
{
if(BulkDevNonDrv_badname(de->d_name))
continue;
sprintf(busname, "%s/%s", base, de->d_name);
devdir = opendir(busname);
if( 0 == devdir )
continue;
while( de = readdir(devdir) )
{
if(BulkDevNonDrv_badname(de->d_name))
{
continue;
}
int nBuffLen = sprintf(devname, "%s/%s", busname, de->d_name);
if( ( hDevHandle = open(devname, O_RDWR) ) >= 0 )
{
//printf("Opened %s\n", devname);
DevDesc = OrigiPtr;
nBuffLen = read(hDevHandle, DevDesc, 1024);
if( !BulkDevNonDrv_check( DevDesc, nBuffLen, USB_DT_DEVICE, USB_DT_DEVICE_SIZE ) )
continue;
dev = (struct usb_device_descriptor *)DevDesc;
nBuffLen -= dev->bLength;
DevDesc += dev->bLength;
if( BulkDevNonDrv_ChecHWIds2(dev->idVendor, dev->idProduct) )
{
if( !BulkDevNonDrv_check( DevDesc, nBuffLen, USB_DT_CONFIG, USB_DT_CONFIG_SIZE ) )
continue;
info.serial_number[0] = 0;
if(dev->iSerialNumber)
{
struct usbdevfs_ctrltransfer ctrl;
__u16 buffer[128];
__u16 preCheck[128];
int nPreCheckCount = 0;
int result;
memset(buffer, 0, sizeof(buffer));
memset(preCheck, 0, sizeof(preCheck));
memset(&ctrl, 0, sizeof(ctrl));
ctrl.bRequestType = USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
ctrl.wValue = (USB_DT_STRING << 8) | 0; //dev->iSerialNumber;
ctrl.wIndex = 0;//__le16_to_cpu(0x409);
ctrl.wLength = sizeof(preCheck);
ctrl.data = preCheck;
result = ioctl(hDevHandle, USBDEVFS_CONTROL, &ctrl);
if(result>0)
{
int nLoop;
nPreCheckCount = (result - 2) / 2;
for( nLoop = 1; nLoop <= nPreCheckCount; nLoop++ )
{
memset(buffer, 0, sizeof(buffer));
memset(&ctrl, 0, sizeof(ctrl));
ctrl.bRequestType = USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
ctrl.wValue = (USB_DT_STRING << 8) | dev->iSerialNumber;
ctrl.wIndex = __le16_to_cpu(preCheck[nLoop]);
ctrl.wLength = sizeof(buffer);
ctrl.data = buffer;
result = ioctl(hDevHandle, USBDEVFS_CONTROL, &ctrl);
if(result>0)
{
int i = 0;
result /= 2;
for(i=1; i<result; i++)
{
info.serial_number[i-1] = buffer[i];
}
info.serial_number[i-1] = 0;
//printf("iSerialNumber: %s\n", info.serial_number);
}
else
{
#if PRINTLOG
printf("Get iSerialNumber ioctl errno %d: %s\n", errno, strerror(errno));
#endif
}
}
}
else
{
#if PRINTLOG
printf("Pre-check ioctl errno %d: %s\n", errno, strerror(errno));
#endif
}
}
cfg = (struct usb_config_descriptor *)DevDesc;
nBuffLen -= cfg->bLength;
DevDesc += cfg->bLength;
for(int loop=0; loop<cfg->bNumInterfaces; )
{
if( !BulkDevNonDrv_check( DevDesc, nBuffLen, USB_DT_INTERFACE, USB_DT_INTERFACE_SIZE ) )
{
nBuffLen -= DevDesc[0];
DevDesc += DevDesc[0];
continue;
}
ifc = (struct usb_interface_descriptor *)DevDesc;
nBuffLen -= ifc->bLength;
DevDesc += ifc->bLength;
if( BulkDevNonDrv_ChecHWIds(dev->idVendor, dev->idProduct, ifc->bInterfaceNumber) )
{
USB_HANDLE usb;
strcpy(usb.DevName, devname);
if( 0 == strlen(info.serial_number) )
{
strcpy(usb.iSerialNumber, "None");
}
else
{
strcpy(usb.iSerialNumber, info.serial_number);
}
hUSBArray[nIndex] = (PUSB_HANDLE)malloc(sizeof(USB_HANDLE));
NEW_USB_HANDLE(hUSBArray[nIndex]);
COPY_USB_HANDLE(hUSBArray[nIndex],&usb);
nIndex++;
bRet = nIndex;
//printf("Got one supported dev: VID: 0x%X, PID: 0x%X, MI:0x%X\n", dev->idVendor, dev->idProduct, ifc->bInterfaceNumber);
}
loop++;
}
}
close(hDevHandle);
}
//if(IsSupported(devname, nBuffLen, DevName, nDevNameLen, bAdd))
// printf("%s\n", devname);
}
closedir(devdir);
}
closedir(busdir);
free(OrigiPtr);
DevDesc = NULL;
OrigiPtr = NULL;
return bRet;
}
int BulkDevNonDrv_CheckDevForNetLink(USB_HANDLE *usb, const char *NetLinkBuff, int nBuffLen, int *bAdd)
{
char DevName[256] = {0};
int nDevNameLen = 0;
int bRet = 0;
bRet = BulkDevNonDrv_IsSupported(NetLinkBuff, nBuffLen, DevName, &nDevNameLen, bAdd);
if(bRet)
{
strcpy(usb->DevName, DevName);
}
return bRet;
}
int BulkDevNonDrv_IsSupported(const char *NetLinkBuff, int nBuffLen, char *Dev_Name, int *nDevNameLen, int *bAdd)
{
int nIndex = 0;
char* position = NULL;
long lVID = 0, lPID = 0;
int bFound = 0;
int bRet = 0;
char tmpNetLinkBuff[4096];
char* sUSBDescription;
/*AsiaTelco MIPS use proc instead of dev, really strange*/
//string sDevName = "/proc/";
char sDevName[512] = "/dev/";
char sVID[64] = "0x";
char sPID[64] = "0x";
// Prepare the device information buffer
memcpy(tmpNetLinkBuff, NetLinkBuff, nBuffLen);
for(; nIndex<nBuffLen; nIndex++)
{
if( '\0' == *(tmpNetLinkBuff+nIndex) )
tmpNetLinkBuff[nIndex] = '\n';
}
sUSBDescription = tmpNetLinkBuff;
//printf("tmpNetLinkBuff is: %s\n", tmpNetLinkBuff);
// Check is a wtptp device
position = strstr(sUSBDescription,"PRODUCT=");
if(position!=NULL)
{
char *EndPtr;
char* tmpPos = position+8;
for(; tmpPos[0] != '/'; tmpPos++)
{
strncat(sVID, tmpPos, 1);
//sVID += sUSBDescription[tmpPos];
}
for(tmpPos++; tmpPos[0] != '/'; tmpPos++)
{
strncat(sPID, tmpPos, 1);
//sPID += sUSBDescription[tmpPos];
}
lVID = strtol(sVID, &EndPtr, 16);
lPID = strtol(sPID, &EndPtr, 16);
//printf("hardwareId is: %s_%s\n", sVID.c_str(), sPID.c_str());
//printf("hardwareId is: %X_%X\n", lVID, lPID);
strcpy(Dev_Name, sDevName);
*nDevNameLen = strlen(sDevName);
}
if( BulkDevNonDrv_ChecHWIds2(lVID, lPID) )
{
// Get Dev Name
position = strstr(sUSBDescription,"DEVNAME=");
//printf("\nDevName is:-----------\n %s\n---------------\n", sUSBDescription.c_str());
if(position!=NULL)
{
char* tmpPos = position+8;
for(; tmpPos[0] != '\n'; tmpPos++)
{
strncat(sDevName, tmpPos, 1);
//sDevName += sUSBDescription[tmpPos];
}
//printf("sDevName is: %s\n", sDevName.c_str());
strcpy(Dev_Name, sDevName);
*nDevNameLen = strlen(sDevName);
//nDevNameLen = sDevName.copy(Dev_Name, sDevName.length());
*bAdd = strstr(sUSBDescription,"add@")!=NULL ? 1 : 0;
*bAdd = strstr(sUSBDescription,"bind@")!=NULL ? 2 : *bAdd;
bRet = 1;
//printf("It is a support device, return the Dev_Name: %s and bAdd: %d\n", Dev_Name, bAdd);
}
//printf("\nbAdd: %d\n",bAdd);
}
//else
//printf("This is not a support device.\n");
return bRet;
}
int BulkDevNonDrv_ChecHWIds(long idVendor, long idProduct, long MI)
{
int nIndex = 0;
int bFound = 0;
for(nIndex=0; 0x0!=HWIds_CurrentTable[nIndex][0]; nIndex++)
{
if( idVendor == HWIds_CurrentTable[nIndex][0] \
&& idProduct == HWIds_CurrentTable[nIndex][1] \
&& ( -1 == MI || -1 == HWIds_CurrentTable[nIndex][2] || MI == HWIds_CurrentTable[nIndex][2] ) )
{
bFound = 1;
break;
}
}
return bFound;
}
int BulkDevNonDrv_GetPipeOfDev(/*int fd, */char *ptr, int len, int *ept_in_id, int *ept_out_id, int *ifc_id)
{
struct usb_device_descriptor *dev;
struct usb_config_descriptor *cfg;
struct usb_interface_descriptor *ifc;
struct usb_endpoint_descriptor *ept;
//USB_IFC_INFO info;
int in, out;
unsigned i;
unsigned e;
if(!BulkDevNonDrv_check(ptr, len, USB_DT_DEVICE, USB_DT_DEVICE_SIZE))
return 0;
dev = (struct usb_device_descriptor *) ptr;
len -= dev->bLength;
ptr += dev->bLength;
if(!BulkDevNonDrv_check(ptr, len, USB_DT_CONFIG, USB_DT_CONFIG_SIZE))
return 0;
cfg = (struct usb_config_descriptor *) ptr;
len -= cfg->bLength;
ptr += cfg->bLength;
//info.dev_vendor = dev->idVendor;
//info.dev_product = dev->idProduct;
//info.dev_class = dev->bDeviceClass;
//info.dev_subclass = dev->bDeviceSubClass;
//info.dev_protocol = dev->bDeviceProtocol;
//info.writable = writable;
// read device serial number (if there is one)
/*info.serial_number[0] = 0;
if (dev->iSerialNumber)
{
struct usbdevfs_ctrltransfer ctrl;
__u16 buffer[128];
int result;
memset(buffer, 0, sizeof(buffer));
ctrl.bRequestType = USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE;
ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
ctrl.wValue = (USB_DT_STRING << 8) | dev->iSerialNumber;
ctrl.wIndex = 0;
ctrl.wLength = sizeof(buffer);
ctrl.data = buffer;
result = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
if (result > 0)
{
int i;
// skip first word, and copy the rest to the serial string, changing shorts to bytes.
result /= 2;
for (i = 1; i < result; i++)
info.serial_number[i - 1] = buffer[i];
info.serial_number[i - 1] = 0;
}
else
{
printf("errno(%d): %s\n", errno, strerror(errno));
}
}*/
for(i = 0; i < cfg->bNumInterfaces;)
{
if( !BulkDevNonDrv_check( ptr, len, USB_DT_INTERFACE, USB_DT_INTERFACE_SIZE ) )
{
len -= *ptr;
ptr += *ptr;
continue;
}
i++;
ifc = (struct usb_interface_descriptor *) ptr;
len -= ifc->bLength;
ptr += ifc->bLength;
if( !BulkDevNonDrv_ChecHWIds(dev->idVendor, dev->idProduct, ifc->bInterfaceNumber) )
continue;
in = -1;
out = -1;
//info.ifc_class = ifc->bInterfaceClass;
//info.ifc_subclass = ifc->bInterfaceSubClass;
//info.ifc_protocol = ifc->bInterfaceProtocol;
for(e = 0; e < ifc->bNumEndpoints; e++)
{
if(!BulkDevNonDrv_check(ptr, len, USB_DT_ENDPOINT, USB_DT_ENDPOINT_SIZE))
return 0;
ept = (struct usb_endpoint_descriptor *) ptr;
len -= ept->bLength;
ptr += ept->bLength;
if((ept->bmAttributes & 0x03) != 0x02)
continue;
if(ept->bEndpointAddress & 0x80)
{
in = ept->bEndpointAddress;
}
else
{
out = ept->bEndpointAddress;
}
}
//info.has_bulk_in = (in != -1);
//info.has_bulk_out = (out != -1);
*ept_in_id = in;
*ept_out_id = out;
*ifc_id = ifc->bInterfaceNumber;
//printf("ept_in_id: %d, ept_out_id: %d, ifc_id: %d\n", *ept_in_id, *ept_out_id, *ifc_id);
return 1;
}
return 0;
}
int BulkDevNonDrv_Write(USB_HANDLE *h, const void *_data, int len)
{
unsigned char *data = (unsigned char*) _data;
unsigned count = 0;
struct usbdevfs_bulktransfer bulk;
int n;
if(h->nPipeOut == 0)
{
return -1;
}
if(len == 0)
{
bulk.ep = h->nPipeOut;
bulk.len = 0;
bulk.data = data;
bulk.timeout = 0;
n = ioctl(h->hDevHandle, USBDEVFS_BULK, &bulk);
if(n != 0)
{
#if DEBUG_MODE
printf("1ERROR: n = %d, errno = %d (%s)\n",
n, errno, strerror(errno));
#endif
return -1;
}
return n;
}
while(len > 0)
{
int xfer;
xfer = len;
bulk.ep = h->nPipeOut;
bulk.len = xfer;
bulk.data = data;
bulk.timeout = 5000;
n = ioctl(h->hDevHandle, USBDEVFS_BULK, &bulk);
if(n != xfer)
{
#if DEBUG_MODE
printf("2ERROR: n = %d, errno = %d (%s)\n",
n, errno, strerror(errno));
#endif
return -1;
}
count += xfer;
len -= xfer;
data += xfer;
}
return count;
}
int BulkDevNonDrv_Read(USB_HANDLE *h, void *_data, int len, int timeout)
{
unsigned char *data = (unsigned char*) _data;
unsigned count = 0;
struct usbdevfs_bulktransfer bulk;
int n, retry;
if(h->nPipeIn == 0)
{
return -1;
}
while(len > 0)
{
int xfer = len;
//int xfer = (len > 4096) ? 4096 : len;
bulk.ep = h->nPipeIn;
bulk.len = xfer;
bulk.data = data;
bulk.timeout = timeout;
retry = 0;
do
{
n = ioctl(h->hDevHandle, USBDEVFS_BULK, &bulk);
if( n < 0 )
{
if ( ++retry > MAX_RETRIES )
{
#if DEBUG_MODE
printf("ERROR: n = %d, errno = %d (%s)\n",n, errno, strerror(errno));
#endif
return -1;
}
usleep(10000);
}
}
while( n < 0 );
count += n;
len -= n;
data += n;
if(n < xfer)
{
break;
}
}
return count;
}
-156
View File
@@ -1,156 +0,0 @@
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <dirent.h>
#include <fcntl.h>
#include <errno.h>
#include <pthread.h>
#include <ctype.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/usbdevice_fs.h>
#include <linux/usbdevice_fs.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
#include <linux/usb/ch9.h>
#else
#include <linux/usb_ch9.h>
#endif
#include <asm/byteorder.h>
#ifdef __ANDROID__
#include <sys/stat.h>
#endif
#define MAX_DEVNUM 5
#define MAX_FILE_LENGTH 1024
static int HWIds_WTPTPTable[37][3] =
{
{0x8086, 0xE001, -1},
{0x8086, 0xC001, -1},
{0x8086, 0xD001, -1},
{0x1286, 0x8100, -1},
{0x1286, 0x8101, -1},
{0x1286, 0x8102, -1},
{0x1286, 0x8103, -1},
{0x1286, 0x8104, -1},
{0x1286, 0x8105, -1},
{0x1286, 0x8106, -1},
{0x1286, 0x8111, -1},
{0x1286, 0x8112, -1},
{0x1286, 0x8113, -1},
{0x1286, 0x8114, -1},
{0x1286, 0x8115, -1},
{0x1286, 0x8116, -1},
{0x1286, 0x8117, -1},
{0x1286, 0x8118, -1},
{0x1286, 0x8128, -1},
{0x1286, 0x8129, -1},
{0x1286, 0x812a, -1},
{0x1286, 0x8130, -1},
{0x1286, 0x8164, -1},
{0x1286, 0x8170, -1},
{0x1286, 0x8165, -1},
{0x1286, 0x8174, -1},
{0x1286, 0x8175, -1},
{0x1286, 0x8181, -1},
{0x1286, 0x8182, -1},
{0x1286, 0x8189, -1},
{0x1286, 0x8167, -1},
{0x2ECC, 0x3001, -1},
{0x2ECC, 0x3002, -1},
{0x2ECC, 0x3003, -1},
{0x19D2, 0x1491, -1},
{0x305A, 0x1413, -1},
{0x0, 0x0, 0x0}
};
static int HWIds_USBDiagTable[11][3] =
{
{0x1286, 0x4E3C, 0},
{0x1286, 0x4E38, 4},
{0x1286, 0x4E2C, 0},
{0x1286, 0x4E28, 4},
{0x1286, 0x4E30, 0},
{0x1286, 0x4E31, 2},
{0x0BB4, 0x4E49, 0},
{0x0BB4, 0x4E4A, 4},
{0x0BB4, 0x4E4D, 3},
{0x0BB4, 0x4E4E, 0},
{0x0, 0x0, 0x0}
};
static int (*HWIds_CurrentTable)[3] = HWIds_WTPTPTable;
typedef struct _USB_HANDLE
{
char DevName[256];
char iSerialNumber[256];
int hDevHandle;
int nPipeIn;
int nPipeOut;
} USB_HANDLE, *PUSB_HANDLE;
static void NEW_USB_HANDLE(PUSB_HANDLE me)
{
memset(me->DevName, 0, sizeof(me->DevName));
memset(me->iSerialNumber, 0, sizeof(me->iSerialNumber));
me->hDevHandle = -1;
me->nPipeIn = -1;
me->nPipeOut = -1;
}
static void COPY_USB_HANDLE(PUSB_HANDLE me, PUSB_HANDLE pusb)
{
strcpy(me->DevName, pusb->DevName);
strcpy(me->iSerialNumber, pusb->iSerialNumber);
me->hDevHandle = pusb->hDevHandle;
me->nPipeIn = pusb->nPipeIn;
me->nPipeOut = pusb->nPipeOut;
}
typedef struct _USB_IFC_INFO
{
unsigned short dev_vendor;
unsigned short dev_product;
unsigned char dev_class;
unsigned char dev_subclass;
unsigned char dev_protocol;
unsigned char ifc_class;
unsigned char ifc_subclass;
unsigned char ifc_protocol;
unsigned char has_bulk_in;
unsigned char has_bulk_out;
unsigned char writable;
char serial_number[256];
} USB_IFC_INFO, *PUSB_IFC_INFO;
int BulkDevNonDrv_OpenDev(USB_HANDLE *usb);
int BulkDevNonDrv_CloseDev(USB_HANDLE *usb);
int BulkDevNonDrv_Write(USB_HANDLE *h, const void *_data, int nLen);
int BulkDevNonDrv_Read(USB_HANDLE *h, void *_data, int nLen, int timeout);
int BulkDevNonDrv_CheckDevForNetLink(USB_HANDLE *usb, const char *NetLinkBuff, int nBuffLen, int *bAdd);
int BulkDevNonDrv_WaitDev();
int BulkDevNonDrv_FindAllSupportedDevices(PUSB_HANDLE hUSBArray[]);
int BulkDevNonDrv_check(void *_desc, int nLen, unsigned int type, int size);
int BulkDevNonDrv_badname(const char *name);
int BulkDevNonDrv_ChecHWIds(long idVendor, long idProduct, long MI);
int BulkDevNonDrv_IsSupported(const char *NetLinkBuff, int nBuffLen, char *Dev_Name, int *nDevNameLen, int *bAdd);
int BulkDevNonDrv_GetPipeOfDev(/*int fd, */char *ptr, int nLen, int *ept_in_id, int *ept_out_id, int *ifc_id);
#define BulkDevNonDrv_ChecHWIds2(a,b) BulkDevNonDrv_ChecHWIds(a,b,-1)
-190
View File
@@ -1,190 +0,0 @@
#include "kstring.h"
#include "CommonFun.h"
#include <stdarg.h>
#ifdef _WINDOWS
#include <direct.h>
#endif
#define MAX_FILE_LENGTH 1024
#pragma warning ( disable : 4996)
#ifdef MACDOWNLOAD
#include <mach-o/dyld.h>
#endif
kstring_t GetAppPath()
{
kstring_t strRet = { 0, 0, NULL };
TCHAR exeFullPath[MAX_FILE_LENGTH] = {0};
TCHAR exeAbsFullPath[MAX_FILE_LENGTH] = {0};
#ifdef LINUX
#ifdef MACDOWNLOAD
UINT32 size = MAX_FILE_LENGTH;
_NSGetExecutablePath(exeFullPath, &size);
//exeFullPath[size] = '\0';
realpath(exeFullPath,exeAbsFullPath);
TCHAR *p = _tcsrchr(exeAbsFullPath,'/');
if(p) *p = 0;
#if PRINTLOG
tprintf(_T("GetAppPath: %s.....\n\n"),exeAbsFullPath);
#endif
kputs(exeAbsFullPath,&strRet);
return strRet;
#else
readlink ("/proc/self/exe", exeFullPath, MAX_FILE_LENGTH);
TCHAR *p = _tcsrchr(exeFullPath,'/');
if(p) *p = 0;
kputs(exeFullPath,&strRet);
return strRet;
#endif
#else
kstring_t strAppPath = {0,0,NULL};
TCHAR szFullExeName[MAX_FILE_LENGTH];
DWORD nResult = ::GetModuleFileName(NULL, szFullExeName, MAX_FILE_LENGTH);
kstring_t strFullFileName= {0,0,NULL};
kputs(szFullExeName,&strFullFileName);
char* cPos = strrchr(szFullExeName,'\\');
*cPos = 0;
kputs(szFullExeName,&strAppPath);
return strAppPath;
#endif
}
void DelFile(const TCHAR* pszFile)
{
if (ACCESS_FILE_EXIST != taccess(pszFile,ACCESS_FILE_EXIST))
{
return;
}
#ifdef LINUX
chmod(pszFile,0777);
TCHAR szBuffer[MAX_FILE_LENGTH];
memset(szBuffer,0,sizeof(TCHAR)*MAX_FILE_LENGTH);
tsnprintf(szBuffer,sizeof(szBuffer),_T("rm -f %s"),pszFile);
system(szBuffer);
#else
SetFileAttributes(pszFile,FILE_ATTRIBUTE_NORMAL);
DeleteFile(pszFile);
#endif
}
BOOL IsFileExist(const TCHAR *pFileName)
{
if(taccess(pFileName,0)!=0)
{
return FALSE;
}
return TRUE;
}
unsigned int Str2Uint32 (const TCHAR* pValue)
{
unsigned int iRetVal = 0;
if (pValue[0]== _T('0') && (pValue[1]== _T('x') || pValue[1]== _T('X')))
tsscanf( pValue, _T("%x"), &iRetVal );
else
tsscanf( pValue, _T("%i"), &iRetVal );
return iRetVal;
}
UINT64 TranslateEx (kstring_t sValue)
{
int *fields,n;
if(strstr(sValue.s,_T("0xffffffffff"))!=NULL||
strstr(sValue.s,_T("0xFFFFFFFFFF"))!=NULL)
{
UINT64 iRetVal = 0xFFFFFFFFFFll;
return iRetVal;
}
if(strstr(sValue.s,_T("0xffffffff"))!=NULL||
strstr(sValue.s,_T("0xFFFFFFFF"))!=NULL)
{
return 0xFFFFFFFF;
}
UINT64 iRetVal = 0;
// remove leading whitespace
// remove any trailing whitespace
fields = ksplit(&sValue, 0, &n);
kstrcpy(&sValue,sValue.s+fields[0]);
free(fields);
if(strstr(sValue.s,_T("0x"))!=NULL || strstr(sValue.s,_T("0X"))!=NULL)
{
tsscanf( sValue.s, _T("%llx"), &iRetVal );
}
else
{
tsscanf( sValue.s, _T("%lli"), &iRetVal );
}
return iRetVal;
}
void EndianConvertMasterBlockHeader(MasterBlockHeader *mbHeader)
{
int i;
for (i = 0; i < NUM_OF_SUPPORTED_FLASH_DEVS; i++){
mbHeader->Flash_Device_Spare_Area_Size[i] = le16toh(mbHeader->Flash_Device_Spare_Area_Size[i]);
}
mbHeader->Format_Version = le16toh(mbHeader->Format_Version);
mbHeader->Size_of_Block = le16toh(mbHeader->Size_of_Block);
mbHeader->Bytes_To_Program = le32toh(mbHeader->Bytes_To_Program);
mbHeader->Bytes_To_Verify = le32toh(mbHeader->Bytes_To_Verify);
mbHeader->Number_of_Bytes_To_Erase = le32toh(mbHeader->Number_of_Bytes_To_Erase);
mbHeader->Main_Commands = le32toh(mbHeader->Main_Commands);
mbHeader->nOfDevices = le32toh(mbHeader->nOfDevices);
mbHeader->DLerVersion = le32toh(mbHeader->DLerVersion);
for (i = 0; i < MAX_NUMBER_OF_FLASH_DEVICES_IN_MASTER_HEADER; i++){
mbHeader->deviceHeaderOffset[i] = le32toh(mbHeader->deviceHeaderOffset[i]);
}
}
void EndianConvertDeviceHeader_V11(DeviceHeader_V11 *pDeviceHeader)
{
int i;
pDeviceHeader->DeviceFlags = le32toh(pDeviceHeader->DeviceFlags);
for (i = 0; i < 16; i++){
pDeviceHeader->DeviceParameters[i] = le32toh(pDeviceHeader->DeviceParameters[i]);
}
pDeviceHeader->FlashOpt.EraseAll = le32toh(pDeviceHeader->FlashOpt.EraseAll);
pDeviceHeader->FlashOpt.ResetBBT = le32toh(pDeviceHeader->FlashOpt.ResetBBT);
pDeviceHeader->FlashOpt.NandID = le32toh(pDeviceHeader->FlashOpt.NandID);
for (i = 0; i < MAX_RESEVERD_LEN-1; i++){
pDeviceHeader->FlashOpt.Reserved[i] = le32toh(pDeviceHeader->FlashOpt.Reserved[i]);
}
pDeviceHeader->FlashOpt.Skip_Blocks_Struct.Total_Number_Of_SkipBlocks = le32toh(pDeviceHeader->FlashOpt.Skip_Blocks_Struct.Total_Number_Of_SkipBlocks);
for (i = 0; i < MAX_NUM_SKIP_BLOCKS; i++){
pDeviceHeader->FlashOpt.Skip_Blocks_Struct.Skip_Blocks[i] = le32toh(pDeviceHeader->FlashOpt.Skip_Blocks_Struct.Skip_Blocks[i]);
}
pDeviceHeader->ProductionMode = le32toh(pDeviceHeader->ProductionMode);
for (i = 0; i < MAX_RESEVERD_LEN-2; i++){
pDeviceHeader->Reserved[i] = le32toh(pDeviceHeader->Reserved[i]);
}
pDeviceHeader->nOfImages = le32toh(pDeviceHeader->nOfImages);
for (i = 0; i < MAX_NUMBER_OF_IMAGE_STRUCTS_IN_DEVICE_HEADER; i++){
pDeviceHeader->imageStruct[i].Image_ID = le32toh(pDeviceHeader->imageStruct[i].Image_ID);
pDeviceHeader->imageStruct[i].Image_In_TIM = le32toh(pDeviceHeader->imageStruct[i].Image_In_TIM);
pDeviceHeader->imageStruct[i].Flash_partition = le32toh(pDeviceHeader->imageStruct[i].Flash_partition);
pDeviceHeader->imageStruct[i].Flash_erase_size = le32toh(pDeviceHeader->imageStruct[i].Flash_erase_size);
pDeviceHeader->imageStruct[i].commands = le32toh(pDeviceHeader->imageStruct[i].commands);
pDeviceHeader->imageStruct[i].First_Sector = le32toh(pDeviceHeader->imageStruct[i].First_Sector);
pDeviceHeader->imageStruct[i].length = le32toh(pDeviceHeader->imageStruct[i].length);
pDeviceHeader->imageStruct[i].Flash_Start_Address = le32toh(pDeviceHeader->imageStruct[i].Flash_Start_Address);
for (int j = 0; j < MAX_RESEVERD_LEN; j++){
pDeviceHeader->imageStruct[i].Reserved[j] = le32toh(pDeviceHeader->imageStruct[i].Reserved[j]);
}
pDeviceHeader->imageStruct[i].ChecksumFormatVersion2 = le32toh(pDeviceHeader->imageStruct[i].ChecksumFormatVersion2);
}
}
-41
View File
@@ -1,41 +0,0 @@
#pragma once
#include "Typedef.h"
#include <errno.h>
#if !defined(LINUX)
#include "StdAfx.h"
#include <afxmt.h>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "Shlwapi.h"
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#include "downloader.h"
#define _countof(array) (sizeof(array) / sizeof(array[0]))
kstring_t GetAppPath();
void DelFile(const TCHAR* pszFile);
unsigned int Str2Uint32 (const TCHAR* pValue);
UINT64 TranslateEx (kstring_t sValue);
BOOL IsFileExist(const TCHAR *pFileName);
//inline function
inline int CloseFilePtr(FILE** fpFile)
{
int ret = 0;
if (NULL != *fpFile)
{
ret = fclose(*fpFile);
*fpFile = NULL;
}
return ret;
}
void EndianConvertMasterBlockHeader(MasterBlockHeader *mbHeader);
void EndianConvertDeviceHeader_V11(DeviceHeader_V11 *pDeviceHeader);
-60
View File
@@ -1,60 +0,0 @@
#include "ConvetEdian.h"
UINT32 Endian32ConvertLToB(struct CConvertLT2B *me,UINT32 InputNum)
{
if(!me->m_bIsLittleEndian) ////big endian ,please convert
{
UINT32 ConvertNum =((((UINT32)(InputNum) & 0xff000000) >> 24)
+ (((UINT32)(InputNum) & 0x00ff0000) >> 8)
+ (((UINT32)(InputNum) & 0x0000ff00) << 8)
+ (((UINT32)(InputNum) & 0x000000ff) << 24));
return ConvertNum;
}
else
{
return InputNum;
}
}
UINT16 Endian16ConvertLToB(struct CConvertLT2B *me,UINT16 InputNum)
{
if(!me->m_bIsLittleEndian) //big endian ,please convert
{
return ((((UINT16)(InputNum) & 0xff00) >> 8) |(((UINT16)(InputNum) & 0x00ff) << 8));
}
else
{
return InputNum;
}
}
void IsLittleEndian(struct CConvertLT2B *me)
{
int a=1;
char *b;
b = (char *)&a;
if((*b)==1)
{
me->m_bIsLittleEndian = TRUE;
//tprintf (_T("Little Endian\n"));
}
else
{
me->m_bIsLittleEndian = FALSE;
//tprintf (_T("Big Endian\n"));
}
}
void NewCConvertLT2B (struct CConvertLT2B *me)
{
me->m_bIsLittleEndian = TRUE;
IsLittleEndian(me);
}
-16
View File
@@ -1,16 +0,0 @@
#pragma once
#include "Typedef.h"
#include <stdlib.h>
#include <stdio.h>
struct CConvertLT2B
{
BOOL m_bIsLittleEndian;
};
UINT32 Endian32ConvertLToB(struct CConvertLT2B *me,UINT32 InputNum);
UINT16 Endian16ConvertLToB(struct CConvertLT2B *me,UINT16 InputNum);
void IsLittleEndian(struct CConvertLT2B *me);
void NewCConvertLT2B (struct CConvertLT2B *me);
-145
View File
@@ -1,145 +0,0 @@
#pragma once
enum eProcessorType { PXA_NONE = -1,
PXA168 = 0,
PXA30x, PXA31x, PXA32x,
PXA688,
PXA91x, PXA92x, PXA93x, PXA94x, PXA95x,
ARMADA168,
PXA2128,
MG1,
TAVOR_PV_MG2,
ESHEL,
PXA988,
PXA1088,
PXA1202,
PXA1802,
PXA1928,
PXA1920,
PXA1822,
ARMADA620,
ESHEL_LTE,
ARMADA622,
WUKONG,
PXA1826,
PXA1908,
PXA1936,
PXA1956,
PXA1918,
PXAMAX_PT
};
typedef enum
{
BLF_V_3_0_0 = 0,
BLF_V_2_0_0 = 1,
UNKNOWN_VERSION = 0xFF
}eBLFVersion;
typedef enum
{
FLASH = 0,
DDR,
UNKNOWN_TYPE
}EUploadType;
typedef enum _eFlashType
{
FLASH_NAND = 0,
FLASH_EMMC = 1,
FLASH_SPINOR = 2,
FLASH_ONENAND = 3,
FLASH_SPINAND = 4,
FLASH_UNKNOWN = 10
}
eFlashType;
enum eEraseAllMode
{
ERASE_ALL_NOTSET = 0,
ERASE_ALL_BEFOREBURNING = 1,
ERASE_ALL_WIHTOUTBURNING = 2,
UNKNOWN_MODE = 0xFF
};
typedef enum _eUserBootMode
{
UE_NORESET = 0,
UE_RESET = 1,
UNKNOWN_BOOT_MODE = 0xFF
}
eUserBootMode;
typedef enum
{
PLAT_PXA92x_Old=0,
PLAT_PXA92x ,
PLAT_MMP2 ,
PLAT_WUKONG,
PLAT_NEVO,//
PLAT_MMP3,
PLAT_NEZHA,
PLAT_NEVO_OTA,
PLAT_EMEI,
PLAT_HELAN,
PLAT_EDEN, //PLAT_EDEN_Zx
PLAT_HELANLTE,
PLAT_NEZHA2,
PLAT_HELAN2,
PLAT_EDEN_A0,
PLAT_NEZHA3,
PLAT_ULC1,
PLAT_HELAN3,
PLAT_HELAN4,
PLAT_ULC2,
PLAT_UNKNOWN = 0xff
} ePlatForm;
//subtype enum for upload
enum EUploadSubType
{
DEFAULT_FLASH_PROBE = 0,
HSI1,
X16_ONENAND,
XIP_FLASH_X16,
X16_NAND_HAMMING,
X16_XIP_SIBLEY,
NAND_X8_HAMMING,
SDMMC_FLASH_OPT0,
SDMMC_FLASH_OPT1,
SDMMC_FLASH_OPT2,
SPI_FALSH,
SDMMC_FLASH_OPT3,
SDMMC_FLASH_OPT4,
X16_NAND_BCH,
X8_NAND_BCH,
CS1_XIP_FLASH, // XIP (CS1) - for SV only
NAND_FLASH_X16_BCH_OPT1, // x16 NAND BCH (16 bit correction per 1K)
NAND_FLASH_X8_BCH_OPT1, // x8 NAND BCH (16 bit correction per 1K)
NAND_FLASH_X16_NO_ECC,// x16 NAND No ECC (ECC is done by flash device)
NAND_FLASH_X8_NO_ECC, // x8 NAND No ECC (ECC is done by flash device)
SDIO_BUS,
BOOTSPI_FLASH,
SPI_NAND_FLASH = 26,
UNKOWN_SUBTYPE = 0xff
};
enum eProductMode{
DO_NOTHING_FUSE,
ONLY_BURN_FUSE,
ONLY_READ_FUSE,
BURN_READ_FUSE,
DONTBURN_ONLY_BURN_FUSE,
DONTBURN_ONLY_READ_FUSE,
DONTBURN_BURN_READ_FUSE,
};
enum eDDREMMCTypeMode{
NoneType,
DDRType,
EMMCType,
DDRandEMMCType,
};
-369
View File
@@ -1,369 +0,0 @@
/**************************************************************************
**
** (C) Copyright December 2006 Marvell International Ltd.
**
** All Rights Reserved.
**
**
** THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
** IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
** PURPOSE ARE EXPRESSLY DISCLAIMED.
**
** FILENAME: ErrorCodes.h
**
** PURPOSE: Contains DKB error definitions
**
******************************************************************************/
#pragma once
#ifndef ERROR_CODE_H
#define ERROR_CODE_H
#include "Macrodef.h"
#define MAXERRORCODES 1024
#define MAXNOTIFICATIONSCODES 256
typedef enum EDDREMMCMatchResult
{
kMatchNoError,
kDDRMismatchError,
kEMMCMismatchError,
kImagePreparationError,
} eDDREMMCMatchResult;
#ifndef COMPRESSDATA
typedef struct
{
unsigned int ErrorCode;
TCHAR Description[100];
} ERRORCODETABLE;
typedef struct
{
unsigned int NotificationCode;
TCHAR Description[100];
} NOTIFICATIONTABLE;
#else
typedef struct
{
unsigned int ErrorCode;
} ERRORCODETABLE;
typedef struct
{
unsigned int NotificationCode;
} NOTIFICATIONTABLE;
#endif
/* General error code definitions 0x0 - 0x1F
**/
#define PlatformBusy 0x1
#define PlatformReady 0x2
#define PlatformResetBBT 0x3
#define PlatformEraseAllFlash 0x4
#define PlatformDisconnect 0x5
#define PlatformEraseAllFlashDone 0x6
#define PlatformEraseAllFlashWithoutBurn 0x7
#define PlatformEraseAllFlashWithoutBurnDone 0x8
#define PlatformFuseOperationStart 0x9
#define PlatformFuseOperationDone 0xA
#define PlatformUEInfoStart 0xB
#define PlatformUEInfoDone 0xc
#define PXA92x_PlatformBusy 0x7
#define PXA92x_PlatformReady 0x8
#define PXA92x_PlatformDisconnect 0xC
#define ERRORFLAG 0x64
#define NoError 0x0
#define NotFoundError 0x1
#define GeneralError 0x2
#define WriteError 0x3
#define ReadError 0x4
#define NotSupportedError 0x5
#define InvalidPlatformConfigError 0x6
#define InvalidPlatformState 0x7
#define InvalidSizeError 0x9
#define ProbeListExhaustError 0xA
#define DDR_NotInitializedError 0xB
#define UnknownReservedPackage 0xD
#define NULLPointer 0xE
#define NANDIDDISMATCH 0xF
#define FBF_VersionNotMatch 0x10
#define FBF_DeviceMoreThanOne 0x11
#define PlatformConfigBuckError 0x12
#define ChipIdMismatch 0x13
// Flash Related Errors 0x20 - 0x3F
#define EraseError 0x20
#define ProgramError 0x21
#define InvalidBootTypeError 0x22
#define ProtectionRegProgramError 0x23
#define NoOTPFound 0x24
#define BBTReadError 0x25
#define MDOCInitFailed 0x26
#define OneNandInitFailed 0x27
#define MDOCFormatFailed 0x28
#define BBTExhaustedError 0x29
#define NANDNotFound 0x2A
#define SDMMCNotFound 0x2B
#define FlexOneNANDNotFound 0x2C
#define SDMMCReadError 0x2D
#define XIPReadError 0x2E
#define FlexOneNANDError 0x2F
#define FlashDriverInitError 0x30
#define FlashFuncNotDefined 0x31
#define OTPError 0x32
#define InvalidAddressRangeError 0x33
#define FlashLockError 0x34
#define ReadDisturbError 0x35
#define FlashReadError 0x36
#define SPIFlashNotResponding 0x37
#define ImageOverlayError 0x38
#define FlashAddrNotChunkAlign 0x39
#define FlashAddrNotWordAlign 0x3A
#define BBTOUTOFRANGE 0x3B
#define FlashWriteVerifyError 0x3C
#define FlashAddrOutOfRange 0x3d
// DFC Related Errors 0x40 - 0x4F
#define DFCDoubleBitError 0x40
#define DFCSingleBitError 0x41
#define DFCCS0BadBlockDetected 0x42
#define DFCCS1BadBlockDetected 0x43
#define DFCInitFailed 0x44
#define DFCONFIConfigError 0x45
#define DFC_WRREQ_TO 0x46
#define DFC_WRCMD_TO 0x47
#define DFC_RDDREQ_TO 0x48
#define DFC_RDY_TO 0x49
#define DFCCS0CommandDoneError 0x4A
#define DFCCS1CommandDoneError 0x4B
#define DFC_PGDN_TO 0x4C
// SPI Related Errors
#define SPINORPROGRAMFAIL 0x50
#define SPINORERASEFAIL 0x51
// Security Related Errors 0x60 - 0x8F
#define InvalidOEMVerifyKeyError 0x60
#define InvalidOBMImageError 0x61
#define SecureBootFailureError 0x62
#define InvalidSecureBootMethodError 0x63
#define UnsupportedFlashError 0x64
#define InvalidCaddoFIFOEntryError 0x65
#define InvalidCaddoKeyNumberError 0x66
#define InvalidCaddoKeyTypeError 0x67
#define RSADigitalSignatureDecryptError 0x68
#define InvalidHashValueLengthError 0x69
#define InvalidTIMImageError 0x6A
#define HashSizeMismatch 0x6B
#define InvalidKeyHashError 0x6C
#define TIMNotFound 0x6D
#define WTMStateError 0x6E
#define FuseRWError 0x6F
#define InvalidOTPHashError 0x70
#define CRCFailedError 0x71
#define SaveStateNotFound 0x72
#define WTMInitializationError 0x73
#define ImageNotFound 0x74
#define InvalidImageHash 0x75
#define MicroCodePatchingError 0x76
#define SetJtagKeyError 0x77
#define WTMDisabled 0x78
#define PlatformVerifyFailure 0x79
#define ImageLoadError 0x7A
#define IPPCPHASHERROR 0x7B
// Download Protocols 0x90 - 0x9F
#define DownloadPortError 0x90
#define DownloadError 0x91
#define FlashNotErasedError 0x92
#define InvalidKeyLengthError 0x93
#define DownloadImageTooBigError 0x94
#define UsbPreambleError 0x95
#define TimeOutError 0x96
#define UartReadWriteTimeOutError 0x97
#define UnknownImageError 0x98
#define MessageBufferFullError 0x99
#define NoEnumerationResponseTimeOutError 0x9A
#define UnknownProtocolCmd 0x9B
#define UsbRxError 0x9C
#define ForceDownloadPseudoError 0x9D
#define UsbTxError 0x9E
//JTAG ReEnable Error Codes 0xB0 - 0xCF
#define JtagReEnableError 0xB0
#define JtagReEnableOEMPubKeyError 0xB1
#define JtagReEnableOEMSignedPassWdError 0xB2
#define JtagReEnableTimeOutError 0xB3
#define JtagReEnableOEMKeyLengthError 0xB4
// SDMMC Errors 0xD0-0xE5
#define SDMMC_SWITCH_ERROR 0xD0
#define SDMMC_ERASE_RESET_ERROR 0xD1
#define SDMMC_CIDCSD_OVERWRITE_ERROR 0xD2
#define SDMMC_OVERRUN_ERROR 0xD3
#define SDMMC_UNDERUN_ERROR 0xD4
#define SDMMC_GENERAL_ERROR 0xD5
#define SDMMC_CC_ERROR 0xD6
#define SDMMC_ECC_ERROR 0xD7
#define SDMMC_ILL_CMD_ERROR 0xD8
#define SDMMC_COM_CRC_ERROR 0xD9
#define SDMMC_LOCK_ULOCK_ERRROR 0xDA
#define SDMMC_LOCK_ERROR 0xDB
#define SDMMC_WP_ERROR 0xDC
#define SDMMC_ERASE_PARAM_ERROR 0xDD
#define SDMMC_ERASE_SEQ_ERROR 0xDE
#define SDMMC_BLK_LEN_ERROR 0xDF
#define SDMMC_ADDR_MISALIGN_ERROR 0xE0
#define SDMMC_ADDR_RANGE_ERROR 0xE1
#define SDMMCDeviceNotReadyError 0xE2
#define SDMMCInitializationError 0xE3
#define SDMMCDeviceVoltageNotSupported 0xE4
#define SDMMCWriteError 0xE5
#define SDMMCAltBootDataAlignmentError 0xE6
#define SDMMC_SGPT_ILLEGAL_LENGTH 0xE7
// SDIO Errors 0xF0 -
#define SDIOReadError 0xF0
#define SDIOWriteError 0xF1
#define SDIOOutOfSyncError 0xF2
#define SDIONullBuffer 0xF3
#define SDIOBufferMisalignError 0xF4
#define SDIOImageSizeError 0xF5
// WTM FuseBlock Errors
#define FUSE_FuseBlockNotActive 0x100
#define FUSE_BufferTooSmall 0x101
#define FUSE_FuseBlockLocked 0x102
#define FUSE_UnsupportedFuseBlock 0x103
#define FUSE_IncompleteBurnRequest 0x104
#define FUSE_NoBurnRequest 0x105
#define FUSE_FuseBlockFieldNotActive 0x106
#define FUSE_BurnError 0x107
#define FUSE_FuseBlockFieldOverflow 0x108
#define FUSE_InvalidFuseBlockField 0x109
#define FUSE_FuseBlockCompareFailed 0x10A
#define FUSE_InvalidState 0x10B
#define FUSE_InvalidBufferSize 0x10C
#define FUSE_BitSetError 0x10D
#define FUSE_FuseBlockLockedAndNotReadable 0x10E
#define FUSE_FuseBlockFieldFull 0x10F
#define FUSE_FuseSoftwareResetTimeout 0x110
#define FUSE_FuseBurnTimeout 0x111
#define FUSE_FuseBlockStickyBitSet 0x112
#define FUSE_UsbPhyBandgapNotEnabled 0x113
#define FUSE_UncorrectableEccError 0x114
#define FUSE_FieldWriteProtectedByEcc 0x115
#define FUSE_LastLogicalBitBurned 0x116
#define FUSE_TamperError 0x117
#define FUSE_FuseReprogrammingError 0x118
#define FUSE_IncompleteFuseFieldsSetup 0x119
// GEU FuseBlock Errors
#define GEU_FuseBlockNotActive 0x100
#define GEU_BufferTooSmall 0x101
#define GEU_FuseBlockLocked 0x102
#define GEU_UnsupportedFuseBlock 0x103
#define GEU_IncompleteBurnRequest 0x104
#define GEU_NoBurnRequest 0x105
#define GEU_FuseBlockFieldNotActive 0x106
#define GEU_BurnError 0x107
#define GEU_FuseBlockFieldOverflow 0x108
#define GEU_InvalidFuseBlockField 0x109
#define GEU_FuseBlockCompareFailed 0x10A
#define GEU_InvalidState 0x10B
#define GEU_InvalidBufferSize 0x10C
#define GEU_BitSetError 0x10D
#define GEU_FuseBlockLockedAndNotReadable 0x10E
#define GEU_FuseBlockFieldFull 0x10F
#define GEU_FuseSoftwareResetTimeout 0x110
#define GEU_FuseBurnTimeout 0x111
#define GEU_FuseBlockStickyBitSet 0x112
#define GEU_UsbPhyBandgapNotEnabled 0x113
#define GEU_UncorrectableEccError 0x114
#define GEU_FieldWriteProtectedByEcc 0x115
#define GEU_LastLogicalBitBurned 0x116
#define GEU_TamperError 0x117
#define GEU_FuseReprogrammingError 0x118
#define GEU_IncompleteFuseFieldsSetup 0x119
// TrustZone Related Errors
#define TZ_Region0NotProtected 0x120
#define TZ_FusesNotConfiguredForTrustzone 0x121
#define TZ_PackageNotFound 0x122
#define TZ_InitDisabled 0x123
#define TZ_UnknownOperation 0x124
//DDR Related Error Codes
#define DDR_Package_Obsolete 0x200
#define DDR_Unknown_Operation 0x201
#define DDR_MemoryTest_Failed 0x202
#define DDR_InitDisabled 0x203
#define DDR_CMCC_Package_Obsolete 0x204
#define DDR_Trustzone_Package_Obsolete 0x205
#define DDR_PackageNotFound 0x206
#define DDR_FusesNotConfiguredForTrustzone 0x207
//Instruction related codes
#define UnknownInstruction 0x300
#define InstructionTimeout 0x301
#define INSTR_InvalidAddress 0x302
#define INSTR_InvalidScratchMemoryId 0x303
#define INSTR_InvalidMaskOrValue 0x304
// sparse file related codes
#define Sparse_ImageLengthLimitExceeded 0x400
#define Sparse_BadMagic 0x401
#define Sparse_IncompatibleFormat 0x402
#define Sparse_BadChunkSize 0x403
#define Sparse_BogusDontCareChunk 0x404
#define Sparse_UnknownChunkId 0x405
#define Sparse_WriteError 0x406
//Relate to EMMC error
#define SDH_CMD_TIMEOUT_ERR 0x420
#define SDH_CMD_CRC_ERR 0x421
#define SDH_CMD_END_BIT_ERR 0x422
#define SDH_CMD_INDEX_ERR 0x423
#define SDH_DATA_TIMEOUT_ERR 0x424
#define SDH_RD_DATA_CRC_ERR 0x425
#define SDH_RD_DATA_END_BIT_ERR 0x426
#define SDH_AUTO_CMD12_ERR 0x427
#define SDH_ADMA_ERR 0x428
#define SDH_TUNE_ERR 0x429
#define SDH_SPI_ERR 0x42A
#define SDH_AXI_RESP_ERR 0x42B
#define SDH_CPL_TIMEOUT_ERR 0x42C
#define SDH_CRC_STATUS_ERR 0x42D
// DTIM related codes
#define IMAP_PackageNotFound 0x500
#define IMAP_ErrorFormat 0x501
#define IMAP_DTIMNotFound 0x502
#define IMAP_DTIMLoadError 0x503
#define IMAP_DTIMValidationFailed 0x504
#define IMAP_BootFailed 0x505
#define IMAP_KeyNotFound 0x506
#define IMAP_ImageLoadError 0x507
#define IMAP_ImageValidateError 0x508
// MRD related codes
#define MRD_BadMagic 0x520
#define MRD_CheckSumNotMatch 0x521
#define MRD_IMEINotMatch 0x522
#endif
-900
View File
@@ -1,900 +0,0 @@
#include <errno.h>
#include "CommonFun.h"
#include "downloader.h"
#include "WtptpDownLoad.h"
#include <sys/time.h>
#include "ParaDefine.h"
#include "BinFileWtp.h"
#include "kstring.h"
#include "fbfdownload.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
#include <syslog.h>
#include <sys/stat.h>
#include <endian.h>
#define SUCCEED 0
#define FAILED 1
#define MIN_ARGS 3
#define FBF_TIMHEADER 'i'
#define FBF_FILE 'f'
#define DKB_TIMHEADER 't'
#define DKB_FILE 'd'
#define BIN_FILE 'b'
#define LOG_PATH 'p'
// #define PLATFORM_TYPE 'p'
#define MAX_FILE_LENGTH 256
kstring_t g_DkbTimPath={0,0,NULL}, g_DkbFilePath={0,0,NULL}, g_BinFilePath={0,0,NULL};
kstring_t strDeviceDetectFile={0,0,NULL};
BOOL bDownload = TRUE;
BOOL bUpload = FALSE;
BOOL bSingle = TRUE;
BOOL btimeoutset = FALSE;
BOOL bIgnoreBlankLines = TRUE;
int exit_code = -1;
int timeout = 0;
pthread_mutex_t mutex;
pthread_cond_t cond;
int g_nDownloadPercent = 0;
int g_nBurnPercent = 0;
const TCHAR* pszSWDReleaseDate = _T("2020-6-19");
const TCHAR* pszSWDReleaseVersion = _T("4.9.0.7");
//char SWDLOCKFILE[255] = "/var/run/swdlinux.pid";
char SWDLOCKFILE[255] = "./fbfdownloader.pid";
extern char g_LogPath[255];
#define LOCKMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
#if DEBUG_MODE
BOOL bDebugTrace = TRUE;
#else
BOOL bDebugTrace = FALSE;
#endif
int lockfile(int fd)
{
struct flock fl;
fl.l_type = F_WRLCK;
fl.l_start = 0;
fl.l_whence = SEEK_SET;
fl.l_len = 0;
return(fcntl(fd, F_SETLK, &fl));
}
int already_running(void)
{
int fd;
if (strlen(g_LogPath) > 0)
{
strncpy(SWDLOCKFILE,g_LogPath,_countof(SWDLOCKFILE));
strncat(SWDLOCKFILE,"/fbfdownloader.pid",_countof(SWDLOCKFILE));
}
fd = open(SWDLOCKFILE, O_RDWR | O_CREAT, LOCKMODE);
if (fd < 0) {
//syslog(LOG_ERR, "can't open %s: %s", SWDLOCKFILE, strerror(errno));
#if PRINTLOG
printf("can't open %s: %s", SWDLOCKFILE, strerror(errno));
#endif
exit(1);
}
if (lockfile(fd) < 0) {
if (errno == EACCES || errno == EAGAIN) {
close(fd);
return(1);
}
//syslog(LOG_ERR, "can't lock %s: %s", SWDLOCKFILE, strerror(errno));
#if PRINTLOG
printf("can't lock %s: %s", SWDLOCKFILE, strerror(errno));
#endif
exit(1);
}
//close(fd);
return(0);
}
BOOL ParseCommandLine(int argc, char* argv[])
{
int currentOption = 1;
BYTE Option = 0;
while (currentOption < argc)
{
if (*argv[currentOption] == '-')
{
Option = *++argv[currentOption++];
switch (Option)
{
case FBF_FILE:
{
/*
TCHAR szFbfPath[MAX_FILE_LENGTH];
memset(szFbfPath, 0, sizeof(TCHAR)*MAX_FILE_LENGTH);
_tcscpy(szFbfPath, argv[currentOption]);
tstring strFbfPath(szFbfPath);
g_lpFbfImageList->push_back(strFbfPath);
*/
}
break;
case FBF_TIMHEADER:
{
/*
TCHAR szFbfTimPath[MAX_FILE_LENGTH];
memset(szFbfTimPath, 0, sizeof(TCHAR)*MAX_FILE_LENGTH);
_tcscpy(szFbfTimPath, argv[currentOption]);
tstring strFbfTimPath(szFbfTimPath);
g_lpFbfImageList->push_front(strFbfTimPath);
*/
}
break;
case DKB_FILE:
{
// g_DkbFilePath = argv[currentOption];
}
break;
case DKB_TIMHEADER:
{
// g_DkbTimPath = argv[currentOption];
}
break;
case BIN_FILE:
{
kstrcpy(&g_BinFilePath, argv[currentOption]);
}
break;
case LOG_PATH:
{
strncpy(g_LogPath,argv[currentOption],_countof(g_LogPath));
if (strlen(g_LogPath) >0 && g_LogPath[strlen(g_LogPath)-1] == '/')
{
g_LogPath[strlen(g_LogPath)-1] = 0;
}
}
break;
default:
{
#if PRINTLOG
printf("\n Error: Command line option -%c is invalid!\n", Option);
#endif
return FALSE;
}
break;
}
}
else
{
currentOption++;
}
}
return TRUE;
}
void CallbackProc(PProcInfo pNotifyInfo)
{
//tprintf(_T("CallbackProc......\n"));
if (!bIgnoreBlankLines)
{
#if PRINTLOG
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
#endif
}
switch ((eProcessState)pNotifyInfo->eProcState)
{
case kProcConnecting:
{
g_nDownloadPercent = 0;
#if PRINTLOG
tprintf(_T("|%s:Add an device |\n"), pNotifyInfo->pszUSBPortAddress);
#endif
}
break;
case kProcDownloading:
{
if (!bIgnoreBlankLines)
{
#if PRINTLOG
tprintf(_T("|%s:Download percentage is:%d |\r"), pNotifyInfo->pszUSBPortAddress, pNotifyInfo->nDownloadedPercent);
#endif
}
else if (pNotifyInfo->nDownloadedPercent > g_nDownloadPercent)
{
#if PRINTLOG
tprintf(_T("|%s:Download percentage is:%d |\r"), pNotifyInfo->pszUSBPortAddress, pNotifyInfo->nDownloadedPercent);
#endif
g_nDownloadPercent = pNotifyInfo->nDownloadedPercent;
}
if ( _tcscmp(pNotifyInfo->pszProcMsg, _T("BadBlkNum") ) == 0 )
{
kstring_t g_strBBPath = GetAppPath();
kstring_t strBBFile ={0,0,NULL};
kputs(_T("/bbcs.txt"),&g_strBBPath);
FILE* BbcLogFile = _tfopen(g_strBBPath.s,_T("w"));
tfprintf (BbcLogFile,_T("%lf"),le32toh(pNotifyInfo->lpBadBlk.TotalBadBlocks)/le32toh(pNotifyInfo->lpBadBlk.TotalBlocks));
fflush(BbcLogFile);
fclose(BbcLogFile);
free(g_strBBPath.s);
// tprintf(_T("\rFlash Info: TotalBadBlocks = %d, Total Blocks = %d"),
// le32toh(pNotifyInfo->lpBadBlk.TotalBadBlocks), le32toh(pNotifyInfo->lpBadBlk.TotalBlocks));
//To do your code, you can abort the download at certain bad blocks number.
/* if(((pNotifyInfo->lpBadBlk.TotalBadBlocks)*50) > pNotifyInfo->lpBadBlk.TotalBlocks)
{
tprintf(_T("|%s:Too many bad blocks |\n"), pNotifyInfo->pszUSBPortAddress);
exit_code = FAILED;
pthread_cond_signal(&cond);
}
*/
}
}
break;
case kProcAborting:
{
#if PRINTLOG
tprintf(_T("\n|%s:Abort in download |"), pNotifyInfo->pszUSBPortAddress);
#endif
exit_code = FAILED;
pthread_cond_signal(&cond);
}
break;
case kProcCompleted:
{
if (bUpload)
{
#if PRINTLOG
tprintf(_T("|%s:Upload Successfully |\n"), pNotifyInfo->pszUSBPortAddress);
#endif
}
else
{
#if PRINTLOG
tprintf(_T("|%s:Burn Successfully |\n"), pNotifyInfo->pszUSBPortAddress);
#endif
}
exit_code = SUCCEED;
pthread_cond_signal(&cond);
}
break;
case kProcBurningFlash:
{
if (!bIgnoreBlankLines)
{
#if PRINTLOG
tprintf(_T("|%s:Burning Flash percentage is:%d |\r"), pNotifyInfo->pszUSBPortAddress, pNotifyInfo->nDownloadedPercent);
#endif
}
else if (pNotifyInfo->nDownloadedPercent > g_nBurnPercent && pNotifyInfo->nDownloadedPercent <= 100)
{
#if PRINTLOG
tprintf(_T("|%s:Burning Flash percentage is:%d |\r"), pNotifyInfo->pszUSBPortAddress, pNotifyInfo->nDownloadedPercent);
#endif
g_nBurnPercent = pNotifyInfo->nDownloadedPercent;
}
if ( _tcscmp(pNotifyInfo->pszProcMsg, _T("CRCS") ) == 0 )
{
// tprintf(_T("\t\nBurning, Devices: MCPID: 0x%x, ImageNum: %d\n"),
// le32toh(pNotifyInfo->lpImageCrc.MCPID), le32toh(pNotifyInfo->lpImageCrc.ImageNum));
kstring_t g_strAppPath = GetAppPath();
kputs(_T("/crcs.txt"),&g_strAppPath);
FILE* CrcLogFile = _tfopen(g_strAppPath.s,_T("w"));
for(UINT32 i = 0; i < le32toh(pNotifyInfo->lpImageCrc.ImageNum); i++)
{
// tprintf(_T("ImageID: 0x%x, CrcData: 0x%8X\n"),
// le32toh(pNotifyInfo->lpImageCrc.ImageCRC[i].ImageID), le32toh(pNotifyInfo->lpImageCrc.ImageCRC[i].CRC32));
if(i != le32toh(pNotifyInfo->lpImageCrc.ImageNum) -1)
tfprintf (CrcLogFile,_T("0x%08x-"),le32toh(pNotifyInfo->lpImageCrc.ImageCRC[i].CRC32));
else
tfprintf (CrcLogFile,_T("0x%08x"),le32toh(pNotifyInfo->lpImageCrc.ImageCRC[i].CRC32));
}
free(g_strAppPath.s);
fflush(CrcLogFile);
fclose(CrcLogFile);
}
}
break;
case kProcUploadingData:
{
#if PRINTLOG
tprintf(_T("|%s:Uploading percentage is:%d |\r"), pNotifyInfo->pszUSBPortAddress, pNotifyInfo->nDownloadedPercent);
#endif
}
break;
case kProcDebugLog:
{
#if PRINTLOG
tprintf(_T("|%s: %s |\n"),pNotifyInfo->pszProcMsg,pNotifyInfo->pszUSBPortAddress);
#endif
}
break;
case kProcEraseAllFlash:
{
#if PRINTLOG
tprintf(_T("|%s:Erasing all flash percentage is:%d |\r"), pNotifyInfo->pszUSBPortAddress, pNotifyInfo->nDownloadedPercent);
#endif
}
break;
default:
break;
}
#if PRINTLOG
if (!bIgnoreBlankLines)
{
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
tprintf(_T("\n"));
}
#endif
fflush(stdout);
}
BOOL InitInstanceParams(PInstanceParams lpInstanceParam, struct StringList* pFbfList)
{
#define KNEWSTR(ps,src) \
ps = (kstring_t*)malloc(sizeof(kstring_t)); \
ps->s = NULL;ps->l = ps->m = 0; \
kstrcpy(ps, src);
//提取Dkb和DKBTimeheader
for (int i = 0; i < pFbfList->nSize; i++)
{
const char * strFile = pFbfList->strL[i];
printf("Init %s\n",strFile);
if (strstr(strFile,_T("DKB_timheader.bin")) != NULL || strstr(strFile,_T("DKB_ntimheader.bin")) != NULL)
{
kstrcpy(&g_DkbTimPath,strFile);
for (int j = i; j < pFbfList->nSize-1; j++)
pFbfList->strL[j] = pFbfList->strL[j+1];
i--;
pFbfList->nSize--;
} else if (strstr(strFile,_T("Dkb.bin")))
{
kstrcpy(&g_DkbFilePath,strFile);
for (int j = i; j < pFbfList->nSize-1; j++)
pFbfList->strL[j] = pFbfList->strL[j+1];
i--;
pFbfList->nSize--;
}
}
#if PRINTLOG
tprintf(_T("DKB_timheader is %s DKB is %s\n"),g_DkbTimPath.s, g_DkbFilePath.s);
#endif
//g_lpFbfImageList->sort();
for (int i = 0; i < pFbfList->nSize-1; i++)
for (int j = i+1; j < pFbfList->nSize; j++)
if (strcmp(pFbfList->strL[i], pFbfList->strL[j]) > 0)
{
const char *strTmp = pFbfList->strL[i];
pFbfList->strL[i] = pFbfList->strL[j];
pFbfList->strL[j] = strTmp;
}
int ite = 0;
if (strstr(pFbfList->strL[ite],_T("0x")) != NULL )
{
//Multi DDR case
while(ite!=pFbfList->nSize)
{
const char* tpos = strstr(pFbfList->strL[ite],_T("0x"));
if (tpos!= NULL)
{
DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC *pDDRFlashImagInfo = (pDDR_FLASH_DOWNLOADIMAGE_INFO_SPEC)malloc(sizeof(DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC));
New_DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC(pDDRFlashImagInfo);
char buf[32];
int ite2 = ite;
memset(buf, 0, sizeof(buf));
strncpy(buf,tpos,6);
kstrcpy(&pDDRFlashImagInfo->sVendorDDRId,buf);
//pDDRFlashImagInfo->sVendorDDRId = ite->substr(tpos,6);
strncpy(buf,tpos+6,6);
kstrcpy(&pDDRFlashImagInfo->sFlashInfo,buf);
//pDDRFlashImagInfo->sFlashInfo = ite->substr(tpos+6,6);
//tstring sDdrFlashInfo = ite->substr(tpos,12);
ite2++;
printf("VendorDDRId:%s FlashInfo:%s\n",pDDRFlashImagInfo->sVendorDDRId.s,pDDRFlashImagInfo->sFlashInfo.s);
if (strstr(pFbfList->strL[ite],_T("header")) != NULL)
{
kstring_t *kps;
KNEWSTR(kps,pFbfList->strL[ite2])
*kl_pushf(pstrl, *pDDRFlashImagInfo->pImagelist) = kps;
KNEWSTR(kps,pFbfList->strL[ite])
*kl_pushf(pstrl, *pDDRFlashImagInfo->pImagelist) = kps;
//pDDRFlashImagInfo->pImagelist->push_front(new tstring(*ite2));
//pDDRFlashImagInfo->pImagelist->push_front(new tstring(*ite));
#if PRINTLOG
printf("FBF head:%s FBF:%s\n",pFbfList->strL[ite],pFbfList->strL[ite2]);
#endif
} else
{
kstring_t *kps;
KNEWSTR(kps,pFbfList->strL[ite])
*kl_pushf(pstrl, *pDDRFlashImagInfo->pImagelist) = kps;
KNEWSTR(kps,pFbfList->strL[ite2])
*kl_pushf(pstrl, *pDDRFlashImagInfo->pImagelist) = kps;
#if PRINTLOG
printf("FBF head:%s FBF:%s\n",pFbfList->strL[ite2],pFbfList->strL[ite]);
#endif
}
//g_lpFbfImageList->erase(ite++);
//g_lpFbfImageList->erase(ite2++);
for (int k = ite; k < pFbfList->nSize-3; k+=2)
{
pFbfList->strL[k] = pFbfList->strL[k+2];
pFbfList->strL[k+1] = pFbfList->strL[k+3];
}
pFbfList->nSize -= 2;
pDDRFlashImagInfo->TotalFlashTypeNum = 1;
pDDRFlashImagInfo->TotalVendorDDRTypeNum = 1;
*kl_pushp(dfdil,*lpInstanceParam->pDownloadImagesList)=pDDRFlashImagInfo;
}
//pDDRFlashImagInfo->pImagelist->push_back(new tstring(*ite));
ite = 0;
}
} else
{
DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC *pDDRFlashImagInfo = (pDDR_FLASH_DOWNLOADIMAGE_INFO_SPEC)malloc(sizeof(DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC));
New_DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC(pDDRFlashImagInfo);
kstrcpy(&pDDRFlashImagInfo->sVendorDDRId,"Reserve");
kstrcpy(&pDDRFlashImagInfo->sFlashInfo,"Reserve");
int ite2 = ite;
ite2++;
kstring_t *kps;
if (strstr(pFbfList->strL[ite],_T("header")) != NULL )
{
KNEWSTR(kps,pFbfList->strL[ite2])
*kl_pushf(pstrl, *pDDRFlashImagInfo->pImagelist) = kps;
KNEWSTR(kps,pFbfList->strL[ite])
*kl_pushf(pstrl, *pDDRFlashImagInfo->pImagelist) = kps;
#if PRINTLOG
printf("FBF head:%s FBF:%s\n",pFbfList->strL[ite],pFbfList->strL[ite2]);
#endif
} else{
KNEWSTR(kps,pFbfList->strL[ite])
*kl_pushf(pstrl, *pDDRFlashImagInfo->pImagelist) = kps;
KNEWSTR(kps,pFbfList->strL[ite2])
*kl_pushf(pstrl, *pDDRFlashImagInfo->pImagelist) = kps;
#if PRINTLOG
printf("FBF head:%s FBF:%s\n",pFbfList->strL[ite2],pFbfList->strL[ite]);
#endif
}
for (int k = ite; k < pFbfList->nSize-4; k+=2)
{
pFbfList->strL[k] = pFbfList->strL[k+2];
pFbfList->strL[k+1] = pFbfList->strL[k+3];
}
pFbfList->nSize -= 2;
pDDRFlashImagInfo->TotalFlashTypeNum = 1;
pDDRFlashImagInfo->TotalVendorDDRTypeNum = 1;
*kl_pushp(dfdil,*lpInstanceParam->pDownloadImagesList) = pDDRFlashImagInfo;
}
TCHAR* pszTimFile = (TCHAR*)malloc(sizeof(TCHAR)*(g_DkbTimPath.l + 1));
memset(pszTimFile, 0, (g_DkbTimPath.l + 1) * sizeof(TCHAR));
memcpy(pszTimFile, g_DkbTimPath.s, g_DkbTimPath.l * sizeof(TCHAR));
lpInstanceParam->pszDKBTim = pszTimFile;
TCHAR* pszDkbFile = (TCHAR*)malloc(sizeof(TCHAR)*(g_DkbFilePath.l + 1));
memset(pszDkbFile, 0, (g_DkbFilePath.l + 1) * sizeof(TCHAR));
memcpy(pszDkbFile, g_DkbFilePath.s, g_DkbFilePath.l * sizeof(TCHAR));
lpInstanceParam->pszDKBbin = pszDkbFile;
//lpInstanceParam->pDownloadImagesList->front()->pImagelist->back();
kstring_t strFbfFile = *(*kl_back(pstrl, *kl_val(kl_begin(*lpInstanceParam->pDownloadImagesList))->pImagelist));
BinFileWtp_OpenBinFile(&gBinFileWtp,_T("rb"));
// FILE* fpFile = _tfopen(strFbfFile.c_str(),_T("rb"));
// if (NULL == fpFile)
// {
// tprintf(_T("Open file failed:%s"),strFbfFile.c_str());
// return FALSE;
// }
MasterBlockHeader masterBlkHeader;
BinFileWtp_FseekBin(&gBinFileWtp,strFbfFile.s,4L,SEEK_SET);
BinFileWtp_ReadBinFile(&gBinFileWtp,&masterBlkHeader,sizeof(MasterBlockHeader),1,strFbfFile.s);
EndianConvertMasterBlockHeader(&masterBlkHeader);
printf("MasterBlkHeader.SizeOfBlock=%x\n",masterBlkHeader.Size_of_Block);
// fseek(fpFile,4,SEEK_SET);
// fread(&masterBlkHeader,sizeof(MasterBlockHeader),1,fpFile);
DeviceHeader_V11 deviceHeaderBuf;
BinFileWtp_FseekBin(&gBinFileWtp,strFbfFile.s,masterBlkHeader.deviceHeaderOffset[0] + 4,SEEK_SET);
BinFileWtp_ReadBinFile(&gBinFileWtp,&deviceHeaderBuf,sizeof(DeviceHeader_V11),1,strFbfFile.s);
EndianConvertDeviceHeader_V11(&deviceHeaderBuf);
printf("deviceHeaderBuf.DeviceFlags=%x\n",deviceHeaderBuf.DeviceFlags);
// fseek(fpFile,masterBlkHeader.deviceHeaderOffset[0] + 4,SEEK_SET);
// fread(&deviceHeaderBuf,sizeof(DeviceHeader_V11),1,fpFile);
lpInstanceParam->PlaformType = deviceHeaderBuf.ChipID;
lpInstanceParam->Commands |= (deviceHeaderBuf.FlashOpt.EraseAll?1:0);
lpInstanceParam->Commands |= (deviceHeaderBuf.FlashOpt.ResetBBT? (1<<2):0);
if (deviceHeaderBuf.FlashOpt.NandID)
{
lpInstanceParam->FlashType = 0;
}
/*Note: the BBCS and CRCS on/off are controlled by the blf via which fbf file was created.
Here for fbfdownloader pc side, just assume both are ON in order to avoid extract the information from TIMH.
The CallbackProc only try to read the infos when BBCS or CRCS success although the on/off at PC are always set to ON
lpInstanceParam->GetBadBlk = 1;
lpInstanceParam->ImageCrcEn = 1;
*/
lpInstanceParam->GetBadBlk = deviceHeaderBuf.BBCS_EN;
lpInstanceParam->ImageCrcEn = deviceHeaderBuf.CRCS_EN;
BinFileWtp_CloseBinFIle(&gBinFileWtp);
// fclose(fpFile);
return TRUE;
#undef KNEWSTR
}
#ifdef STATICLIB_FBFDOWNLOAD
int fbfdownload(char * strBinFilePath, int nTimeout)
{
struct StringList g_lpFbfImageList;
int i = 0;
BOOL bIsInProcess = FALSE;
memset(&g_lpFbfImageList,0,sizeof(struct StringList));
//SetDebugMode(bDebugTrace);
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cond, NULL);
#if PRINTLOG
printf("\n\nfbfdownloader version: %s\n", pszSWDReleaseVersion);
printf("fbfdownloader date: %s\n\n", pszSWDReleaseDate);
#endif
//remove wtptp.ko
//system("rmmod wtptp.ko");
if (nTimeout <= 0)
{
btimeoutset = FALSE;
}else
{
btimeoutset = TRUE;
timeout = nTimeout;
}
kstrcpy(&g_BinFilePath, strBinFilePath);
if (!IsFileExist(strBinFilePath))
{
tprintf("BinFilePath Error\n");
return 1;
}
PInstanceParams lpInstanceParam = (PInstanceParams)malloc(sizeof(InstanceParams));
if (NULL == lpInstanceParam)
{
#if PRINTLOG
tprintf("malloc memory failed.\n");
#endif
return 1;
}
NewInstanceParams(lpInstanceParam);
if (g_BinFilePath.l > 0)
{
BinFileWtp_InitParameter2(&gBinFileWtp,g_BinFilePath.s, &g_lpFbfImageList);
}
strDeviceDetectFile = GetAppPath();
kputs("/swdl_linux_wtptp_device_detect.log", &strDeviceDetectFile);
if (bDownload)
{
if (InitInstanceParams(lpInstanceParam,&g_lpFbfImageList))
{
lpInstanceParam->CallbackProc = CallbackProc;
if (bSingle)
{
lpInstanceParam->DownloadMode = 1;
}
if (!InitializeBL(lpInstanceParam))
{
#if PRINTLOG
printf("InitializeBL failed , please check failed root cause....\n");
#endif
DelInstanceParams(lpInstanceParam);
free(lpInstanceParam);
return 1;
}
bIsInProcess = TRUE;
}
else
{
DelInstanceParams(lpInstanceParam);
free(lpInstanceParam);
return 1;
}
}
if (bIsInProcess)
{
if (bSingle)
{
if (btimeoutset)
{
struct timespec to;
pthread_mutex_lock(&mutex);
to.tv_sec = time(NULL) + timeout;
to.tv_nsec = 0;
if (ETIMEDOUT == pthread_cond_timedwait(&cond, &mutex, &to))
{
exit_code = FAILED;
printf("swdl_linux timeout exit\n");
printf("current timeout time is %d seconds, please increase timeout time to retry.\n", timeout);
}
TerminateBL();
}
else
{
pthread_mutex_lock(&mutex);
pthread_cond_wait(&cond, &mutex);
TerminateBL();
}
printf("FBFDownloader EXIT.....\n");
}
else
{
if (btimeoutset)
{
struct timespec to;
pthread_mutex_lock(&mutex);
to.tv_sec = time(NULL) + timeout;
to.tv_nsec = 0;
if (ETIMEDOUT == pthread_cond_timedwait(&cond, &mutex, &to))
{
exit_code = FAILED;
printf("swdl_linux timeout exit\n");
printf("current timeout time is %d seconds, please increase timeout time to retry.\n", timeout);
}
TerminateBL();
}
else
{
while (1)
{
sleep(2);
if (tolower(getchar()) == (int)'q')
{
TerminateBL();
DelFile(strDeviceDetectFile.s);
DelInstanceParams(lpInstanceParam);
free(lpInstanceParam);
return 1;
}
}
}
}
}
DelFile(strDeviceDetectFile.s);
DelInstanceParams(lpInstanceParam);
free(lpInstanceParam);
return exit_code;
}
#else
int main(int argc, char *argv[])
{
struct StringList g_lpFbfImageList;
memset(&g_lpFbfImageList,0,sizeof(struct StringList));
if (!ParseCommandLine(argc, argv))
{
#if PRINTLOG
printf("Command line error.\n");
#endif
return 1;
}
if (already_running() == 1)
{
printf("\n\nthere is already an fbfdownloader is running, you can't run it again.\n\n");
return 1;
}
int i = 0;
BOOL bIsInProcess = FALSE;
//SetDebugMode(bDebugTrace);
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cond, NULL);
#if PRINTLOG
printf("\n\nfbfdownloader version: %s\n", pszSWDReleaseVersion);
printf("fbfdownloader date: %s\n\n", pszSWDReleaseDate);
#endif
if (argc < MIN_ARGS)
{
#if PRINTLOG
tprintf(_T("Invalid parameters\n"));
tprintf(_T("Function: Do Remote or automatically Software Download to board\n"));
tprintf(_T("CommandLine: fbfdownloader -b BinFile [-p path of Log File]\n"));
tprintf(_T("Usage: FBFDownloader -b BinFile.bin \n\n"));
#endif
fflush(stdout);
return 1;
}
//remove wtptp.ko
//system("rmmod wtptp.ko");
if (!IsFileExist(g_BinFilePath.s))
{
tprintf("BinFilePath Error\n");
return 1;
}
PInstanceParams lpInstanceParam = (PInstanceParams)malloc(sizeof(InstanceParams));
if (NULL == lpInstanceParam)
{
#if PRINTLOG
tprintf("malloc memory failed.\n");
#endif
return 1;
}
NewInstanceParams(lpInstanceParam);
printf("BinFilePath is :%s\n",g_BinFilePath.s);
if (g_BinFilePath.l > 0)
{
if (FALSE == BinFileWtp_InitParameter2(&gBinFileWtp,g_BinFilePath.s, &g_lpFbfImageList))
{
printf("BinFileWtp_InitParameter2 Faile!\n");
return FAILED;
} else
{
printf("BinFileWtp_InitParameter2 Success!\n");
}
}
strDeviceDetectFile = GetAppPath();
//kputs("/swdl_linux_wtptp_device_detect.log", &strDeviceDetectFile);
printf("AppPath is :%s\n",strDeviceDetectFile.s);
if (bDownload)
{
if (InitInstanceParams(lpInstanceParam, &g_lpFbfImageList))
{
lpInstanceParam->CallbackProc = CallbackProc;
if (bSingle)
{
lpInstanceParam->DownloadMode = 1;
}
if (!InitializeBL(lpInstanceParam))
{
#if PRINTLOG
printf("InitializeBL failed , please check failed root cause....\n");
#endif
DelInstanceParams(lpInstanceParam);
free(lpInstanceParam);
return 1;
}
bIsInProcess = TRUE;
}
else
{
DelInstanceParams(lpInstanceParam);
free(lpInstanceParam);
return 1;
}
}
if (bIsInProcess)
{
if (bSingle)
{
if (btimeoutset)
{
struct timespec to;
pthread_mutex_lock(&mutex);
to.tv_sec = time(NULL) + timeout;
to.tv_nsec = 0;
if (ETIMEDOUT == pthread_cond_timedwait(&cond, &mutex, &to))
{
exit_code = FAILED;
printf("swdl_linux timeout exit\n");
printf("current timeout time is %d seconds, please increase timeout time to retry.\n", timeout);
}
TerminateBL();
}
else
{
pthread_mutex_lock(&mutex);
pthread_cond_wait(&cond, &mutex);
TerminateBL();
}
printf("FBFDownloader EXIT.....\n");
}
else
{
if (btimeoutset)
{
struct timespec to;
pthread_mutex_lock(&mutex);
to.tv_sec = time(NULL) + timeout;
to.tv_nsec = 0;
if (ETIMEDOUT == pthread_cond_timedwait(&cond, &mutex, &to))
{
exit_code = FAILED;
printf("swdl_linux timeout exit\n");
printf("current timeout time is %d seconds, please increase timeout time to retry.\n", timeout);
}
TerminateBL();
}
else
{
while (1)
{
sleep(2);
if (tolower(getchar()) == (int)'q')
{
TerminateBL();
DelFile(strDeviceDetectFile.s);
DelInstanceParams(lpInstanceParam);
free(lpInstanceParam);
return 1;
}
}
}
}
}
DelFile(strDeviceDetectFile.s);
DelInstanceParams(lpInstanceParam);
free(lpInstanceParam);
return exit_code;
}
#endif
-47
View File
@@ -1,47 +0,0 @@
###############################################################
# Makefile for the Marvell download for MMP2/wukong/NEVO on linux platform.
#
#
##############################################################
CC = gcc -static
BASE:=$(shell pwd)
IFL_PATH = ./
IFL_INCLUDE_DIR = $(IFL_PATH)/
IFL_LIBRARY_DIR = $(IFL_PATH)
TBBOBJS = CommonFun.o\
ParaDefine.o\
WTPCOMMCLASS.o\
BinFileWtp.o\
WtptpDownloader.o\
WtptpDownLoad.o\
ConvetEdian.o\
BulkDevNonDrv_Linux.o\
kstring.o\
FBFDownloader.o\
CCFLAGS += -O2 -D LINUX=1 -D WINDOWS=0 -D DEBUG_MODE=0 -D PRINTLOG=1 -std=c99
LIBS = -lpthread
CCFLAGS += -D TRUSTED_BOOT=1 -I $(IFL_INCLUDE_DIR)
OUTPUT = fbfdownloader
OBJS = $(TBBOBJS)
all: $(OBJS)
$(CC) -g -o $(OUTPUT) $(OBJS) $(LIBS) -ldl
-rm *.o
$(TBBOBJS): %.o: $(BASE)/%.c
$(CC) -g $(CCFLAGS) -c $(BASE)/$*.c -o $(BASE)/$*.o
.PHONY: clean tar tar-%
clean:
-rm *.o $(OUTPUT)
@@ -1,55 +0,0 @@
###############################################################
# Makefile for the Marvell download for MMP2/wukong/NEVO on linux platform.
#
#
##############################################################
#CC = arm_1103_le-g++ -static
#CC = mipsel-linux-uclibc-g++ -static
#CC = mipsel-openwrt-linux-g++ -static
#CC = arm-hisiv200-linux-gnueabi-g++ --static
CC = ${CROSS}gcc #-static
BASE:=$(shell pwd)
IFL_PATH = ./
IFL_INCLUDE_DIR = $(IFL_PATH)/
IFL_LIBRARY_DIR = $(IFL_PATH)
TBBOBJS = CommonFun.o\
ParaDefine.o\
WTPCOMMCLASS.o\
BinFileWtp.o\
WtptpDownloader.o\
WtptpDownLoad.o\
ConvetEdian.o\
BulkDevNonDrv_Linux.o\
kstring.o\
FBFDownloader.o\
CCFLAGS += -O2 -D LINUX=1 -D WINDOWS=0 -D DEBUG_MODE=0 -D PRINTLOG=1 -std=c99 -fPIE
LIBS = -lc
CCFLAGS += -D TRUSTED_BOOT=1 -I $(IFL_INCLUDE_DIR)
OUTPUT = fbfdownloader_cross
OBJS = $(TBBOBJS)
all: $(OBJS)
$(CC) -g -o $(OUTPUT) $(OBJS) $(LIBS) -ldl -fPIE -pie
-rm *.o
$(TBBOBJS): %.o: $(BASE)/%.c
$(CC) -g $(CCFLAGS) -c $(BASE)/$*.c -o $(BASE)/$*.o
.PHONY: clean
clean:
-rm *.o $(OUTPUT)
@@ -1,55 +0,0 @@
###############################################################
# Makefile for the Marvell download for MMP2/wukong/NEVO on linux platform.
#
#
##############################################################
#CC = arm_1103_le-g++ -static
#CC = mipsel-linux-uclibc-g++ -static
#CC = mipsel-openwrt-linux-g++ -static
#CC = arm-hisiv200-linux-gnueabi-g++ --static
CC = ${CROSS}gcc #-static
BASE:=$(shell pwd)
IFL_PATH = ./
IFL_INCLUDE_DIR = $(IFL_PATH)
IFL_LIBRARY_DIR = $(IFL_PATH)
TBBOBJS = CommonFun.o\
ParaDefine.o\
WTPCOMMCLASS.o\
BinFileWtp.o\
WtptpDownloader.o\
WtptpDownLoad.o\
ConvetEdian.o\
BulkDevNonDrv_Linux.o\
kstring.o\
FBFDownloader.o\
CCFLAGS += -O2 -D LINUX=1 -D WINDOWS=0 -D DEBUG_MODE=0 -D PRINTLOG=1 -std=gnu99
LIBS = -lpthread -lc -lgcc_eh
CCFLAGS += -D TRUSTED_BOOT=1 -I $(IFL_INCLUDE_DIR)
OUTPUT = fbfdownloader_cross
OBJS = $(TBBOBJS)
all: $(OBJS)
$(CC) -g -o $(OUTPUT) $(OBJS) $(LIBS) -ldl
-rm *.o
$(TBBOBJS): %.o: $(BASE)/%.c
$(CC) -g $(CCFLAGS) -c $(BASE)/$*.c -o $(BASE)/$*.o
.PHONY: clean
clean:
-rm *.o $(OUTPUT)
-141
View File
@@ -1,141 +0,0 @@
#pragma once
#pragma warning ( disable : 4100 ) // Disable warning messages: unreferenced formal parameter
#pragma warning ( disable : 4189 ) // Disable warning messages: local variable is initialized but not referenced
#include <stdio.h>
#include <wchar.h>
#include <stdlib.h>
#include "klist.h"
#include "kstring.h"
#ifdef LINUX
#include <endian.h>
#if defined(__BYTE_ORDER__)&&(__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
#define htobe16(x) (x)
#define htobe32(x) (x)
#define htobe64(x) (x)
#define htole16(x) __builtin_bswap16(x)
#define htole32(x) __builtin_bswap32(x)
#define htole64(x) __builtin_bswap64(x)
#else
#define htobe16(x) __builtin_bswap16(x)
#define htobe32(x) __builtin_bswap32(x)
#define htobe64(x) __builtin_bswap64(x)
#define htole16(x) (x)
#define htole32(x) (x)
#define htole64(x) (x)
#endif /* __BYTE_ORDER__ */
#define be16toh(x) htobe16(x)
#define le16toh(x) htole16(x)
#define be32toh(x) htobe32(x)
#define le32toh(x) htole32(x)
#define be64toh(x) htobe64(x)
#define le64toh(x) htole64(x)
#include <memory.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#define _tmain main
#define _TCHAR TCHAR
#define _fseeki64 fseeko
#ifndef VOID
#define VOID void
typedef char CHAR;
typedef short SHORT;
typedef long LONG;
#endif
#undef FALSE
#undef TRUE
#undef NULL
#define FALSE 0
#define TRUE 1
#define NULL 0
#ifdef UNICODE
#define _T L##
#define TCHAR wchar_t
#define _tprintf wprintf
#define _tcslen wcslen
#define tsnprintf snwprintf
#define _tcslen wcslen
#define _tcscmp wcscmp
#define _tfopen _wfopen
#define _tcsstr wcsstr
#define _tcscat wcscat
#define _taccess access
#define _tcstoul wcstoul
#define _tcsrchr wcsrchr
#define _tcscpy wcscpy
#define _tcsncpy wcsncpy
#define _ttoi _wtoi
#define _ttot _itow
#define _vstprintf vswprintf
#define _trename _wrename
#define _tremove _wremove
#define _stscanf swscanf
#else
#define _T
#define TCHAR char
#define _tprintf printf
#define _tcslen strlen
#define tsnprintf snprintf
#define _tcslen strlen
#define _tcscmp strcmp
#define _tfopen fopen
#define _tcsstr strstr
#define _tcscat strcat
#define _taccess access
#define _tcstoul strtoul
#define _tcsrchr strrchr
#define _tcscpy strcpy
#define _tcsncpy strncpy
#define _ttoi atoi
#define _ttot itoa
#define _vstprintf vsprintf
#define _trename rename
#define _tremove remove
#define _stscanf sscanf
#endif
#else
#ifdef UNICODE
#define tsnprintf _snwprintf
#else
#define tsnprintf _snprintf
#endif
#endif
#ifdef UNICODE
#define tsprintf swprintf
#define taccess _waccess
#define tatoi _wtoi
#define titoa _itow
#define tsscanf swscanf
#define ttolower towlower
#define ttoupper towupper
#define tfprintf fwprintf
#define tprintf wprintf
#define t_splitpath_s _wsplitpath_s
#else
#define tsprintf sprintf
#define taccess access
#define tatoi atoi
#define titoa itoa
#define tsscanf sscanf
#define ttolower tolower
#define ttoupper toupper
#define tfprintf fprintf
#define tprintf printf
#define t_splitpath_s _splitpath_s
#endif
#define ACCESS_FILE_EXIST 0
#define COMPARE_EQUAL 0
-55
View File
@@ -1,55 +0,0 @@
###############################################################
# Makefile for the Marvell download for MMP2/wukong/NEVO on linux platform.
#
#
##############################################################
#CC = arm_1103_le-g++ -static
#CC = mipsel-linux-uclibc-g++ -static
#CC = mipsel-openwrt-linux-g++ -static
#CC = arm-hisiv200-linux-gnueabi-g++ --static
CC = ${CROSS}gcc #-static
BASE:=$(shell pwd)
IFL_PATH = ./
IFL_INCLUDE_DIR = $(IFL_PATH)
IFL_LIBRARY_DIR = $(IFL_PATH)
TBBOBJS = CommonFun.o\
ParaDefine.o\
WTPCOMMCLASS.o\
BinFileWtp.o\
WtptpDownloader.o\
WtptpDownLoad.o\
ConvetEdian.o\
BulkDevNonDrv_Linux.o\
kstring.o\
FBFDownloader.o\
CCFLAGS += -O2 -D LINUX=1 -D WINDOWS=0 -D DEBUG_MODE=0 -D PRINTLOG=1 -std=gnu99
LIBS = -lpthread -lc -lgcc_eh
CCFLAGS += -D TRUSTED_BOOT=1 -I $(IFL_INCLUDE_DIR)
OUTPUT = fbfdownloader_cross
OBJS = $(TBBOBJS)
all: $(OBJS)
$(CC) -g -o $(OUTPUT) $(OBJS) $(LIBS) -ldl
-rm *.o
$(TBBOBJS): %.o: $(BASE)/%.c
$(CC) -g $(CCFLAGS) -c $(BASE)/$*.c -o $(BASE)/$*.o
.PHONY: clean
clean:
-rm *.o $(OUTPUT)
-161
View File
@@ -1,161 +0,0 @@
#include "ParaDefine.h"
#include "BinFileWtp.h"
#include "WtptpDownloader.h"
extern kstring_t strDeviceDetectFile, g_DkbFilePath,g_DkbTimPath,g_BinFilePath;
void Copy_NotifyStatus(PProcInfo me,struct _NotifyStatus* rhs)
{
me->nDevice = rhs->nDevice;
me->nDevType = rhs->nDevType;
me->nDownloadedPercent = rhs->nDownloadedPercent;
me->lpBadBlk = rhs->lpBadBlk;
me->lpImageCrc = rhs->lpImageCrc;
me->eProcState = rhs->eProcState;
me->eProcStatus = rhs->eProcStatus;
me->nErrorCode = rhs->nErrorCode;
memcpy(&me->pszProcMsg,&rhs->pszProcMsg,sizeof(me->pszProcMsg));
memcpy(&me->pszUSBPortAddress,&rhs->pszUSBPortAddress,sizeof(me->pszUSBPortAddress));
}
void New_DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC(pDDR_FLASH_DOWNLOADIMAGE_INFO_SPEC me)
{
me->pImagelist = (t_stringList*)malloc(sizeof(t_stringList));
*me->pImagelist = kl_init(pstrl);
ks_release(&me->sVendorDDRId);
ks_release(&me->sFlashInfo);
me->TotalVendorDDRTypeNum = 0;
me->TotalFlashTypeNum = 1;
}
void Del_DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC(pDDR_FLASH_DOWNLOADIMAGE_INFO_SPEC me)
{
if( me->pImagelist!=NULL)
{
t_stringListIter ImagesIter = kl_begin(*me->pImagelist);
while(ImagesIter!= kl_end(*me->pImagelist) )
{
if (kl_val(ImagesIter)->s)
free(kl_val(ImagesIter)->s);
free(kl_val(ImagesIter));
ImagesIter = kl_next(ImagesIter);
}
kl_destroy(pstrl, *me->pImagelist);
free(me->pImagelist);
me->pImagelist = NULL;
}
if (me->sFlashInfo.s)
free(me->sFlashInfo.s);
if (me->sVendorDDRId.s)
free(me->sVendorDDRId.s);
ks_release(&me->sFlashInfo);
ks_release(&me->sVendorDDRId);
}
void Copy_DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC(pDDR_FLASH_DOWNLOADIMAGE_INFO_SPEC me,struct _DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC* DDRFlashDownloadImageInfo)
{
#define KNEWSTR(ps,src) \
ps = (kstring_t*)malloc(sizeof(kstring_t)); \
ps->s = NULL;ps->l = ps->m = 0; \
kstrcpy(ps, src);
for(t_stringListIter ite = kl_begin(*me->pImagelist); ite != kl_end(*me->pImagelist); ite = kl_next(ite))
{
if (kl_val(ite)->s)
free(kl_val(ite)->s);
free( kl_val(ite));
}
kl_clear(pstrl,*me->pImagelist);
me->sVendorDDRId = DDRFlashDownloadImageInfo->sVendorDDRId;
me->sFlashInfo = DDRFlashDownloadImageInfo->sFlashInfo;
me->TotalVendorDDRTypeNum = DDRFlashDownloadImageInfo->TotalVendorDDRTypeNum;
me->TotalFlashTypeNum = DDRFlashDownloadImageInfo->TotalFlashTypeNum;
t_stringListIter ImagesIter = kl_begin(*DDRFlashDownloadImageInfo->pImagelist);
while(ImagesIter!= kl_end(*DDRFlashDownloadImageInfo->pImagelist) )
{
kstring_t *kps;
KNEWSTR(kps,kl_val(ImagesIter)->s);
*kl_pushp(pstrl,*me->pImagelist) = kps;
ImagesIter = kl_next(ImagesIter);
}
#undef KNEWSTR
}
void Copy_WTPTPREAMBLECOMMAND(pWTPTPREAMBLECOMMAND me,struct _WTPTPREAMBLECOMMAND* WTPCMD)
{
me->CMD = WTPCMD->CMD;
me->SEQ = WTPCMD->SEQ;
me->CID = WTPCMD->CID;
me->Flags = WTPCMD->Flags;
me->LEN = WTPCMD->LEN;
memcpy(WTPCMD->Data,me->Data,CMDDATALENGTH);
}
void DelInstanceParams(PInstanceParams me)
{
if (NULL != me->pszDKBbin) {free((void*)me->pszDKBbin);me->pszDKBbin = NULL;}
if (NULL != me->pszDKBTim) {free((void*)me->pszDKBTim);me->pszDKBTim = NULL;}
if (NULL != me->pszOBMFile) {free((void*)me->pszOBMFile);me->pszOBMFile = NULL;}
if (NULL != me->pszWTMFile) {free((void*)me->pszWTMFile);me->pszWTMFile = NULL;}
if (NULL != me->pszJTAGKeyFile) {free((void*)me->pszJTAGKeyFile);me->pszJTAGKeyFile = NULL;}
if (NULL != me->pszTZIIFile) {free((void*)me->pszTZIIFile);me->pszTZIIFile = NULL;}
if (NULL != me->pWtptpPreaCmd){free((void*)me->pWtptpPreaCmd); me->pWtptpPreaCmd = NULL;}
if (NULL != me->pUploadSpecs)
{
for (t_UpLoadDataSpecIter iter = kl_begin(*me->pUploadSpecs);iter != kl_end(*me->pUploadSpecs);iter = kl_next(iter))
{
free( kl_val(iter));
}
free( me->pUploadSpecs);
me->pUploadSpecs = NULL;
}
if (NULL != me->pDownloadImagesList)
{
for (t_DdrFlashDownloadImgInfoIter iter = kl_begin(*me->pDownloadImagesList);iter != kl_end(*me->pDownloadImagesList);iter = kl_next(iter))
{
Del_DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC(kl_val(iter));
free( kl_val(iter));
}
}
kl_destroy(dfdil, *me->pDownloadImagesList);
free( me->pDownloadImagesList);
DelCWtptpDownLoad(&gWtptpDownload);
BinFileWtp_DelMe(&gBinFileWtp);
//global var
free(strDeviceDetectFile.s);
free(g_DkbFilePath.s);
free(g_DkbTimPath.s);
free(g_BinFilePath.s);
}
void NewInstanceParams(PInstanceParams me)
{
me->pszDKBbin=NULL;
me->pszDKBTim= NULL;
me->CallbackProc=NULL;
me->pszOBMFile=NULL;
me->pszWTMFile=NULL;
me->pszJTAGKeyFile=NULL;
me->pszTZIIFile=NULL;
me->pUploadSpecs=NULL;
me->pWtptpPreaCmd=NULL;
me->Commands=0;
me->FlashType=5;
me->PlaformType=4;
me->FlashPageSize=0;
me->DownloadMode=0;
me->ProductionMode=0;
me->GetBadBlk=0;
me->ImageCrcEn=0;
me->ReservedVal[0] = BADBLOCKRATE_BASE*100;//坏块率默认值
me->pDownloadImagesList = (t_DdrFlashDownloadImgInfoList*)malloc(sizeof(t_DdrFlashDownloadImgInfoList));
(*me->pDownloadImagesList) = kl_init(dfdil);
memset(&gBinFileWtp, 0, sizeof(struct CBinFileWtp));
BinFileWtp_ResetPara(&gBinFileWtp);
memset(&gWtptpDownload, 0, sizeof(struct CWtptpDownLoad));
NewCWtptpDownLoad(&gWtptpDownload);
}
-774
View File
@@ -1,774 +0,0 @@
#ifndef PARADEFINE_H
#define PARADEFINE_H
#include "./Macrodef.h"
#include "./Typedef.h"
#include "ErrorCode.h"
#include "./UploadParaDef.h"
#include "kstring.h"
#define BADBLOCKRATE_BASE 10000
extern struct CWtptpDownLoad gWtptpDownload;
extern struct CBinFileWtp gBinFileWtp;
#define __pstrl_free(x)
KLIST_INIT(pstrl,kstring_t*,__pstrl_free)
struct StringList
{
const char* strL[64];
int nSize;
};
typedef struct
{
UINT32 ImageID;
UINT32 BadCnt;
}ImageBBInfo;
typedef struct
{
UINT32 ImageID;
UINT32 CRC32;
}CRCInfo;
// Badblock data
typedef struct {
UINT32 TotalBadBlocks;
UINT32 TotalBlocks;
ImageBBInfo BadCount[8]; //reserved for critical partitions support
} BadBlockData, *pBadBlockData;
// Image CRC data
typedef struct
{
UINT32 MCPID;
UINT32 ImageNum;
CRCInfo ImageCRC[32]; //Crc32 of all images, support 32 images at maximum
}ImageCRCInfo, *pImageCRCInfo;
typedef enum EProcessState
{
kProcIdle = 0, // Not active
kProcInit = 1, // Initialization
kProcBootRom = 2, // Initialization for BootRom
kProcPrepareData = 3, // Preparation images downloading
kProcConnecting = 4, // Open connection and handshake
kProcDownloading = 5, // Downloading Data
kProcAborting = 6, // Aborting in process
kProcFileCompleted = 7, // File downloading process is completed
kProcCompleted = 8, // Downloading process is completed
kProcUsbRemove = 9, // Usb device is removed
kProcDebugLog = 10, // Debug message report
kProcBurningFlash = 11, // Burning Data
kProcUploadingData = 12, // Uploading Data
kProcWaitingUploadData = 13, // Waiting UE to get upload data
kProcEraseAllFlash = 14, // Erase all Flash
kProcErrorCode = 15, // Error code in downloading
kProcFuseInfo = 16, // fuse Info
kProcFuseInfoError = 17, // fuse Info operate error report
kProcUEInfo = 18, // fuse Info
kProcStateMax = 0xfe
}eProcessState;
typedef enum
{
stOK, // Finished OK
stInvalid, // Couldn't create instance
stUsbError, // Couldn't connect to the USB driver
stNoReply, // Target is not responding
stBadReply, // Protocol error
stDownloadMBError, // Downloading error
stFailedToConnect, // Handshake failure/TimeOut
stFailedFileCreate, // Create file failed
stParseFile, // Parse file error
stEmptyFileList, // Image file list is empty
stFileError, // AXF file not found or file format error
stFilePathError, // File path is not exist
stAborted, // Aborted using abort Process()
stThreadError, // Error creating the instance thread
stNack, // Not acknowledge
stCalculationError, // Check sum calculation error
stImgConversionFail, // Error Image conversion
stImgCheckOverlapFail, // Error image overlap
stImgBuildFail, // Error image build
stFolderError, // Work folder error
stMepBndError, // Error binding Mep data
stBurningFlashError, // Error in burning flash
stUEErrorTrace = 0xff // Target error trace
} eProcessStatus;
//Providing process evaluation information via Callback function
typedef struct _NotifyStatus
{
int nDevice, // Active device number
nDevType, // Device type kUnknown = 0, kBootRom = 1, kBootloader = 2
nDownloadedPercent; // Downloading percent
TCHAR pszProcMsg[1024]; // Callback message
TCHAR pszUSBPortAddress[260]; // USB socket address
BadBlockData lpBadBlk; // flash bad block data
ImageCRCInfo lpImageCrc; // CRC value of Images read back from flash
eProcessState eProcState; // Current process state
eProcessStatus eProcStatus; // Current process status
int nErrorCode; // Errorcode in download or burning
}NotifyStatus, *PProcInfo;
typedef void (/*__stdcall*/ * CALLBACKPROC)(PProcInfo pNotifyInfo);
typedef klist_t(pstrl)* t_stringList;
typedef kliter_t(pstrl)* t_stringListIter;
typedef struct _DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC
{
t_stringList* pImagelist;
kstring_t sVendorDDRId;
kstring_t sFlashInfo;
int TotalVendorDDRTypeNum;
int TotalFlashTypeNum;
} DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC,*pDDR_FLASH_DOWNLOADIMAGE_INFO_SPEC;
#define __dfdi_free(x)
KLIST_INIT(dfdil,DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC*,__dfdi_free)
typedef klist_t(dfdil)* t_DdrFlashDownloadImgInfoList;
typedef kliter_t(dfdil)* t_DdrFlashDownloadImgInfoIter;
#define CMDDATALENGTH 8196
typedef struct _WTPTPREAMBLECOMMAND
{
BYTE CMD;
BYTE SEQ;
BYTE CID;
BYTE Flags;
UINT32 LEN;
BYTE Data[CMDDATALENGTH];
}WTPTPREAMBLECOMMAND,*pWTPTPREAMBLECOMMAND;
#define CFG_VERSION _T("V1.3")
#define CFG_SECTION_NAME _T("DownloadPackageCfg")
#define CFG_VERSION_NUMBER _T("CfgVersion")
#define CFG_IMAGE_NUM _T("ImageNum")
#define CFG_FBF_SET_NUM _T("FbfSetNum")
#define CFG_DDRTYPE_NUM _T("DDRVendorTypeNum")
#define CFG_FLASHTYPE_NUM _T("FlashTypeNum")
#define CFG_IMAGE_IDX _T("Image_")
#define CFG_DDREMMC_TYPE _T("DDRVendorID_EMMC")
#define CFG_DDRTYPE_NAME _T("DDRVendorName")
#define CFG_DDRTYPE_ID _T("DDRVendorID")
#define CFG_FLASH_INFO _T("FlashInfo")
#define CFG_DKB_BIN _T("DKBbin")
#define CFG_DKB_TIM _T("DKBTim")
#define CFG_OBM_FILE _T("OBMFile")
#define CFG_TZII_FILE _T("TZIIFile")
#define CFG_WTM_FILE _T("WTMFile")
#define CFG_IMEI_FILE _T("IMEIFile")
#define CFG_MEP_FILE _T("MEPFile")
#define CFG_PLATFORM_TYPE _T("PlatFormType")
#define CFG_FLASH_TYPE _T("FlashFamilyType")
#define CFG_COMMAND _T("Command")
#define CFG_FLASH_PAGE_SIZE _T("FlashPageSize")
#define CFG_PRODUCTIONMODE _T("ProductionMode")
#define MAX_RESERVED_DATA 4
typedef struct _InstanceParams
{
t_DdrFlashDownloadImgInfoList * pDownloadImagesList;
const TCHAR* pszDKBbin; // Download file for Bootrom
const TCHAR* pszDKBTim; // Primary flasher file path(*.bin, *.axf, *.elf) (can be either Comm. or App flasher)
const TCHAR* pszOBMFile; // OBM file path
const TCHAR* pszWTMFile; // WTM file path
const TCHAR* pszTZIIFile; //TZII file path
const TCHAR* pszJTAGKeyFile; // OEM Key file path to do re-eanble JTAG in case JTAG is disable
CALLBACKPROC CallbackProc; // Callback function that will back relevant process information
pWTPTPREAMBLECOMMAND pWtptpPreaCmd; // Customize Preamble Command
unsigned int PlaformType; /* 2-MMP2 */
/* 3-WUKONG */
/* 4-PXA978 */
/* 5-MMP3 */
/* 6-PXA1802 */
/* 8-PXA988/986 */
/* 9-PXA1088 */
/* 10-PXA1928 */
/* 11-PXA1920 */
/* 15-PXA1826 */
unsigned int FlashType; // 0-NAND, 1-eMMC,3-SPINOR,4-ONENAND,others-Unknown
unsigned int Commands; // flags description /* bit switches */, user only need to set bit3 if user want to use customized preamble
/*bit 0:Erase all flash flag*/
/*bit 1: Upload flag */
/*bit 2: Reset BBT flag */
/*bit 3: Customized preamble flag*/
/*bit 4: erase all flash only flag */
/*bit 5: JTAG Re enable flag */
/*bit 6 ~ bit31 reserved */
unsigned int FlashPageSize; // Nand Flash Data page size
unsigned int DownloadMode; // Single_Download 1,multi_download 0;
unsigned int ProductionMode; // ;
unsigned int GetBadBlk; //get flash bad block enabled 1; otherwise: 0
unsigned int ImageCrcEn; // Image CRC enabled: 1,Image CRC disabled: 0;
unsigned int ReservedVal[MAX_RESERVED_DATA];
t_UpLoadDataSpecList* pUploadSpecs; // Upload spec Info
}InstanceParams, *PInstanceParams;
#ifndef COMPRESSDATA
static ERRORCODETABLE WTPTPErrorCodes[MAXERRORCODES]=
{
{NoError,_T("NoError")},
{NotFoundError,_T("NotFoundError")},
{GeneralError,_T("GeneralError")},
{WriteError,_T("WriteError")},
{ReadError,_T("ReadError")} ,
{NotSupportedError,_T("NotSupportedError")} ,
{InvalidPlatformConfigError,_T("InvalidPlatformConfigError")},
{InvalidPlatformState,_T("InvalidPlatformState")},
{InvalidSizeError,_T("InvalidSizeError")},
{ProbeListExhaustError,_T("ProbeListExhaustError")},
{DDR_NotInitializedError,_T("DDR_NotInitializedError")},
{UnknownReservedPackage,_T("UnknownReservedPackage")},
{NULLPointer,_T("NULLPointer")},
{NANDIDDISMATCH ,_T("NANDIDDISMATCH")},
{FBF_VersionNotMatch,_T("FBF_VersionNotMatch")},
{FBF_DeviceMoreThanOne,_T("FBF_DeviceMoreThanOne")},
{PlatformConfigBuckError,_T("PlatformConfigBuckError")},
{ChipIdMismatch,_T("ChipIdMismatch")},
{EraseError,_T("EraseError ")},
{ProgramError,_T("ProgramError")},
{InvalidBootTypeError,_T("InvalidBootTypeError")},
{ProtectionRegProgramError,_T("ProtectionRegProgramError")},
{NoOTPFound,_T("NoOTPFound")},
{BBTReadError,_T("BBTReadError")},
{MDOCInitFailed,_T("MDOCInitFailed ")},
{OneNandInitFailed,_T("OneNandInitFailed")},
{MDOCFormatFailed,_T("MDOCFormatFailed ")},
{BBTExhaustedError,_T("BBTExhaustedError ")},
{NANDNotFound,_T("NANDNotFound ")},
{SDMMCNotFound,_T("SDMMCNotFound ")},
{FlexOneNANDNotFound,_T("FlexOneNANDNotFound ")},
{SDMMCReadError,_T("SDMMCReadError ")},
{XIPReadError,_T("XIPReadError ")},
{FlexOneNANDError,_T("FlexOneNANDError ")},
{FlashDriverInitError,_T("FlashDriverInitError")},
{FlashFuncNotDefined,_T("FlashFuncNotDefined")},
{OTPError,_T("OTPError")},
{InvalidAddressRangeError,_T("InvalidAddressRangeError")},
{FlashLockError,_T("FlashLockError ")},
{ReadDisturbError,_T("ReadDisturbError")},
{FlashReadError,_T("FlashReadError")},
{SPIFlashNotResponding,_T("SPIFlashNotResponding")},
{ImageOverlayError,_T("ImageOverlayError ")},
{FlashAddrNotChunkAlign ,_T("FlashAddrNotChunkAlign")},
{FlashAddrNotWordAlign ,_T("FlashAddrNotWordAlign")},
{BBTOUTOFRANGE ,_T("BBTOUTOFRANGE")},
{FlashWriteVerifyError ,_T("FlashWriteVerifyError")},
{FlashAddrOutOfRange ,_T("FlashAddrOutOfRange")},
{DFCDoubleBitError,_T("DFCDoubleBitError ")},
{DFCSingleBitError,_T("DFCSingleBitError ")},
{DFCCS0BadBlockDetected,_T("DFCCS0BadBlockDetected ")},
{DFCCS1BadBlockDetected,_T("DFCCS1BadBlockDetected ")},
{DFCInitFailed,_T("DFCInitFailed")},
{DFCONFIConfigError,_T("DFCONFIConfigError")},
{DFC_WRREQ_TO,_T("DFC_WRREQ_TO")},
{DFC_WRCMD_TO,_T("DFC_WRCMD_TO")},
{DFC_RDDREQ_TO,_T("DFC_RDDREQ_TO")} ,
{DFC_RDY_TO,_T("DFC_RDY_TO ")},
{DFCCS0CommandDoneError,_T("DFCCS0CommandDoneError")},
{DFCCS1CommandDoneError,_T("DFCCS1CommandDoneError ")},
{DFC_PGDN_TO,_T("DFC_PGDN_TO")},
{SPINORPROGRAMFAIL,_T("SPINORPROGRAMFAIL")},
{SPINORERASEFAIL,_T("SPINORERASEFAIL")},
{InvalidOEMVerifyKeyError,_T("InvalidOEMVerifyKeyError")},
{InvalidOBMImageError,_T("InvalidOBMImageError")},
{SecureBootFailureError,_T("SecureBootFailureError ")},
{InvalidSecureBootMethodError,_T("InvalidSecureBootMethodError")},
{UnsupportedFlashError,_T("UnsupportedFlashError")},
{InvalidCaddoFIFOEntryError,_T("InvalidCaddoFIFOEntryError ")},
{InvalidCaddoKeyNumberError,_T("InvalidCaddoKeyNumberError ")},
{InvalidCaddoKeyTypeError,_T("InvalidCaddoKeyTypeError")},
{RSADigitalSignatureDecryptError,_T("RSADigitalSignatureDecryptError")},
{InvalidHashValueLengthError,_T("InvalidHashValueLengthError ")},
{InvalidTIMImageError,_T("InvalidTIMImageError")},
{HashSizeMismatch,_T("HashSizeMismatch")},
{InvalidKeyHashError,_T("InvalidKeyHashError")},
{TIMNotFound,_T("TIMNotFound")},
{WTMStateError,_T("WTMStateError")},
{FuseRWError,_T("FuseRWError")},
{InvalidOTPHashError,_T("InvalidOTPHashError, keypair in current blf configuration is not the key of fuse")},
{CRCFailedError,_T("CRCFailedError ")},
{SaveStateNotFound,_T("SaveStateNotFound")},
{WTMInitializationError,_T("WTMInitializationError")},
{ImageNotFound,_T("ImageNotFound")},
{InvalidImageHash,_T("InvalidImageHash")},
{MicroCodePatchingError,_T("MicroCodePatchingError")},
{SetJtagKeyError,_T("SetJtagKeyError")},
{WTMDisabled,_T("WTMDisabled")},
{PlatformVerifyFailure,_T("PlatformVerifyFailure")},
{ImageLoadError,_T("ImageLoadError ")},
{IPPCPHASHERROR,_T("IPPCPHASHERROR ")},
{DownloadPortError,_T("DownloadPortError")},
{DownloadError,_T("DownloadError")},
{FlashNotErasedError,_T("FlashNotErasedError")},
{InvalidKeyLengthError,_T("InvalidKeyLengthError")},
{DownloadImageTooBigError,_T("DownloadImageTooBigError")},
{UsbPreambleError,_T("UsbPreambleError")},
{TimeOutError,_T("TimeOutError")},
{UartReadWriteTimeOutError,_T("UartReadWriteTimeOutError")},
{UnknownImageError,_T("UnknownImageError")},
{MessageBufferFullError,_T("MessageBufferFullError")},
{NoEnumerationResponseTimeOutError,_T("NoEnumerationResponseTimeOutError")},
{UnknownProtocolCmd,_T("UnknownProtocolCmd")},
{UsbRxError,_T("UsbRxError")},
{ForceDownloadPseudoError,_T("ForceDownloadPseudoError")},
{UsbTxError,_T("UsbTxError")},
{JtagReEnableError,_T("JtagReEnableError")} ,
{JtagReEnableOEMPubKeyError,_T("JtagReEnableOEMPubKeyError")},
{JtagReEnableOEMSignedPassWdError,_T("JtagReEnableOEMSignedPassWdError")},
{JtagReEnableTimeOutError,_T("JtagReEnableTimeOutError")},
{JtagReEnableOEMKeyLengthError,_T("JtagReEnableOEMKeyLengthError ")} ,
{SDMMC_SWITCH_ERROR,_T("SDMMC_SWITCH_ERROR")},
{SDMMC_ERASE_RESET_ERROR,_T("SDMMC_ERASE_RESET_ERROR")},
{SDMMC_CIDCSD_OVERWRITE_ERROR,_T("SDMMC_CIDCSD_OVERWRITE_ERROR")},
{SDMMC_OVERRUN_ERROR,_T("SDMMC_OVERRUN_ERROR ")},
{SDMMC_UNDERUN_ERROR,_T("SDMMC_UNDERUN_ERROR ")},
{SDMMC_GENERAL_ERROR,_T("SDMMC_GENERAL_ERROR ")},
{SDMMC_CC_ERROR,_T("SDMMC_CC_ERROR")},
{SDMMC_ECC_ERROR,_T("SDMMC_ECC_ERROR")},
{SDMMC_ILL_CMD_ERROR,_T("SDMMC_ILL_CMD_ERROR")},
{SDMMC_COM_CRC_ERROR,_T("SDMMC_COM_CRC_ERROR")},
{SDMMC_LOCK_ULOCK_ERRROR,_T("SDMMC_LOCK_ULOCK_ERRROR")},
{SDMMC_LOCK_ERROR,_T("SDMMC_LOCK_ERROR ")},
{SDMMC_WP_ERROR,_T("SDMMC_WP_ERROR")},
{SDMMC_ERASE_PARAM_ERROR,_T("SDMMC_ERASE_PARAM_ERROR")},
{SDMMC_ERASE_SEQ_ERROR,_T("SDMMC_ERASE_SEQ_ERROR")},
{SDMMC_BLK_LEN_ERROR,_T("SDMMC_BLK_LEN_ERROR")},
{SDMMC_ADDR_MISALIGN_ERROR,_T("SDMMC_ADDR_MISALIGN_ERROR")},
{SDMMC_ADDR_RANGE_ERROR,_T("SDMMC_ADDR_RANGE_ERROR")},
{SDMMCDeviceNotReadyError,_T("SDMMCDeviceNotReadyError")},
{SDMMCInitializationError,_T("SDMMCInitializationError")},
{SDMMCDeviceVoltageNotSupported,_T("SDMMCDeviceVoltageNotSupported")},
{SDMMCWriteError,_T("SDMMCWriteError")},
{SDMMCAltBootDataAlignmentError,_T("SDMMCAltBootDataAlignmentError")},
{SDMMC_SGPT_ILLEGAL_LENGTH,_T("SDMMC_SGPT_ILLEGAL_LENGTH")},
{SDIOReadError,_T("SDIOReadError")},
{SDIOWriteError,_T("SDIOWriteError")},
{SDIOOutOfSyncError,_T("SDIOOutOfSyncError")},
{SDIONullBuffer,_T("SDIONullBuffer")},
{SDIOBufferMisalignError,_T("SDIOBufferMisalignError")},
{SDIOImageSizeError,_T("SDIOImageSizeError")},
{FUSE_FuseBlockNotActive,_T("FUSE_FuseBlockNotActive")},
{FUSE_BufferTooSmall,_T("FUSE_BufferTooSmall")},
{FUSE_FuseBlockLocked,_T("FUSE_FuseBlockLocked ")},
{FUSE_UnsupportedFuseBlock,_T("FUSE_UnsupportedFuseBlock")},
{FUSE_IncompleteBurnRequest,_T("FUSE_IncompleteBurnRequest")},
{FUSE_NoBurnRequest,_T("FUSE_NoBurnRequest")},
{FUSE_FuseBlockFieldNotActive,_T("FUSE_FuseBlockFieldNotActive")},
{FUSE_BurnError,_T("FUSE_BurnError")},
{FUSE_FuseBlockFieldOverflow,_T("FUSE_FuseBlockFieldOverflow")},
{FUSE_InvalidFuseBlockField,_T("FUSE_InvalidFuseBlockField")},
{FUSE_FuseBlockCompareFailed,_T("FUSE_FuseBlockCompareFailed")},
{FUSE_InvalidState,_T("FUSE_InvalidState")},
{FUSE_InvalidBufferSize,_T("FUSE_InvalidBufferSize")},
{FUSE_BitSetError,_T("FUSE_BitSetError")},
{FUSE_FuseBlockLockedAndNotReadable,_T("FUSE_FuseBlockLockedAndNotReadable")},
{FUSE_FuseBlockFieldFull,_T("FUSE_FuseBlockFieldFull")},
{FUSE_FuseSoftwareResetTimeout,_T("FUSE_FuseSoftwareResetTimeout")},
{FUSE_FuseBurnTimeout,_T("FUSE_FuseBurnTimeout")},
{FUSE_FuseBlockStickyBitSet,_T("FUSE_FuseBlockStickyBitSet")},
{FUSE_UsbPhyBandgapNotEnabled,_T("FUSE_UsbPhyBandgapNotEnabled")},
{FUSE_UncorrectableEccError,_T("FUSE_UncorrectableEccError")},
{FUSE_FieldWriteProtectedByEcc,_T("FUSE_FieldWriteProtectedByEcc")},
{FUSE_LastLogicalBitBurned,_T("FUSE_LastLogicalBitBurned")},
{FUSE_TamperError,_T("FUSE_TamperError")},
{FUSE_FuseReprogrammingError,_T("FUSE_FuseReprogrammingError")},
{FUSE_IncompleteFuseFieldsSetup,_T("FUSE_IncompleteFuseFieldsSetup")},
{GEU_FuseBlockNotActive,_T("GEU_FuseBlockNotActive")},
{GEU_BufferTooSmall,_T("GEU_BufferTooSmall")},
{GEU_FuseBlockLocked,_T("GEU_FuseBlockLocked")},
{GEU_UnsupportedFuseBlock,_T("GEU_UnsupportedFuseBlock ")},
{GEU_IncompleteBurnRequest,_T("GEU_IncompleteBurnRequest ")},
{GEU_NoBurnRequest,_T("GEU_NoBurnRequest")},
{GEU_FuseBlockFieldNotActive,_T("GEU_FuseBlockFieldNotActive")},
{GEU_BurnError,_T("GEU_BurnError")},
{GEU_FuseBlockFieldOverflow,_T("GEU_FuseBlockFieldOverflow")},
{GEU_InvalidFuseBlockField,_T("GEU_InvalidFuseBlockField")},
{GEU_FuseBlockCompareFailed,_T("GEU_FuseBlockCompareFailed")},
{GEU_InvalidState,_T("GEU_InvalidState")},
{GEU_InvalidBufferSize,_T("GEU_InvalidBufferSize")},
{GEU_BitSetError,_T("GEU_BitSetError")},
{GEU_FuseBlockLockedAndNotReadable,_T("GEU_FuseBlockLockedAndNotReadable")},
{GEU_FuseBlockFieldFull,_T("GEU_FuseBlockFieldFull")},
{GEU_FuseSoftwareResetTimeout,_T("GEU_FuseSoftwareResetTimeout")},
{GEU_FuseBurnTimeout,_T("GEU_FuseBurnTimeout")},
{GEU_FuseBlockStickyBitSet,_T("GEU_FuseBlockStickyBitSet")},
{GEU_UsbPhyBandgapNotEnabled,_T("GEU_UsbPhyBandgapNotEnabled")},
{GEU_UncorrectableEccError,_T("GEU_UncorrectableEccError")},
{GEU_FieldWriteProtectedByEcc,_T("GEU_FieldWriteProtectedByEcc")},
{GEU_LastLogicalBitBurned,_T("GEU_LastLogicalBitBurned")},
{GEU_TamperError,_T("GEU_TamperError")},
{GEU_FuseReprogrammingError,_T("GEU_FuseReprogrammingError")},
{GEU_IncompleteFuseFieldsSetup,_T("GEU_IncompleteFuseFieldsSetup")},
{TZ_Region0NotProtected,_T("TZ_Region0NotProtected")},
{TZ_FusesNotConfiguredForTrustzone,_T("TZ_FusesNotConfiguredForTrustzone")},
{TZ_PackageNotFound ,_T("TZ_PackageNotFound")},
{TZ_InitDisabled ,_T("TZ_InitDisabled")},
{TZ_UnknownOperation ,_T("TZ_UnknownOperation")},
{DDR_Package_Obsolete,_T("DDR_Package_Obsolete")},
{DDR_Unknown_Operation,_T("DDR_Unknown_Operation")},
{DDR_MemoryTest_Failed,_T("DDR_MemoryTest_Failed")},
{DDR_InitDisabled,_T("DDR_InitDisabled")},
{DDR_CMCC_Package_Obsolete,_T("DDR_CMCC_Package_Obsolete")},
{DDR_Trustzone_Package_Obsolete,_T("DDR_Trustzone_Package_Obsolete")},
{DDR_PackageNotFound,_T("DDR_PackageNotFound")},
{DDR_FusesNotConfiguredForTrustzone,_T("DDR_FusesNotConfiguredForTrustzone")},
{UnknownInstruction,_T("UnknownInstruction ")},
{InstructionTimeout,_T("InstructionTimeout")},
{INSTR_InvalidAddress,_T("INSTR_InvalidAddress")},
{INSTR_InvalidScratchMemoryId,_T("INSTR_InvalidScratchMemoryId")},
{INSTR_InvalidMaskOrValue,_T("INSTR_InvalidMaskOrValue")},
{Sparse_ImageLengthLimitExceeded,_T("Sparse_ImageLengthLimitExceeded")},
{Sparse_BadMagic,_T("Sparse_BadMagic")},
{Sparse_IncompatibleFormat,_T("Sparse_IncompatibleFormat")},
{Sparse_BadChunkSize,_T("Sparse_BadChunkSize")},
{Sparse_BogusDontCareChunk,_T("Sparse_BogusDontCareChunk")},
{Sparse_UnknownChunkId,_T("Sparse_UnknownChunkId")},
{Sparse_WriteError,_T("Sparse_WriteError")},
{SDH_CMD_TIMEOUT_ERR,_T("SDH_CMD_TIMEOUT_ERR")},
{SDH_CMD_CRC_ERR,_T("SDH_CMD_CRC_ERR")},
{SDH_CMD_END_BIT_ERR,_T("SDH_CMD_END_BIT_ERR")},
{SDH_CMD_INDEX_ERR,_T("SDH_CMD_INDEX_ERR")},
{SDH_DATA_TIMEOUT_ERR,_T("SDH_DATA_TIMEOUT_ERR")},
{SDH_RD_DATA_CRC_ERR,_T("SDH_RD_DATA_CRC_ERR")},
{SDH_RD_DATA_END_BIT_ERR,_T("SDH_RD_DATA_END_BIT_ERR")},
{SDH_AUTO_CMD12_ERR ,_T("SDH_AUTO_CMD12_ERR")},
{SDH_ADMA_ERR,_T("SDH_ADMA_ERR")},
{SDH_TUNE_ERR,_T("SDH_TUNE_ERR")},
{SDH_SPI_ERR,_T("SDH_SPI_ERR")},
{SDH_AXI_RESP_ERR,_T("SDH_AXI_RESP_ERR")},
{SDH_CPL_TIMEOUT_ERR,_T("SDH_CPL_TIMEOUT_ERR")},
{SDH_CRC_STATUS_ERR,_T("SDH_CRC_STATUS_ERR")},
{IMAP_PackageNotFound,_T("IMAP_PackageNotFound")},
{IMAP_ErrorFormat,_T("IMAP_ErrorFormat")},
{IMAP_DTIMNotFound,_T("IMAP_DTIMNotFound")},
{IMAP_DTIMLoadError,_T("IMAP_DTIMLoadError")},
{IMAP_DTIMValidationFailed,_T("IMAP_DTIMValidationFailed")},
{IMAP_BootFailed,_T("IMAP_BootFailed")},
{IMAP_KeyNotFound,_T("IMAP_KeyNotFound")},
{IMAP_ImageLoadError,_T("IMAP_ImageLoadError")},
{IMAP_ImageValidateError,_T("IMAP_ImageValidateError")},
{MRD_BadMagic,_T("MRD_BadMagic")},
{MRD_CheckSumNotMatch,_T("MRD_CheckSumNotMatch")},
{MRD_IMEINotMatch,_T("MRD_IMEINotMatch")},
};
static NOTIFICATIONTABLE WTPTPNotificationMsg[MAXNOTIFICATIONSCODES] =
{
{PlatformBusy,_T("Platform is busy")},
{PlatformReady,_T("Platform is Ready")},
{PlatformResetBBT,_T("Reset BBT")},
{PlatformEraseAllFlash,_T("Erase All flash begin")},
{PlatformDisconnect,_T("platform is disconnect")},
{PlatformEraseAllFlashDone,_T("Erase All flash done")},
{PlatformEraseAllFlashWithoutBurn,_T("Erase All flash without burning begin")},
{PlatformEraseAllFlashWithoutBurnDone,_T("Erase All flash without burning Done")},
{PlatformFuseOperationStart,_T("Platform Fuse Operation Start")},
{PlatformFuseOperationDone,_T("Platform Fuse Operation Done")},
{PlatformUEInfoStart,_T("Platform UE Info Operation Start")},
{PlatformUEInfoDone,_T("Platform UE Info Operation Done")}
};
#else
static ERRORCODETABLE WTPTPErrorCodes[MAXERRORCODES]=
{
{NoError},
{NotFoundError},
{GeneralError},
{WriteError},
{ReadError} ,
{NotSupportedError} ,
{InvalidPlatformConfigError},
{InvalidPlatformState},
{InvalidSizeError},
{ProbeListExhaustError},
{DDR_NotInitializedError},
{UnknownReservedPackage},
{NULLPointer},
{NANDIDDISMATCH },
{FBF_VersionNotMatch},
{FBF_DeviceMoreThanOne},
{PlatformConfigBuckError},
{ChipIdMismatch},
{EraseError},
{ProgramError},
{InvalidBootTypeError},
{ProtectionRegProgramError},
{NoOTPFound},
{BBTReadError},
{MDOCInitFailed},
{OneNandInitFailed},
{MDOCFormatFailed},
{BBTExhaustedError},
{NANDNotFound},
{SDMMCNotFound},
{FlexOneNANDNotFound},
{SDMMCReadError},
{XIPReadError},
{FlexOneNANDError},
{FlashDriverInitError},
{FlashFuncNotDefined},
{OTPError},
{InvalidAddressRangeError},
{FlashLockError},
{ReadDisturbError},
{FlashReadError},
{SPIFlashNotResponding},
{ImageOverlayError},
{FlashAddrNotChunkAlign },
{FlashAddrNotWordAlign },
{BBTOUTOFRANGE },
{FlashWriteVerifyError },
{FlashAddrOutOfRange },
{DFCDoubleBitError},
{DFCSingleBitError},
{DFCCS0BadBlockDetected},
{DFCCS1BadBlockDetected},
{DFCInitFailed},
{DFCONFIConfigError},
{DFC_WRREQ_TO},
{DFC_WRCMD_TO},
{DFC_RDDREQ_TO} ,
{DFC_RDY_TO},
{DFCCS0CommandDoneError},
{DFCCS1CommandDoneError},
{DFC_PGDN_TO},
{SPINORPROGRAMFAIL},
{SPINORERASEFAIL},
{InvalidOEMVerifyKeyError},
{InvalidOBMImageError},
{SecureBootFailureError},
{InvalidSecureBootMethodError},
{UnsupportedFlashError},
{InvalidCaddoFIFOEntryError},
{InvalidCaddoKeyNumberError},
{InvalidCaddoKeyTypeError},
{RSADigitalSignatureDecryptError},
{InvalidHashValueLengthError},
{InvalidTIMImageError},
{HashSizeMismatch},
{InvalidKeyHashError},
{TIMNotFound},
{WTMStateError},
{FuseRWError},
{InvalidOTPHashError},
{CRCFailedError},
{SaveStateNotFound},
{WTMInitializationError},
{ImageNotFound},
{InvalidImageHash},
{MicroCodePatchingError},
{SetJtagKeyError},
{WTMDisabled},
{PlatformVerifyFailure},
{ImageLoadError},
{IPPCPHASHERROR},
{DownloadPortError},
{DownloadError},
{FlashNotErasedError},
{InvalidKeyLengthError},
{DownloadImageTooBigError},
{UsbPreambleError},
{TimeOutError},
{UartReadWriteTimeOutError},
{UnknownImageError},
{MessageBufferFullError},
{NoEnumerationResponseTimeOutError},
{UnknownProtocolCmd},
{UsbRxError},
{ForceDownloadPseudoError},
{UsbTxError},
{JtagReEnableError} ,
{JtagReEnableOEMPubKeyError},
{JtagReEnableOEMSignedPassWdError},
{JtagReEnableTimeOutError},
{JtagReEnableOEMKeyLengthError} ,
{SDMMC_SWITCH_ERROR},
{SDMMC_ERASE_RESET_ERROR},
{SDMMC_CIDCSD_OVERWRITE_ERROR},
{SDMMC_OVERRUN_ERROR},
{SDMMC_UNDERUN_ERROR},
{SDMMC_GENERAL_ERROR},
{SDMMC_CC_ERROR},
{SDMMC_ECC_ERROR},
{SDMMC_ILL_CMD_ERROR},
{SDMMC_COM_CRC_ERROR},
{SDMMC_LOCK_ULOCK_ERRROR},
{SDMMC_LOCK_ERROR},
{SDMMC_WP_ERROR},
{SDMMC_ERASE_PARAM_ERROR},
{SDMMC_ERASE_SEQ_ERROR},
{SDMMC_BLK_LEN_ERROR},
{SDMMC_ADDR_MISALIGN_ERROR},
{SDMMC_ADDR_RANGE_ERROR},
{SDMMCDeviceNotReadyError},
{SDMMCInitializationError},
{SDMMCDeviceVoltageNotSupported},
{SDMMCWriteError},
{SDMMCAltBootDataAlignmentError},
{SDMMC_SGPT_ILLEGAL_LENGTH},
{SDIOReadError},
{SDIOWriteError},
{SDIOOutOfSyncError},
{SDIONullBuffer},
{SDIOBufferMisalignError},
{SDIOImageSizeError},
{FUSE_FuseBlockNotActive},
{FUSE_BufferTooSmall},
{FUSE_FuseBlockLocked},
{FUSE_UnsupportedFuseBlock},
{FUSE_IncompleteBurnRequest},
{FUSE_NoBurnRequest},
{FUSE_FuseBlockFieldNotActive},
{FUSE_BurnError},
{FUSE_FuseBlockFieldOverflow},
{FUSE_InvalidFuseBlockField},
{FUSE_FuseBlockCompareFailed},
{FUSE_InvalidState},
{FUSE_InvalidBufferSize},
{FUSE_BitSetError},
{FUSE_FuseBlockLockedAndNotReadable},
{FUSE_FuseBlockFieldFull},
{FUSE_FuseSoftwareResetTimeout},
{FUSE_FuseBurnTimeout},
{FUSE_FuseBlockStickyBitSet},
{FUSE_UsbPhyBandgapNotEnabled},
{FUSE_UncorrectableEccError},
{FUSE_FieldWriteProtectedByEcc},
{FUSE_LastLogicalBitBurned},
{FUSE_TamperError},
{FUSE_FuseReprogrammingError},
{FUSE_IncompleteFuseFieldsSetup},
{GEU_FuseBlockNotActive},
{GEU_BufferTooSmall},
{GEU_FuseBlockLocked},
{GEU_UnsupportedFuseBlock},
{GEU_IncompleteBurnRequest},
{GEU_NoBurnRequest},
{GEU_FuseBlockFieldNotActive},
{GEU_BurnError},
{GEU_FuseBlockFieldOverflow},
{GEU_InvalidFuseBlockField},
{GEU_FuseBlockCompareFailed},
{GEU_InvalidState},
{GEU_InvalidBufferSize},
{GEU_BitSetError},
{GEU_FuseBlockLockedAndNotReadable},
{GEU_FuseBlockFieldFull},
{GEU_FuseSoftwareResetTimeout},
{GEU_FuseBurnTimeout},
{GEU_FuseBlockStickyBitSet},
{GEU_UsbPhyBandgapNotEnabled},
{GEU_UncorrectableEccError},
{GEU_FieldWriteProtectedByEcc},
{GEU_LastLogicalBitBurned},
{GEU_TamperError},
{GEU_FuseReprogrammingError},
{GEU_IncompleteFuseFieldsSetup},
{TZ_Region0NotProtected},
{TZ_FusesNotConfiguredForTrustzone},
{TZ_PackageNotFound },
{TZ_InitDisabled },
{TZ_UnknownOperation },
{DDR_Package_Obsolete},
{DDR_Unknown_Operation},
{DDR_MemoryTest_Failed},
{DDR_InitDisabled},
{DDR_CMCC_Package_Obsolete},
{DDR_Trustzone_Package_Obsolete},
{DDR_PackageNotFound},
{DDR_FusesNotConfiguredForTrustzone},
{UnknownInstruction},
{InstructionTimeout},
{INSTR_InvalidAddress},
{INSTR_InvalidScratchMemoryId},
{INSTR_InvalidMaskOrValue},
{Sparse_ImageLengthLimitExceeded},
{Sparse_BadMagic},
{Sparse_IncompatibleFormat},
{Sparse_BadChunkSize},
{Sparse_BogusDontCareChunk},
{Sparse_UnknownChunkId},
{Sparse_WriteError},
{SDH_CMD_TIMEOUT_ERR},
{SDH_CMD_CRC_ERR},
{SDH_CMD_END_BIT_ERR},
{SDH_CMD_INDEX_ERR},
{SDH_DATA_TIMEOUT_ERR},
{SDH_RD_DATA_CRC_ERR},
{SDH_RD_DATA_END_BIT_ERR},
{SDH_AUTO_CMD12_ERR },
{SDH_ADMA_ERR},
{SDH_TUNE_ERR},
{SDH_SPI_ERR},
{SDH_AXI_RESP_ERR},
{SDH_CPL_TIMEOUT_ERR},
{SDH_CRC_STATUS_ERR},
{IMAP_PackageNotFound},
{IMAP_ErrorFormat},
{IMAP_DTIMNotFound},
{IMAP_DTIMLoadError},
{IMAP_DTIMValidationFailed},
{IMAP_BootFailed},
{IMAP_KeyNotFound},
{IMAP_ImageLoadError},
{IMAP_ImageValidateError},
{MRD_BadMagic},
{MRD_CheckSumNotMatch},
{MRD_IMEINotMatch}
};
static NOTIFICATIONTABLE WTPTPNotificationMsg[MAXNOTIFICATIONSCODES] =
{
{PlatformBusy},
{PlatformReady},
{PlatformResetBBT},
{PlatformEraseAllFlash},
{PlatformDisconnect},
{PlatformEraseAllFlashDone},
{PlatformEraseAllFlashWithoutBurn},
{PlatformEraseAllFlashWithoutBurnDone},
{PlatformFuseOperationStart},
{PlatformFuseOperationDone},
{PlatformUEInfoStart},
{PlatformUEInfoDone}
};
#endif
void Copy_NotifyStatus(PProcInfo me,struct _NotifyStatus* rhs);
void New_DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC(pDDR_FLASH_DOWNLOADIMAGE_INFO_SPEC me);
void Del_DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC(pDDR_FLASH_DOWNLOADIMAGE_INFO_SPEC me);
void Copy_DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC(pDDR_FLASH_DOWNLOADIMAGE_INFO_SPEC me,struct _DDR_FLASH_DOWNLOADIMAGE_INFO_SPEC* DDRFlashDownloadImageInfo);
void Copy_WTPTPREAMBLECOMMAND(pWTPTPREAMBLECOMMAND me,struct _WTPTPREAMBLECOMMAND* WTPCMD);
void DelInstanceParams(PInstanceParams me);
void NewInstanceParams(PInstanceParams me);
#endif
-9
View File
@@ -1,9 +0,0 @@
FBFDownloader_makefile is the Makefile of fbfdownloader
libmakefile is the Makefile of libfbfdown.a, api is in fbfdownload.h.
//return 0 SUCCRSS
//return 1 FAIL
//timeout 0 Infinite Wait
//timeout >0 Wait N seconds for Download
int fbfdownload(char * strBinFilePath, int timeout);
-960
View File
@@ -1,960 +0,0 @@
#ifndef __TIM_H__
#define __TIM_H__
//#include "general.h"
#include "Macrodef.h"
#include "TimIncludedType.h"
/******************* TIM Layout ************************************/
/* Below Presents the Maxiumum Size TIM layout in memory
VERSION_I VersionBind; // 0
FLASH_I FlashInfo; // 0x10
UINT_T NumImages; // 0x20
UINT_T NumKeys; // 0x24
UINT_T SizeOfReserved; // 0x28
IMAGE_INFO IMG[MAX_IMAGES]; // 0x2C
KEY_MOD Key[MAX_KEYS]; // 0x284
UINT_T Reserved[0x4E8]; // 0x908 (0x4E8 bytes)
PLAT_DS TBTIM_DS; // 0xDF0
// 0x1000 = 4 KB
Below Presents the Maxiumum Size NTIM layout in memory
VERSION_I VersionBind; // 0
FLASH_I FlashInfo; // 0x10
UINT_T NumImages; // 0x20
UINT_T NumKeys; // 0x24
UINT_T SizeOfReserved; // 0x28
IMAGE_INFO IMG[MAX_IMAGES]; // 0x2C
UINT_T Reserved[0xD80]; // 0x284
NTIM, *pNTIM; // 0x1000 = 4KB
/******************* TIM Layout ************************************/
// TIM Versions
#define TIM_3_1_01 0x30101
#define TIM_3_2_00 0x30200 // Support for Partitioning
#define TIM_3_3_00 0x30300 // Support for ECDSA-256 and 64 bit addressing
#define TIM_3_4_00 0x30400 // Support for ECDSA-521
#define TIM_3_5_00 0x30500 // Support for Encrypted Boot
const int MAX_HASH = 256;
const int MAX_HASH_IN_BITS = 512; // 512 bits
// B1 TIM
#include "Typedef.h"
#define MAX_IMAGES 100
#define MAX_KEYS 3
#define MAX_TIM_SIZE 0x1000
#define TIMBUFFER 4096 //4k for a Tim structure size
#define MAXKEYSIZEWORDS 64 // 2048 bits
#define MAXRSAKEYSIZEWORDS 64 // 2048 bits
#define MAXECCKEYSIZEWORDS 17 // 521 bits+
// Predefined Image Identifiers
#define TIMIDENTIFIER 0x54494D48 // "TIMH"
#define TIM1IDENTIFIER 0x54494D31 // "TIM1"
#define TIM4IDENTIFIER 0x54494D34 // "TIM4"
#define WTMIDENTIFIER 0x57544D49 // "WTMI"
#define OBMIDENTIFIER 0x4F424D49 // "OBMI"
#define MONITORIDENTIFIER 0x4D4F4E49 // "MONI"
#define TZSWIDENTIFIER 0x545A5349 // "TZSI" This is also used as consumer ID
#define TBRIDENTIFIER 0x54425249 // "TBRI" This is also used as consumer ID
#define DKBIDENTIFIER 0x444B4249 // "DKBI"
#define JTAGIDENTIFIER 0x4A544147 // "JTAG"
#define AUTHIDENTIFIER 0x41555448 // "AUTH"
#define PATCHIDENTIFIER 0x50415443 // "PATC"
#define TCAIDENTIFIER 0x5443414B // "TCAK"
#define OSLOADERID 0x4F534C4F // "OSLO"
#define ROMC 0x524F4D43 // "ROMC"
#define DSIGIDENTIFIER 0x44534947 // "DSIG"
#define ENCKIDENTIFIER 0x454E434B // "ENCK"
// WTP Format Recognized Reserved Area Indicator
#define WTPRESERVEDAREAID 0x4F505448 // "OPTH"
// Reserved Area Package Headers
#define AUTOBIND 0x42494E44 // "BIND"
#define TERMINATORID 0x5465726D // "Term"
#define GPIOID 0x4750494F // "GPIO"
#define UARTID 0x55415254 // "UART"
#define USBID 0x00555342 // "USB"
#define RESUMEID 0x5265736D // "Resm"
#define USBVENDORREQ 0x56524551 // "VREQ"
#define TBR_XFER 0x54425258 // "TBRX"
#define RESUMEBLID 0x52736D32 // "Rsm2"
#define ESCAPESEQID 0x45534353 // "ESCS"
#define ESCSEQID_v2 0x45537632 // "ESv2" Escape Sequence Version 2
#define OEMCUSTOMID 0x43555354 // "CUST"
#define NOMONITORID 0x4E4F4D43 // "NOMC"
#define COREID 0x434F5245 // "CORE"
#define BBMTID 0x42424D54 // "BBMT"
#define QNXBOOT 0x514E5850 // "QNXP"
#define GPP1ID 0x47505031 // "GPP1" Processed in RESERVEDAREA_State
#define GPP2ID 0x47505032 // "GPP2" Processed in XFER_State
#define ROMRESUMEID 0x52736D33 // "Rsm3"
#define PINID 0x50494E50 // "PINP"
#define IMAPID 0x494D4150 // "IMAP"
// DDR Related ID's
#define DDRID 0x44447248 // "DDrH"
#define DDRGID 0x44445247 // "DDRG"
#define DDRTID 0x44445254 // "DDRT"
#define DDRCID 0x44445243 // "DDRC"
#define CMCCID 0x434d4343 // "CMCC"
// trust zone package
#define CIDPID 0x43494450 // "CIDP"
#define TZRI 0x545A5249 // ”TZRI?#endif
// Operating mode related ID's
#define FREQID 0x46524551 // "FREQ"
#define VOLTID 0x564f4c54 // "VOLT"
#define OPMODEID 0x4d4f4445 // "MODE"
#define OPDIVID 0x4f504456 // "OPDV"
#define CLKEID 0x434c4b45 // "CLKE"
// trust zone package
#define TZID 0x545A4944 // "TZID"
#define TZON 0x545A4f4E // "TZON" Register based
#define FUNC 0x46554E43 // "FUNC"
#define PROI 0x50524F49 // "PROI"
#define ERASID 0x45524153 //ERAS
#define SKIPID 0x534B4950 //SKIP
// USB
#define DESCRIPTOR_RES_ID 0x55534200 // "USB"
#define NUM_USB_DESCRIPTORS 10
#define MAX_USB_STRINGS 7
#define NOFREQUENCYID 0x4E4F4643 // "NOFC"
#define NOKEYDETECTID 0x4E4F4B44 // "NOKD"
#define TRFU 0x54524655 //TR069 control info.
#define DTYP 0x44545950 //DDR type
#define LTWS 0x4C545753 //LTG LWG SELECT PACKAGE
#define OTAI 0x4F544149 //FOTA Info
#define DDR_FLASH_MCP_MAP_PACKAGE_ID 0X44464D50 // "DFMP"
#define CITA_CUMIZED_INFO_TRANSFER_TOAP_ID 0X43495441 // "CITA"
#define BBMTYPEID 0x42424D54 // "BBMT"
#define FLASH_GEO_PKG_ID 0x46475049 // "FGPI" Flash Geometry Package ID
#define BBCS 0x42424353 //Bad block report switch
#define CRCS 0x43524353 //CRC switch
/***************************************************************************
*
* New package for DDR auto adjust -- start
*
****************************************************************************/
#define DDRBYTESELECT 0x44444253 // "DDBS", ddr byte select
#define DDR_SAMSUNG_ID 0x49443031 // "ID01"
#define DDR_QIMONDA_ID 0x49443032 // "ID02"
#define DDR_ELPIDA_ID 0x49443033 // "ID03"
#define DDR_ETRON_ID 0x49443034 // "ID04"
#define DDR_NANYA_ID 0x49443035 // "ID05"
#define DDR_HYNIX_ID 0x49443036 // "ID06"
#define DDR_MOSEL_ID 0x49443037 // "ID07"
#define DDR_WINBOND_ID 0x49443038 // "ID08"
#define DDR_ESMT_ID 0x49443039 // "ID09"
#define DDR_RESERVED_ID 0x49443041 // "ID0A"
#define DDR_SPANSION_ID 0x49443042 // "ID0B"
#define DDR_SST_ID 0x49443043 // "ID0C"
#define DDR_ZMOS_ID 0x49443044 // "ID0D"
#define DDR_INTEL_ID 0x49443045 // "ID0E"
#define DDR_NUMONYX_ID 0x49443046 // "ID0F"
#define DDR_MICRON_ID 0x49443130 // "ID10"
#define DDR_TOSHIBA_ID 0x49443131 // "ID11"
typedef enum
{
eUSB_DEVICE_DESCRIPTOR = (DESCRIPTOR_RES_ID | 0),
eUSB_CONFIG_DESCRIPTOR = (DESCRIPTOR_RES_ID | 1),
eUSB_INTERFACE_DESCRIPTOR = (DESCRIPTOR_RES_ID | 2),
eUSB_LANGUAGE_STRING_DESCRIPTOR = (DESCRIPTOR_RES_ID | 3),
eUSB_MANUFACTURER_STRING_DESCRIPTOR = (DESCRIPTOR_RES_ID | 4),
eUSB_PRODUCT_STRING_DESCRIPTOR = (DESCRIPTOR_RES_ID | 5),
eUSB_SERIAL_STRING_DESCRIPTOR = (DESCRIPTOR_RES_ID | 6),
eUSB_INTERFACE_STRING_DESCRIPTOR = (DESCRIPTOR_RES_ID | 7),
eUSB_DEFAULT_STRING_DESCRIPTOR = (DESCRIPTOR_RES_ID | 8),
eUSB_ENDPOINT_DESCRIPTOR = (DESCRIPTOR_RES_ID | 9)
} USB_DESCRIPTORS;
typedef enum
{
COREID_MP1 = 0,
COREID_MP2 = 1,
COREID_MM = 2
}
COREID_T;
typedef enum
{
BBMT_TYPE_NO_BBM = 0,
BBMT_TYPE_LEGACY = 1,
BBMT_TYPE_MARVELL_FM_V1 = 2,
BBMT_TYPE_MARVELL_FM_V2 = 3
}
BBMT_TYPE_T;
// Global Identifiers
#define FFIDENTIFIER 0x00004646 // "FF"
#define ALTIDENTIFIER 0x00414C54 // "ALT"
#define DIFFIDENTIFIER 0x44696666 // "Diff"
#define SEIDENTIFIER 0x00005345 // "SE"
#define U2DIDENTIFIER 0x55534232 // "USB2"
#define PINSIDENTIFIER 0x50696E73 // "Pins"
#define MDOCFORMATID 0x6d444f43 // "mDOC"
#define MDOCBINID 0x6d42944E // "mBIN"
#define MDOCBDTLID 0x6d424454 // "mBDT"
#define CI2IDENTIFIER 0x00434932 // "CI2"
#define OTGIDENTIFIER 0x554F5447 // "UOTG"
#define INVALIDID 0x21212121 // "!!!!" Should never appear in actual TIM file
#define PARTIONIDENTIFIER 0x50415254 // "PART"
// identifier for common tools Marvell Format image file
#define FBFIDENTIFIER 0x46424649 // "FBFI" Should never appear in actual TIM file
// Miscellanous
#define BINDKEYSIZE 128 // (MAXKEYSIZEWORDS * 2)
#define FLASHSIGMASK 0x0000000F // mask off the 4 bits of platform state
typedef enum INSTRUCTION_OP_CODE_SPEC_E
{
// Enums specify the following:
INSTR_NOP = 0,
INSTR_WRITE = 1,
INSTR_READ = 2 ,
INSTR_DELAY = 3,
INSTR_WAIT_FOR_BIT_SET = 4,
INSTR_WAIT_FOR_BIT_CLEAR = 5,
INSTR_AND_VAL = 6,
INSTR_OR_VAL = 7,
// new DDR Script instructions
INSTR_SET_BITFIELD = 8,
INSTR_WAIT_FOR_BIT_PATTERN = 9,
INSTR_TEST_IF_ZERO_AND_SET = 10,
INSTR_TEST_IF_NOT_ZERO_AND_SET = 11,
INSTR_LOAD_SM_ADDR = 12,
INSTR_LOAD_SM_VAL = 13,
INSTR_STORE_SM_ADDR = 14,
INSTR_MOV_SM_SM = 15,
INSTR_RSHIFT_SM_VAL = 16,
INSTR_LSHIFT_SM_VAL = 17,
INSTR_AND_SM_VAL = 18,
INSTR_OR_SM_VAL = 19,
INSTR_OR_SM_SM = 20,
INSTR_AND_SM_SM = 21,
INSTR_TEST_SM_IF_ZERO_AND_SET = 22,
INSTR_TEST_SM_IF_NOT_ZERO_AND_SET = 23,
// conditional execution branch and subroutine call instructions
INSTR_LABEL = 24,
INSTR_TEST_ADDR_AND_BRANCH = 25,
INSTR_TEST_SM_AND_BRANCH = 26,
INSTR_BRANCH = 27,
// Interpreter Directives
INSTR_END = 28,
//Add/Subtract
INSTR_ADD_SM_VAL = 29,
INSTR_ADD_SM_SM = 30,
INSTR_SUB_SM_VAL = 31,
INSTR_SUB_SM_SM = 32,
INSTR_LOAD_SM_FROM_ADDR_IN_SM = 33,
INSTR_STORE_SM_TO_ADDR_IN_SM = 34,
// New values go above here
INSTRUCTION_OP_CODE_E_MAX,
// These enums identify pseudo op code that
// are used by tools for syntax shortcuts. The
// bootrom does not recognize the pseudo op
// code. When TBB is writing the TIM.bin, the pseudo
// op codes are converted to one or more instructions
// using the above INSTRUCTION_OP_CODE_SPEC_T enums.
// pseudo instruction op codes used only by tools
// Enums specify the following:
INSTRUCTION_PSEUDO_OP_CODE_E_MIN = 10000,
INSTR_PP_WRITE = 10001,
INSTR_PP_TABLEHEADER = 10002,
// New values go above here
INSTRUCTION_PSEUDO_OP_CODE_E_MAX,
} INSTRUCTION_OP_CODE_SPEC_T;
typedef struct
{
unsigned int InstructionId; // InstructionID determines # of params for defined instructions
unsigned int Parameter; // first of the variable sized list of Parameters[ MAX_NUMBER_PARAMS = 3 ]
} INSTRUCTION_S, *pINSTRUCTION_S;
typedef struct
{
unsigned int OpId;
unsigned int OpValue;
} TZ_OPERATION, *pTZ_OPERATION;
typedef enum TZ_OPERATION_SPEC_E
{
TZ_NOP = 0, // Enums specify the following:
TZ_CONFIG_ENABLE, // TZ config enable flag (1 = configure)
// New values go above here
TZ_OPERATION_SPEC_E_MAX
} TZ_OPERATION_SPEC_T;
typedef enum DDR_OPERATION_SPEC_E
{
DDR_NOP = 0, // Enums specify the following:
DDR_INIT_ENABLE, // DDR init flag (1 = init)
DDR_MEMTEST_ENABLE, // DDR Memtest flag (1 = test)
DDR_MEMTEST_START_ADDR, // Memtest start addr (Current default is 0)
DDR_MEMTEST_SIZE, // NumBytes to test (Current default is 2K)
DDR_INIT_LOOP_COUNT, // Loop Count for initialization attempts
DDR_IGNORE_INST_TO, // Treat a time out waiting for a bit to set/clear
// as informational only, operation continues
// New values go above here
DDR_OPERATION_SPEC_E_MAX
} DDR_OPERATION_SPEC_T;
/********** WTP Recognized Reserved Area Layout ********************************
*
* WTPTP_Defined_Reserved_Format_ID \ This clues BR, OBM and DKB that the reserved area is in a known format
* Number of Reserved Area Packages / For each package there is a header, payload size and payload
*
* Header \ Indicates what type of a Reserved Area Package
* Size \ Size Comprises a single Reserved Area Package
* Payload / There may be any number of Packages so long as TIM/NTIM < 4KB
* /
*
* Header \ The Last one should be a Package with a Terminator Header
* Size / The size should be 8 bytes (the size of this package)
*
**********************************************************************************/
typedef struct
{
UINT_T WTPTP_Reserved_Area_ID; // This clues BR, OBM and DKB that the reserved area is in a known format
UINT_T NumReservedHeaders; // For each package there is a header, payload size and payload
}WTP_RESERVED_AREA, *pWTP_RESERVED_AREA;
typedef struct
{
UINT_T Identifier; // Identification of this reserved area entry
UINT_T Size; // Size = Payload Size + 2 words (8 bytes).
}WTP_RESERVED_AREA_HEADER, *pWTP_RESERVED_AREA_HEADER;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T bmRequestType;
UINT_T bRequest;
UINT_T wValue;
UINT_T wIndex;
UINT_T wLength;
UINT_T wData; // First word of the proceeding Data. Note, there may be more traialing data
} USB_VENDOR_REQ, *pUSB_VENDOR_REQ; // There is no restriction that data need be 32 bit aligned.
typedef struct
{
volatile int *Addr;
UINT_T Value;
}GPIO_DEF, *pGPIO_DEF;
// General Purpose Patch (GPPx) related structures
typedef struct
{
unsigned int OpId;
unsigned int OpValue;
} GPP_OPERATION, *pGPP_OPERATION;
typedef enum GPP_OPERATION_SPEC_E
{
GPP_NOP = 0, // Enums specify the following:
GPP_IGNORE_INST_TO = 6, // Treat a time out waiting for a bit to set/clear
// as informational only, operation continues
// New values go above here
GPP_OPERATION_SPEC_E_MAX
} GPP_OPERATION_SPEC_T;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
unsigned int NumberOperations;
unsigned int NumberInstructions;
GPP_OPERATION GPP_Operations; // GPP_Op[NumberOperations];
INSTRUCTION_S GPP_Instructions; // GPP_Instruction[NumberInstructions];
} GPP_PACKAGE, *pGPP_PACKAGE;
// End General Purpose Patch related structures
#if 0 // requires general.h
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T XferLoc; //location to put the XFER table
UINT_T NumPairs;
XFER_DATA_PAIR_T pXferPairs[0];
}}OPT_XFER_SET, *pOPT_XFER_SET;
#endif
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T Port;
UINT_T Enabled; // 1 - Enabled
}OPT_PROTOCOL_SET, *pOPT_PROTCOL_SET;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T EscSeqTimeOutMS; // Value is interpreted in milli secs.
}OPT_ESCAPE_SEQUENCE, *P_OPT_ESCAPE_SEQUENCE;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T Enable; // enable TR069 firmware upgrade or not
UINT_T FlashAddr; // flash address to store FBF header
UINT_T Magic; // Magic number of FBF header
}TR069_INFO, *pTR069_INFO;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T Type;
}DDR_Type, *pDDR_Type;
typedef struct
{
UINT MFPR_address;
UINT MFPR_value;
} MFPR_PAIR_T, *pMFPR_PAIR_T;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T GPIO_number; //GPIO to check
UINT_T GPIO_trigger_val; //value of GPIO to trigger the escape sequence
UINT_T num_MFPR_pairs; //number of MFPR pairs contained in this package
MFPR_PAIR_T mfpr_pairs[1]; //MFPR address/value pairs: array will be of size 'num_MFPR_pairs"
} OPT_ESC_SEQ_v2, *P_OPT_ESC_SEQ_v2;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T NumGpios;
pGPIO_DEF GPIO;
}OPT_GPIO_SET, *pOPT_GPIO_SET;
typedef struct
{
UINT_T ResumeAddr;
UINT_T ResumeParam;
UINT_T ResumeFlag;
}OPT_RESUME_DDR_INFO, *pOPT_RESUME_DDR_INFO;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
OPT_RESUME_DDR_INFO ResumeDDRInfo;
// pOPT_RESUME_DDR_INFO pResumeDDRInfo;
}OPT_RESUME_SET, *pOPT_RESUME_SET;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T ACCR_VALUE;
UINT_T MDCNFG_VALUE;
UINT_T DDR_HCAL_VALUE;
UINT_T MDREFR_VALUE;
}OPT_DDR_SET, *pOPT_DDR_SET;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T ImageAddr;
// UINT_T ImageSize;
// UINT_T ImageCRC;
}OPT_RESM_LOC, *pOPT_RESM_LOC;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH;
UINT_T AutoBind;
}OPT_AUTOBIND, *pOPT_AUTOBIND;
/**** Used only for backwards compatability!!! ***/
typedef struct
{
UINT_T Identifier;
UINT_T PortType;
UINT_T Port;
UINT_T GPIOPresent;
UINT_T NumGpios;
pGPIO_DEF GPIO;
}OPT_SET, *pOPT_SET;
//mDOC general formatting parameters
// look in flstruct.h and flcommon.h
// for parameter definitions
// not spelled out here
//----------------------------------
typedef struct
{ /* byte totals */
WTP_RESERVED_AREA_HEADER WRAH; /*0x08 bytes */
UINT_T percentUse; /*0x0C */ /* NAND flash inherently contains some bad blocks. TrueFFS handles
* those blocks by managing a pool of spare blocks also called transfer
* units. This format parameter specifies the percentage of the media
* to use. Starting from TrueFFS 6.3.0 alpha 4 this field is no longer a
* configurable formatting argument. You must set this field to
* TL_DEFAULT_PERCENTAGE = 0, letting TrueFFS to choose this value for you. */
UINT_T noOfBDTLPartitions; /*0x10 */ /* Indicates the number of Disk partition (1 to 4). */
UINT_T noOfBinaryPartitions; /*0x14 */ /* Indicates the number of binary partitions (up to 3). 0 will
* cause formatting with no binary partition. This value is ignored
* if TL_LEAVE_BINARY_AREA flag is set in the irFlags field the ioreq */
UINT_T cascadedDeviceNo; /*0x18*/ /* Not used */
UINT_T noOfCascadedDevices; /*0x1C*/ /* Not used */
UINT_T progressCallback; /*0x20*/ /* Progress callback routine, will be called if not NULL.
The callback routine is called after erasing each unit,
and its parameters are the total number of erase units
to format and the number erased so far.
The callback routine returns a Status value. A value of
OK (0) allows formatting to continue. Any other value
will abort the formatting with the returned status code. */
/* In case the FL_REPORT_MOUNT_PROGRESS compilation flag is set the
routine will also report the mount progress of the mount routine
for each of the Disk partitions. A 0,0 return values will report
the end of a format status and of a mount operation */
UINT_T FP_0_RFU_0; /*0x24*/ /* Reserved 0 */
UINT_T FP_1_RFU_0; /*0x28*/ /* Reserved 0 */
/* Note the following section is not used by for DiskOnChips */
/*************************************************************/
UINT_T bootImageLen; /*0x2C*/ /* Reserved 0 */
UINT_T vmAddressingLimit; /*0x30*/ /* Reserved 0 */
UINT_T embeddedCISlength; /*0x34*/ /* Reserved 0 */
UINT_T *embeddedCIS; /*0x38*/ /* Reserved NULL */
}MDOC_FORMAT_INFO, *pMDOCFORMAT_INFO;
//mDOC BDTL partition type
//------------------------
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH; /*0x08 bytes */
UINT_T length; /*0x0c */ /* The size in bytes of the usable storage space. The size
rounded upwards to a multiplication of a block size.
The size of the last partition will calculated automatically,
but if the requested size is greater then the remaining space
an error code will be returned,. Requesting zero size for any
partition but the last will generate an flBadParameters status. */
UINT_T fastAreaLength; /*0x10*/
UINT_T lengthType; /*0x14*/
UINT_T fastAreaLengthType; /*0x18*/
UINT_T fastAreaVirtualFactor; /*0x1C*/ /* Should be set to FL_NORMAL_SPACING = 1 */
UINT_T noOfSpareUnits; /*0x20*/ /* BDTL needs at least one spare erase unit in order to function
as a read/write media. It is possible to specify more than one
spare unit, which takes more media space. The advantage of
specifying more than one spare unit is that if one of the flash
erase units becomes bad and un-erasable in the future, then one
of the spare units can replace it. In that case, a second spare
unit enables TrueFFS to continue its read/write functionality,
whereas if no second spare unit is available the media goes into
read-only mode. The standard value used is 3 */
UINT_T BDTLFP_0_RFU_0; /*0x24*/ /* Reserved 0 */
UINT_T BDTLFP_1_RFU_0; /*0x28*/ /* Reserved 0 */
UINT_T BDTLFP_2_RFU_0; /*0x2C*/ /* Reserved 0 */
UINT_T BDTLFP_3_RFU_0; /*0x30*/ /* Reserved 0 */
UINT_T protectionKey[8]; /*0x50*/ /* The key for the protection*/
UINT_T protectionType; /*0x54*/ /* PROTECTABLE - Can receive protection */
/* READ_PROTECTED - Protect against read operations */
/* WRITE_PROTECTED - Protect against write operations */
/* LOCK_ENABLED - Enables the hardware lock signal */
/* PROTECTABLE - This partition can be protected */
/* CHANGEABLE_PROTECTION - protection type can be changed */
/* The ratio between the real media size and the virtual size
reported to the file system when compression is active. */
}MDOC_BDTL_PARTITION, *pMDOC_BDTL_PARTITION;
//mDOC binary partition type
//------------------------
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH; /*0x08 bytes */
UINT_T length; /*0x0c*/ /* Required number of usable bytes (rounded to units) */
/* in the partition. */
UINT_T lengthType; /*0x10*/ /* Must be FL_LENGTH_IN_BYTES = 0 */
UINT_T sign[4]; /*0x20*/ /* signature of the binary partition to format. Typically "BIPO"
The signature 0xFFFF FFFF is not a valid signature */
UINT_T flags; /*0x24*/ /* TL_NORMAL_FORMAT=0 / TL_SPL_FORMAT=0xF0 */
UINT_T spareBlocks; /*0x28*/ /* Spare blocks for DBB support, should be at least 1 */
UINT_T BDKFP_0_RFU_0; /*0x2C*/ /* Reserved 0 */
UINT_T BDKFP_1_RFU_0; /*0x30*/ /* Reserved 0 */
UINT_T BDKFP_2_RFU_0; /*0x34*/ /* Reserved 0 */
UINT_T BDKFP_3_RFU_0; /*0x38*/ /* Reserved 0 */
UINT_T protectionKey[8]; /*0x58*/ /* The key for the protection*/
UINT_T protectionType; /*0x5C*/ /* PROTECTABLE - Can receive protection */
/* READ_PROTECTED - Protect against read operations */
/* WRITE_PROTECTED - Protect against write operations */
/* LOCK_ENABLED - Enables the hardware lock signal */
/* PROTECTABLE - This partition can be protected */
/* CHANGEABLE_PROTECTION - protection type can be changed */
}MDOC_BINARY_PARTITION, *pMDOC_BINARY_PARTITION;
/*********************************************************************************/
typedef enum
{
PlatformVerificationKey,
NetworkOperatorCAKey,
SoftwareUpdateCAKey,
DRMDeviceCAKey,
OEMReservedKey1,
OEMReservedKey2,
NUMKEYMODULES
}
KEYMODULES_T;
typedef enum
{
Marvell_DS = 0,
PKCS1_v1_5_Caddo = 1,
PKCS1_v2_1_Caddo = 2,
PKCS1_v1_5_Ippcp = 3,
PKCS1_v2_1_Ippcp = 4,
ECDSA_256 = 5,
ECDSA_521 = 6
}
ENCRYPTALGORITHMID_T;
#define Intel_DS Marvell_DS
typedef enum
{
MRVL_SHA160 = 20,
MRVL_SHA256 = 32,
MRVL_SHA512 = 64
}
HASHALGORITHMID_T;
typedef struct
{
UINT_T Version;
UINT_T Identifier; // "TIMH"
UINT_T Trusted; // 1- Trusted, 0 Non
UINT_T IssueDate;
UINT_T OEMUniqueID;
} VERSION_I, *pVERSION_I; // 0x10 bytes
typedef struct
{
UINT_T WTMFlashSign;
UINT_T WTMEntryAddr;
UINT_T WTMEntryAddrBack;
UINT_T WTMPatchSign;
UINT_T WTMPatchAddr;
UINT_T BootFlashSign;
} FLASH_I, *pFLASH_I; // 0x10 bytes
typedef struct
{
UINT_T KeyID; // Associate an ID with this key
UINT_T HashAlgorithmID; // See HASHALGORITHMID_T
UINT_T ModulusSize; // 1024 bit or 2048 bit keys
UINT_T PublicKeySize;
UINT_T RSAPublicExponent[MAXKEYSIZEWORDS]; // Contents depend on PublicKeySize
UINT_T RSAModulus[MAXKEYSIZEWORDS];// Up to 2K bits
UINT_T KeyHash[8]; // Reserve 256 bits for the hash
} KEY_MOD, *pKEY_MOD; // 0x22C bytes
typedef struct
{
UINT_T ImageID; // Indicate which Image
UINT_T NextImageID; // Indicate next image in the chain
UINT_T FlashEntryAddr; // Block numbers for NAND
UINT_T LoadAddr;
UINT_T ImageSize;
UINT_T ImageSizeToHash;
UINT_T HashAlgorithmID; // See HASHALGORITHMID_T
UINT_T Hash[8]; // Reserve 256 bits for the hash
UINT_T PartitionNumber; // This is new for V3.2.0
} IMAGE_INFO_3_2_0, *pIMAGE_INFO_3_2_0; // 0x40 bytes
typedef struct
{
UINT_T ImageID; // Indicate which Image
UINT_T NextImageID; // Indicate next image in the chain
UINT_T FlashEntryAddr; // Block numbers for NAND
UINT_T LoadAddr;
UINT_T ImageSize;
UINT_T ImageSizeToHash;
UINT_T HashAlgorithmID; // See HASHALGORITHMID_T
UINT_T Hash[8]; // Reserve 256 bits for the hash
} IMAGE_INFO_3_1_0, *pIMAGE_INFO_3_1_0; // 0x3C bytes
typedef struct
{
UINT_T ImageID; // Indicate which Image
UINT_T NextImageID; // Indicate next image in the chain
UINT_T FlashEntryAddr; // Block numbers for NAND
UINT_T LoadAddr;
UINT_T ImageSize;
UINT_T ImageSizeToHash;
UINT_T HashAlgorithmID; // See HASHALGORITHMID_T
UINT_T Hash[16]; // Reserve 512 bits for the hash, this is new for V3.4.0
UINT_T PartitionNumber;
} IMAGE_INFO_3_4_0, *pIMAGE_INFO_3_4_0; // 0x60 bytes
typedef struct
{
UINT_T ImageID; // Indicate which Image
UINT_T NextImageID; // Indicate next image in the chain
UINT_T FlashEntryAddr; // Block numbers for NAND
UINT_T LoadAddr;
UINT_T ImageSize;
UINT_T ImageSizeToHash;
HASHALGORITHMID_T HashAlgorithmID; // See HASHALGORITHMID_T
UINT_T Hash[16]; // Reserve 512 bits for the hash
UINT_T PartitionNumber;
ENCRYPTALGORITHMID_T EncAlgorithmID; // See ENCRYPTALGORITHMID_T
UINT_T EncryptStartOffset;
UINT_T EncryptSize;
} IMAGE_INFO_3_5_0, *pIMAGE_INFO_3_5_0; // 0x60 bytes
typedef struct
{
UINT_T KeyID; // Associate an ID with this key
UINT_T HashAlgorithmID; // 160 - SHA1, 256 - SHA2
UINT_T KeySize; // Specified in bits
UINT_T PublicKeySize; // Specified in bits
UINT_T RSAPublicExponent[MAXRSAKEYSIZEWORDS]; // Contents depend on PublicKeySize
UINT_T RSAModulus[MAXRSAKEYSIZEWORDS]; // Up to 2K bits
UINT_T KeyHash[8]; // Reserve 256 bits for the hash
} KEY_MOD_3_1_0, *pKEY_MOD_3_1_0; // 0x22C bytes
typedef struct
{
UINT_T KeyID; // Associate an ID with this key
HASHALGORITHMID_T HashAlgorithmID; // See HASHALGORITHMID_T
UINT_T KeySize; // Specified in bits
UINT_T PublicKeySize; // Specified in bits
UINT_T RSAPublicExponent[MAXRSAKEYSIZEWORDS]; // Contents depend on PublicKeySize
UINT_T RSAModulus[MAXRSAKEYSIZEWORDS]; // Up to 2K bits
UINT_T KeyHash[8]; // Reserve 256 bits for the hash
} KEY_MOD_3_2_0, *pKEY_MOD_3_2_0; // 0x22C bytes
#if RVCT
#pragma anon_unions
#endif
typedef struct
{
UINT_T KeyID; // Associate an ID with this key
HASHALGORITHMID_T HashAlgorithmID; // See HASHALGORITHMID_T
UINT_T KeySize; // Specified in bits
UINT_T PublicKeySize; // Specified in bits
ENCRYPTALGORITHMID_T EncryptAlgorithmID; // See ENCRYPTALGORITHMID_T;
union
{
struct
{
UINT_T RSAPublicExponent[MAXRSAKEYSIZEWORDS]; // Contents depend on PublicKeySize
UINT_T RSAModulus[MAXRSAKEYSIZEWORDS]; // Up to 2K bits
}Rsa;
struct
{
UINT_T PublicKeyCompX[MAXECCKEYSIZEWORDS]; // Contents depend on PublicKeySize
UINT_T PublicKeyCompY[MAXECCKEYSIZEWORDS]; // Up to 521 bits
// Pad this struct so it remains consistent with RSA struct
UINT_T Reserved[(2*MAXRSAKEYSIZEWORDS)-(2*MAXECCKEYSIZEWORDS)];
}Ecdsa;
};
UINT_T KeyHash[8]; // Reserve 256 bits for the hash
} KEY_MOD_3_3_0, *pKEY_MOD_3_3_0; //
// use EncryptedBitMask to access bit 31 of EncryptedAlgorithmID
// if bit 31 == 0 the access KEY_MOD_3_4_0 using the Rsa or Ecdsa structs
// if bit 31 == 1 the access KEY_MOD_3_4_0 using the EncryptedRsa or Encrypted Ecdsa structs
#define EncryptedBitMask 0x80000000
typedef struct
{
UINT_T KeyID; // Associate an ID with this key
HASHALGORITHMID_T HashAlgorithmID; // See HASHALGORITHMID_T
UINT_T KeySize; // Specified in bits
UINT_T PublicKeySize; // Specified in bits
ENCRYPTALGORITHMID_T EncryptAlgorithmID; // See ENCRYPTALGORITHMID_T;
union
{
struct
{
UINT_T RSAPublicExponent[MAXRSAKEYSIZEWORDS]; // Contents depend on PublicKeySize
UINT_T RSAModulus[MAXRSAKEYSIZEWORDS]; // Up to 2K bits
}Rsa;
struct
{
UINT_T PublicKeyCompX[MAXECCKEYSIZEWORDS]; // Contents depend on PublicKeySize
UINT_T PublicKeyCompY[MAXECCKEYSIZEWORDS]; // Up to 521 bits
// Pad this struct so it remains consistent with RSA struct
UINT_T Reserved[(2*MAXRSAKEYSIZEWORDS)-(2*MAXECCKEYSIZEWORDS)];
}Ecdsa;
struct
{
UINT_T EncryptedHashRSAPublicExponent[MAXRSAKEYSIZEWORDS]; // Contents depend on PublicKeySize
UINT_T EncryptedHashRSAModulus[MAXRSAKEYSIZEWORDS]; // Up to 2K bits
}EncryptedRsa;
struct
{
UINT_T EncryptedHashPublicKeyCompX_R[MAXECCKEYSIZEWORDS]; // Contents depend on PublicKeySize
UINT_T EncryptedHashPublicKeyCompX_S[MAXECCKEYSIZEWORDS]; // Contents depend on PublicKeySize
UINT_T EncryptedHashPublicKeyCompY_R[MAXECCKEYSIZEWORDS]; // Up to 521 bits
UINT_T EncryptedHashPublicKeyCompY_S[MAXECCKEYSIZEWORDS]; // Up to 521 bits
// Pad this struct so it remains consistent with encrypted RSA struct
UINT_T Reserved[(2 * MAXRSAKEYSIZEWORDS)-(4 * MAXECCKEYSIZEWORDS)];
}EncryptedEcdsa;
};
UINT_T KeyHash[16]; // Reserve 512 bits for the hash
} KEY_MOD_3_4_0, *pKEY_MOD_3_4_0; //
typedef struct
{
ENCRYPTALGORITHMID_T DSAlgorithmID; // See ENCRYPTALGORITHMID_T
HASHALGORITHMID_T HashAlgorithmID; // See HASHALGORITHMID_T
UINT_T KeySize; // Specified in bits
UINT_T Hash[8]; // Reserve 256 bits for the hash
union // Note that this union should not be included as part of the hash for TIM in the Digital Signature
{
struct
{
UINT_T RSAPublicExponent[MAXRSAKEYSIZEWORDS];
UINT_T RSAModulus[MAXRSAKEYSIZEWORDS]; // Up to 2K bits
UINT_T RSADigS[MAXRSAKEYSIZEWORDS]; // Contains TIM Hash
}Rsa;
struct
{
UINT_T ECDSAPublicKeyCompX[MAXECCKEYSIZEWORDS]; // Allow for 544 bits (17 words, 68 bytes for use with EC-521)
UINT_T ECDSAPublicKeyCompY[MAXECCKEYSIZEWORDS];
UINT_T ECDSADigS_R[MAXECCKEYSIZEWORDS];
UINT_T ECDSADigS_S[MAXECCKEYSIZEWORDS];
UINT_T Reserved[(MAXRSAKEYSIZEWORDS*3)-(MAXECCKEYSIZEWORDS*4)];
} Ecdsa;
};
} PLAT_DS, *pPLAT_DS; // 0x780 bytes
// Constant part of the TIMs
typedef struct
{
VERSION_I VersionBind; // 0
FLASH_I FlashInfo; // 0x10
UINT_T NumImages; // 0x20
UINT_T NumKeys; // 0x24
UINT_T SizeOfReserved; // 0x28
} CTIM, *pCTIM; // 0x2C
// TIM structure for use by DKB/OBM/BootROM
/*typedef struct
{
pCTIM pConsTIM; // Constant part
pIMAGE_INFO pImg; // Pointer to Images
pKEY_MOD pKey; // Pointer to Keys
PUINT pReserved; // Pointer to Reserved Area
pPLAT_DS pTBTIM_DS; // Pointer to Digital Signature
}
TIM, *pTIM;*/
// NTIM structure for use by DKB/OBM/BootROM
typedef struct
{
pCTIM pConsTIM; // Constant part
pIMAGE_INFO_3_1_0 pImg; // Pointer to Images
PUINT pReserved; // Pointer to Reserved Area
} NTIM_3_1_0, *pNTIM_3_1_0;
typedef struct
{
pCTIM pConsTIM; // Constant part
pIMAGE_INFO_3_2_0 pImg; // Pointer to Images
PUINT pReserved; // Pointer to Reserved Area
} NTIM_3_2_0, *pNTIM_3_2_0;
typedef struct
{
pCTIM pConsTIM; // Constant part
pIMAGE_INFO_3_4_0 pImg; // Pointer to Images
PUINT pReserved; // Pointer to Reserved Area
} NTIM_3_4_0, *pNTIM_3_4_0;
// Defined for DTIM support 2012-3
typedef enum
{
PRIMARYIMAGE = 0, // Primary image
RECOVERYIMAGE = 1, // Recovery image
CPIMAGE = 2 , // CP image
PPSETINGIMAG = 3, //PP Setting image
MARVELL_RESERVED_MAX = 9 ,
CUSTMOZIEDIMAGE_TYPE1 = 10,
CUSTMOZIEDIMAGE_TYPE2 = 11,
CUSTMOZIEDIMAGE_TYPE3 = 12,
CUSTMOZIEDIMAGE_TYPE4 = 13,
CUSTMOZIEDIMAGE_TYPE5 = 14,
CUSTMOZIEDIMAGE_TYPE6 = 15,
CUSTMOZIEDIMAGE_TYPE7 = 16,
CUSTMOZIEDIMAGE_TYPE8 = 17,
CUSTMOZIEDIMAGE_TYPE9 = 18,
CUSTMOZIEDIMAGE_TYPE10 = 19,
CUSTMOZIEDIMAGE_TYPE11 = 20,
CUSTMOZIEDIMAGE_TYPE12 = 21,
CUSTMOZIEDIMAGE_TYPE13 = 22,
CUSTMOZIEDIMAGE_TYPE14 = 23,
CUSTMOZIEDIMAGE_TYPE15 = 24,
CUSTMOZIEDIMAGE_TYPE16 = 25,
CUSTMOZIEDIMAGE_TYPE17 = 26,
CUSTMOZIEDIMAGE_TYPE18 = 27,
CUSTMOZIEDIMAGE_TYPE19 = 28,
CUSTMOZIEDIMAGE_TYPE20 = 29,
CUSTMOZIEDIMAGE_TYPE_MAX = 50,
} OTA_IMAGE_TYPE;
typedef struct
{
UINT_T ImageID; // 0x54494Dxx - secondary tim ID (TIMx)
OTA_IMAGE_TYPE ImageType; // OTA_IMAGE_TYPE (Primary VS Recovery)
UINT_T FlashEntryAddr[2]; // Reserve 2 words for future compatibility
UINT_T PartitionNumber; // Partition # in the flash
} IMG_MAP_INFO, *pIMG_MAP_INFO;
typedef struct
{
WTP_RESERVED_AREA_HEADER WRAH; // Let it contain IMAP as package ID
UINT_T NumberOfMappedImages; // Number of images with mapping information
IMG_MAP_INFO pImgMapInfo[1]; // First image map information struct
} IMAGE_MAP, *pIMAGE_MAP;
#endif
-36
View File
@@ -1,36 +0,0 @@
#pragma once
typedef enum
{
TIMH_NOTINC = 0,
TIMH_INC = 1,
DTIM_PRIMARY = 2,
DTIM_RECOVERY = 3,
DTIM_CP = 4,
TIMH_RECOVERYINC = 5,
DTIM_PPINFO = 6,
DTIM_CUSTMOZIEDTYPE1 = 10,
DTIM_CUSTMOZIEDTYPE2 = 11,
DTIM_CUSTMOZIEDTYPE3 = 12,
DTIM_CUSTMOZIEDTYPE4 = 13,
DTIM_CUSTMOZIEDTYPE5 = 14,
DTIM_CUSTMOZIEDTYPE6 = 15,
DTIM_CUSTMOZIEDTYPE7 = 16,
DTIM_CUSTMOZIEDTYPE8 = 17,
DTIM_CUSTMOZIEDTYPE9 = 18,
DTIM_CUSTMOZIEDTYPE10 = 19,
DTIM_CUSTMOZIEDTYPE11 = 20,
DTIM_CUSTMOZIEDTYPE12 = 21,
DTIM_CUSTMOZIEDTYPE13 = 22,
DTIM_CUSTMOZIEDTYPE14 = 23,
DTIM_CUSTMOZIEDTYPE15 = 24,
DTIM_CUSTMOZIEDTYPE16 = 25,
DTIM_CUSTMOZIEDTYPE17 = 26,
DTIM_CUSTMOZIEDTYPE18 = 27,
DTIM_CUSTMOZIEDTYPE19 = 28,
DTIM_CUSTMOZIEDTYPE20 = 29,
DKB_TIM = 100,
FBF_TIM = 101,
UNKOWN_TIMTYPE = 0xFF
}
TIMINCLUDEDTYPE_T;
-110
View File
@@ -1,110 +0,0 @@
/******************************************************************************
*
* (C)Copyright 2001-2009 Marvell. All Rights Reserved.
*
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MARVELL.
* The copyright notice above does not evidence any actual or intended
* publication of such source code.
* This Module contains Proprietary Information of Marvell and should be
* treated as Confidential.
* The information in this file is provided for the exclusive use of the
* licensees of Marvell.
* Such users have the right to use, modify, and incorporate this code into
* products for purposes authorized by the license agreement provided they
* include this notice and the associated copyright notice with any such
* product.
* The information in this file is provided "AS IS" without warranty.
*
******************************************************************************/
#ifndef _TYPEDEF_H_
#define _TYPEDEF_H_
#include "Macrodef.h"
typedef volatile unsigned long VUINT32_T;
typedef unsigned long UINT32_T;
typedef volatile unsigned int VUINT_T;
typedef unsigned int UINT_T;
typedef int INT_T;
typedef unsigned short UINT16_T, USHORT;
typedef volatile unsigned short VUINT16_T;
typedef unsigned char UINT8_T;
typedef char INT8_T;
typedef int BOOL;
#ifdef LINUX
typedef unsigned long *PDWORD;
typedef unsigned char *PBYTE;
typedef unsigned int UINT, *PUINT; // The size is not important
typedef unsigned long long UINT64, *PUINT64;
typedef unsigned int UINT32, *PUINT32;
typedef unsigned short UINT16, *PUINT16;
typedef unsigned char UINT8, *PUINT8;
typedef unsigned char UCHAR,BYTE,*PUCHAR;
typedef unsigned long DWORD;
typedef BYTE* LPBYTE;
typedef int INT, *PINT; // The size is not important
typedef long long INT64, *PINT64;
typedef int INT32, *PINT32;
typedef short INT16, *PINT16;
typedef signed char INT8, *PINT8;
#define VOID void
#define PVOID void*
#else
#include "stdafx.h"
#endif
#define LOCKED 1
#define UNLOCKED 0
typedef void(*FnPVOID)(void);
typedef volatile UINT VUINT, *PVUINT; // The size is not important
typedef volatile UINT64 VUINT64, *PVUINT64;
typedef volatile UINT32 VUINT32, *PVUINT32;
typedef volatile UINT16 VUINT16, *PVUINT16;
typedef volatile UINT8 VUINT8, *PVUINT8;
typedef volatile UCHAR VUCHAR, *PVUCHAR;
typedef volatile INT VINT, *PVINT; // The size is not important
typedef volatile INT64 VINT64, *PVINT64;
typedef volatile INT32 VINT32, *PVINT32;
typedef volatile INT16 VINT16, *PVINT16;
typedef volatile INT8 VINT8, *PVINT8;
typedef volatile CHAR VCHAR, *PVCHAR;
typedef struct{
UINT_T ErrorCode;
UINT_T StatusCode;
UINT_T PCRCode;
}FUNC_STATUS, *pFUNC_STATUS;
#ifdef LINUX
#ifdef _UNICODE
#define My_strcpy(a,b,c) wcscpy(a,c)
#else
#define My_strcpy(a,b,c) strcpy(a,c)
#endif
#else
#ifdef _UNICODE
#define My_strcpy(a,b,c) _tcscpy_s(a,b,c)
#else
#define My_strcpy(a,b,c) strcpy(a,c)
#endif
#endif// LINUX
#endif //_TYPEDEF_H_
-62
View File
@@ -1,62 +0,0 @@
#pragma once
#include "Macrodef.h"
#pragma pack(push,1)
typedef struct _UPLOAD_DATA_PARAMS
{
BYTE Type;
BYTE SubType;
BYTE Partition;
BYTE Times;// Total Number of upload Areas
unsigned int Offset;
unsigned int DataSize;
BYTE IncludeSpareAreas; // indicate this upload include spare areas or not
BYTE ResetUE;
BYTE ResetTimeDelay;
BYTE Reserved2; // 用来存放DataSize的高32位,支持一次性upload大于4GB的内容
} UPLOAD_DATA_PARAMS;
static void NEW_UPLOAD_DATA_PARAMS(UPLOAD_DATA_PARAMS *me){me->Reserved2 = 0;}
static void COPY_UPLOAD_DATA_PARAMS(UPLOAD_DATA_PARAMS *me,UPLOAD_DATA_PARAMS* UpLoadDataPara)
{
me->Type = UpLoadDataPara->Type;
me->SubType = UpLoadDataPara->SubType;
me->Partition = UpLoadDataPara->Partition;
me->Times = UpLoadDataPara->Times;
me->Offset = UpLoadDataPara->Offset;
me->DataSize = UpLoadDataPara->DataSize;
me->IncludeSpareAreas = UpLoadDataPara->IncludeSpareAreas; // indicate this upload include spare areas or not
me->ResetUE = UpLoadDataPara->ResetUE;
me->ResetTimeDelay = UpLoadDataPara->ResetTimeDelay;
me->Reserved2 = UpLoadDataPara->Reserved2;
}
#pragma pack(pop)
#pragma pack(push,1)
typedef struct _UPLOAD_DATA_SPEC
{
UPLOAD_DATA_PARAMS m_Params;
kstring_t strOutputFileName;
kstring_t strComparisonFileName;
BOOL bCreateNewFile;
} UPLOAD_DATA_SPEC,*pUPLOAD_DATA_SPEC;
static void NewUPLOAD_DATA_SPEC(pUPLOAD_DATA_SPEC me,struct _UPLOAD_DATA_SPEC* UpLoadDataSpec)
{
me->m_Params = UpLoadDataSpec->m_Params;
me->strOutputFileName = UpLoadDataSpec->strOutputFileName;
me->strComparisonFileName = UpLoadDataSpec->strComparisonFileName;
me->bCreateNewFile = UpLoadDataSpec->bCreateNewFile;
}
#pragma pack(pop)
#define __uds_free(x)
KLIST_INIT(pudsl,UPLOAD_DATA_SPEC*,__uds_free)
typedef klist_t(pudsl)* t_UpLoadDataSpecList;
typedef kliter_t(pudsl)* t_UpLoadDataSpecIter;
File diff suppressed because it is too large. Load diff
-113
View File
@@ -1,113 +0,0 @@
// WTPCOMMCLASS.h: interface for the CWtpComm class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_WTPCOMMCLASS_H__EFECE7AD_7863_476C_A5A5_65A1D728610A__INCLUDED_)
#define AFX_WTPCOMMCLASS_H__EFECE7AD_7863_476C_A5A5_65A1D728610A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <string.h>
#include "define.h"
#include "WTPdef.h"
#include "ParaDefine.h"
#include "ConvetEdian.h"
#include "ApplicationINI.h"
#include "BulkDevNonDrv_Linux.h"
static const PROTOCOL_VERSION TARGET_PROTOCOL_VERSION = {0x01, 0x01, 0x0000};
struct CWtpComm
{
/*void GetCustomizePreambleCmd(pWTPTPREAMBLECOMMAND pCustCmd);*/
struct CConvertLT2B MyConvertLT2B;
USB_HANDLE * m_pLinuxUsb;
int m_PortType;
int m_iPortNumber;
BYTE m_iSequence;
size_t m_BytesWritten, m_BytesRead;
long int m_liTimeout;
TCHAR m_szMessage[1024];
BOOL m_bVerbose;
BOOL m_bLogFile;
BOOL m_bMsg;
volatile int m_ThreadExit;
MESSAGE_MODES MessageMode;
BOOL m_bBaudRateSet;
TCHAR m_szInterfaceName[256];
TCHAR m_szDeviceName[256];
BOOL m_bInterfaceSpecified;
unsigned int m_uiPacketSize;
BOOL m_bXDB_BREAKPOINT_RETRY;
//pWTPTPREAMBLECOMMAND m_pCustPreambleCmd;
FILE *m_hLog;
BOOL m_bfastDownload ;
BOOL m_blastData ;
BOOL m_bIsNonNewWTPTP;
BOOL m_bDebugTrace;
EDeviceType m_DeviceType;
ePlatForm m_PlatformType;
};
void NewCWtpComm (struct CWtpComm *me);
void SetPortType (struct CWtpComm *me,int iSelect);
int GetPortType (struct CWtpComm *me);
void SetUsbPortTimeout (struct CWtpComm *me,long int lTimeout);
int OpenUsbPort (struct CWtpComm *me);
BOOL CloseUsbPort (struct CWtpComm *me);
BOOL SendPreamble (struct CWtpComm *me,BOOL bIsCustPreamble);
BOOL GetVersion (struct CWtpComm *me,WTPSTATUS *pWtpStatus);
BOOL GetBadBlockInfo(struct CWtpComm *me,WTPSTATUS *pWtpStatus);
BOOL GetImageCrc(struct CWtpComm *me,WTPSTATUS *pWtpStatus);
BOOL SelectImage (struct CWtpComm *me,UINT32 *pImageType);
BOOL VerifyImage (struct CWtpComm *me,BYTE AckOrNack);
BOOL DataHeader (struct CWtpComm *me,unsigned int uiRemainingData,WTPSTATUS *pWtpStatus, BOOL bFastDownload);
BOOL Data (struct CWtpComm *me,PBYTE pData,UINT32 Length);
BOOL DebugBoot (struct CWtpComm *me,PBYTE pFlashType);
BOOL Done (struct CWtpComm *me);
BOOL Disconnect (struct CWtpComm *me,WTPSTATUS *pWtpStatus);
BOOL PublicKey (struct CWtpComm *me);
BOOL Password (struct CWtpComm *me,WTPSTATUS *pWtpStatus);
BOOL SignedPassword (struct CWtpComm *me);
BOOL GetWtpMessage (struct CWtpComm *me,WTPSTATUS *pWtpStatus);
BOOL GetTargetMessage (struct CWtpComm *me,WTPSTATUS *pWtpStatus);
void SetFlashType (struct CWtpComm *me,BYTE FlashCode);
BYTE GetFlashType (struct CWtpComm *me);
BOOL OtpView (struct CWtpComm *me);
void SetLogFileMode (struct CWtpComm *me,BOOL bLogOnOff);
void SetInterfaceName (struct CWtpComm *me,TCHAR* pInterfaceName);
void SetMessageMode (struct CWtpComm *me,MESSAGE_MODES MessageModeOnOff);
BOOL WaitForHostReply (struct CWtpComm *me,WTPSTATUS *pWtpStatus,int nCharsRead,int nTotalChars);
void SetPacketSize(struct CWtpComm *me, unsigned short uiSize );
unsigned short GetPacketSize(struct CWtpComm *me);
void SetLogFile(struct CWtpComm *me,FILE *hLog);
FILE * GetLogFile(struct CWtpComm *me);
int GetUSBPort(struct CWtpComm *me);
void SetExitHandle(struct CWtpComm *me,int ThreadExit);
BOOL GetWTPTPFlag(struct CWtpComm *me);
void SetWTPTPFlag(struct CWtpComm *me,BOOL IsNonNewWTPTP);
void HandlePendingMessages(struct CWtpComm *me,WTPSTATUS *pWtpStatus);
BOOL isLastData(struct CWtpComm *me,BOOL mode, BOOL value); //added to set/get the last data condition.
BOOL WriteUSB (struct CWtpComm *me,WTPCOMMAND* pWtpCmd,size_t dwSize);
BOOL WriteUSBWithNoRsp (struct CWtpComm *me,BYTE *pData,size_t dwSize);
BOOL ReadUSB (struct CWtpComm *me,WTPSTATUS *WtpStatus,size_t dwSize);
BOOL isFastDownload(struct CWtpComm *me,BOOL mode, BOOL value);
// features added to support upload
BOOL GetProtocolVersion (struct CWtpComm *me, PROTOCOL_VERSION* pTargetProtocolVersion );
BOOL GetParameters (struct CWtpComm *me, TARGET_PARAMS* pTargetParams );
BOOL UploadDataHeader (struct CWtpComm *me, UPLOAD_DATA_PARAMS* pUploadDataParams );
BOOL UploadData(struct CWtpComm *me, PBYTE pData, unsigned int Length , WTPSTATUS* pWtpStatus);
BOOL HandleUploadDataPacket(struct CWtpComm *me, PBYTE pData, unsigned int Length );
void HandleTraceLog(struct CWtpComm *me,const TCHAR* format,...);
void CWtpCommSetBootDeviceType(struct CWtpComm *me,EDeviceType eType);
void SetPlatformType(struct CWtpComm *me,ePlatForm ePlatformType);
void SetLinuxDev(struct CWtpComm *me,USB_HANDLE* pLinuxDev);
USB_HANDLE* GetLinuxDev(struct CWtpComm *me);
#endif // !defined(AFX_WTPCOMMCLASS_H__EFECE7AD_7863_476C_A5A5_65A1D728610A__INCLUDED_)
-134
View File
@@ -1,134 +0,0 @@
/**************************************************************************
**
** (C) Copyright December 2006 Marvell International Ltd.
**
** All Rights Reserved.
**
** This software file (the "File") is distributed by Marvell International
** Ltd. under the terms of the GNU General Public License Version 2, June
** 1991 (the "License"). You may use, redistribute and/or modify this File
** in accordance with the terms and conditions of the License, a copy of
** which is available along with the File in the license.txt file or by
** writing to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
** Boston, MA 02111-1307 or on the worldwide web at
** http://www.gnu.org/licenses/gpl.txt.
**
** THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
** IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
** PURPOSE ARE EXPRESSLY DISCLAIMED. The License provides additional
** details about this warranty disclaimer.
**
** FILENAME: WTPIOCTL.H
**
** PURPOSE: This contains the IoCtl code(s) and other external interfaces
** supported in BOOT.
**
** IMPORTANT NOTE:
** Because this header file includes the DEFINE_GUID declaration
** it should only be included in the WTPUSBLIB dll. This is
** because the GUID for the USB driver should only be advertised
** once to the operating system.
**
** Environment:
** Kernel mode only
**
******************************************************************************/
#pragma warning (disable : 4005)
#ifndef WTPIOCTLDEF
#define WTPIOCTLDEF
#define CTL_CODE(DeviceType, Function, Method, Access) ( ((DeviceType) << 16) | \
((Access) << 14) | \
((Function) << 2) | \
(Method) )
#define FILE_ANY_ACCESS 0
#define FILE_DEVICE_UNKNOWN 0x00000022
#define METHOD_BUFFERED 0
#define METHOD_IN_DIRECT 1
#define METHOD_OUT_DIRECT 2
#define METHOD_NEITHER 3
#define BOOT_IOCTL_INDEX 0xDF0 // specific ioctls based from here.
#define BOOT_IOCTL_METHOD_NEITHER(function) CTL_CODE(FILE_DEVICE_UNKNOWN, \
(BOOT_IOCTL_INDEX + function), \
METHOD_NEITHER, FILE_ANY_ACCESS)
#define BOOT_IOCTL_METHOD_IN_DIRECT(function) CTL_CODE(FILE_DEVICE_UNKNOWN, \
(BOOT_IOCTL_INDEX + function), \
METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define BOOT_IOCTL_METHOD_OUT_DIRECT(function) CTL_CODE(FILE_DEVICE_UNKNOWN, \
(BOOT_IOCTL_INDEX + function), \
METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define BOOT_IOCTL_METHOD_BUFFERED(function) CTL_CODE(FILE_DEVICE_UNKNOWN, \
(BOOT_IOCTL_INDEX + function), \
METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_BOOT_PREAMBLE BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_GETVERSION BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_PUBLICKEYXMIT BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_SEEDPASSWORDRECEIVE BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_SIGNEDPASSWORDXMIT BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_SELECTIMAGE BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_JUMPADDRESS BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_IMAGEDATAXMIT BOOT_IOCTL_METHOD_BUFFERED(8)
#define IOCTL_BOOT_VERIFYIMAGE BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_DATAHEADER BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_OTPVIEW BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_DEBUGBOOT BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_DISCONNECT BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_DONE BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_MESSAGE BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_PROTOCOLVERSION BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_GETPARAMETERS BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_UPLOADDATAHEADER BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_UPLOADDATA BOOT_IOCTL_METHOD_BUFFERED(9)
#define IOCTL_BOOT_SEND BOOT_IOCTL_METHOD_BUFFERED(14)
#define IOCTL_BOOT_RECEIVE BOOT_IOCTL_METHOD_BUFFERED(15)
typedef unsigned long ULONG;
#pragma pack(push,1)
typedef struct _BOOTROM_COMMAND {
UCHAR Command;
UCHAR Sequence;
USHORT Length;
UCHAR Data[3996];
} BOOTROM_COMMAND, *PBOOTROM_COMMAND;
typedef struct _BOOTROM_PREAMBLE {
UCHAR Data[4];
} BOOTROM_PREAMBLE, *PBOOTROM_PREAMBLE;
typedef struct _BOOTROM_SENDPUBLICKEY {
UCHAR Command;
UCHAR Sequence;
USHORT Length;
ULONG KeyLength; // can be 16, 32, or 64. units is 4 byte words
UCHAR PublicKeyAndModulus[4 * 64 + 4 * 64]; // pub key & mod are same leng
// mod immediately follows actual pub key with no padding
} BOOTROM_SENDPUBLICKEY, *PBOOTROM_SENDPUBLICKEY;
typedef struct _BOOTROM_SENDENCRYPTEDSIGNATURE {
UCHAR Command;
UCHAR Sequence;
USHORT Length;
UCHAR EncryptedSignature[4 * 64];
} BOOTROM_SENDENCRYPTEDSIGNATURE, *PBOOTROM_SENDENCRYPTEDSIGNATURE;
typedef union _BOOTROM_PACKET {
BOOTROM_PREAMBLE Preamble;
BOOTROM_COMMAND Command;
BOOTROM_SENDPUBLICKEY SendPublicKey;
BOOTROM_SENDENCRYPTEDSIGNATURE SendEncryptedSignature;
} BOOTROM_PACKET, *PBOOTROM_PACKET;
#pragma pack(pop)
#endif
-186
View File
@@ -1,186 +0,0 @@
/**************************************************************************
**
** (C) Copyright December 2006 Marvell International Ltd.
**
** All Rights Reserved.
**
** This software file (the "File") is distributed by Marvell International
** Ltd. under the terms of the GNU General Public License Version 2, June
** 1991 (the "License"). You may use, redistribute and/or modify this File
** in accordance with the terms and conditions of the License, a copy of
** which is available along with the File in the license.txt file or by
** writing to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
** Boston, MA 02111-1307 or on the worldwide web at
** http://www.gnu.org/licenses/gpl.txt.
**
** THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
** IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
** PURPOSE ARE EXPRESSLY DISCLAIMED. The License provides additional
** details about this warranty disclaimer.
**
** FILENAME: WTPdef.h
**
** PURPOSE: Definition file for the WTPTP software tools..
**
******************************************************************************/
#ifndef WTPDEF_H // Only make declarations once.
#define WTPDEF_H
#include "kstring.h"
#include "./Macrodef.h"
#define DATALENGTH 0x4000
//#define RETURNDATALENGTH 0x1FFA // Update for upload data size is 0x2000
#define MESSAGELENGTH 256
#ifndef __cplusplus
#define ISMSGPORT FALSE // Use this to enable port handshaking errors for debugging.
#endif
#define USB 0
#define SERIALPORT 1
#define UNKNOWNPORT -1
#define ACK 0
#define NACK 1
#define MESSAGEPENDING 1
#define MESSAGESTRING 0
#define MESSAGEERRORCODE 1
// Image ID definitions
#define TIMH 0x54494D48
#define DKBI 0x444B4249
#define OBMI 0x4F424D49
#define FBFI 0x46424649
#define FBFD 0x46424644
#define PART 0x50415254
#define TZII 0x545A4949
#define WTMI 0x57544D49
#define NOFASTDOWNLOAD 'N' //added for fast download proj--used to turn off fast download
#define GET 0 //added for fast download proj--flag for fast download.
#define SET 1 //added for fast download proj--flag for fast download.
#define FDMODE 1 //dummy/default value when getting the value for fast download.
typedef enum
{
DISABLED = 1, // Standard WTPTP download
MSG_ONLY = 2, //Turn on message mode(listen for msgs forever)
MSG_AND_DOWNLOAD = 3 //Msg mode and WTPTP download
} MESSAGE_MODES;
struct stImageFile
{
UINT32 nFileType;
const char* strImageFile;
};
#define __stI_free(x)
KLIST_INIT(stifl,struct stImageFile,__stI_free)
struct stImageFileByDDR
{
klist_t(stifl) *ImageFileList;
kstring_t sDDRVendorID;
kstring_t sFlashInfo;
};
static void New_stImageFileByDDR(struct stImageFileByDDR * me)
{
me->ImageFileList = kl_init(stifl);
}
static void Del_stImageFileByDDR(struct stImageFileByDDR * me)
{
if (me == NULL) return;
printf("kl_destroy(stifl, me->ImageFileList);\n");
kl_destroy(stifl, me->ImageFileList);
free( me);
}
#define __stID_free(x) Del_stImageFileByDDR(kl_val(x))
KLIST_INIT(stifdl,struct stImageFileByDDR*,__stID_free)
typedef klist_t(stifl)* t_ImageFileList;
typedef kliter_t(stifl)* t_ImageFileListIter;
typedef kliter_t(stifl)* t_ImageFileListConstIter;
typedef klist_t(stifdl)* t_ImageFileByDDRList;
typedef kliter_t(stifdl)* t_ImageFileByDDRIter;
// Protocol command definitions
#define PREAMBLE 0x00
#define PUBLICKEY 0x24
#define PASSWORD 0x28
#define SIGNEDPASSWORD 0x25
#define GETVERSION 0x20
#define SELECTIMAGE 0x26
#define VERIFYIMAGE 0x27
#define DATAHEADER 0x2A
#define DATA 0x22
#define MESSAGE 0x2B
#define OTPVIEW 0x2C
#define DEBUGBOOT 0x2D
#define IMEIBIND 0x2E
#define IMEIDATA 0x2F
#define DONE 0x30
#define DISCONNECT 0x31
#define UPLOADDATAHEADER 0x32
#define UPLOADDATA 0x33
#define PROTOCOLVERSION 0x34
#define GETPARAMETERS 0x35
#define GETBADBLOCK 0x37
#define GETIMAGECRC 0x38
#define UNKNOWNCOMMAND 0xFF
#define UPLOAD_WITH_SPAREAREA 1
#define UPLOAD_WITHOUT_SPAREAREA 0
#pragma pack(push,1)
typedef struct
{
BYTE CMD;
BYTE SEQ;
BYTE CID;
BYTE Flags;
UINT32 LEN;
BYTE Data[DATALENGTH];
} WTPCOMMAND;
typedef struct
{
BYTE CMD;
BYTE SEQ;
BYTE CID;
BYTE Status;
BYTE Flags;
BYTE DLEN;
BYTE Data[DATALENGTH];
} WTPSTATUS;
typedef struct
{
BYTE MajorVersion;
BYTE MinorVersion;
short Build;
} PROTOCOL_VERSION;
typedef struct
{
unsigned int BufferSize;
unsigned int Rsvd1;
unsigned int Rsvd2;
unsigned int Rsvd3;
} TARGET_PARAMS;
#pragma pack(pop)
#endif
-21
View File
@@ -1,21 +0,0 @@
#include "WtptpDownLoad.h"
#include "WtptpDownloader.h"
struct CWtptpDownLoad gWtptpDownload;
BOOL InitializeBL(PInstanceParams pInstParam)
{
return WtptpDownLoad_InitializeBL(&gWtptpDownload,pInstParam);
}
#if 0
BOOL InitializeBLEx(PInstanceParams pInstParam,const TCHAR* pszBlfFile,const TCHAR* pszFBFTimfile, const TCHAR* pszFBFFile)
{
return WtptpDownLoad_InitializeBLEx(&gWtptpDownload,pInstParam,pszBlfFile,pszFBFTimfile,pszFBFFile);
}
#endif
BOOL TerminateBL()
{
return WtptpDownLoad_TerminateBL(&gWtptpDownload);
}
-7
View File
@@ -1,7 +0,0 @@
#include "ParaDefine.h"
extern struct CWtptpDownLoad gWtptpDownload;
BOOL InitializeBL(PInstanceParams pInstParam);
//BOOL InitializeBLEx(PInstanceParams pInstParam,const TCHAR* pszBlfFile,const TCHAR* pszFBFTimfile, const TCHAR* pszFBFFile);
BOOL TerminateBL();
File diff suppressed because it is too large. Load diff
-229
View File
@@ -1,229 +0,0 @@
#pragma once
#include <pthread.h>
#include "ParaDefine.h"
#include "define.h"
#include "WTPdef.h"
#include "ConvetEdian.h"
#include "ApplicationINI.h"
#include "Typedef.h"
#include "BulkDevNonDrv_Linux.h"
#include "BinFileWtp.h"
/*******************************************************************************************************************
(C) Copyright 20011 Marvell Semiconductor Hefei Ltd. All Rights Reserved
*******************************************************************************************************************/
#define MMP2_BOOTLOADER_PROCESSOR _T("MMP2")
#define MMP2_BOOTLOADER_VERSION _T("3215")
#define MMP2_BOOTLOADER_DATE _T("12052009")
#define WKNG_BOOTLOADER_PROCESSOR _T("WKNG")
#define WKNG_BOOTLOADER_VERSION _T("3301")
#define WKNG_BOOTLOADER_DATE _T("06172011")
#define NEVO_BOOTLOADER_PROCESSOR _T("NEVO")
#define NEVO_BOOTLOADER_VERSION _T("3301")
#define NEVO_BOOTLOADER_DATE _T("08182011")
#define MMP3_BOOTLOADER_PROCESSOR _T("MMP3")
#define MMP3_BOOTLOADER_VERSION _T("3302")
#define MMP3_BOOTLOADER_DATE _T("03082012")
#define PXA92X_BOOTLOADER_PROCESSOR _T("TVTD")
#define PXA92X_BOOTLOADER_VERSION _T("3211")
#define PXA92X_BOOTLOADER_DATE _T("06242009")
#define EMEI_BOOTLOADER_PROCESSOR _T("EMEI")
#define EMEI_BOOTLOADER_VERSION _T("3304")
#define EMEI_BOOTLOADER_DATE _T("07022012")
#define HELAN_BOOTLOADER_PROCESSOR _T("HELN")
#define HELAN_BOOTLOADER_VERSION _T("3307")
#define HELAN_BOOTLOADER_DATE _T("01152013")
#define EDEN_BOOTLOADER_PROCESSOR _T("EDEN")
#define EDEN_BOOTLOADER_VERSION _T("3307")
#define EDEN_BOOTLOADER_DATE _T("04162013")
#define NEZHA3_BOOTLOADER_PROCESSOR _T("NZA3")
#define NEZHA3_BOOTLOADER_VERSION _T("3311")
#define NEZHA3_BOOTLOADER_DATE _T("06012014")
#define HELAN2_BOOTLOADER_PROCESSOR _T("HLN2")
#define HELAN2_BOOTLOADER_VERSION _T("3308")
#define HELAN2_BOOTLOADER_DATE _T("02122014")
#define EDENA0_BOOTLOADER_PROCESSOR _T("EDEN")
#define EDENA0_BOOTLOADER_VERSION _T("3307")
#define EDENA0_BOOTLOADER_DATE _T("02142014")
#define ULC1_BOOTLOADER_PROCESSOR _T("ULC1")
#define ULC1_BOOTLOADER_VERSION _T("3313")
#define ULC1_BOOTLOADER_DATE _T("09172014")
#define HELAN3_BOOTLOADER_PROCESSOR _T("HLN3")
#define HELAN3_BOOTLOADER_VERSION _T("3313")
#define HELAN3_BOOTLOADER_DATE _T("11052014")
#define HELAN4_BOOTLOADER_PROCESSOR _T("HLN4")
#define HELAN4_BOOTLOADER_VERSION _T("3313")
#define HELAN4_BOOTLOADER_DATE _T("25032015")
#define ULC2_BOOTLOADER_PROCESSOR _T("ULC2")
#define ULC2_BOOTLOADER_VERSION _T("3313")
#define ULC2_BOOTLOADER_DATE _T("08052015")
struct stFlatformBootLoaderInfo{
ePlatForm ePlatFormType;
const char* strBLDate;
const char* strBLProcessor;
const char* strBLVersion;
};
extern const struct stFlatformBootLoaderInfo gstFlatformBLInfoSet[];
#define USBPACKETSIZE 0x4000
//#define USBPACKETSIZE 4096 //Modify for FD don't work on NEVO c0 and VMWare download
static const int NAND_BURNNING_SPEED = 1000; //per ms
static const int EMMC_BURNNING_SPEED = 8000 ;//per ms
static const int SPINOR_BURNNING_SPEED = 90 ;//per ms
static const double SPINOR_16M_ERASE_SPEED = 1.3;
static const double SPINOR_32M_ERASE_SPEED = 0.52;
static const double SPINAND_128M_ERASE_SPEED = 2.8;
static const double EMMC_ERASE_SPPED = 96.0;
static const double NAND_ERASE_SPPED = 49.0;
#define DLCMD_DO_ERASE_ALL_FLASH_MSK 1
#define DLCMD_DO_UPLOAD_DATA_MSK 2
#define DLCMD_DO_RESETBBT_MSK 4
#define DLCMD_DO_ERASE_ALL_FLASH_ONLY_MSK 16
#define MAX_IMG_FILES 100
#define MAX_DOWNLOAD_DEVICENUM 32
#define IMAGEID_LEN 4
#define stringer(x) #x
void NewCWtptpDownLoad (struct CWtptpDownLoad *me);
BOOL WtptpDownLoad_DownloadImage(struct CWtptpDownLoad *me,PDEVICE pDev, int iFile,const t_ImageFileList* plImgFileList, UINT64 uiAllimgsize,UINT64 *uidownloadsize,int nImages,char* strDownloadImgName);
BYTE WtptpDownLoad_AckWithImageName (struct CWtptpDownLoad *me,const UINT32 ImageType,TCHAR *szFileName,const t_ImageFileList* plImageList);
BOOL WtptpDownLoad_ParseTim (struct CWtptpDownLoad *me,t_ImageFileByDDRList* ImageFileByDDRlist);
BOOL WtptpDownLoad_SetAndWaitForThreadExit(struct CWtptpDownLoad *me,PDEVICE pDev);
BOOL WtptpDownLoad_RemoveEntryList(struct CWtptpDownLoad *me,PDEVICE pDev);
BOOL WtptpDownLoad_GetDeviceBootType(struct CWtptpDownLoad *me,PDEVICE pDev);
BOOL WtptpDownLoad_UploadDataFromTarget(struct CWtptpDownLoad *me,PDEVICE pDev);
BOOL WtptpDownLoad_OpenDevice(struct CWtptpDownLoad *me,PDEVICE pDev);
void WtptpDownLoad_WtptpOpenDevice(struct CWtptpDownLoad *me,struct CWtptpDownLoad *pWtptpDownLoad, USB_HANDLE *pLinuxUsb);
BOOL WtptpDownLoad_ValidateWTPTPMSGReport(struct CWtptpDownLoad *me,PDEVICE pDev, WTPSTATUS *pWtpStatus, UINT32 *ReturnCode);
UINT32 WtptpDownLoad_GetWTPTPMSGReturnCode(struct CWtptpDownLoad *me,WTPSTATUS *pWtpStatus);
BOOL WtptpDownLoad_WTPTPDownLoad (struct CWtptpDownLoad *me,PDEVICE pDev);
void WtptpDownLoad_Report(struct CWtptpDownLoad *me);
void WtptpDownLoad_AddDisplayInfoDevice(struct CWtptpDownLoad *me,PDEVICE pDev);
void WtptpDownLoad_RemoveDisplayInfoDevice(struct CWtptpDownLoad *me,PDEVICE pDev);
void WtptpDownLoad_ResetParameter(struct CWtptpDownLoad *me);
BOOL WtptpDownLoad_prepareDumpFlashParam(struct CWtptpDownLoad *me,const PInstanceParams pInstParam);
BOOL WtptpDownLoad_prepareEnabledJtagImg(struct CWtptpDownLoad *me,const PInstanceParams pInstParam);
BOOL WtptpDownLoad_prepareDownloadImg(struct CWtptpDownLoad *me,const PInstanceParams pInstParam);
static PVOID WtptpDownLoad_BootRomIOThread(PVOID Arg);
static PVOID WtptpDownLoad_BootLoaderIOThread(PVOID Arg);
static PVOID WtptpDownLoad_BootLoaderUploadThread(PVOID Arg);
static PVOID WtptpDownLoad_WtptpDeviceDetectThread(PVOID Arg);
static int WtptpDownLoad_init_hotplug_sock();
BOOL WtptpDownLoad_InitializeBL(struct CWtptpDownLoad *me,PInstanceParams pInstParam);
//BOOL WtptpDownLoadInitializeBLEx(struct CWtptpDownLoad *me,PInstanceParams pInstParam,const TCHAR * pszBLFfileName ,const TCHAR * pszFBFTimFile,const TCHAR * pszFBFfileName);
BOOL WtptpDownLoad_TerminateBL(struct CWtptpDownLoad *me);
void WtptpDownLoad_SetBootDeviceType(struct CWtptpDownLoad *me,PDEVICE pDev,EDeviceType eDevieBootType);
eDDREMMCMatchResult WtptpDownLoad_HandleDownloadImagesByDDRIDandEMMCSize(struct CWtptpDownLoad *me,UINT32 uiDdrVendorId, UINT32 uiDdrUnitSize,UINT32 uiEMMCSize);
eDDREMMCMatchResult WtptpDownLoad_HandleNandDLImgByDDRID(struct CWtptpDownLoad *me,UINT32 uiDdrVendorId, UINT32 uiDdrUnitSize);
char* WtptpDownLoad_replace_all(char* str,const char* old_value,const char* new_value) ;
EDeviceType WtptpDownLoad_GetDeviceType(struct CWtptpDownLoad *me,ePlatForm ePlatfromType,const char* strDate,const char* strVersion ,const char* strProcessor);
void DelCWtptpDownLoad (struct CWtptpDownLoad *me);
struct CWtptpDownLoad
{
struct CConvertLT2B MyConvertLT2B;
TCHAR m_szPrimaryDkbPath[MAX_PATH];
TCHAR m_szPrimTimPath[MAX_PATH];
TCHAR m_szSecondaryFlasherPath[MAX_PATH];
TCHAR m_szOBMPath[MAX_PATH];
TCHAR m_szWTMPath[MAX_PATH];
TCHAR m_szSWDPath[MAX_PATH];
TCHAR m_szTZIPath[MAX_PATH];
UINT32 m_nFlashDataPageSize ;
UINT32 m_nBurningSpeed;
BOOL m_binitFlag;
volatile BOOL m_bTerminateDownload;
int m_uTotalDDRTypeNum;
int m_uTotalFlashTypeNum;
int m_uFlashBadBlockRate;//坏块率门限 m_uFlashBadBlockRate/10000
t_ImageFileList* m_plBootRomImageList;
t_ImageFileList* m_plBootLoaderImageList;
t_ImageFileList* m_plJtagEnabledImageList;
t_ImageFileByDDRList m_lBootRomImageWithDDRList;
t_ImageFileByDDRList m_lBootLoaderImageWithDDRList;
t_ImageFileByDDRList m_lJtagEnabledImageWithDDRList;
BOOL m_bDumpFlash; //to do upload in wtptpdownload
BOOL m_bEnabledJtag;
BOOL m_bInitialiezed ; // Indicates whether the InitializeBL was called (and was TerminateBL called afterwards)
BOOL m_bTermination ;
BOOL m_bUploadFromTarget ; //to do upload in wtptpdownload
//
BOOL m_bCustPreamble ;
BOOL m_bTrusted;
BOOL m_bEraseAllFlash ;
BOOL m_bEraseAllFlashOnly;
BOOL m_bResetBBT ;
BOOL m_bDebugTrace;
BOOL m_bOnlyOBMDownload;
volatile BOOL m_bTerminateUSBDetect;
BOOL m_bSingleDownload;
BOOL m_bGetBadBlk;
BOOL m_bImageCrcEnable;
BOOL m_bIsLittleEndian;
ePlatForm m_ePlatformType;
eFlashType m_FlashType;
t_DeviceList m_WtptpDeviceList;
t_DisplayInfoList m_DisplayInfoList;
PInstanceParams m_lpInstParam ;
//pWTPTPREAMBLECOMMAND m_lpCustPreambleCmd ;
t_UpLoadDataSpecList* m_lpUpLoadDataSpecList ;
int m_nBootRomDevNum ;
int m_nBootLoaderDevNum ;
int m_nUploadDevNum;
pthread_t BootRomTypeThread[MAX_DOWNLOAD_DEVICENUM];
pthread_t BootLoaderTypeThread[MAX_DOWNLOAD_DEVICENUM];
pthread_t UploadThread[MAX_DOWNLOAD_DEVICENUM];
pthread_t DetectThread;
pthread_mutex_t DeviceList_mutex;
//pthread_mutex_t Device_mutex;
pthread_mutex_t Quit_mutex;
pthread_mutex_t callback_mutex;
};
-145
View File
@@ -1,145 +0,0 @@
#ifndef DEFINE_H
#define DEFINE_H
#include "./Typedef.h"
#include "ParaDefine.h"
#include <pthread.h>
#include <stdio.h>
#include "kstring.h"
#define MAX_PATH 1024
struct CWtpComm;
struct CWtptpDownLoad;
#define RXTIMEOUT 10000
#define TXTIMEOUT 5000
#define WTPTPERRORREPORT 1
#define WTPTPNOTIFICATION 0
#define WTPTPNOTIFICATION_BURNTSIZE 2
#define WTPTPNOTIFICATION_UPLOAD 3
#define WTPTPNOTIFICATION_FLASHSIZE 4
#define WTPTPREPORT_EXTENDED_FUSE_INFO 5
#define WTPTPREPORT_UEINFO 6
#define MAX_FILE_PATH 1024
#define USBPACKETSIZE 0x4000
#define STOPFLAG 1
//#define DLCMD_DO_ERASE_ALL_FLASH_MSK 0
//#define DLCMD_DO_UPLOAD_DATA_MSK 1
//#define DLCMD_DO_RESETBBT_MSK 2
//#define DLCMD_DO_CUSTMOIZEPREAMBLE_MSK 3
//#define DLCMD_DO_ERASE_ALL_FLASH_ONLY_MSK 4
//#define DLCMD_DO_ENABLE_JTAG_MSK 5
typedef struct _DEVICE
{
TCHAR UsbDevName[MAX_FILE_PATH];//
TCHAR LogFileName[MAX_FILE_PATH];// record downloding process to get debug information
TCHAR szCurrentMsg[MAX_FILE_PATH];
BadBlockData DevBadBlk; // flash bad block data
ImageCRCInfo DevImageCrc; // CRC value of Images read back from flash
FILE *hLog;
int SerialNo; // Serial number of the device.
int npercent;
int nBootRomId,
nBootLoaderId,
nDevType;
struct CWtpComm *pWtpComm ;
volatile int ThreadExit;
pthread_t ThreadId;
eProcessState kProState;
}DEVICE, *PDEVICE;
typedef struct _DISPLAYINFO
{
TCHAR UsbDevName[MAX_FILE_PATH];
TCHAR szCurrentMsg[MAX_FILE_PATH];
BadBlockData szBadBlk; // flash bad block data
ImageCRCInfo szImageCrc; // CRC value of Images read back from flash
eProcessState kProState;
int npercent;
}DISPLAYINFO,*PDISPLAYINFO;
typedef struct _DOWNLOADTARGET
{
PDEVICE pDev;
struct CWtptpDownLoad *pWtptpDownload;
}DOWNLOADTARGET,*PDOWNLOADTARGET;
#define __pdev_free(x)
KLIST_INIT(pdevl, PDEVICE, __pdev_free)
KLIST_INIT(pdisl, PDISPLAYINFO, __pdev_free)
typedef klist_t(pdevl)* t_DeviceList;
typedef kliter_t(pdevl)* t_DeviceIter;
typedef klist_t(pdisl)* t_DisplayInfoList;
typedef kliter_t(pdisl)* t_DisplayInfoIter;
typedef enum _EDeviceType
{
kNone = 0,
kBootRom = 1,
kBootLoader = 2,
}EDeviceType;
enum eBootROM_Operation_Mode
{
NonTrustedBoot1 = 0,
NonTrustedBoot2 = 1,
TrustedBoot = 2,
TamperBoot = 3 // BootROM will not boot device, so, OBM can't detect such mode.
};
typedef struct
{
UINT32 ChipID : 16; // 0x1920
UINT32 RevisionID : 8; // 0xB0
UINT32 Reserved : 8;
}ChipIDInfo;
// extended message data
typedef struct {
UINT32 OEMKeyHash[8];
UINT32 DeviceUID[2];
enum eBootROM_Operation_Mode BRMode;
UINT32 MMCSerialNumber;
ChipIDInfo ChipId;
} ExMessageData, *pExMessageData;
// extended message report
typedef struct {
UINT8 ReportType;
UINT8 ReportLength;
UINT8 TotalMsgNumber;//OBM分多次送消息,如果消息长度大于0x40
UINT8 MsgIndex; //Current Msg Index
ExMessageData ReportData;
} ExMessageReport, *pExMessageReport;
typedef struct {
UINT32 OEMKeyHash[8];
UINT32 DeviceUID[2];
UINT32 BRMode;
ChipIDInfo ChipId;
UINT8 eMMCInfo[16]; //128bit
UINT32 Reserved1;
UINT32 Reserved2;
UINT32 EmmcSize; //MB
UINT32 DDRSize; //MB
} UEInfo;
// extended message report
typedef struct {
UINT8 ReportType;
UINT8 ReportLength;
UINT8 TotalMsgNumber; //OBM分多次送消息,如果消息长度大于0x40
UINT8 MsgIndex; //Current Msg Index
UEInfo ReportData;
} Ex2MessageReport, *pEx2MessageReport;
typedef struct {
UEInfo UEMessageInfo;
TCHAR lpUsbPortAddress[260];
} MessageUEInfoReport;
#endif
-377
View File
@@ -1,377 +0,0 @@
/******************************************************************************
**
** COPYRIGHT (C) 2000, 2002 Intel Corporation.
**
** This software as well as the software described in it is furnished under
** license and may only be used or copied in accordance with the terms of the
** license. The information in this file is furnished for informational use
** only, is subject to change without notice, and should not be construed as
** a commitment by Intel Corporation. Intel Corporation assumes no
** responsibility or liability for any errors or inaccuracies that may appear
** in this document or any software that may be provided in association with
** this document.
** Except as permitted by such license, no part of this document may be
** reproduced, stored in a retrieval system, or transmitted in any form or by
** any means without the express written consent of Intel Corporation.
**
** FILENAME: downloader.h
**
** PURPOSE:
**
** LAST MODIFIED:
******************************************************************************/
#ifndef DOWNLOADER_H
#define DOWNLOADER_H
#include "Macrodef.h"
#include "Typedef.h"
#if !defined (LINUX)
//#include <windows.h>
#else
//#include "global_types_linux.h"
#endif// LINUX
#define MAX_SIZE_OF_FILENAME_STRING 1024
/* Concentration of all per-build identifiers */
//#define DEBUG_BUILD
#define MAX_NUMBER_OF_IMAGES 200
//#define BLOCK_DEVICE_SECTOR_SIZE (32*1024) // 32 KB
#ifdef FBFMAKEWEB
#define MAX_NUMBER_OF_IMAGE_STRUCTS_IN_DEVICE_HEADER 150
#else
#define MAX_NUMBER_OF_IMAGE_STRUCTS_IN_DEVICE_HEADER 30
#endif
#define MASTER_BLOCK_HEADER_SIZE_IN_BYTES (sizeof(MasterBlockHeader))
#define DEVICE_HEADER_SIZE_IN_BYTES (sizeof(DeviceHeader_VPXA92x))
#define MAX_NUMBER_OF_FLASH_SECTIONS 3
#define MAX_NUM_OF_FLASH_PROTECTION_REGIONS 10
/* end of per-build identifiers */
//#define DEBUG_BUILD
//#define FLASH_BLOCK_SIZE_IN_BYTES (64*1024)
/*-----------------12/22/2004 5:10PM----------------
* Flash Commands
* --------------------------------------------------*/
#define FLASH_CMD_WRITE_WORD_1 0x40
#define FLASH_CMD_WRITE_WORD_2 0x0
#define FLASH_CMD_BLOCK_ERASE_1 0x20
#define FLASH_CMD_BLOCK_ERASE_2 0xD0 /* Confirm erase */
#define FLASH_CMD_LOCK_BLOCK_1 0x60
#define FLASH_CMD_LOCK_BLOCK_2 0x01
#define FLASH_CMD_UNLOCK_BLOCK_1 0x60
#define FLASH_CMD_UNLOCK_BLOCK_2 0xD0
#define FLASH_CMD_RESET_FOR_READ 0xFF
#define FLASH_CMD_CLR_SR 0x50
#define FLASH_CMD_READ_SR 0x70
#define FLASH_ERASED_WORD_16BIT 0xffff
#define FLASH_ERASED_WORD_32BIT 0xffffffff
#define SR_STATUS_BLOCK_LOCKED 0x02
#define DLCMD_DO_VERIFY_WRITE 1
#define DLCMD_DO_ERASE_BLOCKS 2
#define DLCMD_WRITE_IMAGE 3
#define DLCMD_DUMP_IMAGE 4
#define DLCMD_IMAGE_TYPE_FIELD_BIT 4 /* bit 4 through 7*/
#define DLCMD_IMAGE_TYPE_FIELD_SIZE_BITS 4
#define DLCMD_IMAGE_SPARE_AREA_SZ_BIT 8 /* bit 8 through 15 */
#define DLCMD_IMAGE_SPARE_AREA_SZ_FIELD_BITS 8
#define DLCMD_IMAGE_DUMP_SPARE_BIT 16
#define DLCMD_IMAGE_ABSOLUTE_FLASH_OFFSET_ENABLE_BIT 17
#define DLCMD_IMAGE_USE_SECTOR_BASED_ADDRESSING 18
#define DLCMD_PARTITION_NUM_FIELD_BIT (24) /* bit 24 through 31 */
#define DLCMD_PARTITION_NUM_FIELD_BIT_SIZE (8)
//image type define
#define DLCMD_RAW_BINARY_IMAGE_TYPE (0) /* used when burning raw binary */
#define DLCMD_WINDOWS_MOBILE_IMAGE_TYPE (1) /* used for WM image type */
#define DLCMD_YAFFS_IMAGE_TYPE (2) /* this image type is used for YAFFS */
#define DLCMD_UBIFS_IMAGE_TYPE (3) /* this image type is used for UBIFS */
#define DLCMD_JFFS2_IMAGE_TYPE (4) /* this image type is used for JFFS2 */
#define DLCMD_RND_IMAGE_TYPE (5)
#define DLCMD_SPARSE_IMAGE_TYPE (6) /* this image type is used for Sparse file of Android*/
#define DLCMD_LZMA_IMAGE_TYPE (7) //OBM burn compressed image to flash
#define DLCMD_LZMA2_IMAGE_TYPE (8) //OBM burn decompressed image to flash
#define DLCMD_YAFFS_LZMA_IMAGE_TYPE (9) //SWD compress the image with lzma algorithm,write the compressed image to FBF for image type 9-12
#define DLCMD_UBIFS_LZMA_IMAGE_TYPE (10)
#define DLCMD_JFFS2_LZMA_IMAGE_TYPE (11)
#define DLCMD_RAW_LZMA_IMAGE_TYPE (12)
#define DLCMD_DUMP_BINARY_IMAGE_WITH_SPARE_TYPE (3)
#define DLCMD_ABSOLUTE_FLASH_OFFSET_TYPE (4)
#define DLCMD_ABSOLUTE_FLASH_OFFSET_WITH_SPARE_TYPE (5)
/* general downloader commands */
#define FBF_GENERAL_CMD_INITIALIZE_FLASH_MSK (1)
#define FBF_GENERAL_CMD_PRODUCTION_INIT_FLASH_MSK (2)
#define FBF_GENERAL_CMD_DISABLE_ERASE_WM_USER_PARTITIONS_MSK (4)
#define FBF_GENERAL_CMD_ERASE_ALL_FLASH_MSK (8)
#define FBF_GENERAL_CMD_PERFORM_TARGET_RESET_MSK (16)
/* Flash parameters flags */
#define FLASH_PARAMETERS_ENABLE_BIT 1
#define FLASH_ERASED_VALUE 0xFF
#define BUF_FLAG_PRIMARY_VALID 1
#define BUF_FLAG_SECONDARY_VALID 2
#define BUF_FLAG_IS_FIRST_SWITCH 4
#define HARD_SECTOR_SIZE 512 //TBD - receive from ini
//static int numOfFlashDevices = 0; /* number of flash devices */
typedef UINT16 CORE_ID;
#define MANITOBA_CORE_ID 0xABAB
#define HERMON_CORE_ID 0xBBAC
#define BULVERDE_CORE_ID 0xABAD
#define TAVOR_CORE_ID 0x1f34
typedef UINT8 FLASH_FAMILY;
#define BOOT_BLOCKS_START_OFFSET 0x0
#define NUM_OF_BOOT_BLOCKS 4 /* Boot blocks == TIM + OBM + PINMUX + OS Loader */
/* Device Header flags */
#define DEVICE_EXTERNAL_FLASH 1
#define MAX_NUMBER_OF_FLASH_DEVICES_IN_MASTER_HEADER 4
#define MAX_NUMBER_OF_FLASH_DEVICES 10
#define MAX_RESEVERD_LEN 4
#define MAX_NUM_SKIP_BLOCKS 32
#pragma pack (1)
typedef struct
{
UINT32 tCH; /*Enable Signal Hold Time*/
UINT32 tCS; /*Enable Signal Setup Time*/
UINT32 tWH; /*ND_nWE high duration*/
UINT32 tWP; /*ND_nWE pulse width*/
UINT32 tRH; /*ND_nRE high duration*/
UINT32 tRP; /*ND_nRE pulse width*/
UINT32 tR; /*ND_nWE high to ND_nRE Low for Read*/
UINT32 tWHR; /*ND_nWE High to ND_nRE Low for Read Status*/
UINT32 tAR; /*ND_ALE Low to ND_nRE Low Delay*/
} FlashTimingStruct;
typedef struct
{
UINT32 TotalNumOfBlocks; /*The total number of blocks in flash*/
UINT32 FlashBlockSize; /*Block size in Flash*/
UINT32 FlashOffset; /*Flash offset address*/
UINT32 FlashBufferSize; /*Buffer size in Flash*/
UINT32 NumberOfBlocksInBadBlockPool; /*What is the number of Blocks in the Bad Block Pool*/
UINT32 SpareAreaSize; /* Flash Device spare area size */
UINT32 ManufacturerBadBlockInfoOffset; /* Where manufacturer bad block information in flash*/
} FlashSectionStruct;
typedef struct
{
FlashTimingStruct FlashTiming; /*Timing Parameters*/
FlashSectionStruct FlashSection[MAX_NUMBER_OF_FLASH_SECTIONS];
} FlashParametersStruct;
typedef struct
{
UINT32 flash_partition_size; /* flash partition size */
UINT32 commands; /* bit switches */
UINT32 First_Sector; /* First sector of the image in the block device */
UINT32 length; /* Block length in bytes */
UINT32 Flash_Start_Address; /* start address in flash */
UINT32 Flash_block_size; /* flash device block size */
UINT32 ChecksumFormatVersion2; /* new format version image checksum (left for backwards compatibility) */
} ImageStruct_VPXA92x;
typedef struct
{
UINT32 Image_ID; /* image id*/
UINT32 Image_In_TIM; /* indicate this image is in TIM or not*/
UINT32 Flash_partition; /* partition number of the image */
UINT32 Flash_erase_size; /* erase size of the image */
UINT32 commands; /* bit switches */
UINT32 First_Sector; /* First sector of the image in the block device */
UINT32 length; /* Image length in bytes */
UINT32 Flash_Start_Address; /* start address in flash */
UINT32 Reserved[MAX_RESEVERD_LEN];
UINT32 ChecksumFormatVersion2; /* new format version image checksum (left for backwards compatibility) */
} ImageStruct_V11;
typedef ImageStruct_V11 *PImageStruct_V11;
typedef struct
{
UINT32 Total_Number_Of_SkipBlocks; // total numbers of skip blocks
UINT32 Skip_Blocks[MAX_NUM_SKIP_BLOCKS];
} SkipBlocksInfoStruct;
typedef struct
{
UINT32 EraseAll; // erase all flag for user partition
UINT32 ResetBBT; // indicate if reset BBT
UINT32 NandID; // nand flash ID
UINT32 Reserved[MAX_RESEVERD_LEN - 1];
SkipBlocksInfoStruct Skip_Blocks_Struct;
}FlashOptStruct;
typedef struct
{
UINT32 DeviceFlags;
FlashParametersStruct FlashParameters; /* Device Parameters */
UINT8 nOfImages; /* number of images */
UINT8 BufferSizeLSB; /* init to 0x00 */
UINT16 AccessWidth; /* init to 0x0000 */
CORE_ID Core_ID;
FLASH_FAMILY FlashFamily; /* Device Flags */
UINT8 BufferSizeMSB;
ImageStruct_VPXA92x imageStruct[MAX_NUMBER_OF_IMAGE_STRUCTS_IN_DEVICE_HEADER]; /* array of image structs */
} DeviceHeader_VPXA92x;
typedef struct
{
UINT32 DeviceFlags; /* NAND, eMMC, SPI-NOR, etc*/
UINT32 DeviceParameters[16]; /* Device Parameters, reserve 16 U32 here, will be defined depending on different devices */
FlashOptStruct FlashOpt;
UINT32 ProductionMode; // production mode
UINT8 OptValue; // choice: 0 - Not reset after download, 1 - Reset after download
UINT8 ChipID;
UINT8 BBCS_EN;
UINT8 CRCS_EN;
UINT32 Reserved[MAX_RESEVERD_LEN-2];
UINT32 nOfImages; /* number of images */
ImageStruct_V11 imageStruct[MAX_NUMBER_OF_IMAGE_STRUCTS_IN_DEVICE_HEADER]; /* array of image structs */
} DeviceHeader_V11;
typedef DeviceHeader_VPXA92x *PDeviceHeader_VPXA92x;
typedef DeviceHeader_V11 *PDeviceHeader_V11;
#define NUM_OF_SUPPORTED_FLASH_DEVS 4
typedef struct
{
char Unique[24];
UINT16 Flash_Device_Spare_Area_Size[NUM_OF_SUPPORTED_FLASH_DEVS];
UINT16 Format_Version;
UINT16 Size_of_Block;
UINT32 Bytes_To_Program;
UINT32 Bytes_To_Verify;
UINT32 Number_of_Bytes_To_Erase;
UINT32 Main_Commands;
UINT32 nOfDevices; /* number of devices to burn in parallel */
UINT32 DLerVersion; /* Version of downloader current 1 */
UINT32 deviceHeaderOffset[MAX_NUMBER_OF_FLASH_DEVICES_IN_MASTER_HEADER]; /* offset in Sector 0 for each flash device header */
} MasterBlockHeader;
typedef MasterBlockHeader *PMasterBlockHeader;
typedef struct
{
char Unique[24];
UINT16 Flash_Device_Spare_Area_Size[NUM_OF_SUPPORTED_FLASH_DEVS];
UINT16 Format_Version;
UINT16 Size_of_Block;
UINT32 Bytes_To_Program;
UINT32 Bytes_To_Verify;
UINT32 Number_of_Bytes_To_Erase;
UINT32 Main_Commands;
UINT32 nOfDevices; /* number of devices to burn in parallel */
UINT32 DLerVersion; /* Version of downloader current 1 */
UINT32 deviceHeaderOffset[MAX_NUMBER_OF_FLASH_DEVICES]; /* offset in Sector 0 for each flash device header */
} MasterBlockHeader_PXA92x;
typedef MasterBlockHeader_PXA92x *PMasterBlockHeader_PXA92x;
#pragma pack ()
/*- Functions declaration */
void DLMakeMasterBlock(MasterBlockHeader* pMasterBlock, UINT32 nOfDevices, UINT32 DLerVersion);
void DLmakeDeviceHeader(DeviceHeader_V11* devHeader, UINT32 numOfImages);
UINT16 DLgetMasterBlockHeaderChksum(MasterBlockHeader *mBlockHeader);
void DLaddDeviceToMasterHeader(PMasterBlockHeader mbHeader);
void DLaddImageToDeviceHeader(PDeviceHeader_V11 pDev, PImageStruct_V11 pImageStruct);
//void startFlashProgramming(void);
void DLmakeImageStruct( PImageStruct_V11 pImageStruct,
UINT32 commands, /* bit switches */
UINT32 BlockDevice_Start_Block, /* start block in Block device */
UINT32 length, /* Block length in bytes */
UINT32 Flash_Start_Address /* start address in flash */
);
typedef struct
{
UINT16* startAddr;
UINT32 nOfBlocksToErase;
UINT32 Flash_block_size; /* flash device block size */
} BlockRange;
/*
typedef enum
{
INVALID = 0,
READ_REQ,
READ_PENDING,
READ_COMPLETE,
FLASH_WRITING
} BlockStatus;
typedef struct
{
UINT32 sectorNumber;
UINT16* ptrBuffer;
BlockStatus status;
} BlockDeviceHandle;
*/
typedef struct
{
UINT32 DumpAddressRange;
UINT32 FlashStartAddress;
UINT32 length;
UINT32 Core_ID;
} FilePreamble;
typedef void (*pfnDebugLog)(TCHAR* pLogEntry);
#endif // DOWNLOADER_H
-22
View File
@@ -1,22 +0,0 @@
#ifndef FBF_H
#define FBF_H
#include <stdlib.h>
#include <stdio.h>
//return 0 SUCCRSS
//return 1 FAIL
//timeout 0 Infinite Wait
//timeout >0 Wait N seconds for Download
#ifdef __cplusplus
extern "C"{
#endif
int fbfdownload(char * strBinFilePath, int timeout);
#ifdef __cplusplus
}
#endif
#endif
-627
View File
@@ -1,627 +0,0 @@
/* The MIT License
Copyright (c) 2008, 2009, 2011 by Attractive Chaos <attractor@live.co.uk>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
An example:
#include "khash.h"
KHASH_MAP_INIT_INT(32, char)
int main() {
int ret, is_missing;
khiter_t k;
khash_t(32) *h = kh_init(32);
k = kh_put(32, h, 5, &ret);
kh_value(h, k) = 10;
k = kh_get(32, h, 10);
is_missing = (k == kh_end(h));
k = kh_get(32, h, 5);
kh_del(32, h, k);
for (k = kh_begin(h); k != kh_end(h); ++k)
if (kh_exist(h, k)) kh_value(h, k) = 1;
kh_destroy(32, h);
return 0;
}
*/
/*
2013-05-02 (0.2.8):
* Use quadratic probing. When the capacity is power of 2, stepping function
i*(i+1)/2 guarantees to traverse each bucket. It is better than double
hashing on cache performance and is more robust than linear probing.
In theory, double hashing should be more robust than quadratic probing.
However, my implementation is probably not for large hash tables, because
the second hash function is closely tied to the first hash function,
which reduce the effectiveness of double hashing.
Reference: http://research.cs.vt.edu/AVresearch/hashing/quadratic.php
2011-12-29 (0.2.7):
* Minor code clean up; no actual effect.
2011-09-16 (0.2.6):
* The capacity is a power of 2. This seems to dramatically improve the
speed for simple keys. Thank Zilong Tan for the suggestion. Reference:
- http://code.google.com/p/ulib/
- http://nothings.org/computer/judy/
* Allow to optionally use linear probing which usually has better
performance for random input. Double hashing is still the default as it
is more robust to certain non-random input.
* Added Wang's integer hash function (not used by default). This hash
function is more robust to certain non-random input.
2011-02-14 (0.2.5):
* Allow to declare global functions.
2009-09-26 (0.2.4):
* Improve portability
2008-09-19 (0.2.3):
* Corrected the example
* Improved interfaces
2008-09-11 (0.2.2):
* Improved speed a little in kh_put()
2008-09-10 (0.2.1):
* Added kh_clear()
* Fixed a compiling error
2008-09-02 (0.2.0):
* Changed to token concatenation which increases flexibility.
2008-08-31 (0.1.2):
* Fixed a bug in kh_get(), which has not been tested previously.
2008-08-31 (0.1.1):
* Added destructor
*/
#ifndef __AC_KHASH_H
#define __AC_KHASH_H
/*!
@header
Generic hash table library.
*/
#define AC_VERSION_KHASH_H "0.2.8"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
/* compiler specific configuration */
#if UINT_MAX == 0xffffffffu
typedef unsigned int khint32_t;
#elif ULONG_MAX == 0xffffffffu
typedef unsigned long khint32_t;
#endif
#if ULONG_MAX == ULLONG_MAX
typedef unsigned long khint64_t;
#else
typedef unsigned long long khint64_t;
#endif
#ifndef kh_inline
#ifdef _MSC_VER
#define kh_inline __inline
#else
#define kh_inline inline
#endif
#endif /* kh_inline */
#ifndef klib_unused
#if (defined __clang__ && __clang_major__ >= 3) || (defined __GNUC__ && __GNUC__ >= 3)
#define klib_unused __attribute__ ((__unused__))
#else
#define klib_unused
#endif
#endif /* klib_unused */
typedef khint32_t khint_t;
typedef khint_t khiter_t;
#define __ac_isempty(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&2)
#define __ac_isdel(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&1)
#define __ac_iseither(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&3)
#define __ac_set_isdel_false(flag, i) (flag[i>>4]&=~(1ul<<((i&0xfU)<<1)))
#define __ac_set_isempty_false(flag, i) (flag[i>>4]&=~(2ul<<((i&0xfU)<<1)))
#define __ac_set_isboth_false(flag, i) (flag[i>>4]&=~(3ul<<((i&0xfU)<<1)))
#define __ac_set_isdel_true(flag, i) (flag[i>>4]|=1ul<<((i&0xfU)<<1))
#define __ac_fsize(m) ((m) < 16? 1 : (m)>>4)
#ifndef kroundup32
#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
#endif
#ifndef kcalloc
#define kcalloc(N,Z) calloc(N,Z)
#endif
#ifndef kmalloc
#define kmalloc(Z) malloc(Z)
#endif
#ifndef krealloc
#define krealloc(P,Z) realloc(P,Z)
#endif
#ifndef kfree
#define kfree(P) free(P)
#endif
static const double __ac_HASH_UPPER = 0.77;
#define __KHASH_TYPE(name, khkey_t, khval_t) \
typedef struct kh_##name##_s { \
khint_t n_buckets, size, n_occupied, upper_bound; \
khint32_t *flags; \
khkey_t *keys; \
khval_t *vals; \
} kh_##name##_t;
#define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \
extern kh_##name##_t *kh_init_##name(void); \
extern void kh_destroy_##name(kh_##name##_t *h); \
extern void kh_clear_##name(kh_##name##_t *h); \
extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \
extern int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
extern void kh_del_##name(kh_##name##_t *h, khint_t x);
#define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
SCOPE kh_##name##_t *kh_init_##name(void) { \
return (kh_##name##_t*)kcalloc(1, sizeof(kh_##name##_t)); \
} \
SCOPE void kh_destroy_##name(kh_##name##_t *h) \
{ \
if (h) { \
kfree((void *)h->keys); kfree(h->flags); \
kfree((void *)h->vals); \
kfree(h); \
} \
} \
SCOPE void kh_clear_##name(kh_##name##_t *h) \
{ \
if (h && h->flags) { \
memset(h->flags, 0xaa, __ac_fsize(h->n_buckets) * sizeof(khint32_t)); \
h->size = h->n_occupied = 0; \
} \
} \
SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
{ \
if (h->n_buckets) { \
khint_t k, i, last, mask, step = 0; \
mask = h->n_buckets - 1; \
k = __hash_func(key); i = k & mask; \
last = i; \
while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
i = (i + (++step)) & mask; \
if (i == last) return h->n_buckets; \
} \
return __ac_iseither(h->flags, i)? h->n_buckets : i; \
} else return 0; \
} \
SCOPE int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
{ /* This function uses 0.25*n_buckets bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. */ \
khint32_t *new_flags = 0; \
khint_t j = 1; \
{ \
kroundup32(new_n_buckets); \
if (new_n_buckets < 4) new_n_buckets = 4; \
if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; /* requested size is too small */ \
else { /* hash table size to be changed (shrink or expand); rehash */ \
new_flags = (khint32_t*)kmalloc(__ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
if (!new_flags) return -1; \
memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
if (h->n_buckets < new_n_buckets) { /* expand */ \
khkey_t *new_keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
if (!new_keys) { kfree(new_flags); return -1; } \
h->keys = new_keys; \
if (kh_is_map) { \
khval_t *new_vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
if (!new_vals) { kfree(new_flags); return -1; } \
h->vals = new_vals; \
} \
} /* otherwise shrink */ \
} \
} \
if (j) { /* rehashing is needed */ \
for (j = 0; j != h->n_buckets; ++j) { \
if (__ac_iseither(h->flags, j) == 0) { \
khkey_t key = h->keys[j]; \
khval_t val; \
khint_t new_mask; \
new_mask = new_n_buckets - 1; \
if (kh_is_map) val = h->vals[j]; \
__ac_set_isdel_true(h->flags, j); \
while (1) { /* kick-out process; sort of like in Cuckoo hashing */ \
khint_t k, i, step = 0; \
k = __hash_func(key); \
i = k & new_mask; \
while (!__ac_isempty(new_flags, i)) i = (i + (++step)) & new_mask; \
__ac_set_isempty_false(new_flags, i); \
if (i < h->n_buckets && __ac_iseither(h->flags, i) == 0) { /* kick out the existing element */ \
{ khkey_t tmp = h->keys[i]; h->keys[i] = key; key = tmp; } \
if (kh_is_map) { khval_t tmp = h->vals[i]; h->vals[i] = val; val = tmp; } \
__ac_set_isdel_true(h->flags, i); /* mark it as deleted in the old hash table */ \
} else { /* write the element and jump out of the loop */ \
h->keys[i] = key; \
if (kh_is_map) h->vals[i] = val; \
break; \
} \
} \
} \
} \
if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \
h->keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
if (kh_is_map) h->vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
} \
kfree(h->flags); /* free the working space */ \
h->flags = new_flags; \
h->n_buckets = new_n_buckets; \
h->n_occupied = h->size; \
h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); \
} \
return 0; \
} \
SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \
{ \
khint_t x; \
if (h->n_occupied >= h->upper_bound) { /* update the hash table */ \
if (h->n_buckets > (h->size<<1)) { \
if (kh_resize_##name(h, h->n_buckets - 1) < 0) { /* clear "deleted" elements */ \
*ret = -1; return h->n_buckets; \
} \
} else if (kh_resize_##name(h, h->n_buckets + 1) < 0) { /* expand the hash table */ \
*ret = -1; return h->n_buckets; \
} \
} /* TODO: to implement automatically shrinking; resize() already support shrinking */ \
{ \
khint_t k, i, site, last, mask = h->n_buckets - 1, step = 0; \
x = site = h->n_buckets; k = __hash_func(key); i = k & mask; \
if (__ac_isempty(h->flags, i)) x = i; /* for speed up */ \
else { \
last = i; \
while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
if (__ac_isdel(h->flags, i)) site = i; \
i = (i + (++step)) & mask; \
if (i == last) { x = site; break; } \
} \
if (x == h->n_buckets) { \
if (__ac_isempty(h->flags, i) && site != h->n_buckets) x = site; \
else x = i; \
} \
} \
} \
if (__ac_isempty(h->flags, x)) { /* not present at all */ \
h->keys[x] = key; \
__ac_set_isboth_false(h->flags, x); \
++h->size; ++h->n_occupied; \
*ret = 1; \
} else if (__ac_isdel(h->flags, x)) { /* deleted */ \
h->keys[x] = key; \
__ac_set_isboth_false(h->flags, x); \
++h->size; \
*ret = 2; \
} else *ret = 0; /* Don't touch h->keys[x] if present and not deleted */ \
return x; \
} \
SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x) \
{ \
if (x != h->n_buckets && !__ac_iseither(h->flags, x)) { \
__ac_set_isdel_true(h->flags, x); \
--h->size; \
} \
}
#define KHASH_DECLARE(name, khkey_t, khval_t) \
__KHASH_TYPE(name, khkey_t, khval_t) \
__KHASH_PROTOTYPES(name, khkey_t, khval_t)
#define KHASH_INIT2(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
__KHASH_TYPE(name, khkey_t, khval_t) \
__KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
#define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
KHASH_INIT2(name, static kh_inline klib_unused, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
/* --- BEGIN OF HASH FUNCTIONS --- */
/*! @function
@abstract Integer hash function
@param key The integer [khint32_t]
@return The hash value [khint_t]
*/
#define kh_int_hash_func(key) (khint32_t)(key)
/*! @function
@abstract Integer comparison function
*/
#define kh_int_hash_equal(a, b) ((a) == (b))
/*! @function
@abstract 64-bit integer hash function
@param key The integer [khint64_t]
@return The hash value [khint_t]
*/
#define kh_int64_hash_func(key) (khint32_t)((key)>>33^(key)^(key)<<11)
/*! @function
@abstract 64-bit integer comparison function
*/
#define kh_int64_hash_equal(a, b) ((a) == (b))
/*! @function
@abstract const char* hash function
@param s Pointer to a null terminated string
@return The hash value
*/
static kh_inline khint_t __ac_X31_hash_string(const char *s)
{
khint_t h = (khint_t)*s;
if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)*s;
return h;
}
/*! @function
@abstract Another interface to const char* hash function
@param key Pointer to a null terminated string [const char*]
@return The hash value [khint_t]
*/
#define kh_str_hash_func(key) __ac_X31_hash_string(key)
/*! @function
@abstract Const char* comparison function
*/
#define kh_str_hash_equal(a, b) (strcmp(a, b) == 0)
static kh_inline khint_t __ac_Wang_hash(khint_t key)
{
key += ~(key << 15);
key ^= (key >> 10);
key += (key << 3);
key ^= (key >> 6);
key += ~(key << 11);
key ^= (key >> 16);
return key;
}
#define kh_int_hash_func2(key) __ac_Wang_hash((khint_t)key)
/* --- END OF HASH FUNCTIONS --- */
/* Other convenient macros... */
/*!
@abstract Type of the hash table.
@param name Name of the hash table [symbol]
*/
#define khash_t(name) kh_##name##_t
/*! @function
@abstract Initiate a hash table.
@param name Name of the hash table [symbol]
@return Pointer to the hash table [khash_t(name)*]
*/
#define kh_init(name) kh_init_##name()
/*! @function
@abstract Destroy a hash table.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
*/
#define kh_destroy(name, h) kh_destroy_##name(h)
/*! @function
@abstract Reset a hash table without deallocating memory.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
*/
#define kh_clear(name, h) kh_clear_##name(h)
/*! @function
@abstract Resize a hash table.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
@param s New size [khint_t]
*/
#define kh_resize(name, h, s) kh_resize_##name(h, s)
/*! @function
@abstract Insert a key to the hash table.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
@param k Key [type of keys]
@param r Extra return code: -1 if the operation failed;
0 if the key is present in the hash table;
1 if the bucket is empty (never used); 2 if the element in
the bucket has been deleted [int*]
@return Iterator to the inserted element [khint_t]
*/
#define kh_put(name, h, k, r) kh_put_##name(h, k, r)
/*! @function
@abstract Retrieve a key from the hash table.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
@param k Key [type of keys]
@return Iterator to the found element, or kh_end(h) if the element is absent [khint_t]
*/
#define kh_get(name, h, k) kh_get_##name(h, k)
/*! @function
@abstract Remove a key from the hash table.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
@param k Iterator to the element to be deleted [khint_t]
*/
#define kh_del(name, h, k) kh_del_##name(h, k)
/*! @function
@abstract Test whether a bucket contains data.
@param h Pointer to the hash table [khash_t(name)*]
@param x Iterator to the bucket [khint_t]
@return 1 if containing data; 0 otherwise [int]
*/
#define kh_exist(h, x) (!__ac_iseither((h)->flags, (x)))
/*! @function
@abstract Get key given an iterator
@param h Pointer to the hash table [khash_t(name)*]
@param x Iterator to the bucket [khint_t]
@return Key [type of keys]
*/
#define kh_key(h, x) ((h)->keys[x])
/*! @function
@abstract Get value given an iterator
@param h Pointer to the hash table [khash_t(name)*]
@param x Iterator to the bucket [khint_t]
@return Value [type of values]
@discussion For hash sets, calling this results in segfault.
*/
#define kh_val(h, x) ((h)->vals[x])
/*! @function
@abstract Alias of kh_val()
*/
#define kh_value(h, x) ((h)->vals[x])
/*! @function
@abstract Get the start iterator
@param h Pointer to the hash table [khash_t(name)*]
@return The start iterator [khint_t]
*/
#define kh_begin(h) (khint_t)(0)
/*! @function
@abstract Get the end iterator
@param h Pointer to the hash table [khash_t(name)*]
@return The end iterator [khint_t]
*/
#define kh_end(h) ((h)->n_buckets)
/*! @function
@abstract Get the number of elements in the hash table
@param h Pointer to the hash table [khash_t(name)*]
@return Number of elements in the hash table [khint_t]
*/
#define kh_size(h) ((h)->size)
/*! @function
@abstract Get the number of buckets in the hash table
@param h Pointer to the hash table [khash_t(name)*]
@return Number of buckets in the hash table [khint_t]
*/
#define kh_n_buckets(h) ((h)->n_buckets)
/*! @function
@abstract Iterate over the entries in the hash table
@param h Pointer to the hash table [khash_t(name)*]
@param kvar Variable to which key will be assigned
@param vvar Variable to which value will be assigned
@param code Block of code to execute
*/
#define kh_foreach(h, kvar, vvar, code) { khint_t __i; \
for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \
if (!kh_exist(h,__i)) continue; \
(kvar) = kh_key(h,__i); \
(vvar) = kh_val(h,__i); \
code; \
} }
/*! @function
@abstract Iterate over the values in the hash table
@param h Pointer to the hash table [khash_t(name)*]
@param vvar Variable to which value will be assigned
@param code Block of code to execute
*/
#define kh_foreach_value(h, vvar, code) { khint_t __i; \
for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \
if (!kh_exist(h,__i)) continue; \
(vvar) = kh_val(h,__i); \
code; \
} }
/* More convenient interfaces */
/*! @function
@abstract Instantiate a hash set containing integer keys
@param name Name of the hash table [symbol]
*/
#define KHASH_SET_INIT_INT(name) \
KHASH_INIT(name, khint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal)
/*! @function
@abstract Instantiate a hash map containing integer keys
@param name Name of the hash table [symbol]
@param khval_t Type of values [type]
*/
#define KHASH_MAP_INIT_INT(name, khval_t) \
KHASH_INIT(name, khint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal)
/*! @function
@abstract Instantiate a hash set containing 64-bit integer keys
@param name Name of the hash table [symbol]
*/
#define KHASH_SET_INIT_INT64(name) \
KHASH_INIT(name, khint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
/*! @function
@abstract Instantiate a hash map containing 64-bit integer keys
@param name Name of the hash table [symbol]
@param khval_t Type of values [type]
*/
#define KHASH_MAP_INIT_INT64(name, khval_t) \
KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
typedef const char *kh_cstr_t;
/*! @function
@abstract Instantiate a hash map containing const char* keys
@param name Name of the hash table [symbol]
*/
#define KHASH_SET_INIT_STR(name) \
KHASH_INIT(name, kh_cstr_t, char, 0, kh_str_hash_func, kh_str_hash_equal)
/*! @function
@abstract Instantiate a hash map containing const char* keys
@param name Name of the hash table [symbol]
@param khval_t Type of values [type]
*/
#define KHASH_MAP_INIT_STR(name, khval_t) \
KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal)
#endif /* __AC_KHASH_H */
-169
View File
@@ -1,169 +0,0 @@
/* The MIT License
Copyright (c) 2008-2009, by Attractive Chaos <attractor@live.co.uk>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef _AC_KLIST_H
#define _AC_KLIST_H
#include <stdlib.h>
#ifndef klib_unused
#if (defined __clang__ && __clang_major__ >= 3) || (defined __GNUC__ && __GNUC__ >= 3)
#define klib_unused __attribute__ ((__unused__))
#else
#define klib_unused
#endif
#endif /* klib_unused */
#define KMEMPOOL_INIT2(SCOPE, name, kmptype_t, kmpfree_f) \
typedef struct { \
size_t cnt, n, max; \
kmptype_t **buf; \
} kmp_##name##_t; \
SCOPE kmp_##name##_t *kmp_init_##name(void) { \
return (kmp_##name##_t *)calloc(1, sizeof(kmp_##name##_t)); \
} \
SCOPE void kmp_destroy_##name(kmp_##name##_t *mp) { \
size_t k; \
for (k = 0; k < mp->n; ++k) { \
kmpfree_f(mp->buf[k]); free(mp->buf[k]); \
} \
free(mp->buf); free(mp); \
} \
SCOPE kmptype_t *kmp_alloc_##name(kmp_##name##_t *mp) { \
++mp->cnt; \
if (mp->n == 0) return (kmptype_t *)calloc(1, sizeof(kmptype_t)); \
return mp->buf[--mp->n]; \
} \
SCOPE void kmp_free_##name(kmp_##name##_t *mp, kmptype_t *p) { \
--mp->cnt; \
if (mp->n == mp->max) { \
mp->max = mp->max? mp->max<<1 : 16; \
mp->buf = (kmptype_t **)realloc(mp->buf, sizeof(kmptype_t *) * mp->max); \
} \
mp->buf[mp->n++] = p; \
}
#define KMEMPOOL_INIT(name, kmptype_t, kmpfree_f) \
KMEMPOOL_INIT2(static inline klib_unused, name, kmptype_t, kmpfree_f)
#define kmempool_t(name) kmp_##name##_t
#define kmp_init(name) kmp_init_##name()
#define kmp_destroy(name, mp) kmp_destroy_##name(mp)
#define kmp_alloc(name, mp) kmp_alloc_##name(mp)
#define kmp_free(name, mp, p) kmp_free_##name(mp, p)
#define KLIST_INIT2(SCOPE, name, kltype_t, kmpfree_t) \
struct __kl1_##name { \
kltype_t data; \
struct __kl1_##name *next; \
}; \
typedef struct __kl1_##name kl1_##name; \
KMEMPOOL_INIT2(SCOPE, name, kl1_##name, kmpfree_t) \
typedef struct { \
kl1_##name *head, *tail; \
kmp_##name##_t *mp; \
size_t size; \
} kl_##name##_t; \
SCOPE kl_##name##_t *kl_init_##name(void) { \
kl_##name##_t *kl = (kl_##name##_t *)calloc(1, sizeof(kl_##name##_t)); \
kl->mp = kmp_init(name); \
kl->head = kl->tail = kmp_alloc(name, kl->mp); \
kl->head->next = 0; \
return kl; \
} \
SCOPE void kl_destroy_##name(kl_##name##_t *kl) { \
kl1_##name *p; \
if (kl == NULL) return; \
for (p = kl->head; p != kl->tail; p = p->next) \
kmp_free(name, kl->mp, p); \
kmp_free(name, kl->mp, p); \
kmp_destroy(name, kl->mp); \
free(kl);kl=NULL; \
} \
SCOPE kltype_t *kl_pushp_##name(kl_##name##_t *kl) { \
kl1_##name *q, *p = kmp_alloc(name, kl->mp); \
q = kl->tail; p->next = 0; kl->tail->next = p; kl->tail = p; \
++kl->size; \
return &q->data; \
} \
SCOPE kltype_t *kl_pushf_##name(kl_##name##_t *kl) { \
kl1_##name *q, *p = kmp_alloc(name, kl->mp); \
p->next = kl->head; kl->head = p; \
++kl->size; \
return &p->data; \
} \
SCOPE kltype_t *kl_back_##name(kl_##name##_t *kl) { \
kl1_##name *p = kl->head; \
while (p->next != kl->tail) {p = p->next;} \
return &p->data; \
} \
SCOPE int kl_shift_##name(kl_##name##_t *kl, kltype_t *d) { \
kl1_##name *p; \
if (kl->head->next == 0) return -1; \
--kl->size; \
p = kl->head; kl->head = kl->head->next; \
if (d) *d = p->data; \
kmp_free(name, kl->mp, p); \
return 0; \
} \
SCOPE int kl_erase_##name(kl_##name##_t *kl, kl1_##name **pp) { \
kl1_##name *p = *pp; \
if (kl->head->next == 0) return -1; \
if (p == kl->head) return kl_shift_##name(kl,0); \
--kl->size; \
for (kl1_##name *iter=kl->head;iter!=kl->tail;iter=iter->next) \
if (p == iter->next){iter->next = p->next; \
kmp_free(name, kl->mp, p);*pp=iter;break;} \
return 0; \
} \
SCOPE size_t kl_size_##name(kl_##name##_t *kl){ \
return kl->size;} \
SCOPE void kl_clear_##name(kl_##name##_t *kl){ \
while(kl_shift_##name(kl,0) != -1){}}
#define KLIST_INIT(name, kltype_t, kmpfree_t) \
KLIST_INIT2(static inline klib_unused, name, kltype_t, kmpfree_t)
#define kliter_t(name) kl1_##name
#define klist_t(name) kl_##name##_t
#define kl_val(iter) ((iter)->data)
#define kl_next(iter) ((iter)->next)
#define kl_begin(kl) ((kl)->head)
#define kl_end(kl) ((kl)->tail)
#define kl_init(name) kl_init_##name()
#define kl_destroy(name, kl) kl_destroy_##name(kl)
#define kl_pushp(name, kl) kl_pushp_##name(kl)
#define kl_pushf(name, kl) kl_pushf_##name(kl)
#define kl_back(name, kl) kl_back_##name(kl)
#define kl_shift(name, kl, d) kl_shift_##name(kl, d)
#define kl_erase(name, kl, pp) kl_erase_##name(kl, pp)
#define kl_size(name, kl) kl_size_##name(kl)
#define kl_clear(name, kl) kl_clear_##name(kl)
#endif
-294
View File
@@ -1,294 +0,0 @@
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdint.h>
#include "kstring.h"
int kvsprintf(kstring_t *s, const char *fmt, va_list ap)
{
va_list args;
int l;
va_copy(args, ap);
l = vsnprintf(s->s + s->l, s->m - s->l, fmt, args); // This line does not work with glibc 2.0. See `man snprintf'.
va_end(args);
if (l + 1 > s->m - s->l) {
s->m = s->l + l + 2;
kroundup32(s->m);
s->s = (char*)realloc(s->s, s->m);
va_copy(args, ap);
l = vsnprintf(s->s + s->l, s->m - s->l, fmt, args);
va_end(args);
}
s->l += l;
return l;
}
int ksprintf(kstring_t *s, const char *fmt, ...)
{
va_list ap;
int l;
va_start(ap, fmt);
l = kvsprintf(s, fmt, ap);
va_end(ap);
return l;
}
char *kstrtok(const char *str, const char *sep_in, ks_tokaux_t *aux)
{
const unsigned char *p, *start, *sep = (unsigned char *) sep_in;
if (sep) { // set up the table
if (str == 0 && aux->finished) return 0; // no need to set up if we have finished
aux->finished = 0;
if (sep[0] && sep[1]) {
aux->sep = -1;
aux->tab[0] = aux->tab[1] = aux->tab[2] = aux->tab[3] = 0;
for (p = sep; *p; ++p) aux->tab[*p>>6] |= 1ull<<(*p&0x3f);
} else aux->sep = sep[0];
}
if (aux->finished) return 0;
else if (str) start = (unsigned char *) str, aux->finished = 0;
else start = (unsigned char *) aux->p + 1;
if (aux->sep < 0) {
for (p = start; *p; ++p)
if (aux->tab[*p>>6]>>(*p&0x3f)&1) break;
} else {
for (p = start; *p; ++p)
if (*p == aux->sep) break;
}
aux->p = (const char *) p; // end of token
if (*p == 0) aux->finished = 1; // no more tokens
return (char*)start;
}
// s MUST BE a null terminated string; l = strlen(s)
int ksplit_core(char *s, int delimiter, int *_max, int **_offsets)
{
int i, n, max, last_char, last_start, *offsets, l;
n = 0; max = *_max; offsets = *_offsets;
l = strlen(s);
#define __ksplit_aux do { \
if (_offsets) { \
s[i] = 0; \
if (n == max) { \
int *tmp; \
max = max? max<<1 : 2; \
if ((tmp = (int*)realloc(offsets, sizeof(int) * max))) { \
offsets = tmp; \
} else { \
free(offsets); \
*_offsets = NULL; \
return 0; \
} \
} \
offsets[n++] = last_start; \
} else ++n; \
} while (0)
for (i = 0, last_char = last_start = 0; i <= l; ++i) {
if (delimiter == 0) {
if (isspace(s[i]) || s[i] == 0) {
if (isgraph(last_char)) __ksplit_aux; // the end of a field
} else {
if (isspace(last_char) || last_char == 0) last_start = i;
}
} else {
if (s[i] == delimiter || s[i] == 0) {
if (last_char != 0 && last_char != delimiter) __ksplit_aux; // the end of a field
} else {
if (last_char == delimiter || last_char == 0) last_start = i;
}
}
last_char = s[i];
}
*_max = max; *_offsets = offsets;
return n;
}
int kgetline(kstring_t *s, kgets_func *fgets_fn, void *fp)
{
size_t l0 = s->l;
while (s->l == l0 || s->s[s->l-1] != '\n') {
if (s->m - s->l < 200) ks_resize(s, s->m + 200);
if (fgets_fn(s->s + s->l, s->m - s->l, fp) == NULL) break;
s->l += strlen(s->s + s->l);
}
if (s->l == l0) return EOF;
if (s->l > l0 && s->s[s->l-1] == '\n') {
s->l--;
if (s->l > l0 && s->s[s->l-1] == '\r') s->l--;
}
s->s[s->l] = '\0';
return 0;
}
/**********************
* Boyer-Moore search *
**********************/
typedef unsigned char ubyte_t;
// reference: http://www-igm.univ-mlv.fr/~lecroq/string/node14.html
static int *ksBM_prep(const ubyte_t *pat, int m)
{
int i, *suff, *prep, *bmGs, *bmBc;
prep = (int*)calloc(m + 256, sizeof(int));
bmGs = prep; bmBc = prep + m;
{ // preBmBc()
for (i = 0; i < 256; ++i) bmBc[i] = m;
for (i = 0; i < m - 1; ++i) bmBc[pat[i]] = m - i - 1;
}
suff = (int*)calloc(m, sizeof(int));
{ // suffixes()
int f = 0, g;
suff[m - 1] = m;
g = m - 1;
for (i = m - 2; i >= 0; --i) {
if (i > g && suff[i + m - 1 - f] < i - g)
suff[i] = suff[i + m - 1 - f];
else {
if (i < g) g = i;
f = i;
while (g >= 0 && pat[g] == pat[g + m - 1 - f]) --g;
suff[i] = f - g;
}
}
}
{ // preBmGs()
int j = 0;
for (i = 0; i < m; ++i) bmGs[i] = m;
for (i = m - 1; i >= 0; --i)
if (suff[i] == i + 1)
for (; j < m - 1 - i; ++j)
if (bmGs[j] == m)
bmGs[j] = m - 1 - i;
for (i = 0; i <= m - 2; ++i)
bmGs[m - 1 - suff[i]] = m - 1 - i;
}
free(suff);
return prep;
}
void *kmemmem(const void *_str, int n, const void *_pat, int m, int **_prep)
{
int i, j, *prep = 0, *bmGs, *bmBc;
const ubyte_t *str, *pat;
str = (const ubyte_t*)_str; pat = (const ubyte_t*)_pat;
prep = (_prep == 0 || *_prep == 0)? ksBM_prep(pat, m) : *_prep;
if (_prep && *_prep == 0) *_prep = prep;
bmGs = prep; bmBc = prep + m;
j = 0;
while (j <= n - m) {
for (i = m - 1; i >= 0 && pat[i] == str[i+j]; --i);
if (i >= 0) {
int max = bmBc[str[i+j]] - m + 1 + i;
if (max < bmGs[i]) max = bmGs[i];
j += max;
} else return (void*)(str + j);
}
if (_prep == 0) free(prep);
return 0;
}
char *kstrstr(const char *str, const char *pat, int **_prep)
{
return (char*)kmemmem(str, strlen(str), pat, strlen(pat), _prep);
}
char *kstrnstr(const char *str, const char *pat, int n, int **_prep)
{
return (char*)kmemmem(str, n, pat, strlen(pat), _prep);
}
void kstrcpy(kstring_t *s, const char *src)
{
const char *buf = strdup(src);
if (s->s)
free(s->s);
ks_release(s);
kputs(buf, s);
free((void*)buf);
return;
}
/***********************
* The main() function *
***********************/
#ifdef KSTRING_MAIN
#include <stdio.h>
char* WtptpDownLoad_replace_all(char* str,const char* old_value,const char* new_value)
{
char buf[256]={0};
char *p = NULL,*pstr = str;
int lo = strlen(old_value);
p = strstr(pstr, old_value);
while (p)
{
strncat(buf, pstr, p-pstr);
strcat(buf, new_value);
pstr = p + lo;
p = strstr(pstr,old_value);
}
strcat(buf,pstr);
strcpy(str, buf);
return str;
}
typedef const char* t_conststr;
int main()
{
kstring_t *s;
t_conststr a,b;
int *fields, n, i;
ks_tokaux_t aux;
char *p;
char buf[256] = "asdhesdafhehew";
a = "abc";
b = "bcd";
s = (kstring_t*)calloc(1, sizeof(kstring_t));
// test ksprintf()
ksprintf(s, "abcdefg:%d", 100);
printf("'%s'\n", s->s);
kputs("hehe ",s);
printf("%s\n", s->s);
ksprintf(s, "abc%sdefg:", "hehehe");
printf("!!!!%s\n", s->s);
// test ksplit()
fields = ksplit(s, 0, &n);
for (i = 0; i < n; ++i)
printf("field[%d] = '%s'\n", i, s->s + fields[i]);
kstrcpy(s,s->s+fields[0]);
printf("@@@%s\n", s->s);
printf("replace:%s\n",WtptpDownLoad_replace_all(buf,"he","hello"));
// test kstrtok()
s->l = 0;
for (p = kstrtok("ab:cde:fg/hij::k", ":/", &aux); p; p = kstrtok(0, 0, &aux)) {
kputsn(p, aux.p - p, s);
kputc('\n', s);
}
printf("%s", s->s);
// free
free(s->s); free(s); free(fields);
{
static char *str = "abcdefgcdgcagtcakcdcd";
static char *pat = "cd";
char *ret, *s = str;
int *prep = 0;
while ((ret = kstrstr(s, pat, &prep)) != 0) {
printf("match: %s\n", ret);
s = ret + prep[0];
}
free(prep);
}
return 0;
}
#endif
-278
View File
@@ -1,278 +0,0 @@
/* The MIT License
Copyright (c) by Attractive Chaos <attractor@live.co.uk>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef KSTRING_H
#define KSTRING_H
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#ifndef kroundup32
#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
#endif
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#define KS_ATTR_PRINTF(fmt, arg) __attribute__((__format__ (__printf__, fmt, arg)))
#else
#define KS_ATTR_PRINTF(fmt, arg)
#endif
/* kstring_t is a simple non-opaque type whose fields are likely to be
* used directly by user code (but see also ks_str() and ks_len() below).
* A kstring_t object is initialised by either of
* kstring_t str = { 0, 0, NULL };
* kstring_t str; ...; str.l = str.m = 0; str.s = NULL;
* and either ownership of the underlying buffer should be given away before
* the object disappears (see ks_release() below) or the kstring_t should be
* destroyed with free(str.s); */
#ifndef KSTRING_T
#define KSTRING_T kstring_t
typedef struct __kstring_t {
size_t l, m;
char *s;
} kstring_t;
#endif
typedef struct {
uint64_t tab[4];
int sep, finished;
const char *p; // end of the current token
} ks_tokaux_t;
#ifdef __cplusplus
extern "C" {
#endif
int kvsprintf(kstring_t *s, const char *fmt, va_list ap) KS_ATTR_PRINTF(2,0);
int ksprintf(kstring_t *s, const char *fmt, ...) KS_ATTR_PRINTF(2,3);
int ksplit_core(char *s, int delimiter, int *_max, int **_offsets);
char *kstrstr(const char *str, const char *pat, int **_prep);
char *kstrnstr(const char *str, const char *pat, int n, int **_prep);
void *kmemmem(const void *_str, int n, const void *_pat, int m, int **_prep);
void kstrcpy(kstring_t *s, const char *src);
/* kstrtok() is similar to strtok_r() except that str is not
* modified and both str and sep can be NULL. For efficiency, it is
* actually recommended to set both to NULL in the subsequent calls
* if sep is not changed. */
char *kstrtok(const char *str, const char *sep, ks_tokaux_t *aux);
/* kgetline() uses the supplied fgets()-like function to read a "\n"-
* or "\r\n"-terminated line from fp. The line read is appended to the
* kstring without its terminator and 0 is returned; EOF is returned at
* EOF or on error (determined by querying fp, as per fgets()). */
typedef char *kgets_func(char *, int, void *);
int kgetline(kstring_t *s, kgets_func *fgets, void *fp);
#ifdef __cplusplus
}
#endif
static inline int ks_resize(kstring_t *s, size_t size)
{
if (s->m < size) {
char *tmp;
s->m = size;
kroundup32(s->m);
if ((tmp = (char*)realloc(s->s, s->m)))
s->s = tmp;
else
return -1;
}
return 0;
}
static inline char *ks_str(kstring_t *s)
{
return s->s;
}
static inline size_t ks_len(kstring_t *s)
{
return s->l;
}
// Give ownership of the underlying buffer away to something else (making
// that something else responsible for freeing it), leaving the kstring_t
// empty and ready to be used again, or ready to go out of scope without
// needing free(str.s) to prevent a memory leak.
static inline char *ks_release(kstring_t *s)
{
char *ss = s->s;
s->l = s->m = 0;
s->s = NULL;
return ss;
}
static inline int kputsn(const char *p, int l, kstring_t *s)
{
if (s->l + l + 1 >= s->m) {
char *tmp;
s->m = s->l + l + 2;
kroundup32(s->m);
if ((tmp = (char*)realloc(s->s, s->m)))
s->s = tmp;
else
return EOF;
}
memcpy(s->s + s->l, p, l);
s->l += l;
s->s[s->l] = 0;
return l;
}
static inline int kputs(const char *p, kstring_t *s)
{
return kputsn(p, strlen(p), s);
}
static inline int kputc(int c, kstring_t *s)
{
if (s->l + 1 >= s->m) {
char *tmp;
s->m = s->l + 2;
kroundup32(s->m);
if ((tmp = (char*)realloc(s->s, s->m)))
s->s = tmp;
else
return EOF;
}
s->s[s->l++] = c;
s->s[s->l] = 0;
return c;
}
static inline int kputc_(int c, kstring_t *s)
{
if (s->l + 1 > s->m) {
char *tmp;
s->m = s->l + 1;
kroundup32(s->m);
if ((tmp = (char*)realloc(s->s, s->m)))
s->s = tmp;
else
return EOF;
}
s->s[s->l++] = c;
return 1;
}
static inline int kputsn_(const void *p, int l, kstring_t *s)
{
if (s->l + l > s->m) {
char *tmp;
s->m = s->l + l;
kroundup32(s->m);
if ((tmp = (char*)realloc(s->s, s->m)))
s->s = tmp;
else
return EOF;
}
memcpy(s->s + s->l, p, l);
s->l += l;
return l;
}
static inline int kputw(int c, kstring_t *s)
{
char buf[16];
int i, l = 0;
unsigned int x = c;
if (c < 0) x = -x;
do { buf[l++] = x%10 + '0'; x /= 10; } while (x > 0);
if (c < 0) buf[l++] = '-';
if (s->l + l + 1 >= s->m) {
char *tmp;
s->m = s->l + l + 2;
kroundup32(s->m);
if ((tmp = (char*)realloc(s->s, s->m)))
s->s = tmp;
else
return EOF;
}
for (i = l - 1; i >= 0; --i) s->s[s->l++] = buf[i];
s->s[s->l] = 0;
return 0;
}
static inline int kputuw(unsigned c, kstring_t *s)
{
char buf[16];
int l, i;
unsigned x;
if (c == 0) return kputc('0', s);
for (l = 0, x = c; x > 0; x /= 10) buf[l++] = x%10 + '0';
if (s->l + l + 1 >= s->m) {
char *tmp;
s->m = s->l + l + 2;
kroundup32(s->m);
if ((tmp = (char*)realloc(s->s, s->m)))
s->s = tmp;
else
return EOF;
}
for (i = l - 1; i >= 0; --i) s->s[s->l++] = buf[i];
s->s[s->l] = 0;
return 0;
}
static inline int kputl(long c, kstring_t *s)
{
char buf[32];
int i, l = 0;
unsigned long x = c;
if (c < 0) x = -x;
do { buf[l++] = x%10 + '0'; x /= 10; } while (x > 0);
if (c < 0) buf[l++] = '-';
if (s->l + l + 1 >= s->m) {
char *tmp;
s->m = s->l + l + 2;
kroundup32(s->m);
if ((tmp = (char*)realloc(s->s, s->m)))
s->s = tmp;
else
return EOF;
}
for (i = l - 1; i >= 0; --i) s->s[s->l++] = buf[i];
s->s[s->l] = 0;
return 0;
}
/*
* Returns 's' split by delimiter, with *n being the number of components;
* NULL on failue.
*/
static inline int *ksplit(kstring_t *s, int delimiter, int *n)
{
int max = 0, *offsets = 0;
*n = ksplit_core(s->s, delimiter, &max, &offsets);
return offsets;
}
#endif
-49
View File
@@ -1,49 +0,0 @@
###############################################################
# Makefile for the Marvell download for MMP2/wukong/NEVO.
#
#
##############################################################
CC = gcc
AR = ar
RM = rm
CP = cp
ECHO = echo
TARGET = libfbfdown.a
include tool.mak #°üº¬×Ómakefile
BASE:=$(shell pwd)
LIBS = -lpthread
INCLUDES = -I./
CCFLAGS += -O2 $(INCLUDES) -D LINUX=1 -D _FILE_OFFSET_BITS=64 -D WINDOWS=0 -D DEBUG_MODE=0 -D TRUSTED_BOOT=1 -D IFLSWD_STATIC -D STATICLIB_FBFDOWNLOAD -D PRINTLOG=1 -g -std=c99
TBBOBJS =CommonFun.o\
ParaDefine.o\
WTPCOMMCLASS.o \
BinFileWtp.o\
WtptpDownloader.o \
WtptpDownLoad.o\
ConvetEdian.o\
BulkDevNonDrv_Linux.o\
kstring.o\
FBFDownloader.o\
OBJS = $(TBBOBJS)
all:$(TARGET)
$(TARGET):$(OBJS) $(LIBS) -ldl
$(BUILD_LIBRARY)
$(TBBOBJS): %.o: ./%.c
$(CC) -c $(CCFLAGS) -I./ -c "./$*.c" -o "$(BASE)/$*.o"
.PHONY: clean
clean:
-rm *.o
-56
View File
@@ -1,56 +0,0 @@
###############################################################
# Makefile for the Marvell download for MMP2/wukong/NEVO.
#
#
##############################################################
#CC = arm_1103_le-g++
#CC = mipsel-linux-uclibc-g++
#CC = mipsel-openwrt-linux-g++
#CC = arm-hisiv200-linux-gnueabi-g++
CC = ${CROSS}gcc
AR = ar
RM = rm
CP = cp
ECHO = echo
TARGET = libfbfdown_cross.a
include tool.mak #包含子makefile
BASE:=$(shell pwd)
LIBS = -lpthread
INCLUDES = -I./
CCFLAGS += -O2 $(INCLUDES) -D LINUX=1 -D WINDOWS=0 -D DEBUG_MODE=0 -D TRUSTED_BOOT=1 -D IFLSWD_STATIC -D STATICLIB_FBFDOWNLOAD -D PRINTLOG=1 -std=c99
ifneq ($(ANDROIDBLD),1)
CCFLAGS += -D _FILE_OFFSET_BITS=64
endif
TBBOBJS =CommonFun.o\
ParaDefine.o\
WTPCOMMCLASS.o \
BinFileWtp.o\
kstring.o\
WtptpDownloader.o \
WtptpDownLoad.o\
ConvetEdian.o\
BulkDevNonDrv_Linux.o\
FBFDownloader.o\
OBJS = $(TBBOBJS)
all:$(TARGET)
$(TARGET):$(OBJS) $(LIBS) -ldl
$(BUILD_LIBRARY)
$(TBBOBJS): %.o: ./%.c
$(CC) -c $(CCFLAGS) -I./ -c "./$*.c" -o "$(BASE)/$*.o"
.PHONY: clean
clean:
-rm *.o
-72
View File
@@ -1,72 +0,0 @@
交叉编译方法
以使用buildroot-gcc463交叉编译工具链为例:
gcc bin文件路径为:
/home/toolchain/buildroot-gcc463/usr/bin/mipsel-linux-gcc
export CROSS=/home/toolchain/buildroot-gcc463/usr/bin/mipsel-linux-
cd 源码目录
make -f FBFDownloader_makefile_cross
对于一些toolchain,需要:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/toolchain/buildroot-gcc463/usr/lib
生成的fbfdownloader_cross即为下载工具。
程序入口为:FBFDownloader.c:728 main(int argc, char *argv[])
FBFDownloader.c:732 ParseCommandLine为解析参数函数,包括 -b BinFile.bin(必选)
-p logFilePath(可选,指定下载过程中log和临时文件生成的目录)
FBFDownloader.c:780 PInstanceParams lpInstanceParam. 该结构体存放下载相关的参数
FBFDownloader.c:790-800 该过程为从BinFile.bin文件中提取下载相关参数。
FBFDownloader.c:813 执行下载过程函数InitializeBL(lpInstanceParam)
WtptpDownLoad.c:6 InitializeBL(PInstanceParams pInstParam)
WtptpDownloader.c:2762 BOOL WtptpDownLoad_InitializeBL(struct CWtptpDownLoad *me,PInstanceParams pInstParam)
WtptpDownloader.c:2867-2892 下载前参数解析准备过程。
WtptpDownloader.c:2901 创建设备检测线程,检测下载口枚举
WtptpDownloader.c:535 PVOID WtptpDownLoad_WtptpDeviceDetectThread(PVOID Arg)
WtptpDownloader.c:541 WtptpDownLoad_init_hotplug_sock 创建socket,用来检测下载设备hotplug
WtptpDownloader.c:542 BulkDevNonDrv_FindAllSupportedDevices 检测已经接入的下载设备,根据设备的PID和VID判断是否为下载设备
WtptpDownloader.c:554 下载设备已经存在,打开设备WtptpDownLoad_WtptpOpenDevice
WtptpDownloader.c:581 BulkDevNonDrv_CheckDevForNetLink 检测到下载设备插拔事件
WtptpDownloader.c:590 设备插入 打开设备 WtptpDownLoad_WtptpOpenDevice
WtptpDownloader.c:610 设备移除 停止下载流程 WtptpDownLoad_SetAndWaitForThreadExit
打开设备
WtptpDownloader.c:482 void WtptpDownLoad_WtptpOpenDevice(struct CWtptpDownLoad *me,struct CWtptpDownLoad *pWtptpDownLoad, USB_HANDLE *pLinuxUsb)
WtptpDownloader.c:492-507准备工作,根据设备路径创建Log文件
WtptpDownloader.c:509 打开设备函数WtptpDownLoad_OpenDevice
WtptpDownloader.c:916 BOOL WtptpDownLoad_OpenDevice(struct CWtptpDownLoad *me,PDEVICE pDev)
WtptpDownloader.c:954 WtptpDownLoad_GetDeviceBootType 获取设备型号和类型,(BootRom,BootLoader)
该过程主要流程为:
1、打开USB口 WtptpDownloader.c:725 OpenUsbPort
2、与芯片进行握手,发送Preamble消息 WtptpDownloader.c:736 SendPreamble
3、获取芯片当前状态 WtptpDownloader.c:747 GetTargetMessage
4、发送GetVersion消息,获取芯片型号和类型,WtptpDownloader.c:764 GetVersion
5、处理GetVersion返回的内容,WtptpDownloader.c:769-912
如果设备类型为BootRom,即模块为空板,则创建BootRom下载线程。WtptpDownloader.c:971-988
BootRom下载(空板下载、ForceDownload)是将OBM下载至模块DDR中,下载完成后,当前BootROM设备会自动移除,随后模块以BootLoader类型接入大板(Host),工具会再次检测到设备接入,且其类型为BootLoader。
如果设备类型为BootLoader,即非空板,则创建BootLoader下载线程。WtptpDownloader.c:989-1010
BootRom和BootLoader下载过程类似,都是通过调用WtptpDownLoad_WTPTPDownLoad函数来进行下载。主要区别是BootLoader下载完成后,会将下载状态设置为kProcCompleted(成功WtptpDownloader.c:251)或kProcAborting(失败WtptpDownloader.c:258),此后工具会退出;BootRom下载完成后工具不会退出,设备检测线程会继续运行。
下面将描述下载的核心函数的流程WtptpDownloader.c:2044 BOOL WtptpDownLoad_WTPTPDownLoad(struct CWtptpDownLoad *me,PDEVICE pDev)
WtptpDownloader.c:2049-2141 设置下载相关参数和下载的Image List,计算下载总大小。
WtptpDownloader.c:2143-2561 对每个image进行下载和烧写
WtptpDownloader.c:2153 WtptpDownLoad_DownloadImage
WtptpDownloader.c:1019 BOOL WtptpDownLoad_DownloadImage(struct CWtptpDownLoad *me,PDEVICE pdev, int iFile,const t_ImageFileList* plImgFileList, UINT64 uiAllimgsize,UINT64 *uidownloadsize,int nImages,char* strDownloadImgName)
该函数将image下载至模块DDR中,大致流程为:
1、SendPreamble
2、GetVersion
以上两步在下载第一个image时省略,因为WtptpDownLoad_GetDeviceBootType中已经执行上两个步骤
3、SelectImage WtptpDownloader.c:1103
4、VerifyImage WtptpDownloader.c:1117
5、GetBadBlockInfo WtptpDownloader.c:1188
6、DataHeader
7、Data(将image所有数据通过Data传输完)
8、Done WtptpDownloader.c:1447
WtptpDownloader.c:2160-2552 Image下载到DDR后,模块开始将image烧写到flash,该段代码主要通过GetWtpMessage获取模块烧写过程中的状态:
WtptpDownloader.c:2512 当工具收到模块处于PlatformReady状态消息后,表明image烧写完毕。
所有image下载烧写完毕后,如果在blf中使能CRC校验(部分平台支持),模块会计算烧写完的image CRC,并上报给工具。WtptpDownloader.c:2565-2596
其他说明:上述下载过程中提及的image并非指BinFile.bin文件。BinFile.bin是包括下载参数、下载image等内容的包文件,下载过程中通过BinFileWtp.h中的类(c++移植到c形式的类)来解析。
+1 -1
View File
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=26.4.15
PKG_RELEASE:=92
PKG_RELEASE:=93
PKG_PO_VERSION:=$(PKG_VERSION)
PKG_CONFIG_DEPENDS:= \
@@ -16,6 +16,22 @@ local appname = api.appname
display: none !important;
visibility: hidden !important;
}
@media screen and (max-width: 1152px) {
#cbi-<%=appname%>-socks .cbi-section-table-titles {
display: none !important;
}
}
@media screen and (min-width: 1152px) {
#cbi-<%=appname%>-socks input[id*=".<%=appname%>."][id$=".port"],
#cbi-<%=appname%>-socks input[id*=".<%=appname%>."][id$=".http_port"] {
width: 100px !important;
min-width: unset !important;
max-width: unset !important;
text-align: center !important;
}
}
</style>
<script type="text/javascript">
//<![CDATA[
@@ -1,7 +1,8 @@
<%
local api = require "luci.passwall.api"
local appname = api.appname
-%>
<script src="<%=resource%>/view/<%=api.appname%>/Sortable.min.js?v=1.15.7"></script>
<script src="<%=resource%>/view/<%=appname%>/Sortable.min.js?v=1.15.7"></script>
<style>
table .cbi-button-up,
@@ -34,6 +35,34 @@ table .cbi-button-down,
background-color: rgba(131, 191, 255, 0.7) !important;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
@media screen and (max-width: 1152px) {
#cbi-<%=appname%>-haproxy_config .cbi-section-table-titles {
display: none !important;
}
}
@media screen and (min-width: 1152px) {
#cbi-<%=appname%>-haproxy_config input[id*=".<%=appname%>."][id$=".haproxy_port"],
#cbi-<%=appname%>-haproxy_config input[id*=".<%=appname%>."][id$=".lbweight"] {
width: 100px !important;
min-width: unset !important;
max-width: unset !important;
text-align: center !important;
}
#cbi-<%=appname%>-haproxy_config select[id*=".<%=appname%>."][id$=".export"] {
width: 130px !important;
min-width: unset !important;
max-width: unset !important;
}
#cbi-<%=appname%>-haproxy_config select[id*=".<%=appname%>."][id$=".backup"] {
width: 100px !important;
min-width: unset !important;
max-width: unset !important;
}
}
</style>
<script type="text/javascript">
//<![CDATA[
@@ -85,7 +114,7 @@ table .cbi-button-down,
//节点列表添加拖拽排序
document.addEventListener("DOMContentLoaded", function () {
function initSortableForTable() {
var section = document.getElementById("cbi-<%=api.appname%>-haproxy_config");
var section = document.getElementById("cbi-<%=appname%>-haproxy_config");
if (!section) return;
hideSortColumn(section);
@@ -139,8 +168,8 @@ table .cbi-button-down,
var rows = root.querySelectorAll("tr.cbi-section-table-row");
rows.forEach(function (tr) {
var id = tr.id || "";
if (id.startsWith("cbi-<%=api.appname%>-"))
id = id.replace("cbi-<%=api.appname%>-", "");
if (id.startsWith("cbi-<%=appname%>-"))
id = id.replace("cbi-<%=appname%>-", "");
order.push(id);
});
return order;
@@ -34,6 +34,12 @@ table .cbi-button-down,
background-color: rgba(131, 191, 255, 0.7) !important;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
@media screen and (max-width: 1152px) {
#cbi-<%=api.appname%>-subscribe_list .cbi-section-table-titles {
display: none !important;
}
}
</style>
<script type="text/javascript">
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -75,6 +75,7 @@
a-normal-day.com
a248.e.akamai.net
aamacau.com
aave.com
abc.net.au
abc.xyz
abebooks.co.uk
@@ -126,7 +127,6 @@ aiph.net
airconsole.com
airitilibrary.com
airvpn.org
aiss.anws.gov.tw
ait.org.tw
aiweiweiblog.com
akademiye.org
@@ -134,6 +134,7 @@ akamai.tvb.com
akamaihd.net
akiba-online.com
akiba-web.com
akile.io
akinator.com
akow.org
alabout.com
@@ -183,11 +184,9 @@ angela-merkel.de
angola.org
angularjs.org
aniscartujo.com
annas-archive.in
annas-archive.li
annas-archive.org
annas-archive.pm
annas-archive.se
annas-archive.gd
annas-archive.gl
annas-archive.pk
anobii.com
anonfiles.com
anonymouse.org
@@ -224,6 +223,7 @@ apkpure.com
apkpure.net
app.box.com
app.cloudcone.com
app.element.io
app.smartmailcloud.com
appadvice.com
appbrain.com
@@ -235,6 +235,7 @@ appsocks.net
appspot.com
appsto.re
aptoide.com
archive-it.org
archive.fo
archive.is
archive.li
@@ -246,15 +247,16 @@ archive.vn
archiveofourown.com
archiveofourown.org
archives.gov
archives.gov.tw
arctosia.com
areca-backup.org
arena.ai
arena.taipei
arethusa.su
arlingtoncemetery.mil
arte.tv
artstation.com
arvanstorage.ir
arweave.org
asacp.org
asiaharvest.org
asianage.com
@@ -262,6 +264,7 @@ asianews.it
asianfanfics.com
asiansexdiary.com
asiaone.com
asiasociety.org
ask.com
askstudent.com
askynz.net
@@ -269,6 +272,7 @@ aspi.org.au
aspistrategist.org.au
assembla.com
assets.bwbx.io
assets.nxtrace.org
assimp.org
astrill.com
atc.org.au
@@ -288,6 +292,7 @@ avdb.tv
avg.com
avgle.com
avidemux.org
avistaz.to
avmo.pw
avmoo.pw
avoision.com
@@ -352,6 +357,7 @@ beijing1989.com
beijing2022.art
beijingspring.com
bell.wiki
bellingcat.com
berlinerbericht.de
berlintwitterwall.com
bestvpn.com
@@ -739,8 +745,8 @@ chrome.com
chromecast.com
chromeexperiments.com
chromestatus.com
chromium.org
ci-en.jp
cia.gov
cici.com
ciciai.com
cirosantilli.com
@@ -757,6 +763,7 @@ cixiaoya.club
ck101.com
classicalguitarblog.net
claude.ai
claude.com
cldr.unicode.org
clearsurance.com
clementine-player.org
@@ -838,6 +845,7 @@ cpj.org
cpu-monkey.com
cq99.us
crackle.com
crashlytics.com
crazypool.org
crazyshit.com
crbug.com
@@ -905,7 +913,6 @@ darpa.mil
darrenliuwei.com
dashlane.com
data-vocabulary.org
data.gov.tw
daum.net
david-kilgour.com
dawangidc.com
@@ -973,6 +980,8 @@ dmc.nico
dmcdn.net
dmhy.org
dmm.co.jp
dns.cloudflare.com
dns.sb
dns2go.com
dnscrypt.org
dnssec.net
@@ -983,6 +992,7 @@ docker.io
dockerstatus.com
docs.new
documentingreality.com
doh.sb
dolc.de
dolf.org.hk
dongtaiwang.com
@@ -990,6 +1000,7 @@ dongtaiwang.net
doom9.org
doosho.com
doourbest.org
dot.sb
dotplane.com
dotsub.com
dotvpn.com
@@ -1000,7 +1011,7 @@ doublethinklab.org
douchi.space
dougscripts.com
doujincafe.com
download.aircrack-ng.org
download.dappcdn.com
dpool.top
dpp.org.tw
dpr.info
@@ -1052,6 +1063,7 @@ ebook.hyread.com.tw
ebtcbank.com
ecfa.org.tw
ecimg.tw
economist.com
edgecastcdn.net
edubridge.com
edx-cdn.org
@@ -1115,7 +1127,6 @@ euronews.com
evchk.wikia.com
everipedia.org
evschool.net
exam.gov.tw
exchristian.hk
exhentai.org
exmo.com
@@ -1127,13 +1138,11 @@ exploader.net
expressvpn.com
exrates.me
extmatrix.com
ey.gov.tw
eyevio.jp
eyny.com
f-droid.org
f2pool.com
f8.com
fa.gov.tw
facebook.com
facebook.de
facebook.design
@@ -1189,7 +1198,6 @@ fbcdn.net
fbsbx.com
fbworkmail.com
fc2cn.com
fda.gov.tw
feedburner.com
feeder.co
feedly.com
@@ -1266,6 +1274,7 @@ free.com.tw
freebeacon.com
freebrowser.org
freechinaweibo.com
freedom.gov
freedomhouse.org
freedominfonetweb.wordpress.com
freedomsherald.org
@@ -1415,6 +1424,7 @@ glorystar.me
glype.com
gmail.com
gmgard.com
gmgn.ai
gmodules.com
gmp4.com
gnci.org.hk
@@ -1559,6 +1569,7 @@ google.com.vn
google.cv
google.cz
google.de
google.dev
google.dj
google.dk
google.dm
@@ -1685,6 +1696,7 @@ gotrusted.com
gotw.ca
gov.ir
gov.taipei
gov.tw
grammaly.com
graph.org
graphis.ne.jp
@@ -1783,8 +1795,6 @@ hk.gradconnection.com
hk.jiepang.com
hk01.com
hka8964.wordpress.com
hkacg.com
hkacg.net
hkanews.wordpress.com
hkbookcity.com
hkchronicles.com
@@ -1832,7 +1842,6 @@ hotvpn.com
howtoforge.com
hoxx.com
hoy.tv
hpa.gov.tw
hpjav.com
hqcdp.org
hqjapanesesex.com
@@ -1942,7 +1951,6 @@ imgchili.net
imgur.com
imkev.com
imlive.co
immigration.gov.tw
improd.works
incloak.com
incredibox.fr
@@ -1975,6 +1983,7 @@ internetpopculture.com
interseclab.org
inthenameofconfuciusmovie.com
investigating.wordpress.com
investing.com
invidio.us
inxian.com
ipdefenseforum.com
@@ -2005,9 +2014,9 @@ islamhouse.com
ismaelan.com
ismprofessional.net
israbox.com
issues.chromium.org
issuu.com
isupportuyghurs.org
itaiwan.gov.tw
italiatibet.org
itasoftware.com
itch.io
@@ -2070,7 +2079,6 @@ journalofdemocracy.org
jpl.nasa.gov
jsdelivr.net
jtvnw.net
judicial.gov.tw
jukujo-club.com
juliepost.com
juliereyc.com
@@ -2148,6 +2156,7 @@ lama.com.tw
lamayeshe.com
lamnia.co.uk
landofhope.tv
lantern.io
laogai.org
laogairesearch.org
laqingdan.net
@@ -2243,7 +2252,6 @@ lupm.org
lushstories.com
lvhai.org
lvv2.com
ly.gov.tw
lyfhk.net
lzjscript.com
lzmtnews.org
@@ -2267,6 +2275,7 @@ mangafox.com
mangafox.me
mangmang.run
manta.com
manus.im
manyvoices.news
marc.info
martau.com
@@ -2301,7 +2310,7 @@ mediachinese.com
mediafreakcity.com
mediawiki.org
medium.com
meetup.com
meee.com.tw
mega.co.nz
mega.io
mega.nz
@@ -2369,6 +2378,7 @@ mirrorbooks.com
mirrormedia.mg
missav.com
missav.ws
mistral.ai
mitbbs.com
miuipolska.pl
mixero.com
@@ -2376,7 +2386,6 @@ mixi.jp
mixx.com
mizzmona.com
mji.rip
mjib.gov.tw
mjj.rip
mjlsh.usc.cuhk.edu.hk
mlc.ai
@@ -2389,16 +2398,12 @@ mobileways.de
moby.to
mod.io
modernchinastudies.org
moeaic.gov.tw
moeerolibrary.com
moeshare.cc
mofa.gov.tw
mog.com
mohu.club
mohu.rocks
moj.gov.tw
mojim.com
mol.gov.tw
momoshop.com.tw
mondex.org
money-link.com.tw
@@ -2415,6 +2420,7 @@ moptt.tw
moresci.sale
morningsun.org
mos.ru
mosavi.io
motherless.com
movements.org
moviefap.com
@@ -2434,9 +2440,7 @@ musixmatch.com
muzi.com
muzi.net
muzu.tv
mvdis.gov.tw
mvg.jp
mx981.com
my-private-network.co.uk
my.pcloud.com
myaudiocast.com
@@ -2464,7 +2468,6 @@ namu.wiki
nanopool.org
nanyang.com
nanyangpost.com
nat.gov.tw
nat.moe
national-lottery.co.uk
nationalawakening.org
@@ -2527,7 +2530,6 @@ nflxvideo.net
nftstorage.link
nga.mil
nhentai.net
nhi.gov.tw
nic.cz.cc
nic.gov
nicovideo.jp
@@ -2562,16 +2564,10 @@ now.com
nownews.com
noxinfluencer.com
npa.go.jp
npa.gov.tw
npm.gov.tw
npnt.me
npsboost.com
nradio.me
nrk.no
nsc.gov.tw
ntbk.gov.tw
ntbna.gov.tw
ntbt.gov.tw
ntd.tv
ntdtv.com
ntdtv.com.tw
@@ -2613,8 +2609,10 @@ ogate.org
ohmyrss.com
ok.ru
okayfreedom.com
okcoin.com
okex.com
okk.tw
oklink.com
okpool.me
okx.com
old.honeynet.org
@@ -2648,6 +2646,8 @@ ooni.io
ooni.org
open.firstory.me
openai.com
openart.ai
opencritic.com
opendemocracy.net
openid.net
openleaks.org
@@ -2664,6 +2664,7 @@ orient-doll.com
orientaldaily.com.my
orn.jp
osfoora.com
osmand.net
otcbtc.com
otto.de
ourdearamy.com
@@ -2710,7 +2711,6 @@ pbs.org
pbworks.com
pbxes.com
pbxes.org
pcc.gov.tw
pcgamestorrents.com
pcij.org
pct.org.tw
@@ -2885,7 +2885,6 @@ pursuestar.com
putty.org
pximg.net
python.com.tw
pytorch.org
qbittorrent.org
qgirl.com.tw
qi-gong.me
@@ -2939,6 +2938,7 @@ rationalwiki.org
raw.githack.com
rawgit.com
rawgithub.com
rawstory.com
rcam.target.com
rcinet.ca
rd.com
@@ -2950,6 +2950,7 @@ readydown.com
realcourage.org
realitykings.com
reason.com
recordedfuture.com
recoveryversion.com.tw
red-lang.org
redbubble.com
@@ -2985,6 +2986,7 @@ rixcloud.com
rixcloud.us
rlwlw.com
rmbl.ws
roblox.com
robustnessiskey.com
rocket-inc.net
rocket.chat
@@ -3018,13 +3020,6 @@ rxhj.net
s-cute.com
s.yimg.com
s3-ap-northeast-1.amazonaws.com
s3-ap-northeast-2.amazonaws.com
s3-ap-southeast-1.amazonaws.com
s3-ap-southeast-2.amazonaws.com
s3-eu-central-1.amazonaws.com
s3.ap-northeast-2.amazonaws.com
s3.eu-central-1.amazonaws.com
s3.us-east-1.amazonaws.com
sacks.com
sacom.hk
sadistic-v.com
@@ -3046,6 +3041,7 @@ savetibet.org
savetibetstore.org
saveuighur.org
sbme.me
sbti.unun.dev
scache.vzw.com
scache1.vzw.com
scache2.vzw.com
@@ -3074,7 +3070,6 @@ securitykiss.com
seed4.me
seevpn.com
seezone.net
sef.org.tw
sehuatang.net
sehuatang.org
sensortower.com
@@ -3106,6 +3101,7 @@ shenyunshop.com
shenzhoufilm.com
shenzhouzhengdao.org
shiksha.com
shitjournal.org
shixiao.org
shizhao.org
shodanhq.com
@@ -3202,8 +3198,8 @@ southmongolia.org
southnews.com.tw
southpark.cc.com
sowers.org.hk
soylentnews.org
spaces.hightail.com
spacex.com
spankbang.com
sparkpool.com
spatial.io
@@ -3245,7 +3241,6 @@ standwithhk.org
starp2p.com
startpage.com
startuplivingchina.com
stat.gov.tw
static-economist.com
static.pocketcasts.com
static.shemalez.com
@@ -3317,16 +3312,13 @@ t.me
t66y.com
taa-usa.org
taaze.tw
tacc.cwb.gov.tw
taedp.org.tw
tagwalk.com
tails.net
taipei.gov.tw
taipeisociety.org
taipeitimes.com
taisounds.com
taiwanhot.net
taiwanjobs.gov.tw
taiwanjustice.net
taiwanncf.org.tw
taiwannews.com.tw
@@ -3352,7 +3344,6 @@ tbsn.org
tbssqh.org
teachparentstech.org
technews.tw
techspot.com
techviz.net
teck.in
teco-hk.org
@@ -3366,7 +3357,6 @@ telegram.me
telegram.org
telegram.space
telegramdownload.com
telegraph.co.uk
telesco.pe
tellapart.com
temu.com
@@ -3383,7 +3373,6 @@ tfhub.dev
tfiflve.com
tg-me.com
tg.dev
thb.gov.tw
theatlantic.com
theatrum-belli.com
thebcomplex.com
@@ -3419,6 +3408,7 @@ thetvdb.com
thewgo.org
thewirechina.com
theync.com
thinkchina.sg
thinkgeek.com
thinkingtaiwan.com
thinkwithgoogle.com
@@ -3503,7 +3493,6 @@ tinychat.com
tinypaste.com
tinyurl.com
tipas.net
tipo.gov.tw
tkcs-collins.com
tl.gd
tma.co.jp
@@ -3529,6 +3518,7 @@ toppornsites.com
topsy.com
toptip.ca
toptoon.net
tor.eff.org
torguard.net
torlock.com
torproject.org
@@ -3610,6 +3600,7 @@ tweez.net
twelve.today
twerkingbutt.com
twftp.org
twgov.tw
twgreatdaily.com
twibble.de
twibs.com
@@ -3682,6 +3673,7 @@ uncyclopedia.tw
underwoodammo.com
unholyknight.com
unirule.cloud
uniswap.org
unknownspace.org
unmineable.com
unseen.is
@@ -3832,16 +3824,17 @@ vrchat.com
vrporn.com
vrsmash.com
vtunnel.com
vuku.cc
vultryhw.com
w-pool.com
w3s.link
waffle1999.com
wainao.me
walletconnect.com
walletconnect.org
wallmama.com
wallpapercasa.com
wallsttv.com
wallzhihu.com
waltermartin.com
waltermartin.org
wanderinghorse.net
@@ -3862,7 +3855,6 @@ waveprotocol.org
waybig.com
waymo.com
wd.bible
wda.gov.tw
wealth.com.tw
wearn.com
web.dev
@@ -3943,6 +3935,7 @@ wiredbytes.com
wiredpen.com
wireguard.com
wisevid.com
wispbyte.com
withgoogle.com
withyoutube.com
witopia.net
@@ -3986,6 +3979,7 @@ wwitv.com
www.ajsands.com
www.antd.org
www.aolnews.com
www.clashverge.dev
www.cmoinc.org
www.dmm.com
www.eastturkistan.net
@@ -3994,7 +3988,6 @@ www.gmiddle.net
www.hoyolab.com
www.hustlercash.com
www.idlcoyote.com
www.imdb.com
www.kindleren.com
www.lorenzetti.com.br
www.m-sport.co.uk
@@ -4028,6 +4021,7 @@ xbtce.com
xcafe.in
xcancel.com
xcity.jp
xdaforums.com
xerotica.com
xfinity.com
xfxssr.me
@@ -4043,16 +4037,17 @@ xijie.wordpress.com
xing.com
xinjiangpolicefiles.org
xinmiao.com.hk
xjp.cc
xjtravelguide.com
xm.com
xml-training-guide.com
xn--11xs86f.icu
xn--1jqvh729avzfcy2d8ummib.com
xn--4gq171p.com
xn--9iqy04a7fi01l.com
xn--9pr62r24a.com
xn--czq75pvv1aj5c.org
xn--i2ru8q2qg.com
xn--kcrv3utim32hx9f6qe.com
xn--ngstr-lra8j.com
xn--noss43i.com
xn--oiq.cc
@@ -4153,7 +4148,6 @@ z-library.ec
z-library.sk
zalmos.com
zamimg.com
zaobao.com.sg
zaochenbao.com
zattoo.com
zb.com
+1 -3
View File
@@ -2,10 +2,8 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-pingcontrol
LUCI_DEPENDS:=+pingcontrol
PKG_VERSION:=1
PKG_RELEASE:=4
PKG_RELEASE:=5
LUCI_TITLE:=LuCI network interface control
@@ -43,6 +43,9 @@ return view.extend({
o = s.taboption('general',form.DynamicList, 'testip', _('IP address or hostname of test servers'));
o.datatype = 'or(hostname,ipaddr("nomask"))';
o = s.taboption('general',form.Flag, 'ping_silent', _('Silent mode'), _('Do not log success ping'));
o = s.taboption('general',form.Value, 'check_period', _('Period of check, sec'));
o.rmempty = false;
o.datatype = 'and(uinteger,min(20))';
@@ -10,6 +10,12 @@ msgstr "Интерфейс для ping-запросов"
msgid "IP address or hostname of test servers"
msgstr "IP-адрес или имя хоста тестовых серверов"
msgid "Silent mode"
msgstr "Тихий режим"
msgid "Do not log success ping"
msgstr "Не журналировать успешные попытки"
msgid "Failed attempts before iface up/down"
msgstr "Количество неудачных попыток до переподключения интерфейса"
@@ -1,7 +1,6 @@
{
"admin/services/pingcontrol": {
"title": "Pingcontrol",
"order": 30,
"action": {
"type": "view",
"path": "pingcontrol/pingcontrol"
-14
View File
@@ -1,14 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-pollmydevice
LUCI_DEPENDS:= +pollmydevice
PKG_VERSION:=1.0
PKG_RELEASE:=2
LUCI_TITLE:=LuCI TCP to RS232 and RS485 Configuration Frontend
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -1,303 +0,0 @@
'use strict';
'require form';
'require view';
'require uci';
'require rpc';
'require ui';
var consoleStatus = rpc.declare({
object: 'pollmydevice',
method: 'status',
expect: { '': {} }
});
var consoleDisable = rpc.declare({
object: 'pollmydevice',
method: 'con_off',
expect: { '': {} }
});
var consoleEnable = rpc.declare({
object: 'pollmydevice',
method: 'con_on',
expect: { '': {} }
});
var getID = rpc.declare({
object: 'pollmydevice',
method: 'get_id',
expect: { '': {} }
});
return view.extend({
load: function() {
return Promise.all([
consoleStatus(),
getID()
]);
},
render: function(rpc_replies) {
var status = rpc_replies[0];
var ids = rpc_replies[1];
var m, s, o;
m = new form.Map('pollmydevice', _('PollMyDevice'));
m.description = _('TCP to RS232/RS485 converter');
s = m.section(form.GridSection, 'interface');
s.tab('general', _('Mode Settings'));
s.tab('serial', _('Port Settings'));
s.addremove = true;
s.nodescriptions = true;
s.addbtntitle = _('Add new configuration...');
s.handleAdd = function(ev,name) {
for (var i = 0; i < 8; i++) {
var section = uci.get('pollmydevice', String(i));
if (section == null) {
var section_id = String(i);
uci.add('pollmydevice', 'interface', section_id);
uci.set('pollmydevice', section_id, 'desc',name);
uci.set('pollmydevice', section_id, 'devicename','/dev/com1');
uci.set('pollmydevice', section_id, 'baudrate','9600');
uci.set('pollmydevice', section_id, 'bytesize','8');
uci.set('pollmydevice', section_id, 'mode','disabled');
uci.set('pollmydevice', section_id, 'open_in_firewall','1');
uci.set('pollmydevice', section_id, 'server_port',String(30000+i));
this.addedSection = section_id;
return this.renderMoreOptionsModal(section_id);
};
};
ui.addNotification(null, E('p', 'Exceeded the maximum number of configurations.'), 'error');
};
o = s.taboption('general', form.Value, 'desc', _('Description'));
o.rmempty = false;
o.optional = false;
o.datatype = 'uciname';
o = s.taboption('serial', form.Value, 'devicename', _('Port'));
o.rmempty = false;
o.value('/dev/com0');
o.value('/dev/com1');
o.textvalue = function(section_id) {
return uci.get('pollmydevice', section_id, 'devicename');
}
o = s.taboption('general', form.ListValue, 'mode', _('Mode'));
o.default = 'disabled';
o.value('disabled',_('disabled'));
o.value('server',_('server'));
o.value('client',_('client'));
o = s.taboption('general', form.Flag, 'quiet',_('Disable log messages'));
o.default = 0;
o.modalonly = true;
o.depends({mode: 'server'});
o.depends({mode: 'client'});
o = s.taboption('general', form.Value, 'server_port', _('Listening port'), _('Network port used for data exchange with a configurable serial port'));
o.modalonly = true;
o.rmempty = false;
o.optional = false;
o.datatype = 'or(502,range(1025,65535))';
o.depends({mode: 'server'});
o = s.taboption('general', form.Flag, 'open_in_firewall', _("Open a port for incoming connections from the 'wan' zone"),_("A new rule for traffic in the firewall will be created, allowing connections to the specified network port from external networks. Access from the 'lan' zone is open by default for all network ports"))
o.modalonly = true;
o.depends({mode: 'server'});
o = s.taboption('general', form.ListValue, 'connection_mode', _('Connection Mode'));
o.modalonly = true;
o.default = 0;
o.value(0,_('Alternating'));
o.value(1,_('Simultaneous'));
o.depends({mode: 'server'});
o = s.taboption('general', form.Value, 'holdconntime', _('Connection Hold Time (sec)'));
o.default = 60;
o.datatype = 'and(uinteger, min(0), max(100000))'
o.depends({connection_mode: '0'});
o.modalonly = true;
o = s.taboption('general', form.Value, 'pack_size', _('Minimum packet size [0-255] (byte)'));
o.modalonly = true;
o.default = 0;
o.datatype = 'and(uinteger, min(0), max(255))';
o.depends({mode: 'server'});
o.depends({mode: 'client'});
o = s.taboption('general', form.Value, 'pack_timeout', _('Packet timeout [0-255] (x100ms)'));
o.modalonly = true;
o.default = 0;
o.datatype = 'and(uinteger, min(0), max(255))';
for (var i = 1; i < 256; i++){
o.depends({pack_size: i.toString()});
}
o = s.taboption('general', form.Value, 'client_host', _('Server Host or IP Address'));
o.default = 'hub.m2m24.ru';
o.datatype = 'string';
o.depends({mode: 'client'});
o.textvalue = function(section_id) {
if(uci.get('pollmydevice', section_id, 'mode') === 'client') {
return uci.get('pollmydevice', section_id, 'client_host');
} else {
return '-'
}
};
o = s.taboption('general', form.DummyValue, 'port', _('Port'));
o.modalonly = false;
o.textvalue = function(section_id) {
if(uci.get('pollmydevice', section_id, 'client_port')) return uci.get('pollmydevice', section_id, 'client_port');
if(uci.get('pollmydevice', section_id, 'server_port')) return uci.get('pollmydevice', section_id, 'server_port');
}
o = s.taboption('general', form.Value, 'client_port', _('Server Port'));
o.modalonly = true;
o.rmempty = false;
o.optional = false;
o.default = 6008;
o.datatype = 'or(502,range(1025,65535))';
o.depends({mode: 'client'});
o = s.taboption('general', form.Value, 'client_timeout', _('Client Reconnection Timeout (sec)'));
o.modalonly = true;
o.default = 60;
o.datatype = 'and(uinteger, min(0), max(100000))';
o.depends({mode: 'client'});
o = s.taboption('general', form.ListValue, 'client_auth', _('Client Authentification'));
o.widget='radio';
o.default = 0;
o.value(0,_('Disable'));
o.value(1,_('Enable'));
o.depends({mode: 'client'});
o.textvalue = function(section_id) {
return this.cfgvalue(section_id)==1 ? 'enabled' : 'disabled';
};
o = s.taboption('general', form.DummyValue, 'client_id', _('Client ID'));
o.modalonly = true;
o.depends({mode: 'client'});
o.cfgvalue = function(section_id) {
return ids['id' + section_id];
};
o = s.taboption('general', form.ListValue, 'modbus_gateway', _('Modbus TCP/IP'));
o.default = 0
o.value(0,_('Disabled'));
o.value(1,_('RTU'));
o.value(2,_('ASCII'));
o.depends({mode: 'server'});
o.depends({client_auth: '0'});
o.textvalue = function(section_id) {
if(this.cfgvalue(section_id)==0) return 'disabled';
if(this.cfgvalue(section_id)==1) return 'RTU';
if(this.cfgvalue(section_id)==2) return 'ASCII';
};
o = s.taboption('general', form.DummyValue, 'console_status',_('Console status'));
o.modalonly = true;
o.depends({desc: 'console'});
o.cfgvalue = function(section_id) {
return _(status.status);
};
o = s.taboption('general', form.Button, 'switch',_('Console'),_('Save the changes. The router will reboot'));
o.modalonly = true;
o.inputstyle = 'action important';
o.inputtitle = _('On/Off');
o.depends({desc: 'console'});
o.onclick = L.bind(function(section_id) {
if (status.status == 'activated') {
consoleDisable().then(function(){
L.ui.showModal(_('Rebooting…'), [
E('p', { 'class': 'spinning' }, _('Waiting for device...'))
]);
window.setTimeout(function() {
L.ui.showModal(_('Rebooting…'), [
E('p', { 'class': 'spinning alert-message warning' },
_('Device unreachable! Still waiting for device...'))
]);
}, 150000);
L.ui.awaitReconnect();
})
} else {
consoleEnable().then(function(){
L.ui.showModal(_('Rebooting…'), [
E('p', { 'class': 'spinning' }, _('Waiting for device...'))
]);
window.setTimeout(function() {
L.ui.showModal(_('Rebooting…'), [
E('p', { 'class': 'spinning alert-message warning' },
_('Device unreachable! Still waiting for device...'))
]);
}, 150000);
L.ui.awaitReconnect();
})
}
},this)
o = s.taboption('serial', form.ListValue, 'baudrate', _('BaudRate'));
o.default = 9600;
o.value(300);
o.value(600);
o.value(1200);
o.value(2400);
o.value(4800);
o.value(9600);
o.value(19200);
o.value(38400);
o.value(57600);
o.value(115200);
o.value(230400);
o.value(460800);
o.value(921600);
o.datatype = 'uinteger';
o.modalonly = true;
o.depends({mode: 'disabled', '!reverse': true});
o = s.taboption('serial', form.ListValue, 'bytesize', _('ByteSize'));
o.default = 8;
o.value(5);
o.value(6);
o.value(7);
o.value(8);
o.datatype = 'uinteger';
o.modalonly = true;
o.depends({mode: 'disabled', '!reverse': true});
o = s.taboption('serial', form.ListValue, 'stopbits', _('StopBits'));
o.default = 1;
o.value(1);
o.value(2);
o.datatype = 'uinteger';
o.modalonly = true;
o.depends({mode: 'disabled', '!reverse': true});
o = s.taboption('serial', form.ListValue, 'parity', _('Parity'));
o.default = 'none';
o.value('even');
o.value('odd');
o.value('none');
o.datatype = 'string';
o.modalonly = true;
o.depends({mode: 'disabled', '!reverse': true});
o = s.taboption('serial', form.ListValue, 'flowcontrol', _('Flow Control'));
o.modalonly = true;
o.default = 'none';
o.value('XON/XOFF');
o.value('RTS/CTS');
o.value('none');
o.datatype = 'string';
o.depends({mode: 'disabled', '!reverse': true});
return m.render();
}
});
@@ -1,86 +0,0 @@
msgid ""
msgstr ""
msgid "simman"
msgstr "simman"
msgid "SIM manager for 3g modem"
msgstr "SIM manager for 3g modem"
msgid "General settings"
msgstr "General settings"
msgid "Main module options"
msgstr "Main module options"
msgid "Enable Simman"
msgstr "Enable Simman"
msgid "Number of failed attempts"
msgstr "Number of failed attempts"
msgid "Period of check, sec"
msgstr "Period of check, sec"
msgid "Return to priority SIM, sec"
msgstr "Return to priority SIM, sec"
msgid "AT modem device name"
msgstr "AT modem device name"
msgid "IP address of remote servers"
msgstr "IP address of remote servers"
msgid "SIM1 settings"
msgstr "SIM1 settings"
msgid "Priority"
msgstr "Priority"
msgid "APN"
msgstr "APN"
msgid "Pincode"
msgstr "Pincode"
msgid "User name"
msgstr "User name"
msgid "Password"
msgstr "Password"
msgid "SIM2 settings"
msgstr "SIM2 settings"
msgid "Disabled"
msgstr "Disabled"
msgid "Disable"
msgstr "Disable"
msgid "Enable"
msgstr "Enable"
msgid "New configuration (range [0-6]):"
msgstr "New configuration (range [0-6]):"
msgid "Connection Mode"
msgstr "Connection Mode"
msgid "Alternating"
msgstr "Alternating"
msgid "Simultaneous"
msgstr "Simultaneous"
msgid "Listening port"
msgstr "Listening port"
msgid "Open a port for incoming connections from the 'wan' zone"
msgstr "Open a port for incoming connections from the 'wan' zone"
msgid "Network port used for data exchange with a configurable serial port"
msgstr "Network port used for data exchange with a configurable serial port"
msgid "A new rule for traffic in the firewall will be created, allowing connections to the specified network port from external networks. Access from the 'lan' zone is open by default for all network ports"
msgstr "A new rule for traffic in the firewall will be created, allowing connections to the specified network port from external networks. Access from the 'lan' zone is open by default for all network ports"
-122
View File
@@ -1,122 +0,0 @@
msgid "PollMyDevice"
msgstr "Опрос портов по TCP"
msgid "Utility Settings"
msgstr "Настройки"
msgid "TCP to RS232/RS485 converter"
msgstr "Конвертер TCP - Последовательный порт"
msgid "BaudRate"
msgstr "Скорость (бод)"
msgid "ByteSize"
msgstr "Размер слова"
msgid "Parity"
msgstr "Четность"
msgid "Flow Control"
msgstr "Управление потоком"
msgid "StopBits"
msgstr "Стоп-биты"
msgid "Server Port"
msgstr "Порт"
msgid "Connection Hold Time (sec)"
msgstr "Время удержания приоритета соединения (сек)"
msgid "Server Host or IP Address"
msgstr "Адрес сервера"
msgid "Server Port"
msgstr "Порт сервера"
msgid "Client Reconnection Timeout (sec)"
msgstr "Таймаут соединения (сек)"
msgid "Client Authentification"
msgstr "Авторизация Teleofis"
msgid "Use Teleofis Authentification"
msgstr "Использовать авторизацию по Teleofis ID"
msgid "Save the changes. The router will reboot"
msgstr "Сохраните настройки. Роутер перезагрузится"
msgid "Disable console port"
msgstr "Отключить консоль"
msgid "Enable console port"
msgstr "Включить консоль"
msgid "Disabled"
msgstr "Отключено"
msgid "Disable"
msgstr "Отключить"
msgid "Enable"
msgstr "Включить"
msgid "Disable log messages"
msgstr "Отключить логирование"
msgid "New configuration (range [0-6]):"
msgstr "Новая конфигурация (диапазон [0-6]): "
msgid "Minimum data packet size to send. 0 - not used"
msgstr "Минимальный размер пакета данных для отправки. 0 - не применяется"
msgid "Time of data accumulation before sending. 0 - not used"
msgstr "Время накопления данных для отправки. 0 - не применяется"
msgid "Packet timeout [0-255] (x100ms)"
msgstr "Таймаут пакета [0-255] (x100мс)"
msgid "Minimum packet size [0-255] (byte)"
msgstr "Минимальный размер пакета [0-255] (байт)"
msgid "Connection Mode"
msgstr "Алгоритм опроса"
msgid "Alternating"
msgstr "Попеременный"
msgid "Simultaneous"
msgstr "Одновременный"
msgid "Port Settings"
msgstr "Настройки порта"
msgid "Console status"
msgstr "Статус консоли"
msgid "activated"
msgstr "включена"
msgid "deactivated"
msgstr "отключена"
msgid "Console"
msgstr "Консоль"
msgid "On/Off"
msgstr "Вкл/откл"
msgid "Mode Settings"
msgstr "Настройки подключения"
msgid "Listening port"
msgstr "Порт для входящих соединений"
msgid "Open a port for incoming connections from the 'wan' zone"
msgstr "Открыть порт для входящих соединений из зоны 'wan'"
msgid "Network port used for data exchange with a configurable serial port"
msgstr "Сетевой порт, используемый для обмена данными с настраиваемым последовательным портом"
msgid "A new rule for traffic in the firewall will be created, allowing connections to the specified network port from external networks. Access from the 'lan' zone is open by default for all network ports"
msgstr "Будет создано новое правило для трафика в firewall-е, разрешающее подключения к указанному сетевому порту из внешних сетей. Доступ из зоны 'lan' открыт по умолчанию для всех сетевых портов"
@@ -1,14 +0,0 @@
{
"admin/services/pollmydevice": {
"title": "PollMyDevice",
"order": 40,
"action": {
"type": "view",
"path": "pollmydevice/pollmydevice"
},
"depends": {
"acl": [ "luci-app-pollmydevice" ],
"uci": { "pollmydevice": true }
}
}
}
@@ -1,14 +0,0 @@
{
"luci-app-pollmydevice": {
"description": "Grant UCI access for luci-app-pollmydevice",
"read": {
"uci": [ "pollmydevice" ],
"ubus": {
"pollmydevice": [ "status", "con_on", "con_off", "get_id" ]
}
},
"write": {
"uci": [ "pollmydevice" ]
}
}
}
-21
View File
@@ -1,21 +0,0 @@
# Custom configurator
#
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-simman
LUCI_DEPENDS:=+simman
# Version: <major>.<minor>.<patch>
PKG_VERSION:=0.2.6
PKG_RELEASE:=2
PKG_MAINTAINER:=Sklyarec Konstantin <atskyua@gmail.com> Vladimir Ovseychuk <vgovseychuk@gmail.com>
LUCI_TITLE:=LuCI SIM manager Configuration Frontend
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -1,13 +0,0 @@
module("luci.controller.simman", package.seeall)
function index()
if not nixio.fs.access("/etc/config/simman") then
return
end
local page
page = entry({"admin", "services", "simman"}, cbi("simman"), _(translate("Simman")))
page.dependent = true
end
-225
View File
@@ -1,225 +0,0 @@
--
--
require 'luci.sys'
function split(text, delim)
-- returns an array of fields based on text and delimiter (one character only)
local result = {}
local magic = "().%+-*?[]^$"
if delim == nil then
delim = "%s"
elseif string.find(delim, magic, 1, true) then
-- escape magic
delim = "%"..delim
end
local pattern = "[^"..delim.."]+"
for w in string.gmatch(text, pattern) do
table.insert(result, w)
end
return result
end
m = Map("simman", "Simman", translate("SIM manager for modem"))
--- General settings ---
section_gen = m:section(NamedSection, "core", "simman", translate("General settings")) -- create general section
enabled = section_gen:option(Flag, "enabled", translate("Enabled"), translate("To switch on/off require a reboot"), translate("Enabled")) -- create enable checkbox
enabled.rmempty = false
enabled = section_gen:option(Flag, "only_first_sim", translate("Use only high priority SIM"), translate("If you use only one SIM, the remaining SIM will be considered a priority"), translate("Enabled"))
enabled.rmempty = false
retry_num = section_gen:option(Value, "retry_num", translate("Number of failed attempts"))
retry_num.default = 3
retry_num.datatype = "and(uinteger, min(1))"
retry_num.rmempty = false
retry_num.optional = false
check_period = section_gen:option(Value, "check_period", translate("Period of check, sec"))
check_period.default = 60
check_period.datatype = "and(uinteger, min(30))"
check_period.rmempty = false
check_period.optional = false
delay = section_gen:option(Value, "delay", translate("Return to priority SIM, sec"))
delay.default = 600
delay.datatype = "and(uinteger, min(60))"
delay.rmempty = false
delay.optional = false
csq_level = section_gen:option(Value, "csq_level", translate("Minimum acceptable signal level, ASU (min: 1, max: 31)"), translate("0 - not used"))
csq_level.default = 0
csq_level.datatype = "and(uinteger, min(0), max(31))"
csq_level.rmempty = false
csq_level.optional = false
atdevice = section_gen:option(Value, "atdevice", translate("AT modem device name"))
atdevice.default = "/dev/ttyACM3"
atdevice.datatype = "device"
atdevice.rmempty = false
atdevice.optional = false
iface = section_gen:option(Value, "iface", translate("Ping iface name"))
iface.default = "internet"
iface.datatype = "network"
iface.rmempty = false
iface.optional = false
testip = section_gen:option(DynamicList, "testip", translate("IP address of remote servers"))
testip.datatype = "ipaddr"
testip.cast = "string"
testip.rmempty = false
testip.optional = false
sw_before_modres = section_gen:option(Value, "sw_before_modres", translate("Switches before modem reset"), translate("0 - not used"))
sw_before_modres.default = 0
sw_before_modres.datatype = "and(uinteger, min(0), max(100))"
sw_before_modres.rmempty = false
sw_before_modres.optional = false
sw_before_sysres = section_gen:option(Value, "sw_before_sysres", translate("Switches before reboot"), translate("0 - not used"))
sw_before_sysres.default = 0
sw_before_sysres.datatype = "and(uinteger, min(0), max(100))"
sw_before_sysres.rmempty = false
sw_before_sysres.optional = false
--- SIM info ---
section_info = m:section(NamedSection, "info", "simman", translate("SIM Info"))
atdevice = section_info:option(Value, "atdevice", translate("AT modem device name"))
atdevice.default = "/dev/ttyACM3"
atdevice.datatype = "device"
atdevice.rmempty = false
atdevice.optional = false
imei = section_info:option(DummyValue, "imei", translate("Modem IMEI"))
sim = section_info:option(DummyValue, "sim", translate("SIM State"))
ccid = section_info:option(DummyValue, "ccid", translate("Active SIM CCID"))
pincode_stat = section_info:option(DummyValue, "pincode_stat", translate("Pincode Status"))
sig_lev = section_info:option(DummyValue, "sig_lev", translate("Signal Strength"))
reg_stat = section_info:option(DummyValue, "reg_stat", translate("Registration Status"))
base_st_id = section_info:option(DummyValue, "base_st_id", translate("Base Station ID"))
base_st_bw = section_info:option(DummyValue, "base_st_bw", translate("Base Station Band"))
net_type = section_info:option(DummyValue, "net_type", translate("Cellural Network Type"))
gprs_reg_stat = section_info:option(DummyValue, "gprs_reg_stat", translate("GPRS Status"))
pack_type = section_info:option(DummyValue, "pack_type", translate("Package Type"))
refresher = section_info:option( Button, "refresher", translate("Refresh") )
refresher.title = translate("Refresh Info")
refresher.inputtitle = translate("Refresh")
refresher.inputstyle = "apply"
function refresher.write()
luci.sys.call("/sbin/simman_getinfo")
end
--- SIM1 settings ---
sim = m:section(TypedSection, "sim0", translate("SIM1 settings"))
sim.addremove = false
sim.anonymous = true
priority = sim:option(ListValue, "priority", translate("Priority"))
priority.default = "1"
priority:value("0", "low")
priority:value("1", "high")
priority.optional = false
GPRS_apn = sim:option(Value, "GPRS_apn", translate("APN"))
GPRS_apn.default = ""
GPRS_apn.rmempty = true
GPRS_apn.optional = false
GPRS_apn.cast = "string"
pin = sim:option(Value, "pin", translate("Pincode"))
pin.default = ""
pin.rmempty = true
pin.optional = false
GPRS_user = sim:option(Value, "GPRS_user", translate("User name"))
GPRS_user.default = ""
GPRS_user.rmempty = true
GPRS_user.optional = false
GPRS_pass = sim:option(Value, "GPRS_pass", translate("Password"))
GPRS_pass.default = ""
GPRS_pass.rmempty = true
GPRS_pass.optional = false
testip = sim:option(DynamicList, "testip", translate("IP address of remote servers"))
testip.datatype = "ipaddr"
testip.cast = "string"
--- SIM2 settings ---
sim = m:section(TypedSection, "sim1", translate("SIM2 settings"))
sim.addremove = false
sim.anonymous = true
priority = sim:option(ListValue, "priority", translate("Priority"))
priority.default = "0"
priority:value("0", "low")
priority:value("1", "high")
priority.optional = false
GPRS_apn = sim:option(Value, "GPRS_apn", translate("APN"))
GPRS_apn.default = ""
GPRS_apn.rmempty = true
GPRS_apn.optional = false
GPRS_apn.cast = "string"
pin = sim:option(Value, "pin", translate("Pincode"))
pin.default = ""
pin.rmempty = true
pin.optional = false
GPRS_user = sim:option(Value, "GPRS_user", translate("User name"))
GPRS_user.default = ""
GPRS_user.rmempty = true
GPRS_user.optional = false
GPRS_pass = sim:option(Value, "GPRS_pass", translate("Password"))
GPRS_pass.default = ""
GPRS_pass.rmempty = true
GPRS_pass.optional = false
testip = sim:option(DynamicList, "testip", translate("IP address of remote servers"))
testip.datatype = "ipaddr"
testip.cast = "string"
nbiot = m:section(TypedSection, "nbiot", translate("NB-IoT Modem Info"), translate("if available"))
nbiot.addremove = false
nbiot.anonymous = true
nb_imei = nbiot:option(DummyValue, "nb_imei", translate("NB-IoT modem IMEI"))
nb_imei.default = ""
nb_ccid = nbiot:option(DummyValue, "nb_ccid", translate("NB-IoT SIM CCID"))
nb_ccid.default = ""
btn = nbiot:option(Button, "_btn", translate("Refresh"))
btn.title = translate("Refresh Info")
btn.inputtitle = translate("Refresh")
btn.inputstyle = "apply"
function btn.write(self, section)
local test = io.popen("/etc/simman/nbinfo.sh imei")
local result = test:read("*a")
test:close()
nb_imei.value = result
test = io.popen("/etc/simman/nbinfo.sh ccid")
local result = test:read("*a")
test:close()
nb_ccid.value = result
end
function m.on_commit(self)
-- Modified configurations got committed and the CBI is about to restart associated services
end
function m.on_init(self)
-- The CBI is about to render the Map object
end
return m
-67
View File
@@ -1,67 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-02-26 12:54+0300\n"
"PO-Revision-Date: 2016-02-26 12:54+0300\n"
"Last-Translator: Константин <atskyua@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Virtaal 0.7.1\n"
msgid "simman"
msgstr "simman"
msgid "SIM manager for modem"
msgstr "SIM manager for modem"
msgid "General settings"
msgstr "General settings"
msgid "Main module options"
msgstr "Main module options"
msgid "To switch on/off require a reboot"
msgstr "To switch on/off require a reboot"
msgid "Number of failed attempts"
msgstr "Number of failed attempts"
msgid "Period of check, sec"
msgstr "Period of check, sec"
msgid "Return to priority SIM, sec"
msgstr "Return to priority SIM, sec"
msgid "AT modem device name"
msgstr "AT modem device name"
msgid "IP address of remote servers"
msgstr "IP address of remote servers"
msgid "SIM1 settings"
msgstr "SIM1 settings"
msgid "Priority"
msgstr "Priority"
msgid "APN"
msgstr "APN"
msgid "Pincode"
msgstr "Pincode"
msgid "User name"
msgstr "User name"
msgid "Password"
msgstr "Password"
msgid "SIM2 settings"
msgstr "SIM2 settings"
-145
View File
@@ -1,145 +0,0 @@
# Константин <atskyua@gmail.com>, 2016.
msgid ""
msgstr ""
"Project-Id-Version: LuCI: Simman\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-02-22 10:10+0300\n"
"PO-Revision-Date: 2016-02-26 12:28+0300\n"
"Last-Translator: Константин <atskyua@gmail.com>\n"
"Language-Team: Konstantin Sklyarec <atskyua@gmail.com>\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Virtaal 0.7.1\n"
msgid "Simman"
msgstr "Менеджер SIM"
msgid "SIM manager for modem"
msgstr "Менеджер SIM-карт модема"
msgid "General settings"
msgstr "Настройки"
msgid "To switch on/off require a reboot"
msgstr "Для переключения необходима перезагрузка"
msgid "Enabled"
msgstr "Включить"
msgid "Use only high priority SIM"
msgstr "Использовать только SIM с высоким приоритетом"
msgid "If you use only one SIM, the remaining SIM will be considered a priority"
msgstr "Если вставлен только один SIM-холдер, то SIM карта в нем будет считаться приоритетной"
msgid "Number of failed attempts"
msgstr "Число неудачных попыток пинга"
msgid "Period of check, sec"
msgstr "Период между попытками пинга, сек"
msgid "Return to priority SIM, sec"
msgstr "Период переключения на приоритетную SIM-карту, сек"
msgid "AT modem device name"
msgstr "Имя устройства АТ модема"
msgid "Ping iface name"
msgstr "Имя интерфейса"
msgid "IP address of remote servers"
msgstr "Адреса тестовых серверов для пинга"
msgid "Switches before modem reset"
msgstr "Переключений SIM-карт до сброса модема"
msgid "Switches before reboot"
msgstr "Переключений SIM-карт до перезагрузки роутера"
msgid "0 - not used"
msgstr "0 - не применяется"
msgid "SIM1 settings"
msgstr "Параметры SIM-карты 1"
msgid "Priority"
msgstr "Приоритет"
msgid "APN"
msgstr "Имя точки доступа"
msgid "Pincode"
msgstr "Пин код"
msgid "User name"
msgstr "Имя пользователя"
msgid "Password"
msgstr "Пароль"
msgid "SIM2 settings"
msgstr "Параметры SIM-карты 2"
msgid "SIM Info"
msgstr "Информация по подключению"
msgid "SIM State"
msgstr "Состояние SIM карт"
msgid "Active SIM CCID"
msgstr "CCID активной SIM карты"
msgid "Pincode Status"
msgstr "Статус PIN-кода"
msgid "Signal Strength"
msgstr "Уровень сигнала"
msgid "Registration Status"
msgstr "Статус регистрации в сети"
msgid "Base Station ID"
msgstr "ID базовой станции"
msgid "Base Station Band"
msgstr "Частотный канал"
msgid "Cellural Network Type"
msgstr "Технология доступа"
msgid "GPRS Status"
msgstr "Статус GPRS"
msgid "Package Type"
msgstr "Тип пакетной передачи"
msgid "Modem IMEI"
msgstr "IMEI модема"
msgid "Provider Info"
msgstr "Информация об операторе"
msgid "Refresh Info"
msgstr "Обновить информацию"
msgid "Refresh"
msgstr "Обновить"
msgid "NB-IoT Modem Info"
msgstr "Информация об NB-IoT модеме"
msgid "if available"
msgstr "если доступен"
msgid "NB-IoT modem IMEI"
msgstr "IMEI NB-IoT модема"
msgid "Not available"
msgstr "Не доступен"
msgid "Minimum acceptable signal level, ASU (min: 1, max: 31)"
msgstr "Минимально допустимый уровень сигнала, ASU (мин: 1, макс: 31)"
-11
View File
@@ -1,11 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-simman2
LUCI_TITLE:=LuCI interface for Simman2 configuration
LUCI_DEPENDS:=+luci-base
LUCI_PKGARCH:=all
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -1,268 +0,0 @@
'use strict';
'require fs';
'require rpc';
'require uci';
'require ui';
'require view';
'require form';
'require tools.widgets as widgets';
var modemRequestAll = rpc.declare({
object: 'simman2',
method: 'statusall',
params: [ 'config' ],
expect: { '': {} }
});
var DummyValueExt = form.DummyValue.extend({
renderWidget: function(section_id, option_index, cfgvalue) {
return E([], [
E('div', {
'class': 'cbi-value-field',
'id': this.cbid(section_id),
'style': 'color:#c73d3d;margin-left:0'
})
]);
}
});
return view.extend({
handleEnableService: rpc.declare({
object: 'luci',
method: 'setInitAction',
params: [ 'simman2', 'enable' ],
expect: { result: false }
}),
render: function() {
var m, s, o;
m = new form.Map('simman2', _('Simman2'));
m.description = _('SIM manager for modem');
s = m.section(form.GridSection, 'simman2', _('Settings'));
s.tab('general', _('General Settings'));
s.tab('sim0', _('SIM1 Settings'));
s.tab('sim1', _('SIM2 Settings'));
s.tab('info', _('Information'));
s.addremove = false;
s.nodescriptions = true;
o = s.taboption('general', form.Flag, 'enabled', _('Enabled'));
o.rmempty = false;
o.write = L.bind(function(section, value) {
if (value == '1') {
this.handleEnableService();
}
return uci.set('simman2', section, 'enabled', value);
}, this);
o = s.taboption('general', widgets.NetworkSelect, 'iface', _('Interface name'));
o.rmempty = false;
o.textvalue = function(section_id) {
return uci.get('simman2', section_id, 'iface');
}
o = s.taboption('general', form.Value, 'atdevice', _('AT modem device name'));
o.rmempty = false;
o = s.taboption('general', form.Flag, 'only_first_sim', _('Use only high priority SIM'), _('If you use only one SIM, the remaining SIM will be considered a priority'));
o.rmempty = false;
o.modalonly = true;
o = s.taboption('general', form.DynamicList, 'testip', _('IP address of remote servers'));
o.rmempty = false;
o.datatype = 'host';
o = s.taboption('general', form.Value, 'csq_level', _('Minimum acceptable signal level, ASU (min: 1, max: 31)'), _('0 - not used'));
o.rmempty = false;
o.datatype = 'and(uinteger, min(0), max(31))'
o.default = '0';
o.modalonly = true;
o = s.taboption('general', form.Value, 'retry_num', _('Number of failed attempts'));
o.rmempty = false;
o.datatype = 'and(uinteger,min(1))';
o.default = '3';
o.modalonly = true;
o = s.taboption('general', form.Value, 'check_period', _('Period of check, sec'));
o.rmempty = false;
o.datatype = 'and(uinteger,min(30))';
o.default = '60';
o.modalonly = true;
o = s.taboption('general', form.Value, 'sw_before_modres', _('Switches before modem reset'), _('0 - not used'));
o.rmempty = false;
o.datatype = 'and(uinteger,min(0),max(100))';
o.default = '0';
o = s.taboption('general', form.Value, 'sw_before_sysres', _('Switches before reboot'), _('0 - not used'));
o.rmempty = false;
o.datatype = 'and(uinteger,min(0),max(100))';
o.default = '0';
o = s.taboption('general', form.Value, 'delay', _('Return to priority SIM, sec'));
o.rmempty = false;
o.datatype = 'and(uinteger,min(60))';
o.default = '600';
o.modalonly = true;
o = s.taboption('sim0', form.ListValue, 'sim0_priority', _('Priority'));
o.default = '1';
o.value('0','low');
o.value('1','high');
o.rmempty = false;
o.modalonly = true;
o = s.taboption('sim0', form.ListValue, 'sim0_mode', _('Service type'));
o.default = 'all';
o.value('all',_('All'));
o.value('lte',_('LTE only'));
o.value('umts',_('UMTS only'));
o.value('gsm',_('GPRS only'));
o.rmempty = false;
o.modalonly = true;
o = s.taboption('sim0', form.Value, 'sim0_apn', _('APN'));
o.modalonly = true;
o = s.taboption('sim0', form.Value, 'sim0_pincode', _('Pincode'));
o.modalonly = true;
o = s.taboption('sim0', form.ListValue, 'sim0_auth', _('Authentication Type'));
o.default = 'none';
o.value('both','PAP/CHAP');
o.value('pap','PAP');
o.value('chap','CHAP');
o.value('none','NONE');
o.modalonly = true;
o = s.taboption('sim0', form.Value, 'sim0_username', _('User name'));
o.modalonly = true;
o.depends({sim0_auth: 'none', '!reverse': true});
o = s.taboption('sim0', form.Value, 'sim0_password', _('Password'));
o.modalonly = true;
o.password = true;
o.depends({sim0_auth: 'none', '!reverse': true});
o = s.taboption('sim0', form.DynamicList, 'sim0_testip', _('IP address of remote servers'));
o.datatype = 'host';
o.modalonly = true;
o = s.taboption('sim1', form.ListValue, 'sim1_priority', _('Priority'));
o.default = '0';
o.value('0','low');
o.value('1','high');
o.rmempty = false;
o.modalonly = true;
o = s.taboption('sim1', form.ListValue, 'sim1_mode', _('Service type'));
o.default = 'all';
o.value('all',_('All'));
o.value('lte',_('LTE only'));
o.value('umts',_('UMTS only'));
o.value('gsm',_('GPRS only'));
o.rmempty = false;
o.modalonly = true;
o = s.taboption('sim1', form.Value, 'sim1_apn', _('APN'));
o.modalonly = true;
o = s.taboption('sim1', form.Value, 'sim1_pincode', _('Pincode'));
o.modalonly = true;
o = s.taboption('sim1', form.ListValue, 'sim1_auth', _('Authentication Type'));
o.default = 'none';
o.value('both','PAP/CHAP');
o.value('pap','PAP');
o.value('chap','CHAP');
o.value('none','NONE');
o.modalonly = true;
o = s.taboption('sim1', form.Value, 'sim1_username', _('User name'));
o.modalonly = true;
o.depends({sim1_auth: 'none', '!reverse': true});
o = s.taboption('sim1', form.Value, 'sim1_password', _('Password'));
o.modalonly = true;
o.password = true;
o.depends({sim1_auth: 'none', '!reverse': true});
o = s.taboption('sim1', form.DynamicList, 'sim1_testip', _('IP address of remote servers'));
o.datatype = 'host';
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'modem', _('Modem'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'firmware', _('Firmware version'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'imei', _('Modem IMEI'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'ccid', _('Active SIM CCID'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'imsi', _('Active SIM IMSI'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'sim', _('SIM State'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'pincode_stat', _('Pincode Status'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'operator', _('Operator'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'sig_lev', _('Signal Strength'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'reg_stat', _('Registration Status'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'net_type', _('Cellural Network Type'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'gprs_reg_stat', _('GPRS Status'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'pack_type', _('Package Type'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'base_st_id', _('Base Station ID'));
o.modalonly = true;
o = s.taboption('info', DummyValueExt, 'base_st_bw', _('Base Station Band'));
o.modalonly = true;
o = s.taboption('info', form.Button, 'refresh',_(' '));
o.modalonly = true;
o.inputstyle = 'action important';
o.inputtitle = _('Refresh');
o.onclick = L.bind(function(ev, section_id) {
return modemRequestAll(section_id).then(function(t) {
document.getElementById('cbid.simman2.%s.modem'.format(section_id)).textContent = t.modem || 'n/a';
document.getElementById('cbid.simman2.%s.firmware'.format(section_id)).textContent = t.firmware || 'n/a';
document.getElementById('cbid.simman2.%s.imei'.format(section_id)).textContent = t.imei || 'n/a';
document.getElementById('cbid.simman2.%s.ccid'.format(section_id)).textContent = t.ccid || 'n/a';
document.getElementById('cbid.simman2.%s.imsi'.format(section_id)).textContent = t.imsi || 'n/a';
document.getElementById('cbid.simman2.%s.sim'.format(section_id)).textContent = t.sim_state || 'n/a';
document.getElementById('cbid.simman2.%s.pincode_stat'.format(section_id)).textContent = t.pin_state || 'n/a';
document.getElementById('cbid.simman2.%s.operator'.format(section_id)).textContent = t.operator || 'n/a';
document.getElementById('cbid.simman2.%s.sig_lev'.format(section_id)).textContent = t.csq || 'n/a';
document.getElementById('cbid.simman2.%s.reg_stat'.format(section_id)).textContent = t.net_reg || 'n/a';
document.getElementById('cbid.simman2.%s.net_type'.format(section_id)).textContent = t.net_type || 'n/a';
document.getElementById('cbid.simman2.%s.gprs_reg_stat'.format(section_id)).textContent = t.data_reg || 'n/a';
document.getElementById('cbid.simman2.%s.pack_type'.format(section_id)).textContent = t.data_type || 'n/a';
document.getElementById('cbid.simman2.%s.base_st_id'.format(section_id)).textContent = t.bs_id || 'n/a';
document.getElementById('cbid.simman2.%s.base_st_bw'.format(section_id)).textContent = t.band || 'n/a';
});
})
return m.render();
}
});
-70
View File
@@ -1,70 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-02-26 12:54+0300\n"
"PO-Revision-Date: 2016-02-26 12:54+0300\n"
"Last-Translator: Константин <atskyua@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Virtaal 0.7.1\n"
msgid "simman"
msgstr "simman"
msgid "SIM manager for modem"
msgstr "SIM manager for modem"
msgid "General settings"
msgstr "General settings"
msgid "Main module options"
msgstr "Main module options"
msgid "To switch on/off require a reboot"
msgstr "To switch on/off require a reboot"
msgid "Number of failed attempts"
msgstr "Number of failed attempts"
msgid "Period of check, sec"
msgstr "Period of check, sec"
msgid "Return to priority SIM, sec"
msgstr "Return to priority SIM, sec"
msgid "AT modem device name"
msgstr "AT modem device name"
msgid "IP address of remote servers"
msgstr "IP address of remote servers"
msgid "SIM1 settings"
msgstr "SIM1 settings"
msgid "Priority"
msgstr "Priority"
msgid "APN"
msgstr "APN"
msgid "Pincode"
msgstr "Pincode"
msgid "User name"
msgstr "User name"
msgid "Password"
msgstr "Password"
msgid "SIM2 settings"
msgstr "SIM2 settings"
msgid "Operator"
msgstr "Operator"
-169
View File
@@ -1,169 +0,0 @@
# Константин <atskyua@gmail.com>, 2016.
msgid ""
msgstr ""
"Project-Id-Version: LuCI: Simman\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-02-22 10:10+0300\n"
"PO-Revision-Date: 2016-02-26 12:28+0300\n"
"Last-Translator: Константин <atskyua@gmail.com>\n"
"Language-Team: Konstantin Sklyarec <atskyua@gmail.com>\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Virtaal 0.7.1\n"
msgid "Simman"
msgstr "Менеджер SIM"
msgid "SIM manager for modem"
msgstr "Менеджер SIM-карт модема"
msgid "General settings"
msgstr "Настройки"
msgid "To switch on/off require a reboot"
msgstr "Для переключения необходима перезагрузка"
msgid "Enabled"
msgstr "Включить"
msgid "Use only high priority SIM"
msgstr "Использовать только SIM с высоким приоритетом"
msgid "If you use only one SIM, the remaining SIM will be considered a priority"
msgstr "Если вставлен только один SIM-холдер, то SIM карта в нем будет считаться приоритетной"
msgid "Number of failed attempts"
msgstr "Число неудачных попыток пинга"
msgid "Period of check, sec"
msgstr "Период между попытками пинга, сек"
msgid "Return to priority SIM, sec"
msgstr "Период переключения на приоритетную SIM-карту, сек"
msgid "AT modem device name"
msgstr "Имя устройства АТ модема"
msgid "Ping iface name"
msgstr "Имя интерфейса"
msgid "IP address of remote servers"
msgstr "Адреса тестовых серверов для пинга"
msgid "Switches before modem reset"
msgstr "Переключений SIM-карт до сброса модема"
msgid "Switches before reboot"
msgstr "Переключений SIM-карт до перезагрузки роутера"
msgid "0 - not used"
msgstr "0 - не применяется"
msgid "SIM1 settings"
msgstr "Параметры SIM-карты 1"
msgid "Priority"
msgstr "Приоритет"
msgid "APN"
msgstr "Имя точки доступа"
msgid "Pincode"
msgstr "Пин код"
msgid "User name"
msgstr "Имя пользователя"
msgid "Password"
msgstr "Пароль"
msgid "SIM2 settings"
msgstr "Параметры SIM-карты 2"
msgid "SIM Info"
msgstr "Информация по подключению"
msgid "SIM State"
msgstr "Состояние SIM карт"
msgid "Active SIM CCID"
msgstr "CCID активной SIM карты"
msgid "Pincode Status"
msgstr "Статус PIN-кода"
msgid "Signal Strength"
msgstr "Уровень сигнала"
msgid "Registration Status"
msgstr "Статус регистрации в сети"
msgid "Base Station ID"
msgstr "ID базовой станции"
msgid "Base Station Band"
msgstr "Частотный канал"
msgid "Cellural Network Type"
msgstr "Технология доступа"
msgid "GPRS Status"
msgstr "Статус GPRS"
msgid "Package Type"
msgstr "Тип пакетной передачи"
msgid "Modem IMEI"
msgstr "IMEI модема"
msgid "Provider Info"
msgstr "Информация об операторе"
msgid "Refresh Info"
msgstr "Обновить информацию"
msgid "Refresh"
msgstr "Обновить"
msgid "NB-IoT Modem Info"
msgstr "Информация об NB-IoT модеме"
msgid "if available"
msgstr "если доступен"
msgid "NB-IoT modem IMEI"
msgstr "IMEI NB-IoT модема"
msgid "Not available"
msgstr "Не доступен"
msgid "Minimum acceptable signal level, ASU (min: 1, max: 31)"
msgstr "Минимально допустимый уровень сигнала, ASU (мин: 1, макс: 31)"
msgid "Modem"
msgstr "Модем"
msgid "Firmware version"
msgstr "Версия прошивки"
msgid "Active SIM IMSI"
msgstr "IMSI активной SIM карты"
msgid "Simman2"
msgstr "Менеджер SIM"
msgid "SIM1 Settings"
msgstr "Настройки SIM1"
msgid "SIM2 Settings"
msgstr "Настройки SIM2"
msgid "Service type"
msgstr "Тип службы"
msgid "Operator"
msgstr "Оператор"
@@ -1,14 +0,0 @@
{
"admin/services/simman2": {
"title": "Simman2",
"order": 60,
"action": {
"type": "view",
"path": "simman2/simman2"
},
"depends": {
"acl": [ "luci-app-simman2" ],
"uci": { "simman2": true }
}
}
}
@@ -1,17 +0,0 @@
{
"luci-app-simman2": {
"description": "Grant UCI access for luci-app-simman2",
"read": {
"uci": [ "simman2" ],
"ubus": {
"simman2": [ "info", "statusall"]
}
},
"write": {
"uci": [ "simman2" ],
"ubus": {
"simman2": [ "info" ]
}
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=Bootstrap Teleofis Theme
LUCI_DEPENDS:=
LUCI_DEPENDS:= +luci-lua-runtime
PKG_LICENSE:=Apache-2.0
@@ -14,6 +14,109 @@
* Props to Eric Meyer (meyerweb.com) for his CSS reset file. We're using an adapted version here that cuts out some of the reset HTML elements we will never need here (i.e., dfn, samp, etc).
* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
:root {
--background-color-delta-l-sign: -1;
--background-color-h: 0;
--background-color-s: 0%;
--background-color-l: 100%;
--background-color-high-hsl:
var(--background-color-h),
var(--background-color-s),
var(--background-color-l);
--background-color-high: hsl(var(--background-color-high-hsl));
--background-color-medium-hsl:
var(--background-color-h),
var(--background-color-s),
calc(var(--background-color-l) + var(--background-color-delta-l-sign) * calc(6 / 255 * 100%));
--background-color-medium: hsl(var(--background-color-medium-hsl));
--background-color-low-hsl:
var(--background-color-h),
var(--background-color-s),
calc(var(--background-color-l) + var(--background-color-delta-l-sign) * calc(10 / 255 * 100%));
--background-color-low: hsl(var(--background-color-low-hsl));
--text-color-delta-l-sign: 1;
--text-color-h: 0;
--text-color-s: 0%;
--text-color-l: 0%;
--text-color-highest-hsl:
var(--text-color-h),
var(--text-color-s),
var(--text-color-l);
--text-color-highest: hsl(var(--text-color-highest-hsl));
--text-color-high-hsl:
var(--text-color-h),
var(--text-color-s),
calc(var(--text-color-l) + var(--text-color-delta-l-sign) * calc(64 / 255 * 100%));
--text-color-high: hsl(var(--text-color-high-hsl));
--text-color-medium-hsl:
var(--text-color-h),
var(--text-color-s),
calc(var(--text-color-l) + var(--text-color-delta-l-sign) * calc(128 / 255 * 100%));
--text-color-medium: hsl(var(--text-color-medium-hsl));
--text-color-low-hsl:
var(--text-color-h),
var(--text-color-s),
calc(var(--text-color-l) + var(--text-color-delta-l-sign) * calc(191 / 255 * 100%));
--text-color-low: hsl(var(--text-color-low-hsl));
--border-color-delta-l-sign: -1;
--border-color-h: var(--background-color-h);
--border-color-s: var(--background-color-s);
--border-color-l: var(--background-color-l);
--border-color-high-hsl:
var(--border-color-h),
var(--border-color-s),
calc(var(--border-color-l) + var(--border-color-delta-l-sign) * calc(51 / 255 * 100%));
--border-color-high: hsl(var(--border-color-high-hsl));
--border-color-medium-hsl:
var(--border-color-h),
var(--border-color-s),
calc(var(--border-color-l) + var(--border-color-delta-l-sign) * calc(34 / 255 * 100%));
--border-color-medium: hsl(var(--border-color-medium-hsl));
--border-color-low-hsl:
var(--border-color-h),
var(--border-color-s),
calc(var(--border-color-l) + var(--border-color-delta-l-sign) * calc(17 / 255 * 100%));
--border-color-low: hsl(var(--border-color-low-hsl));
--primary-color-high: #1976d2;
--primary-color-medium: #1564c0;
--primary-color-low: #b00000;
--on-primary-color: var(--background-color-high);
--error-color-high-rgb: 246, 43, 18;
--error-color-high: rgb(var(--error-color-high-rgb));
--error-color-medium: #e8210d;
--error-color-low: #d00000;
--on-error-color: var(--background-color-high);
--success-color-high-rgb: 0, 172, 89;
--success-color-high: rgb(var(--success-color-high-rgb));
--success-color-medium: #009a4c;
--success-color-low: #007936;
--on-success-color: var(--background-color-high);
--warn-color-high: #efbd0b;
--warn-color-medium: #f0c629;
--warn-color-low: #f2d24f;
--on-warn-color: var(--text-color-highest);
--disabled-opacity: .7;
color-scheme: light;
}
* {
margin: 0;
padding: 0;
@@ -1657,14 +1760,15 @@ input[type="text"] + .cbi-button-remove {
transition: opacity .25s ease-in;
}
.cbi-progressbar {
border: 1px solid #ccc;
border: 1px solid var(--border-color-high);
border-radius: 3px;
position: relative;
min-width: 170px;
height: 20px;
margin: 4px 0;
background: #f9f9f9;
height: 8px;
margin: 1.4em 0 4px 0;
background: #fcfcfc;
}
.cbi-progressbar > div {
@@ -1672,16 +1776,13 @@ input[type="text"] + .cbi-button-remove {
height: 100%;
transition: width .25s ease-in;
width: 0%;
border-radius: 2px;
}
.cbi-progressbar::after {
.cbi-progressbar::before {
position: absolute;
bottom: 0;
top: 0;
right: 0;
top: -1.4em;
left: 0;
text-align: center;
text-shadow: 0 0 2px #fff;
content: attr(title);
white-space: pre;
overflow: hidden;
@@ -2316,7 +2417,7 @@ html body.apply-overlay-active {
bottom: 0;
width: 32px;
content: " ";
background: url(../resources/icons/loading.gif) no-repeat center;
background: url(../resources/icons/loading.svg) no-repeat center;
background-size: 16px;
}
@@ -8,7 +8,7 @@
<% local ver = require "luci.version" %>
<footer>
<div style="height:40px;font-size:95%;color:#999;font-family: Arial,sans-serif;">&#169;&nbsp;TELEOFIS&nbsp;2004-2025&nbsp;</div>
<div style="height:40px;font-size:95%;color:#999;font-family: Arial,sans-serif;">&#169;&nbsp;TELEOFIS&nbsp;2004-2022&nbsp;</div>
<ul class="breadcrumb pull-right" id="modemenu" style="display:none"></ul>
</footer>
</div>
+2 -2
View File
@@ -1,9 +1,9 @@
:
include $(TOPDIR)/rules.mk
PKG_NAME:=pingcontrol
PKG_VERSION:=1
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_BUILD_DIR:=$(BUILD_DIR)/pingcontrol
include $(INCLUDE_DIR)/package.mk
+18 -6
View File
@@ -10,6 +10,7 @@ SW_BEFORE_MODRES=$(uci -q get pingcontrol.$1.sw_before_modres)
SW_BEFORE_SYSRES=$(uci -q get pingcontrol.$1.sw_before_sysres)
PING_OK=$(uci -q get pingcontrol.$1.ping_ok)
SILENT=$(uci -q get pingcontrol.$1.ping_silent)
PING_LOST=$(uci -q get pingcontrol.$1.ping_lost)
PING_RESTORED=$(uci -q get pingcontrol.$1.ping_restored)
BEFORE_IFACE_DOWN=$(uci -q get pingcontrol.$1.before_iface_down)
@@ -34,8 +35,15 @@ done
while true; do
for IP in $TESTIP
do
/bin/ping -w5 -c1 -s8 -I $IFNAME $IP &> /dev/null
if [[ "$?" -eq "0" ]]; then
[ -n $IFNAME ] && {
/bin/ping -w5 -c1 -s8 -I $IFNAME $IP &> /dev/null
STATUS=$?
} || {
/bin/ping -w5 -c1 -s8 $IP &> /dev/null
STATUS=$?
}
if [[ "${STATUS}" -eq "0" ]]; then
let host_up_count++
else
logger -t pingcontrol "$INSTANCE: Ping to host $IP lost"
@@ -50,7 +58,9 @@ while true; do
done
if [[ "$host_up_count" -gt "0" ]]; then
logger -t pingcontrol "$INSTANCE: Ping OK, reset counters"
[ "${SILENT}" != "1" ] && {
logger -t pingcontrol "$INSTANCE: Ping OK, reset counters"
}
if [[ "$lost_flag" -eq "1" ]]; then
if [[ -n "$PING_RESTORED" ]]; then
logger -t pingcontrol "$INSTANCE: Execute $PING_RESTORED"
@@ -58,8 +68,10 @@ while true; do
fi
else
if [[ -n "$PING_OK" ]]; then
logger -t pingcontrol "$INSTANCE: Execute $PING_OK"
eval $PING_OK
[ "${SILENT}" != "1" ] && {
logger -t pingcontrol "$INSTANCE: Execute $PING_OK"
}
eval $PING_OK
fi
fi
host_up_count=0
@@ -99,4 +111,4 @@ while true; do
fi
sleep $CHECK_PERIOD
done
done
+1
View File
@@ -3,5 +3,6 @@ config pingcontrol 'pingcontrol'
option check_period '30'
option iface 'internet'
option testip '8.8.8.8'
option ping_silent '1'
option sw_before_modres '3'
option sw_before_sysres '0'
+5
View File
@@ -42,3 +42,8 @@ service_triggers() {
procd_add_reload_trigger 'pingcontrol'
procd_add_validation validate_pingcontrol_section
}
reload_service() {
stop
start
}
-51
View File
@@ -1,51 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=pollmydevice
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/pollmydevice
PKG_MAINTAINER:=TELEOFIS
include $(INCLUDE_DIR)/package.mk
define Package/pollmydevice
SECTION:=utils
CATEGORY:=Utilities
TITLE:=PollMyDevice project
DEPENDS:=+libpthread +libuci
endef
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
TARGET_LDFLAGS += -L$(STAGING_DIR)/usr/lib
define Package/pollmydevice/description
This package contains utility for sim check manage.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/pollmydevice/install
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/pollmydevice $(1)/sbin/
$(INSTALL_DIR) $(1)/etc/config
$(CP) ./files/pollmydevice.config $(1)/etc/config/pollmydevice
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/pollmydevice.init $(1)/etc/init.d/pollmydevice
$(INSTALL_DIR) $(1)/etc/pollmydevice
$(INSTALL_BIN) ./files/console $(1)/etc/pollmydevice/console
$(INSTALL_BIN) ./files/exp_board $(1)/etc/pollmydevice/exp_board
$(INSTALL_BIN) ./files/exp_port $(1)/etc/pollmydevice/exp_port
$(INSTALL_DIR) $(1)/etc/sysctl.d
$(CP) ./files/printk.sysctl $(1)/etc/sysctl.d/12-printk.conf
$(INSTALL_DIR) $(1)/usr/libexec/rpcd/
$(INSTALL_BIN) ./files/pollmydevice.rpcd $(1)/usr/libexec/rpcd/pollmydevice
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/pollmydevice.defaults $(1)/etc/uci-defaults/30_pollmydevice
endef
$(eval $(call BuildPackage,pollmydevice))
-54
View File
@@ -1,54 +0,0 @@
#!/bin/sh
disable()
{
CHECK=$(grep -r "#::askconsole" /etc/inittab)
if [ -z "$CHECK" ]; then
sed -i -e "s/::askconsole/#::askconsole/g" /etc/inittab
CHECK=$(grep -r "#kernel.printk" /etc/sysctl.d/12-printk.conf)
if [ -n "$CHECK" ]; then
sed -i -e "s/#kernel.printk/kernel.printk/g" /etc/sysctl.d/12-printk.conf
fi
reboot
else
CHECK=$(grep -r "#kernel.printk" /etc/sysctl.conf)
if [ -n "$CHECK" ]; then
sed -i -e "s/#kernel.printk/kernel.printk/g" /etc/sysctl.d/12-printk.conf
reboot
fi
fi
}
enable()
{
CHECK=$(grep -r "#::askconsole" /etc/inittab)
if [ -n "$CHECK" ]; then
sed -i -e "s/#::askconsole/::askconsole/g" /etc/inittab
CHECK=$(grep -r "#kernel.printk" /etc/sysctl.d/12-printk.conf)
if [ -z "$CHECK" ]; then
sed -i -e "s/kernel.printk/#kernel.printk/g" /etc/sysctl.d/12-printk.conf
fi
reboot
else
CHECK=$(grep -r "#kernel.printk" /etc/sysctl.d/12-printk.conf)
if [ -z "$CHECK" ]; then
sed -i -e "s/kernel.printk/#kernel.printk/g" /etc/sysctl.d/12-printk.conf
reboot
fi
fi
}
status()
{
CHECK1=$(grep -r "#::askconsole" /etc/inittab)
CHECK2=$(grep -r "#kernel.printk" /etc/sysctl.d/12-printk.conf)
if [ -z "$CHECK1" -a -n "$CHECK2" ]; then
echo "activated"
else
echo "deactivated"
fi
}
$1
exit 0
-40
View File
@@ -1,40 +0,0 @@
#!/bin/sh
uci set pollmydevice.3='interface'
uci set pollmydevice.3.mode='disabled'
uci set pollmydevice.3.desc='RS-232(1)'
uci set pollmydevice.3.devicename='/dev/com10'
uci set pollmydevice.3.baudrate='9600'
uci set pollmydevice.3.bytesize='8'
uci set pollmydevice.3.open_in_firewall='1'
uci set pollmydevice.4='interface'
uci set pollmydevice.4.mode='disabled'
uci set pollmydevice.4.desc='RS-232(2)'
uci set pollmydevice.4.devicename='/dev/com11'
uci set pollmydevice.4.baudrate='9600'
uci set pollmydevice.4.bytesize='8'
uci set pollmydevice.4.open_in_firewall='1'
uci set pollmydevice.5='interface'
uci set pollmydevice.5.mode='disabled'
uci set pollmydevice.5.desc='A1B1'
uci set pollmydevice.5.devicename='/dev/com12'
uci set pollmydevice.5.baudrate='9600'
uci set pollmydevice.5.bytesize='8'
uci set pollmydevice.5.open_in_firewall='1'
uci set pollmydevice.6='interface'
uci set pollmydevice.6.mode='disabled'
uci set pollmydevice.6.desc='A2B2'
uci set pollmydevice.6.devicename='/dev/com13'
uci set pollmydevice.6.baudrate='9600'
uci set pollmydevice.6.bytesize='8'
uci set pollmydevice.6.open_in_firewall='1'
uci set pollmydevice.7='interface'
uci set pollmydevice.7.mode='disabled'
uci set pollmydevice.7.desc='A3B3'
uci set pollmydevice.7.devicename='/dev/com14'
uci set pollmydevice.7.baudrate='9600'
uci set pollmydevice.7.bytesize='8'
uci set pollmydevice.7.open_in_firewall='1'
uci commit pollmydevice
exit 0
-12
View File
@@ -1,12 +0,0 @@
#!/bin/sh
uci set pollmydevice.2='interface'
uci set pollmydevice.2.mode='disabled'
uci set pollmydevice.2.desc='A2B2'
uci set pollmydevice.2.devicename='/dev/com2'
uci set pollmydevice.2.baudrate='9600'
uci set pollmydevice.2.bytesize='8'
uci set pollmydevice.2.open_in_firewall='1'
uci commit pollmydevice
exit 0
-41
View File
@@ -1,41 +0,0 @@
config interface '0'
option mode 'disabled'
option desc 'AB'
option devicename '/dev/com1'
option baudrate '9600'
option bytesize '8'
option parity 'none'
option flowcontrol 'none'
option stopbits '1'
option server_port '33000'
option holdconntime '60'
option client_port '6008'
option client_host ''
option client_auth '0'
option client_timeout '600'
option modbus_gateway '0'
option quiet '0'
option pack_timeout '0'
option pack_size '0'
option open_in_firewall '1'
config interface '1'
option mode 'disabled'
option desc 'console'
option devicename '/dev/com0'
option baudrate '9600'
option bytesize '8'
option parity 'none'
option flowcontrol 'none'
option stopbits '1'
option server_port '33001'
option holdconntime '60'
option client_port '6008'
option client_host ''
option client_auth '0'
option client_timeout '600'
option modbus_gateway '0'
option quiet '0'
option pack_timeout '0'
option pack_size '0'
option open_in_firewall '1'
-25
View File
@@ -1,25 +0,0 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
json_load "$(ubus call system board)"
json_get_var MODEL model
case "$MODEL" in
"TELEOFIS LT70")
uci set pollmydevice.0.rs485_mode='1'
uci commit pollmydevice
;;
"TELEOFIS LT70U")
uci set pollmydevice.0.rs485_mode='1'
uci set pollmydevice.1.mode='server'
uci set pollmydevice.1.baudrate='115200'
uci commit pollmydevice
sleep 30 && /etc/pollmydevice/console disable &
;;
"TELEOFIS RTUx68 RE-DE")
uci set pollmydevice.0.rs485_mode='1'
uci set pollmydevice.2.rs485_mode='1'
uci commit pollmydevice
;;
esac
exit 0
-130
View File
@@ -1,130 +0,0 @@
#!/bin/sh /etc/rc.common
START=99
STOP=10
USE_PROCD=1
DIR=/sbin
PROG=pollmydevice
error()
{
echo "${initscript}:" "$@" 1>&2
}
check_client_id()
{
[ ! -d "/etc/pollmydevice" ] && mkdir -p "/etc/pollmydevice"
[ ! -d "/tmp/pollmydevice" ] && mkdir -p "/tmp/pollmydevice"
INTERFACE=$1
if [[ -e "/etc/pollmydevice/client_id$INTERFACE" ]]; then
cp /etc/pollmydevice/client_id$INTERFACE /tmp/pollmydevice/client_id$INTERFACE
else
. /usr/share/libubox/jshn.sh
json_load "$(ubus call system board)"
json_get_var MODEL model
case "$MODEL" in
"TELEOFIS LT70" | "TELEOFIS LT70U")
SERIALNUM=$(getinfo serialnum)
if [[ "$SERIALNUM" != "n/a" ]]; then
SERIALNUM="0x$SERIALNUM"
CLIENT_ID=$((SERIALNUM*100000+INTERFACE))
fi
rs485_count=$(fw_printenv -n rs485_count 2>/dev/null)
if [[ "$rs485_count" == "2" ]]; then
if [ -e /etc/pollmydevice/exp_port ]; then
/etc/pollmydevice/exp_port
rm /etc/pollmydevice/exp_port
uci set pollmydevice.2.rs485_mode='1'
uci commit pollmydevice
fi
fi
;;
"TELEOFIS RTUx68")
SERIALNUM=$((0x$(getserialnum)))
CLIENT_ID=$((SERIALNUM*100000+INTERFACE))
;;
"TELEOFIS RTUx68 RE-DE")
SERIALNUM=$((0x$(getserialnum)))
CLIENT_ID=$((SERIALNUM*100000+INTERFACE))
if [ -e /etc/pollmydevice/exp_port ]; then
/etc/pollmydevice/exp_port
rm /etc/pollmydevice/exp_port
fi
;;
esac
[[ -n "$CLIENT_ID" ]] && echo $CLIENT_ID > /tmp/pollmydevice/client_id$INTERFACE
fi
}
clear_firewall_settings()
{
RULE=$(uci show firewall | grep -m1 port-pollmydevice)
while [[ -n "$RULE" ]]; do
RULE_N=$(echo $RULE | cut -d[ -f2 | cut -d] -f1)
uci delete firewall.@rule[$RULE_N]
RULE=$(uci show firewall | grep -m1 port-pollmydevice)
done
uci commit firewall
}
open_firewall_port()
{
config_get MODE "$1" mode
if [[ "$MODE" == "server" ]]; then
config_get OPEN "$1" open_in_firewall
if [[ "$OPEN" -eq "1" ]]; then
config_get DESCRIPTION "$1" desc
config_get PORT "$1" server_port
if [[ -n "$PORT" ]] && [[ -n "$DESCRIPTION" ]]; then
DESCRIPTION=$(echo $DESCRIPTION | tr -d ' ')
RULE=$(uci add firewall rule)
uci set firewall.$RULE.name=$DESCRIPTION-$1-port-pollmydevice
uci set firewall.$RULE.src='wan'
uci set firewall.$RULE.proto='tcp'
uci set firewall.$RULE.target='ACCEPT'
uci set firewall.$RULE.dest_port=$PORT
uci commit firewall
fi
fi
fi
}
start_service_daemon()
{
procd_open_instance
procd_set_param command "$DIR/$PROG"
procd_set_param respawn ${respawn_threshold:-360} ${respawn_timeout:-5} ${respawn_retry:-0}
procd_close_instance
}
start_service()
{
config_load 'pollmydevice'
config_foreach check_client_id 'interface'
clear_firewall_settings
config_foreach open_firewall_port 'interface'
/etc/init.d/firewall restart 2>/dev/null
start_service_daemon
}
service_triggers()
{
procd_add_reload_trigger 'pollmydevice'
}
stop()
{
service_stop $DIR/$PROG
}
# reload_service()
# {
# service_stop $DIR/$PROG
# start_service
# }
reload_service() {
stop
start
}
-34
View File
@@ -1,34 +0,0 @@
#!/bin/sh
case "$1" in
list)
echo '{ "con_on": { }, "con_off": { }, "status": { }, "get_id": { } }'
;;
call)
case "$2" in
con_on)
/etc/pollmydevice/console enable
echo '{ "con_on": "done" }'
;;
con_off)
/etc/pollmydevice/console disable
echo '{ "con_off": "done" }'
;;
status)
status=$(/etc/pollmydevice/console status)
echo "{ \"status\": \"$status\" }"
;;
get_id)
echo '{'
for num in 0 1 2 3 4 5 6 7
do
value=$(cat /tmp/pollmydevice/client_id$num)
echo "\"id$num\": \"$value\","
done
value=$(cat /tmp/pollmydevice/client_id8)
echo "\"id8\": \"$value\""
echo '}'
;;
esac
;;
esac
-1
View File
@@ -1 +0,0 @@
#kernel.printk=0 4 1 7
-6
View File
@@ -1,6 +0,0 @@
{
"files.associations": {
"cerrno": "cpp",
"thread": "cpp"
}
}
-14
View File
@@ -1,14 +0,0 @@
CC = gcc
CFLAGS = -Os -Wall -Wmissing-declarations -g3
LDLIBS = -luci -lpthread -lubox
PROGRAMS=pollmydevice
all: $(PROGRAMS)
pollmydevice: pollmydevice.o crc16.o modbus.o client_list.o
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
clean:
rm -f *.o $(PROGRAMS)
-101
View File
@@ -1,101 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include "client_list.h"
struct client_list {
int descr;
struct client_list *next;
};
struct client_list *head = NULL;
struct client_list *request = NULL;
struct client_list * get_end_list()
{
struct client_list * current = head;
if (current == NULL)
{
return NULL;
}
while (current->next != NULL)
{
current=current->next;
}
return current;
}
void client_insert(int new_descr)
{
struct client_list *end=NULL;
if (head == NULL)
{
head = malloc(sizeof(struct client_list));
if (head == NULL){
return;
}
head->descr = new_descr;
head->next = NULL;
return;
}
end = get_end_list();
if (end==NULL){
return;
}
struct client_list *new_client =(struct client_list *) malloc(sizeof(struct client_list));
if(new_client==NULL)
{
return;
}
new_client->descr = new_descr;
new_client->next = NULL;
end->next = new_client;
}
void start_request_descr()
{
request=head;
}
int get_next_descr(int *descr)
{
if(request==NULL)
{
return 1;
}
*descr=request->descr;
request=request->next;
return 0;
}
void remove_descr(int descr)
{
struct client_list *current = head;
struct client_list *prev = NULL;
if(current==NULL)
{
return;
}
while(current->descr!=descr)
{
prev=current;
current=current->next;
if(current==NULL)
{
return;
}
}
if(current!=head){
prev->next=current->next;
} else {
head=head->next;
}
free(current);
start_request_descr();
}
-9
View File
@@ -1,9 +0,0 @@
#ifndef _CLIENT_LIST_H
#define _CLIENT_LIST_H
void start_request_descr();
void client_insert(int new_descr);
int get_next_descr(int *descr);
void remove_descr(int descr);
#endif
-79
View File
@@ -1,79 +0,0 @@
/*
* OpenMODBUS/TCP to RS-232/485 MODBUS RTU gateway
*
* crc16.c - Cyclic Redundant Checks calculating
*
* Copyright (c) 2002-2003, 2013, Victor Antonovich (v.antonovich@gmail.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: crc16.c,v 1.3 2015/02/25 10:33:57 kapyar Exp $
*/
#include "crc16.h"
unsigned short
crc_16_tab[] = {
0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440,
0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841,
0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40,
0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641,
0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040,
0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441,
0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41,
0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41,
0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40,
0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041,
0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240,
0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41,
0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840,
0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40,
0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640,
0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241,
0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440,
0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841,
0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40,
0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641,
0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040
};
unsigned short
crc16(unsigned char *buf, unsigned int bsize)
{
unsigned short crc = 0xffff;
while (bsize--)
crc = (unsigned short)(crc >> 8) ^ crc_16_tab[(crc ^ *buf++) & 0xff];
return crc;
}
-41
View File
@@ -1,41 +0,0 @@
/*
* OpenMODBUS/TCP to RS-232/485 MODBUS RTU gateway
*
* crc16.h - Cyclic Redundant Checks calculating
*
* Copyright (c) 2002-2003, 2013, Victor Antonovich (v.antonovich@gmail.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: crc16.h,v 1.3 2015/02/25 10:33:57 kapyar Exp $
*/
#ifndef _CRC_H
#define _CRC_H
//#include "globals.h"
unsigned short crc16(unsigned char *buf, unsigned int bsize);
#endif /*_CRC_H */
-103
View File
@@ -1,103 +0,0 @@
/*
* OpenMODBUS/TCP to RS-232/485 MODBUS RTU gateway
*
* globals.h - global definitions
*
* Copyright (c) 2002-2003, 2013, Victor Antonovich (v.antonovich@gmail.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: globals.h,v 1.4 2015/02/25 10:33:58 kapyar Exp $
*/
#ifndef _GLOBALS_H
#define _GLOBALS_H
/* Include global configuration header file */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <netdb.h>
#include <fcntl.h>
#ifdef HAVE_LIBUTIL
# include <libutil.h>
#endif
/*
* Uncomment this for enabling logging facility
*/
#define LOG
#ifdef LOG
/* uncomment this line for extra debug log info */
# define DEBUG
#endif
/*
* Useful min/max macroses
*/
#define MAX(a, b) ( (a > b) ? a : b )
#define MIN(a, b) ( (a < b) ? a : b )
/*
* Boolean constants
*/
#define FALSE 0
#define TRUE !FALSE
/*
* Constants
*/
#define RC_OK 0
#define RC_ERR -1
#define RC_BREAK -2
#define RC_TIMEOUT -3
#define RC_AOPEN -4
#define RC_ACLOSE -5
/* Internal string buffers size */
#if defined(PATH_MAX)
# define INTBUFSIZE PATH_MAX
#else
# define INTBUFSIZE 1023
#endif
#endif
-18
View File
@@ -1,18 +0,0 @@
#ifndef _log_h
#define _log_h
#include <stdio.h>
#include <syslog.h>
#define LOG(fmt, ...) do { \
syslog(LOG_NOTICE,"pollmydevice: "fmt, ## __VA_ARGS__); \
fprintf(stderr, "pollmydevice: "fmt, ## __VA_ARGS__); \
} while (0)
#define ERROR(fmt, ...) do { \
syslog(LOG_ERR,"pollmydevice: "fmt, ## __VA_ARGS__); \
fprintf(stderr, "pollmydevice: "fmt, ## __VA_ARGS__); \
} while (0)
#endif
-93
View File
@@ -1,93 +0,0 @@
/*
* OpenMODBUS/TCP to RS-232/485 MODBUS RTU gateway
*
* modbus.c - MODBUS protocol related procedures
*
* Copyright (c) 2002-2003, 2013, Victor Antonovich (v.antonovich@gmail.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: modbus.c,v 1.3 2015/02/25 10:33:58 kapyar Exp $
*/
#include "modbus.h"
#define RC_OK 0
#define RC_ERR -1
#define RC_BREAK -2
#define RC_TIMEOUT -3
#define RC_AOPEN -4
#define RC_ACLOSE -5
/*
* Check CRC of MODBUS frame
* Parameters: FRAME - address of the frame,
* LEN - frame length;
* Return: 0 if CRC failed,
* non-zero otherwise
*/
int
modbus_crc_correct(unsigned char *frame, unsigned int len)
{
return (!crc16(frame, len));
}
/*
* Write CRC to MODBUS frame
* Parameters: FRAME - address of the frame,
* LEN - frame length;
* Return: none
*/
void
modbus_crc_write(unsigned char *frame, unsigned int len)
{
WORD_WR_LE(frame + len, crc16(frame, len));
}
/*
* Write exception response to OpenMODBUS request
* Parameters: PACKET - address of the request packet,
* CODE - exception code;
* Return: none
*/
void
modbus_ex_write(unsigned char *packet, unsigned char code)
{
MB_HDR(packet, MB_FCODE) |= 0x80;
MB_HDR(packet, MB_DATA) = code;
WORD_WR_BE(packet + MB_LENGTH_H, MB_EX_LEN);
}
/*
* Check MODBUS packet header consistency
* Parameters: HEADER - address of the header
* Return: RC_OK if (mostly) all is right, RC_ERR otherwise
*/
int
modbus_check_header(unsigned char *packet)
{
return (MB_HDR(packet, MB_PROTO_ID_H) == 0 &&
MB_HDR(packet, MB_PROTO_ID_L) == 0 &&
MB_HDR(packet, MB_LENGTH_H) == 0 &&
MB_HDR(packet, MB_LENGTH_L) > 0) ? RC_OK : RC_ERR;
}
-96
View File
@@ -1,96 +0,0 @@
/*
* OpenMODBUS/TCP to RS-232/485 MODBUS RTU gateway
*
* modbus.h - MODBUS protocol related procedures
*
* Copyright (c) 2002-2003, 2013, Victor Antonovich (v.antonovich@gmail.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: modbus.h,v 1.3 2015/02/25 10:33:57 kapyar Exp $
*/
#ifndef _MODBUS_H
#define _MODBUS_H
//#include "globals.h"
#include "crc16.h"
/*
* Macros for invoking data from MODBUS packet header
*/
#define MB_HDR(p, d) ( *(p + d) )
/*
* MODBUS frame lengths
*/
#define MB_EX_LEN 3
#define MB_MIN_LEN 4
#define MB_MAX_LEN 256
/*
* Macroses for word operations
*/
#define HIGH(w) ( (unsigned char)(((w) >> 8) & 0xff) )
#define LOW(w) ( (unsigned char)((w) & 0xff) )
#define WORD_WR_BE(p, w) do \
{ *(p) = (unsigned char)(((w) >> 8) & 0xff); \
*(p + 1) = (unsigned char)((w) & 0xff); } \
while (0);
#define WORD_RD_BE(p) ( (((unsigned short)*(p) << 8) & 0xff00) + \
(*(p + 1) & 0xff) )
#define WORD_WR_LE(p, w) do \
{ *(p) = (unsigned char)((w) & 0xff); \
*(p + 1) = (unsigned char)(((w) >> 8) & 0xff); } \
while (0);
#define WORD_RD_LE(p) ( (((unsigned short)*(p + 1) << 8) & 0xff00) + \
(*(p) & 0xff) )
/*
* MODBUS packet structure
*/
#define MB_TRANS_ID_H 0 /* transaction ID high byte */
#define MB_TRANS_ID_L 1 /* transaction ID low byte */
#define MB_PROTO_ID_H 2 /* protocol ID high byte */
#define MB_PROTO_ID_L 3 /* protocol ID low byte */
#define MB_LENGTH_H 4 /* length field high byte */
#define MB_LENGTH_L 5 /* length field low byte */
#define MB_UNIT_ID 6 /* unit identifier */
#define MB_FCODE 7 /* function code */
#define MB_DATA 8 /* MODBUS data */
/*
* Exception codes
*/
#define MB_EX_CRC 4
#define MB_EX_TIMEOUT 0x0B
/* Prototypes */
int modbus_crc_correct(unsigned char *frame, unsigned int len);
void modbus_crc_write(unsigned char *frame, unsigned int len);
void modbus_ex_write(unsigned char *packet, unsigned char code);
int modbus_check_header(unsigned char *packet);
#endif /* _MODBUS_H */
File diff suppressed because it is too large. Load diff
Loaded 100 of 180 files, more files were not shown because too many files have changed in this diff. Show more