mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-07-27 02:11:19 +08:00
🤞 Sync 2026-04-23 06:19:46
This commit is contained in:
parent
a1df15cd3d
commit
b86d032e91
40
cp210x-cfg/Makefile
Executable file
40
cp210x-cfg/Makefile
Executable file
@ -0,0 +1,40 @@
|
||||
|
||||
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))
|
||||
42
event-handler/Makefile
Executable file
42
event-handler/Makefile
Executable file
@ -0,0 +1,42 @@
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=event-handler
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/event-handler
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/event-handler
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Event Handler for lt70
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/event-handler/description
|
||||
This package contains a utility
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/event-handler/install
|
||||
$(INSTALL_DIR) $(1)/bin
|
||||
$(INSTALL_BIN) ./files/event-handler $(1)/bin/
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(CP) ./files/event-handler.config $(1)/etc/config/event-handler
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/event-handler.init $(1)/etc/init.d/event-handler
|
||||
$(INSTALL_DIR) $(1)/etc/rc.button
|
||||
$(INSTALL_BIN) ./files/BTN_0 $(1)/etc/rc.button/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,event-handler))
|
||||
10
event-handler/files/BTN_0
Executable file
10
event-handler/files/BTN_0
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "${ACTION}" = "released" ]; then
|
||||
#logger "gd3x: waiting for interrupt"
|
||||
fi
|
||||
|
||||
if [ "${ACTION}" = "pressed" ]; then
|
||||
event-handler int
|
||||
#logger "gd3x: new interrupt"
|
||||
fi
|
||||
71
event-handler/files/event-handler
Executable file
71
event-handler/files/event-handler
Executable file
@ -0,0 +1,71 @@
|
||||
#!/bin/sh
|
||||
POE="$(uci -q get event-handler.@event-handler[0].poe_gpio)"
|
||||
USB="$(uci -q get event-handler.@event-handler[0].usb_gpio)"
|
||||
HEAT="$(uci -q get event-handler.@event-handler[0].heat_gpio)"
|
||||
WD="$(uci -q get event-handler.@event-handler[0].wd_gpio)"
|
||||
LOG=/etc/event_log
|
||||
int=$1
|
||||
|
||||
while true; do
|
||||
touch $LOG
|
||||
DATE=$(date)
|
||||
INTS_MASK=$(cat /sys/class/i2c-dev/i2c-0/device/0-0011/int_sum)
|
||||
|
||||
# poe out power error int
|
||||
if [[ "$(echo $((INTS_MASK & 1)))" == "1" ]]; then
|
||||
VALUE=$(cat /sys/class/gpio/gpio$POE/value)
|
||||
if [[ "$VALUE" == "1" ]]; then
|
||||
echo "$DATE: ${int:+$int: }poe: Warning! The maximum current limit on the PoE-OUT output has been exceeded." >> $LOG
|
||||
else
|
||||
echo "$DATE: ${int:+$int: }poe: The PoE-OUT output current has been restored to normal values after exceeding the maximum thresholds." >> $LOG
|
||||
fi
|
||||
fi
|
||||
|
||||
# usb power error int
|
||||
if [[ "$(echo $((INTS_MASK & 2)))" == "2" ]]; then
|
||||
VALUE=$(cat /sys/class/gpio/gpio$USB/value)
|
||||
if [[ "$VALUE" == "1" ]]; then
|
||||
echo "$DATE: ${int:+$int: }usb: Warning! The maximum current limit for the USB has been exceeded." >> $LOG
|
||||
else
|
||||
echo "$DATE: ${int:+$int: }usb: The USB current has been restored to normal values after exceeding the maximum threshold." >> $LOG
|
||||
fi
|
||||
fi
|
||||
|
||||
# heat int
|
||||
if [[ "$(echo $((INTS_MASK & 4)))" == "4" ]]; then
|
||||
VALUE=$(cat /sys/class/gpio/gpio$HEAT/value)
|
||||
if [[ "$VALUE" == "1" ]]; then
|
||||
echo "$DATE: ${int:+$int: }heat: The device heating circuit is enabled." >> $LOG
|
||||
else
|
||||
echo "$DATE: ${int:+$int: }heat: The device heating circuit is disabled." >> $LOG
|
||||
fi
|
||||
fi
|
||||
|
||||
# wd toggle int
|
||||
if [[ "$(echo $((INTS_MASK & 8)))" == "8" ]]; then
|
||||
VALUE=$(cat /sys/class/gpio/gpio$WD/value)
|
||||
fi
|
||||
|
||||
# voltage threshold int
|
||||
if [[ "$(echo $((INTS_MASK & 16)))" == "16" ]]; then
|
||||
input_voltage="$(cat /sys/class/i2c-dev/i2c-0/device/0-0011/input_voltage)"
|
||||
voltage_threshold="$(cat /sys/class/i2c-dev/i2c-0/device/0-0011/voltage_threshold)"
|
||||
poe_out_power_gpio="$(uci -q get powersupply.system.poe_out_power_gpio)"
|
||||
if [[ "$input_voltage" -lt "$voltage_threshold" ]]; then
|
||||
echo 0 > /sys/class/gpio/gpio$poe_out_power_gpio/value
|
||||
echo "$DATE: ${int:+$int: }voltage: PoE-OUT power supply is disabled. The input voltage is below the required threshold of $voltage_threshold mV DC. Current voltage: $input_voltage mV." >> $LOG
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$(wc -l < $LOG)" -ge "100" ]]; then
|
||||
mv $LOG $LOG.old
|
||||
fi
|
||||
|
||||
if [[ -n "$int" ]]; then
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
exit 0
|
||||
6
event-handler/files/event-handler.config
Normal file
6
event-handler/files/event-handler.config
Normal file
@ -0,0 +1,6 @@
|
||||
config event-handler
|
||||
option poe_gpio '632'
|
||||
option usb_gpio '633'
|
||||
option heat_gpio '634'
|
||||
option wd_gpio '635'
|
||||
|
||||
23
event-handler/files/event-handler.init
Executable file
23
event-handler/files/event-handler.init
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=11
|
||||
USE_PROCD=1
|
||||
PROG=/bin/event-handler
|
||||
|
||||
start_service() {
|
||||
touch /etc/event_log
|
||||
poe_gpio="$(uci -q get event-handler.@event-handler[0].poe_gpio)"
|
||||
echo $poe_gpio > /sys/class/gpio/export
|
||||
usb_gpio="$(uci -q get event-handler.@event-handler[0].usb_gpio)"
|
||||
echo $usb_gpio > /sys/class/gpio/export
|
||||
heat_gpio="$(uci -q get event-handler.@event-handler[0].heat_gpio)"
|
||||
echo $heat_gpio > /sys/class/gpio/export
|
||||
wd_gpio="$(uci -q get event-handler.@event-handler[0].wd_gpio)"
|
||||
echo $wd_gpio > /sys/class/gpio/export
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
36
fbfdownloader/Makefile
Executable file
36
fbfdownloader/Makefile
Executable file
@ -0,0 +1,36 @@
|
||||
|
||||
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
fbfdownloader/src/ApplicationINI.h
Normal file
432
fbfdownloader/src/ApplicationINI.h
Normal file
@ -0,0 +1,432 @@
|
||||
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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
fbfdownloader/src/BinFileWtp.c
Normal file
353
fbfdownloader/src/BinFileWtp.c
Normal file
@ -0,0 +1,353 @@
|
||||
#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
fbfdownloader/src/BinFileWtp.h
Normal file
51
fbfdownloader/src/BinFileWtp.h
Normal file
@ -0,0 +1,51 @@
|
||||
#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
fbfdownloader/src/BulkDevNonDrv_Linux.c
Normal file
710
fbfdownloader/src/BulkDevNonDrv_Linux.c
Normal file
@ -0,0 +1,710 @@
|
||||
#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
fbfdownloader/src/BulkDevNonDrv_Linux.h
Normal file
156
fbfdownloader/src/BulkDevNonDrv_Linux.h
Normal file
@ -0,0 +1,156 @@
|
||||
#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
fbfdownloader/src/CommonFun.c
Normal file
190
fbfdownloader/src/CommonFun.c
Normal file
@ -0,0 +1,190 @@
|
||||
#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
fbfdownloader/src/CommonFun.h
Normal file
41
fbfdownloader/src/CommonFun.h
Normal file
@ -0,0 +1,41 @@
|
||||
#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
fbfdownloader/src/ConvetEdian.c
Normal file
60
fbfdownloader/src/ConvetEdian.c
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
#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
fbfdownloader/src/ConvetEdian.h
Normal file
16
fbfdownloader/src/ConvetEdian.h
Normal file
@ -0,0 +1,16 @@
|
||||
#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
fbfdownloader/src/EnumVal.h
Normal file
145
fbfdownloader/src/EnumVal.h
Normal file
@ -0,0 +1,145 @@
|
||||
#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
fbfdownloader/src/ErrorCode.h
Normal file
369
fbfdownloader/src/ErrorCode.h
Normal file
@ -0,0 +1,369 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** (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
fbfdownloader/src/FBFDownloader.c
Normal file
900
fbfdownloader/src/FBFDownloader.c
Normal file
@ -0,0 +1,900 @@
|
||||
#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
fbfdownloader/src/FBFDownloader_makefile
Normal file
47
fbfdownloader/src/FBFDownloader_makefile
Normal file
@ -0,0 +1,47 @@
|
||||
###############################################################
|
||||
# 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)
|
||||
|
||||
55
fbfdownloader/src/FBFDownloader_makefile_android
Normal file
55
fbfdownloader/src/FBFDownloader_makefile_android
Normal file
@ -0,0 +1,55 @@
|
||||
###############################################################
|
||||
# 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)
|
||||
|
||||
|
||||
|
||||
|
||||
55
fbfdownloader/src/FBFDownloader_makefile_cross
Normal file
55
fbfdownloader/src/FBFDownloader_makefile_cross
Normal file
@ -0,0 +1,55 @@
|
||||
###############################################################
|
||||
# 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
fbfdownloader/src/Macrodef.h
Normal file
141
fbfdownloader/src/Macrodef.h
Normal file
@ -0,0 +1,141 @@
|
||||
#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
fbfdownloader/src/Makefile
Normal file
55
fbfdownloader/src/Makefile
Normal file
@ -0,0 +1,55 @@
|
||||
###############################################################
|
||||
# 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
fbfdownloader/src/ParaDefine.c
Normal file
161
fbfdownloader/src/ParaDefine.c
Normal file
@ -0,0 +1,161 @@
|
||||
#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
fbfdownloader/src/ParaDefine.h
Normal file
774
fbfdownloader/src/ParaDefine.h
Normal file
@ -0,0 +1,774 @@
|
||||
#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
fbfdownloader/src/ReadMe.txt
Normal file
9
fbfdownloader/src/ReadMe.txt
Normal file
@ -0,0 +1,9 @@
|
||||
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
fbfdownloader/src/Tim.h
Normal file
960
fbfdownloader/src/Tim.h
Normal file
@ -0,0 +1,960 @@
|
||||
#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
fbfdownloader/src/TimIncludedType.h
Normal file
36
fbfdownloader/src/TimIncludedType.h
Normal file
@ -0,0 +1,36 @@
|
||||
#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
fbfdownloader/src/Typedef.h
Normal file
110
fbfdownloader/src/Typedef.h
Normal file
@ -0,0 +1,110 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* (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
fbfdownloader/src/UploadParaDef.h
Normal file
62
fbfdownloader/src/UploadParaDef.h
Normal file
@ -0,0 +1,62 @@
|
||||
#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;
|
||||
1409
fbfdownloader/src/WTPCOMMCLASS.c
Normal file
1409
fbfdownloader/src/WTPCOMMCLASS.c
Normal file
File diff suppressed because it is too large
Load Diff
113
fbfdownloader/src/WTPCOMMCLASS.h
Normal file
113
fbfdownloader/src/WTPCOMMCLASS.h
Normal file
@ -0,0 +1,113 @@
|
||||
// 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
fbfdownloader/src/WTPIOCTL.h
Normal file
134
fbfdownloader/src/WTPIOCTL.h
Normal file
@ -0,0 +1,134 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** (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
fbfdownloader/src/WTPdef.h
Normal file
186
fbfdownloader/src/WTPdef.h
Normal file
@ -0,0 +1,186 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** (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
fbfdownloader/src/WtptpDownLoad.c
Normal file
21
fbfdownloader/src/WtptpDownLoad.c
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
#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
fbfdownloader/src/WtptpDownLoad.h
Normal file
7
fbfdownloader/src/WtptpDownLoad.h
Normal file
@ -0,0 +1,7 @@
|
||||
#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();
|
||||
3386
fbfdownloader/src/WtptpDownloader.c
Normal file
3386
fbfdownloader/src/WtptpDownloader.c
Normal file
File diff suppressed because it is too large
Load Diff
229
fbfdownloader/src/WtptpDownloader.h
Normal file
229
fbfdownloader/src/WtptpDownloader.h
Normal file
@ -0,0 +1,229 @@
|
||||
#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
fbfdownloader/src/define.h
Normal file
145
fbfdownloader/src/define.h
Normal file
@ -0,0 +1,145 @@
|
||||
|
||||
#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
fbfdownloader/src/downloader.h
Normal file
377
fbfdownloader/src/downloader.h
Normal file
@ -0,0 +1,377 @@
|
||||
/******************************************************************************
|
||||
**
|
||||
** 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
fbfdownloader/src/fbfdownload.h
Normal file
22
fbfdownloader/src/fbfdownload.h
Normal file
@ -0,0 +1,22 @@
|
||||
#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
fbfdownloader/src/khash.h
Normal file
627
fbfdownloader/src/khash.h
Normal file
@ -0,0 +1,627 @@
|
||||
/* 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
fbfdownloader/src/klist.h
Normal file
169
fbfdownloader/src/klist.h
Normal file
@ -0,0 +1,169 @@
|
||||
/* 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
fbfdownloader/src/kstring.c
Normal file
294
fbfdownloader/src/kstring.c
Normal file
@ -0,0 +1,294 @@
|
||||
#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
fbfdownloader/src/kstring.h
Normal file
278
fbfdownloader/src/kstring.h
Normal file
@ -0,0 +1,278 @@
|
||||
/* 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
fbfdownloader/src/libmakefile
Normal file
49
fbfdownloader/src/libmakefile
Normal file
@ -0,0 +1,49 @@
|
||||
###############################################################
|
||||
# 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
fbfdownloader/src/libmakefile_cross
Normal file
56
fbfdownloader/src/libmakefile_cross
Normal file
@ -0,0 +1,56 @@
|
||||
###############################################################
|
||||
# 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
fbfdownloader/src/源码说明.txt
Normal file
72
fbfdownloader/src/源码说明.txt
Normal file
@ -0,0 +1,72 @@
|
||||
交叉编译方法
|
||||
以使用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形式的类)来解析。
|
||||
38
hotplug-generator/Makefile
Executable file
38
hotplug-generator/Makefile
Executable file
@ -0,0 +1,38 @@
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=hotplug-generator
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/hotplug-generator
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/hotplug-generator
|
||||
TITLE:=generator of hotplug scripts
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/hotplug-generator/description
|
||||
This package contains additional scripts and configuration files for generation hotplug scripts
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/hotplug-generator/install
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(CP) ./files/hotplug.config $(1)/etc/config/hotplug
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/hotplug.init $(1)/etc/init.d/hotplug
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,hotplug-generator))
|
||||
8
hotplug-generator/files/hotplug.config
Executable file
8
hotplug-generator/files/hotplug.config
Executable file
@ -0,0 +1,8 @@
|
||||
config iface 'gre'
|
||||
option action 'ifup'
|
||||
option enabled '0'
|
||||
list command 'sleep 5'
|
||||
list command 'ip route add 10.10.1.1 dev $DEVICE'
|
||||
list command 'ip route add 192.168.13.1 dev $DEVICE'
|
||||
option description 'GRE: +routes via $DEVICE after 5s'
|
||||
option interface 'gre_tun2'
|
||||
50
hotplug-generator/files/hotplug.init
Executable file
50
hotplug-generator/files/hotplug.init
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=10
|
||||
USE_PROCD=1
|
||||
IFACE_PATH="/etc/hotplug.d/iface/90-hp-generator"
|
||||
|
||||
add_iface_rule() {
|
||||
local enabled action command description interface
|
||||
|
||||
config_get enabled "$1" enabled
|
||||
[ "$enabled" = "0" ] && continue
|
||||
|
||||
config_get action "$1" action
|
||||
config_get description "$1" description
|
||||
config_get interface "$1" interface
|
||||
|
||||
echo "#!/bin/sh" >> "$IFACE_PATH-$1"
|
||||
echo "# Generated automatically, to change it use /etc/config/hotplug" >> "$IFACE_PATH-$1"
|
||||
description=$(echo $description | tr '\n' ' ')
|
||||
echo "# Description: $description" >> "$IFACE_PATH-$1"
|
||||
echo "" >> "$IFACE_PATH-$1"
|
||||
|
||||
echo "if [ \"\$ACTION\" = \"$action\" ]; then" >> "$IFACE_PATH-$1"
|
||||
echo " if [ \"\$INTERFACE\" = \"$interface\" ]; then" >> "$IFACE_PATH-$1"
|
||||
|
||||
command_list=$(uci -q get hotplug."$1".command)
|
||||
[ "${command_list:0:1}" = "'" ] && command_list=$(echo ${command_list:1})
|
||||
[ "${command_list: -1}" = "'" ] && command_list=$(echo ${command_list:0:-1})
|
||||
i=0
|
||||
while true ; do
|
||||
i=$((i+1))
|
||||
command=$(echo $command_list | awk -v i=$i -F "' '" '{print $i}')
|
||||
[ -z "$command" ] && break
|
||||
echo " $command" >> "$IFACE_PATH-$1"
|
||||
done
|
||||
|
||||
echo " fi" >> "$IFACE_PATH-$1"
|
||||
echo "fi" >> "$IFACE_PATH-$1"
|
||||
echo "exit 0" >> "$IFACE_PATH-$1"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
rm "$IFACE_PATH-"* 2>/dev/null
|
||||
config_load hotplug
|
||||
config_foreach add_iface_rule iface
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "hotplug"
|
||||
}
|
||||
38
iolines/Makefile
Executable file
38
iolines/Makefile
Executable file
@ -0,0 +1,38 @@
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=iolines
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/iolines
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/iolines
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Network interface watchdog
|
||||
DEPENDS:=
|
||||
endef
|
||||
|
||||
define Package/iolines/description
|
||||
This package contains a utility for managing the interface using ping requests.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/iolines/install
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(CP) ./files/iolines.config $(1)/etc/config/iolines
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/iolines.init $(1)/etc/init.d/iolines
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,iolines))
|
||||
23
iolines/files/iolines.config
Normal file
23
iolines/files/iolines.config
Normal file
@ -0,0 +1,23 @@
|
||||
config io
|
||||
option name "IO1"
|
||||
option dev "adc0"
|
||||
option enabled "0"
|
||||
option mode "mode1"
|
||||
|
||||
config io
|
||||
option name "IO2"
|
||||
option dev "adc1"
|
||||
option enabled "0"
|
||||
option mode "mode1"
|
||||
|
||||
config io
|
||||
option name "IO3"
|
||||
option dev "adc2"
|
||||
option enabled "0"
|
||||
option mode "mode1"
|
||||
|
||||
config io
|
||||
option name "IO4"
|
||||
option dev "adc3"
|
||||
option enabled "0"
|
||||
option mode "mode1"
|
||||
112
iolines/files/iolines.init
Executable file
112
iolines/files/iolines.init
Executable file
@ -0,0 +1,112 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=50
|
||||
|
||||
load_iolines_boot() {
|
||||
|
||||
config_get dev "$1" "dev"
|
||||
|
||||
num=$(echo ${dev:3:1})
|
||||
pu="/dev/pu$num"
|
||||
pd="/dev/pd$num"
|
||||
|
||||
config_get mode "$1" "mode"
|
||||
config_get enabled "$1" "enabled" "0"
|
||||
if [ $enabled -eq 1 ]; then
|
||||
case "$mode" in
|
||||
"mode1")
|
||||
echo in > $pu/direction
|
||||
echo low > $pd/direction
|
||||
;;
|
||||
"mode2")
|
||||
echo low > $pu/direction
|
||||
echo low > $pd/direction
|
||||
;;
|
||||
"mode3")
|
||||
echo high > $pu/direction
|
||||
echo high > $pd/direction
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo in > $pu/direction
|
||||
echo low > $pd/direction
|
||||
fi
|
||||
}
|
||||
|
||||
load_iolines() {
|
||||
|
||||
config_get dev "$1" "dev"
|
||||
|
||||
num=$(echo ${dev:3:1})
|
||||
pu="/dev/pu$num"
|
||||
pd="/dev/pd$num"
|
||||
|
||||
config_get mode "$1" "mode"
|
||||
|
||||
case "$mode" in
|
||||
"mode1")
|
||||
echo in > $pu/direction
|
||||
echo low > $pd/direction
|
||||
;;
|
||||
"mode2")
|
||||
echo low > $pu/direction
|
||||
echo low > $pd/direction
|
||||
;;
|
||||
"mode3")
|
||||
echo high > $pu/direction
|
||||
echo high > $pd/direction
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
boot() {
|
||||
echo 51 > /sys/class/gpio/export
|
||||
echo 50 > /sys/class/gpio/export
|
||||
echo 54 > /sys/class/gpio/export
|
||||
echo 53 > /sys/class/gpio/export
|
||||
echo 57 > /sys/class/gpio/export
|
||||
echo 64 > /sys/class/gpio/export
|
||||
echo 66 > /sys/class/gpio/export
|
||||
echo 65 > /sys/class/gpio/export
|
||||
|
||||
ln -s /sys/bus/iio/devices/iio\:device0/in_voltage3_raw /dev/board
|
||||
BOARD=$((($(cat /dev/board)+$(cat /dev/board)+$(cat /dev/board))/3))
|
||||
|
||||
if [ "$BOARD" -gt "600" -a "$BOARD" -lt "900" ]; then
|
||||
echo v4 > /tmp/sysinfo/hw
|
||||
ln -s /sys/class/gpio/gpio51 /dev/pu3
|
||||
ln -s /sys/class/gpio/gpio50 /dev/pd3
|
||||
ln -s /sys/class/gpio/gpio54 /dev/pu2
|
||||
ln -s /sys/class/gpio/gpio53 /dev/pd2
|
||||
ln -s /sys/class/gpio/gpio57 /dev/pu1
|
||||
ln -s /sys/class/gpio/gpio64 /dev/pd1
|
||||
ln -s /sys/class/gpio/gpio66 /dev/pu0
|
||||
ln -s /sys/class/gpio/gpio65 /dev/pd0
|
||||
ln -s /sys/bus/iio/devices/iio\:device0/in_voltage0_raw /dev/io3
|
||||
ln -s /sys/bus/iio/devices/iio\:device0/in_voltage1_raw /dev/io2
|
||||
ln -s /sys/bus/iio/devices/iio\:device0/in_voltage4_raw /dev/io1
|
||||
ln -s /sys/bus/iio/devices/iio\:device0/in_voltage6_raw /dev/io0
|
||||
else
|
||||
echo v2 > /tmp/sysinfo/hw
|
||||
ln -s /sys/class/gpio/gpio51 /dev/pu0
|
||||
ln -s /sys/class/gpio/gpio50 /dev/pd0
|
||||
ln -s /sys/class/gpio/gpio54 /dev/pu1
|
||||
ln -s /sys/class/gpio/gpio53 /dev/pd1
|
||||
ln -s /sys/class/gpio/gpio57 /dev/pu2
|
||||
ln -s /sys/class/gpio/gpio64 /dev/pd2
|
||||
ln -s /sys/class/gpio/gpio66 /dev/pu3
|
||||
ln -s /sys/class/gpio/gpio65 /dev/pd3
|
||||
ln -s /sys/bus/iio/devices/iio\:device0/in_voltage0_raw /dev/io0
|
||||
ln -s /sys/bus/iio/devices/iio\:device0/in_voltage1_raw /dev/io1
|
||||
ln -s /sys/bus/iio/devices/iio\:device0/in_voltage4_raw /dev/io2
|
||||
ln -s /sys/bus/iio/devices/iio\:device0/in_voltage6_raw /dev/io3
|
||||
fi
|
||||
config_load iolines
|
||||
config_foreach load_iolines_boot io
|
||||
}
|
||||
|
||||
restart() {
|
||||
config_load iolines
|
||||
config_foreach load_iolines io
|
||||
}
|
||||
34
linux-serial-test/Makefile
Normal file
34
linux-serial-test/Makefile
Normal file
@ -0,0 +1,34 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=linux-serial-test
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=https://github.com/cbrake/linux-serial-test.git
|
||||
PKG_SOURCE_DATE:=2024-01-15
|
||||
PKG_SOURCE_VERSION:=6a28493a29f7b941172bc58cf4fdabbf8109022f
|
||||
PKG_MIRROR_HASH:=skip
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/linux-serial-test
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Linux Serial Test Application
|
||||
endef
|
||||
|
||||
define Package/linux-serial-test/description
|
||||
Linux Serial Test Application
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) $(PKG_BUILD_DIR)/linux-serial-test.c -o $(PKG_BUILD_DIR)/linux-serial-test
|
||||
endef
|
||||
|
||||
define Package/linux-serial-test/install
|
||||
$(INSTALL_DIR) $(1)/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/linux-serial-test $(1)/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,linux-serial-test))
|
||||
@ -6,7 +6,7 @@ LUCI_TITLE:=LuCI interface for hotplug configuration
|
||||
LUCI_DEPENDS:=+luci-base
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-hotplug.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-hotplug.json << EEOF
|
||||
{
|
||||
"config": "hotplug",
|
||||
"init": "hotplug"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@hotplug[-1]
|
||||
add ucitrack hotplug
|
||||
set ucitrack.@hotplug[-1].init=hotplug
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -5,7 +5,7 @@ LUCI_DEPENDS:= +pollmydevice
|
||||
|
||||
PKG_VERSION:=1.0
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
LUCI_TITLE:=LuCI TCP to RS232 and RS485 Configuration Frontend
|
||||
|
||||
|
||||
@ -61,8 +61,8 @@ return view.extend({
|
||||
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))
|
||||
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);
|
||||
};
|
||||
@ -130,7 +130,7 @@ return view.extend({
|
||||
o.modalonly = true;
|
||||
o.default = 0;
|
||||
o.datatype = 'and(uinteger, min(0), max(255))';
|
||||
for(i=1;i<256;i++){
|
||||
for (var i = 1; i < 256; i++){
|
||||
o.depends({pack_size: i.toString()});
|
||||
}
|
||||
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-powersupply.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-powersupply.json << EEOF
|
||||
{
|
||||
"config": "powersupply",
|
||||
"init": "powersupply"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@powersupply[-1]
|
||||
add ucitrack powersupply
|
||||
set ucitrack.@powersupply[-1].init=powersupply
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-pptpd.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-pptpd.json << EEOF
|
||||
{
|
||||
"config": "pptpd",
|
||||
"init": "pptpd"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@pptpd[-1]
|
||||
add ucitrack pptpd
|
||||
set ucitrack.@pptpd[-1].init=pptpd
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -10,7 +10,7 @@ LUCI_DEPENDS:=+simman
|
||||
# Version: <major>.<minor>.<patch>
|
||||
PKG_VERSION:=0.2.6
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_MAINTAINER:=Sklyarec Konstantin <atskyua@gmail.com> Vladimir Ovseychuk <vgovseychuk@gmail.com>
|
||||
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-simman.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-simman.json << EEOF
|
||||
{
|
||||
"config": "simman",
|
||||
"init": "simman"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@simman[-1]
|
||||
add ucitrack simman
|
||||
set ucitrack.@simman[-1].init=simman
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -10,7 +10,7 @@ LUCI_DEPENDS:=
|
||||
# Version: <major>.<minor>.<patch>
|
||||
PKG_VERSION:=0.2.0
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
LUCI_TITLE:=LuCI utility to remote control via SMS
|
||||
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-smscontrol.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-smscontrol.json << EEOF
|
||||
{
|
||||
"config": "smscontrol",
|
||||
"init": "smscontrol"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@smscontrol[-1]
|
||||
add ucitrack smscontrol
|
||||
set ucitrack.@smscontrol[-1].init=smscontrol
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-snmpd.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-snmpd.json << EEOF
|
||||
{
|
||||
"config": "snmpd",
|
||||
"init": "snmpd"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@snmpd[-1]
|
||||
add ucitrack snmpd
|
||||
set ucitrack.@snmpd[-1].init=snmpd
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -1,7 +1,6 @@
|
||||
{
|
||||
"admin/vpn/strongswan": {
|
||||
"title": "IPsec",
|
||||
"order": 85,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "strongswan/strongswan"
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-xl2tpd.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-xl2tpd.json << EEOF
|
||||
{
|
||||
"config": "xl2tpd",
|
||||
"init": "xl2tpd"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@xl2tpd[-1]
|
||||
add ucitrack xl2tpd
|
||||
set ucitrack.@xl2tpd[-1].init=xl2tpd
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -4,7 +4,7 @@ PKG_NAME:=luci-app-zabbix
|
||||
|
||||
LUCI_TITLE:=zabbix agentd configuration
|
||||
LUCI_DEPENDS:=+luci-base
|
||||
LUCI_DEPENDS:=zabbix-agentd-ssl
|
||||
LUCI_DEPENDS:=zabbix-agentd-openssl
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-zabbix.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-zabbix.json << EEOF
|
||||
{
|
||||
"config": "zabbix",
|
||||
"init": "zabbix"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@zabbix[-1]
|
||||
add ucitrack zabbix
|
||||
set ucitrack.@zabbix[-1].init=zabbix_agentd
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -8,7 +8,7 @@
|
||||
<% local ver = require "luci.version" %>
|
||||
|
||||
<footer>
|
||||
<div style="height:40px;font-size:95%;color:#999;font-family: Arial,sans-serif;">© TELEOFIS 2004-2026 </div>
|
||||
<div style="height:40px;font-size:95%;color:#999;font-family: Arial,sans-serif;">© TELEOFIS 2004-2025 </div>
|
||||
<ul class="breadcrumb pull-right" id="modemenu" style="display:none"></ul>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
41
mxsldr/Makefile
Normal file
41
mxsldr/Makefile
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mxsldr
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/mxsldr
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/mxsldr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:= The i.MX233/i.MX28 USB Loader
|
||||
DEPENDS:=+libusb-1.0
|
||||
endef
|
||||
|
||||
define Package/mxsldr/description
|
||||
This tool allows user to load U-Boot via BootROM USB download.
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include/libusb-1.0
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||
CC="$(TARGET_CC)" \
|
||||
CFLAGS="$(TARGET_CFLAGS) -Wall"
|
||||
endef
|
||||
|
||||
define Package/mxsldr/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mxsldr $(1)/usr/bin
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,mxsldr))
|
||||
339
mxsldr/src/COPYING
Normal file
339
mxsldr/src/COPYING
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
24
mxsldr/src/Makefile
Normal file
24
mxsldr/src/Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
DESTDIR ?=
|
||||
prefix ?= "/usr/local"
|
||||
PKG_CONFIG ?= pkg-config
|
||||
|
||||
LIBUSB_FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libusb-1.0 && echo Y)
|
||||
|
||||
ifneq ($(LIBUSB_FOUND),Y)
|
||||
$(error Missing libusb!)
|
||||
endif
|
||||
|
||||
CFLAGS += $(shell $(PKG_CONFIG) --cflags libusb-1.0)
|
||||
LIBS += $(shell $(PKG_CONFIG) --libs libusb-1.0)
|
||||
|
||||
all: mxsldr
|
||||
|
||||
mxsldr: mxsldr.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -lusb-1.0
|
||||
|
||||
install: mxsldr
|
||||
mkdir -p $(DESTDIR)/$(prefix)/bin
|
||||
install -m 755 $^ $(DESTDIR)/$(prefix)/bin
|
||||
|
||||
clean:
|
||||
rm -f mxsldr
|
||||
31
mxsldr/src/README
Normal file
31
mxsldr/src/README
Normal file
@ -0,0 +1,31 @@
|
||||
Freescale i.MX233/i.MX28 USB loader
|
||||
===================================
|
||||
|
||||
This tool allows user to load U-Boot via BootROM USB download.
|
||||
|
||||
Prerequisites:
|
||||
==============
|
||||
|
||||
This tool depends on libusb 1.0, make sure to install development
|
||||
version of this library.
|
||||
|
||||
|
||||
In case your kernel is very outdated, meaning kernel older than 3.7.4,
|
||||
3.4.26 (stable) etc. or if your kernel does not properly handle the
|
||||
MXS BootROM recovery mode, which can be seen in 'dmesg' output by
|
||||
kernel reporting that the device is ignored due to problem with HID
|
||||
descriptor, apply patches (*.diff) onto kernel on your host machine
|
||||
and rebuild the kernel. Then restart the machine with the new kernel.
|
||||
|
||||
Usage:
|
||||
======
|
||||
|
||||
1) Connect the MX233/MX28 device to USB via device cable
|
||||
|
||||
2) Compile U-Boot and produce u-boot.sb
|
||||
|
||||
3) Compile this tool:
|
||||
$ make
|
||||
|
||||
4) Load u-boot.sb onto the device:
|
||||
$ sudo ./mxsldr <path to u-boot.sb>
|
||||
11
mxsldr/src/hid1.diff
Normal file
11
mxsldr/src/hid1.diff
Normal file
@ -0,0 +1,11 @@
|
||||
--- a/drivers/hid/hid-core.c 2012-08-04 23:53:38.900126160 +0200
|
||||
+++ b/drivers/hid/hid-core.c 2012-08-04 23:54:03.148127188 +0200
|
||||
@@ -374,7 +374,7 @@
|
||||
|
||||
case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
|
||||
parser->global.report_size = item_udata(item);
|
||||
- if (parser->global.report_size > 96) {
|
||||
+ if (parser->global.report_size > 128) {
|
||||
hid_err(parser->device, "invalid report_size %d\n",
|
||||
parser->global.report_size);
|
||||
return -1;
|
||||
26
mxsldr/src/hid2.diff
Normal file
26
mxsldr/src/hid2.diff
Normal file
@ -0,0 +1,26 @@
|
||||
--- a/drivers/hid/usbhid/hid-quirks.c 2012-08-05 02:58:15.880274023 +0200
|
||||
+++ b/drivers/hid/usbhid/hid-quirks.c 2012-08-05 02:58:10.228273782 +0200
|
||||
@@ -102,6 +102,8 @@
|
||||
{ USB_VENDOR_ID_SIGMA_MICRO, USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD, HID_QUIRK_NO_INIT_REPORTS },
|
||||
{ USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X, HID_QUIRK_MULTI_INPUT },
|
||||
{ USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X, HID_QUIRK_MULTI_INPUT },
|
||||
+ { USB_VENDOR_ID_SIGMATEL, USB_DEVICE_ID_SIGMATEL_STMP3780, HID_QUIRK_NOGET },
|
||||
+ { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
--- a/drivers/hid/hid-ids.h 2012-08-05 02:59:00.340275908 +0200
|
||||
+++ b/drivers/hid/hid-ids.h 2012-08-05 02:58:56.008275723 +0200
|
||||
@@ -296,6 +296,12 @@
|
||||
#define USB_VENDOR_ID_EZKEY 0x0518
|
||||
#define USB_DEVICE_ID_BTC_8193 0x0002
|
||||
|
||||
+#define USB_VENDOR_ID_FREESCALE 0x15A2
|
||||
+#define USB_DEVICE_ID_FREESCALE_MX28 0x004F
|
||||
+
|
||||
+#define USB_VENDOR_ID_SIGMATEL 0x066F
|
||||
+#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780
|
||||
+
|
||||
#define USB_VENDOR_ID_FRUCTEL 0x25B6
|
||||
#define USB_DEVICE_ID_GAMETEL_MT_MODE 0x0002
|
||||
|
||||
294
mxsldr/src/mxsldr.c
Normal file
294
mxsldr/src/mxsldr.c
Normal file
@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Freescale i.MX233/i.MX28 USB loader
|
||||
*
|
||||
* Copyright (C) 2012 Marek Vasut <marex@denx.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libusb.h>
|
||||
|
||||
#define TRANSFER_TIMEOUT_MS 60000
|
||||
#define HID_SET_REPORT 0x09
|
||||
#define HID_REPORT_TYPE_OUTPUT 0x02
|
||||
|
||||
#define MX23_VID 0x066f
|
||||
#define MX23_PID 0x3780
|
||||
#define MX28_VID 0x15a2
|
||||
#define MX28_PID 0x004f
|
||||
|
||||
#define BLTC_CMD_INQUIRY 0x01
|
||||
#define BLTC_CMD_DOWNLOAD_FIRMWARE 0x02
|
||||
|
||||
#define BLTC_PAGE_INQUIRY_CHIP_INFO 0x01
|
||||
|
||||
struct page_inquiry_chip_info {
|
||||
uint16_t chip_id;
|
||||
uint8_t __pad;
|
||||
uint8_t chip_rev;
|
||||
uint16_t rom_ver;
|
||||
uint16_t proto_ver;
|
||||
};
|
||||
|
||||
static int get_mxs_dev(libusb_device_handle **h)
|
||||
{
|
||||
int i, cnt, ret;
|
||||
struct libusb_device_descriptor desc;
|
||||
libusb_device **devs;
|
||||
libusb_device *rdev = NULL;
|
||||
|
||||
cnt = libusb_get_device_list(NULL, &devs);
|
||||
if (cnt < 0)
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
if (!devs[i])
|
||||
continue;
|
||||
|
||||
ret = libusb_get_device_descriptor(devs[i], &desc);
|
||||
if (ret < 0)
|
||||
continue;
|
||||
|
||||
if (desc.idVendor == MX23_VID && desc.idProduct == MX23_PID) {
|
||||
rdev = devs[i];
|
||||
break;
|
||||
}
|
||||
|
||||
if (desc.idVendor == MX28_VID && desc.idProduct == MX28_PID) {
|
||||
rdev = devs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!rdev) {
|
||||
fprintf(stderr, "No compatible device found.\n");
|
||||
ret = -ENODEV;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = libusb_open(rdev, h);
|
||||
if (ret)
|
||||
fprintf(stderr, "Could not open device, ret=%i\n", ret);
|
||||
exit:
|
||||
libusb_free_device_list(devs, 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int transfer(struct libusb_device_handle *h, int report,
|
||||
unsigned char *buf, unsigned cnt, int *offset)
|
||||
{
|
||||
int ret;
|
||||
int last_trans = 0;
|
||||
const int control_transfer =
|
||||
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS |
|
||||
LIBUSB_RECIPIENT_INTERFACE;
|
||||
const int interrupt_transfer =
|
||||
LIBUSB_RECIPIENT_INTERFACE | LIBUSB_ENDPOINT_IN;
|
||||
|
||||
if (report < 3) {
|
||||
ret = libusb_control_transfer(h, control_transfer,
|
||||
HID_SET_REPORT,
|
||||
(HID_REPORT_TYPE_OUTPUT << 8) | report,
|
||||
0, buf, cnt, TRANSFER_TIMEOUT_MS);
|
||||
last_trans = (ret > 0) ? ret - 1 : 0;
|
||||
if (ret > 0)
|
||||
ret = 0;
|
||||
} else {
|
||||
if (cnt > 64)
|
||||
cnt = 64;
|
||||
ret = libusb_interrupt_transfer(h, interrupt_transfer,
|
||||
buf, cnt, &last_trans,
|
||||
TRANSFER_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
*offset += last_trans;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int detect_mxs_cpu(libusb_device_handle *h)
|
||||
{
|
||||
int ret;
|
||||
uint8_t buf[1025];
|
||||
uint8_t fin[14];
|
||||
int last_trans = 0;
|
||||
const int len = sizeof(buf);
|
||||
struct page_inquiry_chip_info *info;
|
||||
info = (struct page_inquiry_chip_info *)(buf + 1);
|
||||
|
||||
const uint8_t inquiry_chip_info[] = {
|
||||
BLTC_CMD_INQUIRY, 'B', 'L', 'T', 'C', 0, 0, 0,
|
||||
0, 0x04, 0, 0,
|
||||
0, 0x80, 0, 0,
|
||||
|
||||
BLTC_CMD_INQUIRY, BLTC_PAGE_INQUIRY_CHIP_INFO, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
};
|
||||
|
||||
ret = transfer(h, 1, (uint8_t *)inquiry_chip_info,
|
||||
sizeof(inquiry_chip_info), &last_trans);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
last_trans = 0;
|
||||
do {
|
||||
ret = transfer(h, 3, buf + last_trans, len, &last_trans);
|
||||
if (ret)
|
||||
return ret;
|
||||
} while (last_trans < len);
|
||||
|
||||
last_trans = 0;
|
||||
ret = transfer(h, 4, fin, sizeof(fin), &last_trans);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if ((fin[0] != 0x04) || memcmp(fin + 1, "BLTS", 4))
|
||||
return -EINVAL;
|
||||
|
||||
printf("Detected: i.MX%i\n"
|
||||
"Chip ID: 0x%04x\n"
|
||||
"Chip Revision: 0x%04x\n"
|
||||
"ROM Version: 0x%04x\n"
|
||||
"Protocol Version: 0x%04x\n",
|
||||
(info->chip_id == 0x2800) ? 28 : 23,
|
||||
info->chip_id, info->chip_rev,
|
||||
info->rom_ver, info->proto_ver);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int upload_firmware(char *fn, libusb_device_handle *h)
|
||||
{
|
||||
FILE *f;
|
||||
long len, tmplen;
|
||||
uint8_t buf[1025] = { BLTC_CMD_DOWNLOAD_FIRMWARE };
|
||||
int ret = 0;
|
||||
int last_trans = 0;
|
||||
|
||||
uint8_t inquiry_download_fw[] = {
|
||||
BLTC_CMD_INQUIRY, 'B', 'L', 'T', 'C', 1, 0, 0,
|
||||
0, 0x60, 0x24, 0x4a,
|
||||
0, 0, 0, 0,
|
||||
|
||||
BLTC_CMD_DOWNLOAD_FIRMWARE, 0, 0x4a, 0x24,
|
||||
0x60, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
};
|
||||
|
||||
f = fopen(fn, "rb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Failed to open firmware (%s)\n", fn);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = fseek(f, 0, SEEK_END);
|
||||
if (ret)
|
||||
goto exit;
|
||||
|
||||
len = ftell(f);
|
||||
if (len <= 0)
|
||||
goto exit;
|
||||
tmplen = __builtin_bswap32(len);
|
||||
|
||||
memcpy(inquiry_download_fw + 9, &len, 4);
|
||||
memcpy(inquiry_download_fw + 17, &tmplen, 4);
|
||||
|
||||
ret = fseek(f, 0, SEEK_SET);
|
||||
if (ret)
|
||||
goto exit;
|
||||
|
||||
ret = transfer(h, 1, (uint8_t *)inquiry_download_fw,
|
||||
sizeof(inquiry_download_fw), &last_trans);
|
||||
if (ret) {
|
||||
fprintf(stderr,
|
||||
"An Error occured while transfering the firmware through USB.\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
while ((len = fread(buf + 1, 1, sizeof(buf) - 1, f))) {
|
||||
buf[0] = BLTC_CMD_DOWNLOAD_FIRMWARE;
|
||||
ret = transfer(h, 2, buf, len + 1, &last_trans);
|
||||
if (ret)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void print_usage()
|
||||
{
|
||||
printf(
|
||||
"Usage: mxsldr <bootstream>\n"
|
||||
" (e.g: u-boot.sb)\n");
|
||||
}
|
||||
|
||||
int main(int argc, char const *const argv[])
|
||||
{
|
||||
int ret;
|
||||
libusb_device_handle *h = NULL;
|
||||
|
||||
/* Detect and exit. */
|
||||
if (argc != 2) {
|
||||
print_usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = libusb_init(NULL);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
ret = get_mxs_dev(&h);
|
||||
if (ret)
|
||||
goto out;
|
||||
if (!h)
|
||||
goto out;
|
||||
|
||||
if (libusb_kernel_driver_active(h, 0))
|
||||
libusb_detach_kernel_driver(h, 0);
|
||||
|
||||
ret = libusb_claim_interface(h, 0);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Failed to claim interface\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = detect_mxs_cpu(h);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Failed to detect CPU\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = upload_firmware((char *)argv[1], h);
|
||||
if (ret)
|
||||
goto exit;
|
||||
|
||||
exit:
|
||||
libusb_release_interface(h, 0);
|
||||
out:
|
||||
if (h)
|
||||
libusb_close(h);
|
||||
|
||||
libusb_exit(NULL);
|
||||
return ret;
|
||||
}
|
||||
14
net-snmp-ssl/Config.in.wut
Normal file
14
net-snmp-ssl/Config.in.wut
Normal file
@ -0,0 +1,14 @@
|
||||
menu "Configuration"
|
||||
depends on PACKAGE_libnetsnmp
|
||||
|
||||
config SNMP_WITH_PERL_EMBEDDED
|
||||
bool
|
||||
default n
|
||||
prompt "Enable embedded perl in the SNMP agent and snmptrapd."
|
||||
|
||||
config SNMP_WITH_PERL_MODULES
|
||||
bool
|
||||
default n
|
||||
prompt "Install perl modules"
|
||||
|
||||
endmenu
|
||||
287
net-snmp-ssl/Makefile
Normal file
287
net-snmp-ssl/Makefile
Normal file
@ -0,0 +1,287 @@
|
||||
#
|
||||
# Copyright (C) 2006-2017 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=net-snmp
|
||||
PKG_VERSION:=5.9.4
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/net-snmp
|
||||
PKG_HASH:=skip
|
||||
PKG_MAINTAINER:=Stijn Tintel <stijn@linux-ipv6.be>
|
||||
PKG_LICENSE:=MIT BSD-3-Clause-Clear
|
||||
PKG_CPE_ID:=cpe:/a:net-snmp:net-snmp
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/net-snmp-ssl/Default
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
URL:=http://www.net-snmp.org/
|
||||
endef
|
||||
|
||||
define Package/net-snmp-ssl/Default/description
|
||||
Simple Network Management Protocol (SNMP) is a widely used protocol for
|
||||
monitoring the health and welfare of network equipment (eg. routers),
|
||||
computer equipment and even devices like UPSs. Net-SNMP is a suite of
|
||||
applications used to implement SNMP v1, SNMP v2c and SNMP v3 using both
|
||||
IPv4 and IPv6.
|
||||
endef
|
||||
|
||||
|
||||
define Package/libnetsnmp-ssl
|
||||
$(call Package/net-snmp-ssl/Default)
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
DEPENDS:=+libnl-tiny +libpci +libpcre2 +libopenssl
|
||||
TITLE:=Open source SNMP implementation (libraries)
|
||||
endef
|
||||
|
||||
define Package/libnetsnmp-ssl/description
|
||||
$(call Package/net-snmp-ssl/Default/description)
|
||||
.
|
||||
This package contains shared libraries, needed by other programs.
|
||||
endef
|
||||
|
||||
|
||||
define Package/snmp-mibs-ssl
|
||||
$(call Package/net-snmp-ssl/Default)
|
||||
TITLE:=Open source SNMP implementation (MIB-files)
|
||||
endef
|
||||
|
||||
define Package/snmp-mibs-ssl/description
|
||||
$(call Package/net-snmp-ssl/Default/description)
|
||||
.
|
||||
This package contains SNMP MIB-Files.
|
||||
endef
|
||||
|
||||
|
||||
define Package/snmp-utils-ssl
|
||||
$(call Package/net-snmp-ssl/Default)
|
||||
DEPENDS:=+libnetsnmp-ssl
|
||||
TITLE:=Open source SNMP implementation (utilities)
|
||||
endef
|
||||
|
||||
define Package/snmp-utils-ssl/description
|
||||
$(call Package/net-snmp-ssl/Default/description)
|
||||
.
|
||||
This package contains SNMP client utilities:
|
||||
- snmpget
|
||||
- snmpset
|
||||
- snmpstatus
|
||||
- snmptest
|
||||
- snmptrap
|
||||
- snmpwalk
|
||||
endef
|
||||
|
||||
|
||||
define Package/snmpd-ssl
|
||||
$(call Package/net-snmp-ssl/Default)
|
||||
DEPENDS:=+libnetsnmp-ssl
|
||||
TITLE:=Open source SNMP implementation (daemon)
|
||||
endef
|
||||
|
||||
define Package/snmpd-ssl/description
|
||||
$(call Package/net-snmp-ssl/Default/description)
|
||||
.
|
||||
This package contains the SNMP agent, dynamically linked.
|
||||
endef
|
||||
|
||||
|
||||
define Package/snmpd-static-ssl
|
||||
$(call Package/net-snmp-ssl/Default)
|
||||
DEPENDS:=+snmpd-ssl
|
||||
TITLE:=Open source SNMP implementation (daemon)
|
||||
BUILDONLY:=1
|
||||
endef
|
||||
|
||||
|
||||
define Package/snmptrapd-ssl
|
||||
$(call Package/net-snmp-ssl/Default)
|
||||
DEPENDS:=+libnetsnmp-ssl
|
||||
TITLE:=Open source SNMP implementation (notification receiver)
|
||||
endef
|
||||
|
||||
define Package/snmptrapd-ssl/description
|
||||
$(call Package/net-snmp-ssl/Default/description)
|
||||
.
|
||||
This package contains the SNMP notification receiver.
|
||||
endef
|
||||
|
||||
|
||||
SNMP_MIB_MODULES_INCLUDED = \
|
||||
agent/extend \
|
||||
agentx \
|
||||
host/hr_device \
|
||||
host/hr_disk \
|
||||
host/hr_filesys \
|
||||
host/hr_network \
|
||||
host/hr_partition \
|
||||
host/hr_proc \
|
||||
host/hr_storage \
|
||||
host/hr_system \
|
||||
ieee802dot11 \
|
||||
if-mib/ifXTable \
|
||||
ip-mib/ipAddressTable \
|
||||
ip-mib/inetNetToMediaTable \
|
||||
ip-forward-mib/inetCidrRouteTable \
|
||||
ip-forward-mib/ipCidrRouteTable \
|
||||
mibII/at \
|
||||
mibII/icmp \
|
||||
mibII/ifTable \
|
||||
mibII/ip \
|
||||
mibII/snmp_mib \
|
||||
mibII/sysORTable \
|
||||
mibII/system_mib \
|
||||
mibII/tcp \
|
||||
mibII/udp \
|
||||
mibII/vacm_context \
|
||||
mibII/vacm_vars \
|
||||
snmpv3/snmpEngine \
|
||||
snmpv3/snmpMPDStats \
|
||||
snmpv3/usmConf \
|
||||
snmpv3/usmStats \
|
||||
snmpv3/usmUser \
|
||||
tunnel \
|
||||
ucd-snmp/disk_hw \
|
||||
ucd-snmp/dlmod \
|
||||
ucd-snmp/extensible \
|
||||
ucd-snmp/loadave \
|
||||
ucd-snmp/memory \
|
||||
ucd-snmp/pass \
|
||||
ucd-snmp/pass_persist \
|
||||
ucd-snmp/proc \
|
||||
ucd-snmp/vmstat \
|
||||
util_funcs \
|
||||
utilities/execute \
|
||||
|
||||
SNMP_MIB_MODULES_EXCLUDED = \
|
||||
agent_mibs \
|
||||
disman/event \
|
||||
disman/schedule \
|
||||
hardware \
|
||||
host \
|
||||
if-mib \
|
||||
ip-mib \
|
||||
mibII \
|
||||
notification \
|
||||
notification-log-mib \
|
||||
snmpv3mibs \
|
||||
target \
|
||||
tcp-mib \
|
||||
ucd_snmp \
|
||||
udp-mib \
|
||||
utilities \
|
||||
|
||||
SNMP_TRANSPORTS_INCLUDED = Callback UDP Unix
|
||||
|
||||
SNMP_TRANSPORTS_EXCLUDED = TCP TCPIPv6
|
||||
|
||||
TARGET_CFLAGS += $(FPIC)
|
||||
TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-mfd-rewrites \
|
||||
--enable-shared \
|
||||
--enable-static \
|
||||
--with-endianness=$(if $(CONFIG_BIG_ENDIAN),big,little) \
|
||||
--with-logfile=/var/log/snmpd.log \
|
||||
--with-persistent-directory=/usr/lib/snmp/ \
|
||||
--with-default-snmp-version=1 \
|
||||
--with-sys-contact=root@localhost \
|
||||
--with-sys-location=Unknown \
|
||||
--enable-applications \
|
||||
--disable-debugging \
|
||||
--disable-manuals \
|
||||
--disable-scripts \
|
||||
--with-out-mib-modules="$(SNMP_MIB_MODULES_EXCLUDED)" \
|
||||
--with-mib-modules="$(SNMP_MIB_MODULES_INCLUDED)" \
|
||||
--with-out-transports="$(SNMP_TRANSPORTS_EXCLUDED)" \
|
||||
--with-transports="$(SNMP_TRANSPORTS_INCLUDED)" \
|
||||
--without-openssl \
|
||||
--without-libwrap \
|
||||
--without-mysql \
|
||||
--without-rpm \
|
||||
--without-zlib \
|
||||
--with-pcre2-8 \
|
||||
--with-nl \
|
||||
$(call autoconf_bool,CONFIG_IPV6,ipv6) \
|
||||
--disable-perl-cc-checks \
|
||||
--disable-embedded-perl \
|
||||
--without-perl-modules
|
||||
|
||||
CONFIGURE_VARS += \
|
||||
ac_cv_header_netlink_netlink_h=yes \
|
||||
netsnmp_cv_func_nl_connect_LIBS=-lnl-tiny \
|
||||
|
||||
ifeq ($(CONFIG_IPV6),y)
|
||||
SNMP_TRANSPORTS_INCLUDED+= UDPIPv6
|
||||
endif
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||
INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS) -lm -lc" \
|
||||
all install
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(2)/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/net-snmp-config $(2)/bin/
|
||||
$(SED) 's,=/usr,=$(STAGING_DIR)/usr,g' $(2)/bin/net-snmp-config
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/bin
|
||||
$(LN) $(STAGING_DIR)/host/bin/net-snmp-config $(STAGING_DIR)/usr/bin/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/net-snmp $(1)/usr/include/
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnetsnmp{,agent,helpers,mibs}.{a,so*} $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libnetsnmp-ssl/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnetsnmp{,agent,helpers,mibs}.so.* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/snmp-mibs-ssl/install
|
||||
$(INSTALL_DIR) $(1)/usr/share/snmp/mibs
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/snmp/mibs/* $(1)/usr/share/snmp/mibs/
|
||||
endef
|
||||
|
||||
define Package/snmp-utils-ssl/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/snmp{get,set,status,test,trap,walk} $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
define Package/snmpd-ssl/install
|
||||
$(INSTALL_DIR) $(1)/etc/snmp
|
||||
$(LN) /var/run/snmpd.conf $(1)/etc/snmp/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/snmpd.init $(1)/etc/init.d/snmpd
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/snmpd $(1)/usr/sbin/snmpd
|
||||
endef
|
||||
|
||||
define Package/snmptrapd-ssl/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/snmptrapd.init $(1)/etc/init.d/snmptrapd
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnetsnmptrapd.so.* $(1)/usr/lib/
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/snmptrapd $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libnetsnmp-ssl))
|
||||
$(eval $(call BuildPackage,snmp-mibs-ssl))
|
||||
$(eval $(call BuildPackage,snmp-utils-ssl))
|
||||
$(eval $(call BuildPackage,snmpd-ssl))
|
||||
$(eval $(call BuildPackage,snmpd-static-ssl))
|
||||
$(eval $(call BuildPackage,snmptrapd-ssl))
|
||||
417
net-snmp-ssl/files/snmpd.init
Normal file
417
net-snmp-ssl/files/snmpd.init
Normal file
@ -0,0 +1,417 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2008 OpenWrt.org
|
||||
START=99
|
||||
|
||||
USE_PROCD=1
|
||||
PROG="/usr/sbin/snmpd"
|
||||
|
||||
CONFIGFILE="/var/run/snmpd.conf"
|
||||
CONFIGFILE2="/usr/lib/snmp/snmpd.conf"
|
||||
|
||||
snmpd_agent_add() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get agentaddress "$cfg" agentaddress
|
||||
[ -n "$agentaddress" ] || return 0
|
||||
echo "agentaddress $agentaddress" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_agentx_add() {
|
||||
local cfg="$1"
|
||||
echo "master agentx" >> $CONFIGFILE
|
||||
config_get agentxsocket "$cfg" agentxsocket
|
||||
[ -n "$agentxsocket" ] && echo "agentXSocket $agentxsocket" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_system_add() {
|
||||
local cfg="$1"
|
||||
config_get syslocation "$cfg" sysLocation
|
||||
[ -n "$syslocation" ] && echo "sysLocation $syslocation" >> $CONFIGFILE
|
||||
config_get syscontact "$cfg" sysContact
|
||||
[ -n "$syscontact" ] && echo "sysContact $syscontact" >> $CONFIGFILE
|
||||
config_get sysname "$cfg" sysName
|
||||
[ -n "$sysname" ] && echo "sysName $sysname" >> $CONFIGFILE
|
||||
config_get sysservice "$cfg" sysService
|
||||
[ -n "$sysservice" ] && echo "sysService $sysservice" >> $CONFIGFILE
|
||||
config_get sysdescr "$cfg" sysDescr
|
||||
[ -n "$sysdescr" ] && echo "sysDescr $sysdescr" >> $CONFIGFILE
|
||||
config_get sysobjectid "$cfg" sysObjectID
|
||||
[ -n "$sysobjectid" ] && echo "sysObjectID $sysobjectid" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_com2sec_add() {
|
||||
local cfg="$1"
|
||||
config_get secname "$cfg" secname
|
||||
[ -n "$secname" ] || return 0
|
||||
config_get source "$cfg" source
|
||||
[ -n "$source" ] || return 0
|
||||
config_get community "$cfg" community
|
||||
[ -n "$community" ] || return 0
|
||||
echo "com2sec $secname $source $community" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_com2sec6_add() {
|
||||
local cfg="$1"
|
||||
config_get secname "$cfg" secname
|
||||
[ -n "$secname" ] || return 0
|
||||
config_get source "$cfg" source
|
||||
[ -n "$source" ] || return 0
|
||||
config_get community "$cfg" community
|
||||
[ -n "$community" ] || return 0
|
||||
echo "com2sec6 $secname $source $community" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_group_add() {
|
||||
local cfg="$1"
|
||||
config_get group "$cfg" group
|
||||
[ -n "$group" ] || return 0
|
||||
config_get version "$cfg" version
|
||||
[ -n "$version" ] || return 0
|
||||
config_get secname "$cfg" secname
|
||||
[ -n "$secname" ] || return 0
|
||||
echo "group $group $version $secname" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_view_add() {
|
||||
local cfg="$1"
|
||||
config_get viewname "$cfg" viewname
|
||||
[ -n "$viewname" ] || return 0
|
||||
config_get type "$cfg" type
|
||||
[ -n "$type" ] || return 0
|
||||
config_get oid "$cfg" oid
|
||||
[ -n "$oid" ] || return 0
|
||||
# optional mask
|
||||
config_get mask "$cfg" mask
|
||||
echo "view $viewname $type $oid $mask" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_access_add() {
|
||||
local cfg="$1"
|
||||
config_get group "$cfg" group
|
||||
[ -n "$group" ] || return 0
|
||||
config_get context "$cfg" context
|
||||
[ -n $context ] || return 0
|
||||
[ "$context" == "none" ] && context='""'
|
||||
config_get version "$cfg" version
|
||||
[ -n "$version" ] || return 0
|
||||
config_get level "$cfg" level
|
||||
[ -n "$level" ] || return 0
|
||||
config_get prefix "$cfg" prefix
|
||||
[ -n "$prefix" ] || return 0
|
||||
config_get read "$cfg" read
|
||||
[ -n "$read" ] || return 0
|
||||
config_get write "$cfg" write
|
||||
[ -n "$write" ] || return 0
|
||||
config_get notify "$cfg" notify
|
||||
[ -n "$notify" ] || return 0
|
||||
echo "access $group $context $version $level $prefix $read $write $notify" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_trap_hostname_add() {
|
||||
local cfg="$1"
|
||||
config_get hostname "$cfg" HostName
|
||||
config_get port "$cfg" Port
|
||||
config_get community "$cfg" Community
|
||||
config_get type "$cfg" Type
|
||||
echo "$type $hostname $community $port" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_trap_ip_add() {
|
||||
local cfg="$1"
|
||||
config_get host_ip "$cfg" HostIP
|
||||
config_get port "$cfg" Port
|
||||
config_get community "$cfg" Community
|
||||
config_get type "$cfg" Type
|
||||
echo "$type $host_ip $community $port" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_access_default_add() {
|
||||
local cfg="$1"
|
||||
config_get mode "$cfg" Mode
|
||||
config_get community "$cfg" CommunityName
|
||||
config_get oidrestrict "$cfg" RestrictOID
|
||||
config_get oid "$cfg" RestrictedOID
|
||||
echo -n "$mode $community default" >> $CONFIGFILE
|
||||
[ "$oidrestrict" == "yes" ] && echo " $oid" >> $CONFIGFILE
|
||||
[ "$oidrestrict" == "no" ] && echo "" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_access_HostName_add() {
|
||||
local cfg="$1"
|
||||
config_get hostname "$cfg" HostName
|
||||
config_get mode "$cfg" Mode
|
||||
config_get community "$cfg" CommunityName
|
||||
config_get oidrestrict "$cfg" RestrictOID
|
||||
config_get oid "$cfg" RestrictedOID
|
||||
echo -n "$mode $community $hostname" >> $CONFIGFILE
|
||||
[ "$oidrestrict" == "yes" ] && echo " $oid" >> $CONFIGFILE
|
||||
[ "$oidrestrict" == "no" ] && echo "" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_access_HostIP_add() {
|
||||
local cfg="$1"
|
||||
config_get host_ip "$cfg" HostIP
|
||||
config_get ip_mask "$cfg" IPMask
|
||||
config_get mode "$cfg" Mode
|
||||
config_get community "$cfg" CommunityName
|
||||
config_get oidrestrict "$cfg" RestrictOID
|
||||
config_get oid "$cfg" RestrictedOID
|
||||
echo -n "$mode $community $host_ip/$ip_mask" >> $CONFIGFILE
|
||||
[ "$oidrestrict" == "yes" ] && echo " $oid" >> $CONFIGFILE
|
||||
[ "$oidrestrict" == "no" ] && echo "" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_pass_add() {
|
||||
local cfg="$1"
|
||||
local pass='pass'
|
||||
|
||||
config_get miboid "$cfg" miboid
|
||||
[ -n "$miboid" ] || return 0
|
||||
config_get prog "$cfg" prog
|
||||
[ -n "$prog" ] || return 0
|
||||
config_get_bool persist "$cfg" persist 0
|
||||
[ $persist -ne 0 ] && pass='pass_persist'
|
||||
config_get priority "$cfg" priority
|
||||
priority=${priority:+-p $priority}
|
||||
echo "$pass $priority $miboid $prog" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_exec_add() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get name "$cfg" name
|
||||
[ -n "$name" ] || return 0
|
||||
config_get prog "$cfg" prog
|
||||
[ -n "$prog" ] || return 0
|
||||
config_get args "$cfg" args
|
||||
config_get miboid "$cfg" miboid
|
||||
echo "exec $miboid $name $prog $args" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_extend_add() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get name "$cfg" name
|
||||
[ -n "$name" ] || return 0
|
||||
config_get prog "$cfg" prog
|
||||
[ -n "$prog" ] || return 0
|
||||
config_get args "$cfg" args
|
||||
config_get miboid "$cfg" miboid
|
||||
echo "extend $miboid $name $prog $args" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_disk_add() {
|
||||
local cfg="$1"
|
||||
local disk='disk'
|
||||
|
||||
config_get partition "$cfg" partition
|
||||
[ -n "$partition" ] || return 0
|
||||
config_get size "$cfg" size
|
||||
[ -n "$size" ] || return 0
|
||||
echo "$disk $partition $size" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_engineid_add() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get engineid "$cfg" engineid
|
||||
[ -n "$engineid" ] && echo "engineID $engineid" >> $CONFIGFILE
|
||||
config_get engineidtype "$cfg" engineidtype
|
||||
[ "$engineidtype" -ge 1 -a "$engineidtype" -le 3 ] && \
|
||||
echo "engineIDType $engineidtype" >> $CONFIGFILE
|
||||
config_get engineidnic "$cfg" engineidnic
|
||||
[ -n "$engineidnic" ] && echo "engineIDNic $engineidnic" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_sink_add() {
|
||||
local cfg="$1"
|
||||
local section="$2"
|
||||
local community
|
||||
local port
|
||||
local host
|
||||
|
||||
config_get host "$cfg" host
|
||||
[ -n "section" -a -n "$host" ] || return 0
|
||||
# optional community
|
||||
config_get community "$cfg" community
|
||||
# optional port
|
||||
config_get port "$cfg" port
|
||||
port=${port:+:$port}
|
||||
echo "$section $host$port $community" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
append_parm() {
|
||||
local section="$1"
|
||||
local option="$2"
|
||||
local switch="$3"
|
||||
local _loctmp
|
||||
config_get _loctmp "$section" "$option"
|
||||
[ -z "$_loctmp" ] && return 0
|
||||
echo "$switch $_loctmp" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
append_authtrapenable() {
|
||||
local section="$1"
|
||||
local option="$2"
|
||||
local switch="$3"
|
||||
local _loctmp
|
||||
config_get_bool _loctmp "$section" "$option"
|
||||
[ -z "$_loctmp" ] && return 0
|
||||
[ "$_loctmp" -gt 0 ] && echo "$switch $_loctmp" >> $CONFIGFILE
|
||||
}
|
||||
|
||||
snmpd_setup_fw_rules() {
|
||||
local net="$1"
|
||||
local zone
|
||||
|
||||
zone=$(fw3 -q network "$net" 2>/dev/null)
|
||||
|
||||
local handled_zone
|
||||
for handled_zone in $HANDLED_SNMP_ZONES; do
|
||||
[ "$handled_zone" = "$zone" ] && return
|
||||
done
|
||||
|
||||
json_add_object ""
|
||||
json_add_string type rule
|
||||
json_add_string src "$zone"
|
||||
json_add_string proto udp
|
||||
json_add_string dest_port 161
|
||||
json_add_string target ACCEPT
|
||||
json_close_object
|
||||
|
||||
HANDLED_SNMP_ZONES="$HANDLED_SNMP_ZONES $zone"
|
||||
}
|
||||
|
||||
snmpd_v3_add() {
|
||||
local section="$1"
|
||||
config_get mode "$section" mode
|
||||
if [[ "$mode" != "v1_v2c_v3" ]] && [[ "$mode" != "v3" ]]; then
|
||||
return
|
||||
fi
|
||||
config_get security_name "$section" security_name
|
||||
[ -n "$security_name" ] || return
|
||||
config_get security_type "$section" security_type
|
||||
[ -n "$security_type" ] || return
|
||||
config_get v3_mode "$section" v3_mode
|
||||
[ -n "$v3_mode" ] || return
|
||||
config_get auth_prot "$section" auth_prot
|
||||
config_get auth_pass "$section" auth_pass
|
||||
config_get priv_prot "$section" priv_prot
|
||||
config_get priv_pass "$section" priv_pass
|
||||
case "$security_type" in
|
||||
"noAuthNoPriv" )
|
||||
echo "createUser $security_name" >> $CONFIGFILE
|
||||
echo "$v3_mode $security_name noauth" >> $CONFIGFILE
|
||||
;;
|
||||
"authNoPriv" )
|
||||
if [[ -z "$auth_prot" ]] || [[ -z "$auth_pass" ]]; then
|
||||
return
|
||||
fi
|
||||
echo "createUser $security_name $auth_prot \"$auth_pass\"" >> $CONFIGFILE
|
||||
echo "$v3_mode $security_name auth" >> $CONFIGFILE
|
||||
;;
|
||||
"authPriv" )
|
||||
if [[ -z "$auth_prot" ]] || [[ -z "$auth_pass" ]]; then
|
||||
return
|
||||
fi
|
||||
if [[ -z "$priv_prot" ]] || [[ -z "$priv_pass" ]]; then
|
||||
return
|
||||
fi
|
||||
echo "createUser $security_name $auth_prot \"$auth_pass\" $priv_prot \"$priv_pass\"" >> $CONFIGFILE
|
||||
echo "$v3_mode $security_name priv" >> $CONFIGFILE
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
start_service() {
|
||||
[ -f "$CONFIGFILE" ] && rm -f "$CONFIGFILE"
|
||||
[ -f "$CONFIGFILE2" ] && sed -i '/usmUser/d' "$CONFIGFILE2"
|
||||
|
||||
config_load snmpd
|
||||
|
||||
config_get_bool snmp_enabled general enabled 1
|
||||
[ "$snmp_enabled" -eq 0 ] && return
|
||||
|
||||
config_get ip_family general ip_family
|
||||
config_get mode general mode
|
||||
|
||||
procd_open_instance
|
||||
|
||||
config_foreach snmpd_agent_add agent
|
||||
config_foreach snmpd_agentx_add agentx
|
||||
config_foreach snmpd_system_add system
|
||||
if [[ "$mode" == "v1_v2c_v3" ]] || [[ "$mode" == "v1_v2c" ]]; then
|
||||
if [[ "$ip_family" == "ipv4" || "$ip_family" == "both" ]]; then
|
||||
config_foreach snmpd_com2sec_add com2sec
|
||||
fi
|
||||
if [[ "$ip_family" == "ipv6" || "$ip_family" == "both" ]]; then
|
||||
config_foreach snmpd_com2sec6_add com2sec6
|
||||
fi
|
||||
fi
|
||||
config_foreach snmpd_group_add group
|
||||
config_foreach snmpd_view_add view
|
||||
config_foreach snmpd_access_add access
|
||||
config_foreach snmpd_trap_hostname_add trap_HostName
|
||||
config_foreach snmpd_trap_ip_add trap_HostIP
|
||||
config_foreach snmpd_access_default_add access_default
|
||||
config_foreach snmpd_access_HostName_add access_HostName
|
||||
config_foreach snmpd_access_HostIP_add access_HostIP
|
||||
config_foreach snmpd_pass_add pass
|
||||
config_foreach snmpd_exec_add exec
|
||||
config_foreach snmpd_extend_add extend
|
||||
config_foreach snmpd_disk_add disk
|
||||
config_foreach snmpd_engineid_add engineid
|
||||
append_parm trapcommunity community trapcommunity
|
||||
config_foreach snmpd_sink_add trapsink trapsink
|
||||
config_foreach snmpd_sink_add trap2sink trap2sink
|
||||
config_foreach snmpd_sink_add informsink informsink
|
||||
config_foreach snmpd_v3_add snmpd
|
||||
append_authtrapenable authtrapenable enable authtrapenable
|
||||
append_parm v1trapaddress host v1trapaddress
|
||||
append_parm trapsess trapsess trapsess
|
||||
|
||||
procd_set_param command $PROG -Lf /dev/null -f -r
|
||||
procd_set_param file $CONFIGFILE
|
||||
procd_set_param respawn
|
||||
|
||||
for iface in $(ls /sys/class/net 2>/dev/null); do
|
||||
procd_append_param netdev "$iface"
|
||||
done
|
||||
|
||||
procd_open_data
|
||||
|
||||
json_add_array firewall
|
||||
config_list_foreach general network snmpd_setup_fw_rules
|
||||
json_close_array
|
||||
|
||||
procd_close_data
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
[ -f "$CONFIGFILE" ] || return
|
||||
rm -f "$CONFIGFILE"
|
||||
procd_set_config_changed firewall
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers(){
|
||||
local script=$(readlink "$initscript")
|
||||
local name=$(basename ${script:-$initscript})
|
||||
|
||||
procd_open_trigger
|
||||
procd_add_raw_trigger "interface.*" 2000 /etc/init.d/$name reload
|
||||
procd_close_trigger
|
||||
|
||||
procd_add_reload_trigger 'snmpd'
|
||||
}
|
||||
|
||||
service_started() {
|
||||
[ "$snmp_enabled" -eq 0 ] && return
|
||||
procd_set_config_changed firewall
|
||||
}
|
||||
15
net-snmp-ssl/files/snmptrapd.init
Normal file
15
net-snmp-ssl/files/snmptrapd.init
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=50
|
||||
|
||||
USE_PROCD=1
|
||||
PROG="/usr/sbin/snmptrapd"
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
|
||||
procd_set_param command $PROG -Lf /dev/null -f
|
||||
procd_set_param respawn
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
47
net-snmp-ssl/patches/000-cross-compile.patch
Normal file
47
net-snmp-ssl/patches/000-cross-compile.patch
Normal file
@ -0,0 +1,47 @@
|
||||
From: Jo-Philipp Wich <jo@mein.io>
|
||||
Date: Fri, 6 Jan 2017 13:41:00 +0100
|
||||
Subject: [PATCH] configure: allow overriding hardcoded /usr/include/libnl3
|
||||
|
||||
In a cross-compile setting we do not want to probe the host systems
|
||||
/usr/include path, therfore allow to disable this include path by passing
|
||||
ac_cv_header_netlink_netlink_h=yes to configure.
|
||||
|
||||
Also disable the testing for libraries providing nl_connect when
|
||||
netsnmp_cv_func_nl_connect_LIBS is predefined since the proprietary
|
||||
NETSNMP_SEARCH_LIBS() macro will clobber the internal link flags upon
|
||||
encountering predefined cache variables, causing all subsequent configure
|
||||
link tests to fail due to a stray "no" word getting passed to the linker.
|
||||
|
||||
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
||||
--- a/configure.d/config_os_libs2
|
||||
+++ b/configure.d/config_os_libs2
|
||||
@@ -252,14 +252,22 @@ if test "x$with_nl" != "xno"; then
|
||||
case $target_os in
|
||||
linux*) # Check for libnl (linux)
|
||||
netsnmp_save_CPPFLAGS="$CPPFLAGS"
|
||||
- CPPFLAGS="${LIBNL3_CFLAGS} ${LIBNLROUTE3_CFLAGS} $CPPFLAGS"
|
||||
- NETSNMP_SEARCH_LIBS(nl_connect, nl-3,
|
||||
- [AC_CHECK_HEADERS(netlink/netlink.h)
|
||||
- EXTERNAL_MIBGROUP_INCLUDES="$EXTERNAL_MIBGROUP_INCLUDES ${LIBNL3_CFLAGS}"],
|
||||
- [CPPFLAGS="$netsnmp_save_CPPFLAGS"], [], [LMIBLIBS])
|
||||
+ netsnmp_netlink_include_flags=""
|
||||
if test "x$ac_cv_header_netlink_netlink_h" != xyes; then
|
||||
- NETSNMP_SEARCH_LIBS(nl_connect, nl, [
|
||||
- AC_CHECK_HEADERS(netlink/netlink.h)], [], [], LMIBLIBS)
|
||||
+ netsnmp_netlink_include_flags="-I/usr/include/libnl3"
|
||||
+ fi
|
||||
+ CPPFLAGS="$netsnmp_netlink_include_flags $CPPFLAGS"
|
||||
+ if test "x$netsnmp_cv_func_nl_connect_LIBS" = x; then
|
||||
+ NETSNMP_SEARCH_LIBS(nl_connect, nl-3,
|
||||
+ [AC_CHECK_HEADERS(netlink/netlink.h)
|
||||
+ EXTERNAL_MIBGROUP_INCLUDES="$EXTERNAL_MIBGROUP_INCLUDES $netsnmp_netlink_include_flags"],
|
||||
+ [CPPFLAGS="$netsnmp_save_CPPFLAGS"], [], [], [LMIBLIBS])
|
||||
+ if test "x$ac_cv_header_netlink_netlink_h" != xyes; then
|
||||
+ NETSNMP_SEARCH_LIBS(nl_connect, nl, [
|
||||
+ AC_CHECK_HEADERS(netlink/netlink.h)], [], [], LMIBLIBS)
|
||||
+ fi
|
||||
+ else
|
||||
+ LMIBLIBS="$LMIBLIBS $netsnmp_cv_func_nl_connect_LIBS"
|
||||
fi
|
||||
if test "x$ac_cv_header_netlink_netlink_h" = xyes; then
|
||||
AC_EGREP_HEADER([nl_socket_free], [netlink/socket.h],
|
||||
@ -0,0 +1,34 @@
|
||||
From 9588b5c9c27239b1f8c02f0bf417f13735e93225 Mon Sep 17 00:00:00 2001
|
||||
From: Stijn Tintel <stijn@linux-ipv6.be>
|
||||
Date: Sat, 26 Sep 2020 04:34:18 +0300
|
||||
Subject: [PATCH] HOST-MIB, hr_filesys: fix compile error
|
||||
|
||||
On non-AIX systems without getfsstat, a variable is being declared right
|
||||
after a label. This is a violation of the C language standard, and
|
||||
causes the following compile error:
|
||||
|
||||
host/hr_filesys.c: In function 'Get_Next_HR_FileSys':
|
||||
host/hr_filesys.c:752:5: error: a label can only be part of a statement and a declaration is not a statement
|
||||
const char **cpp;
|
||||
^~~~~
|
||||
|
||||
Fix the problem by adding an empty statement after the label.
|
||||
|
||||
Fixes: 22e1371bb1fd ("HOST-MIB, hr_filesys: Convert recursion into iteration")
|
||||
|
||||
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
|
||||
---
|
||||
agent/mibgroup/host/hr_filesys.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/agent/mibgroup/host/hr_filesys.c
|
||||
+++ b/agent/mibgroup/host/hr_filesys.c
|
||||
@@ -718,7 +718,7 @@ static const char *HRFS_ignores[] = {
|
||||
int
|
||||
Get_Next_HR_FileSys(void)
|
||||
{
|
||||
-next:
|
||||
+next: ;
|
||||
#ifdef HAVE_GETFSSTAT
|
||||
if (HRFS_index >= fscount)
|
||||
return -1;
|
||||
13
net-snmp-ssl/patches/100-debian-statistics.patch
Normal file
13
net-snmp-ssl/patches/100-debian-statistics.patch
Normal file
@ -0,0 +1,13 @@
|
||||
--- a/agent/mibgroup/mibII/interfaces.c
|
||||
+++ b/agent/mibgroup/mibII/interfaces.c
|
||||
@@ -1586,6 +1586,10 @@ Interface_Scan_Init(void)
|
||||
char *stats, *ifstart = line;
|
||||
size_t len;
|
||||
|
||||
+ /* Ignore interfaces with no statistics. */
|
||||
+ if (strstr(line, "No statistics available."))
|
||||
+ continue;
|
||||
+
|
||||
len = strlen(line);
|
||||
if (len && line[len - 1] == '\n')
|
||||
line[len - 1] = '\0';
|
||||
40
net-snmp-ssl/patches/110-debian-makefiles.patch
Normal file
40
net-snmp-ssl/patches/110-debian-makefiles.patch
Normal file
@ -0,0 +1,40 @@
|
||||
--- a/local/Makefile.in
|
||||
+++ b/local/Makefile.in
|
||||
@@ -101,7 +101,7 @@ tkmib.made: $(srcdir)/tkmib
|
||||
|
||||
mib2c.made: $(srcdir)/mib2c
|
||||
if test "x$(PERL)" != "x" ; then \
|
||||
- $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%;s#/usr/local/share/snmp#$(snmplibdir)#;' ${srcdir}/mib2c > mib2c.made; \
|
||||
+ $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%;s#/usr/local/share/snmp#$(snmplibdir)#;s#/usr/local/etc/snmp#$(SNMPCONFPATH)#;' ${srcdir}/mib2c > mib2c.made; \
|
||||
else \
|
||||
touch mib2c.made; \
|
||||
fi
|
||||
--- a/Makefile.top
|
||||
+++ b/Makefile.top
|
||||
@@ -28,6 +28,7 @@ man8dir = $(mandir)/man8
|
||||
snmplibdir = $(datadir)/snmp
|
||||
mibdir = $(snmplibdir)/mibs
|
||||
persistentdir = @PERSISTENT_DIRECTORY@
|
||||
+sysconfdir = @sysconfdir@
|
||||
DESTDIR = @INSTALL_PREFIX@
|
||||
INSTALL_PREFIX = $(DESTDIR)
|
||||
|
||||
--- a/mibs/Makefile.in
|
||||
+++ b/mibs/Makefile.in
|
||||
@@ -47,11 +47,15 @@ NETSNMPMIBS = NET-SNMP-TC.txt NET-SNMP-M
|
||||
UCDMIBS = UCD-SNMP-MIB.txt UCD-DEMO-MIB.txt UCD-IPFWACC-MIB.txt \
|
||||
UCD-DLMOD-MIB.txt UCD-DISKIO-MIB.txt
|
||||
|
||||
+EXTRAMIBS = BGP4-MIB.txt BRIDGE-MIB.txt GNOME-SMI.txt OSPF-MIB.txt \
|
||||
+ OSPF-TRAP-MIB.txt RIPv2-MIB.txt SOURCE-ROUTING-MIB.txt \
|
||||
+ LM-SENSORS-MIB.txt
|
||||
+
|
||||
DEFAULTMIBS = @default_mibs_install@
|
||||
|
||||
MIBS = $(V1MIBS) $(V2MIBS) $(V3MIBS) $(RFCMIBS) \
|
||||
$(AGENTMIBS) $(IANAMIBS) \
|
||||
- $(NETSNMPMIBS) $(UCDMIBS) $(DEFAULTMIBS)
|
||||
+ $(NETSNMPMIBS) $(UCDMIBS) $(DEFAULTMIBS) $(EXTRAMIBS)
|
||||
|
||||
all: standardall
|
||||
|
||||
14
net-snmp-ssl/patches/120-debian-searchdirs.patch
Normal file
14
net-snmp-ssl/patches/120-debian-searchdirs.patch
Normal file
@ -0,0 +1,14 @@
|
||||
--- a/local/mib2c
|
||||
+++ b/local/mib2c
|
||||
@@ -61,8 +61,9 @@ $currentlevel = -1;
|
||||
if($ENV{MIB2C_DIR}) {
|
||||
push @def_search_dirs, split(/:/, $ENV{MIB2C_DIR});
|
||||
}
|
||||
-push @def_search_dirs, "/usr/local/share/snmp/";
|
||||
-push @def_search_dirs, "/usr/local/share/snmp/mib2c-data";
|
||||
+push @def_search_dirs, "/etc/snmp/";
|
||||
+push @def_search_dirs, "/usr/share/snmp/";
|
||||
+push @def_search_dirs, "/usr/share/snmp/mib2c-data";
|
||||
push @def_search_dirs, "./mib2c-conf.d";
|
||||
|
||||
sub usage {
|
||||
5183
net-snmp-ssl/patches/130-debian-extramibs.patch
Normal file
5183
net-snmp-ssl/patches/130-debian-extramibs.patch
Normal file
File diff suppressed because it is too large
Load Diff
11
net-snmp-ssl/patches/160-no_ldconfig.patch
Normal file
11
net-snmp-ssl/patches/160-no_ldconfig.patch
Normal file
@ -0,0 +1,11 @@
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -16599,7 +16599,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu
|
||||
need_version=no
|
||||
library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
|
||||
soname_spec='$libname$release$shared_ext$major'
|
||||
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
|
||||
+ finish_cmds=''
|
||||
shlibpath_var=LD_LIBRARY_PATH
|
||||
shlibpath_overrides_runpath=no
|
||||
|
||||
11
net-snmp-ssl/patches/161-project_types.patch
Normal file
11
net-snmp-ssl/patches/161-project_types.patch
Normal file
@ -0,0 +1,11 @@
|
||||
--- a/configure.d/config_project_types
|
||||
+++ b/configure.d/config_project_types
|
||||
@@ -66,7 +66,7 @@ netsnmp_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
|
||||
AC_MSG_CHECKING([for the type of fd_set::fds_bits])
|
||||
-for type in __fd_mask __int32_t unknown; do
|
||||
+for type in fd_mask int32_t size_t; do
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
|
||||
#include <sys/select.h>
|
||||
#include <stddef.h>
|
||||
11
net-snmp-ssl/patches/170-ldflags.patch
Normal file
11
net-snmp-ssl/patches/170-ldflags.patch
Normal file
@ -0,0 +1,11 @@
|
||||
--- a/Makefile.top
|
||||
+++ b/Makefile.top
|
||||
@@ -87,7 +87,7 @@ LIBCURRENT = 42
|
||||
LIBAGE = 2
|
||||
LIBREVISION = 1
|
||||
|
||||
-LIB_LD_CMD = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath $(libdir) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) @LD_NO_UNDEFINED@ -o
|
||||
+LIB_LD_CMD = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath $(libdir) $(LDFLAGS) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) @LD_NO_UNDEFINED@ -o
|
||||
LIB_EXTENSION = la
|
||||
LIB_VERSION =
|
||||
LIB_LDCONFIG_CMD = $(LIBTOOL) --mode=finish $(INSTALL_PREFIX)$(libdir)
|
||||
407
net-snmp-ssl/patches/200-add-pcre2-support.patch
Normal file
407
net-snmp-ssl/patches/200-add-pcre2-support.patch
Normal file
@ -0,0 +1,407 @@
|
||||
From d3e95c87b32397815f6d5bcfc844259f2552697a Mon Sep 17 00:00:00 2001
|
||||
From: gagan sidhu <gagan@hotmail.com>
|
||||
Date: Sun, 21 May 2023 15:47:36 -0600
|
||||
Subject: [PATCH] add pcre2 support
|
||||
|
||||
---
|
||||
agent/mibgroup/host/data_access/swrun.c | 29 ++++++++++--
|
||||
agent/mibgroup/if-mib/data_access/interface.c | 47 ++++++++++++++++---
|
||||
agent/mibgroup/struct.h | 2 +-
|
||||
agent/mibgroup/ucd-snmp/proc.c | 32 +++++++++----
|
||||
agent/mibgroup/ucd-snmp/proc.h | 2 +-
|
||||
configure.d/config_os_libs1 | 27 +++++++++++
|
||||
configure.d/config_project_with_enable | 4 ++
|
||||
include/net-snmp/data_access/interface.h | 9 +++-
|
||||
include/net-snmp/data_access/swrun.h | 2 +-
|
||||
include/net-snmp/types.h | 2 +-
|
||||
10 files changed, 132 insertions(+), 24 deletions(-)
|
||||
|
||||
--- a/agent/mibgroup/host/data_access/swrun.c
|
||||
+++ b/agent/mibgroup/host/data_access/swrun.c
|
||||
@@ -17,7 +17,10 @@
|
||||
#include "swrun.h"
|
||||
#include "swrun_private.h"
|
||||
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+#define PCRE2_CODE_UNIT_WIDTH 8
|
||||
+#include <pcre2.h>
|
||||
+#elif defined(HAVE_PCRE_H)
|
||||
#include <pcre.h>
|
||||
#endif
|
||||
|
||||
@@ -100,32 +103,52 @@ swrun_max_processes( void )
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_SWRUN_MAX_PROCESSES */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_SWRUN_COUNT_PROCESSES_BY_REGEX
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
int
|
||||
swrun_count_processes_by_regex( char *name, netsnmp_regex_ptr regexp )
|
||||
{
|
||||
netsnmp_swrun_entry *entry;
|
||||
netsnmp_iterator *it;
|
||||
int i = 0;
|
||||
+#ifdef HAVE_PCRE2_H
|
||||
+ pcre2_match_data *ndx_match;
|
||||
+ int *found_ndx;
|
||||
+ ndx_match = pcre2_match_data_create(30, NULL);
|
||||
+ found_ndx = pcre2_get_ovector_pointer(ndx_match);
|
||||
+#elif defined(HAVE_PCRE_H)
|
||||
int found_ndx[30];
|
||||
+#endif
|
||||
int found;
|
||||
char fullCommand[64 + 128 + 128 + 3];
|
||||
|
||||
netsnmp_cache_check_and_reload(swrun_cache);
|
||||
if ( !swrun_container || !name || !regexp.regex_ptr )
|
||||
+#ifdef HAVE_PCRE2_H
|
||||
+ {
|
||||
+ pcre2_match_data_free(ndx_match);
|
||||
+ return 0;
|
||||
+ }
|
||||
+#else
|
||||
return 0; /* or -1 */
|
||||
+#endif
|
||||
|
||||
it = CONTAINER_ITERATOR( swrun_container );
|
||||
while ((entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) != NULL) {
|
||||
/* need to assemble full command back so regexps can get full picture */
|
||||
sprintf(fullCommand, "%s %s", entry->hrSWRunPath, entry->hrSWRunParameters);
|
||||
+#ifdef HAVE_PCRE2_H
|
||||
+ found = pcre2_match(regexp.regex_ptr, fullCommand, strlen(fullCommand), 0, 0, ndx_match, NULL);
|
||||
+#elif HAVE_PCRE_H
|
||||
found = pcre_exec(regexp.regex_ptr, NULL, fullCommand, strlen(fullCommand), 0, 0, found_ndx, 30);
|
||||
+#endif
|
||||
if (found > 0) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
ITERATOR_RELEASE( it );
|
||||
-
|
||||
+#ifdef HAVE_PCRE2_H
|
||||
+ pcre2_match_data_free(ndx_match);
|
||||
+#endif
|
||||
return i;
|
||||
}
|
||||
#endif /* HAVE_PCRE_H */
|
||||
--- a/agent/mibgroup/if-mib/data_access/interface.c
|
||||
+++ b/agent/mibgroup/if-mib/data_access/interface.c
|
||||
@@ -16,7 +16,11 @@
|
||||
#include "if-mib/ifTable/ifTable.h"
|
||||
#include "if-mib/data_access/interface.h"
|
||||
#include "interface_private.h"
|
||||
-#if defined(HAVE_PCRE_H)
|
||||
+
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+#define PCRE2_CODE_UNIT_WIDTH 8
|
||||
+#include <pcre2.h>
|
||||
+#elif defined(HAVE_PCRE_H)
|
||||
#include <pcre.h>
|
||||
#elif defined(HAVE_REGEX_H)
|
||||
#include <sys/types.h>
|
||||
@@ -824,7 +828,13 @@ int netsnmp_access_interface_max_reached
|
||||
int netsnmp_access_interface_include(const char *name)
|
||||
{
|
||||
netsnmp_include_if_list *if_ptr;
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+ //pcre_exec->pcre2_match
|
||||
+ //ovector->pcre2_match_data
|
||||
+ pcre2_match_data *ndx_match;
|
||||
+ ndx_match = pcre2_match_data_create(3, NULL);
|
||||
+ int *found_ndx = pcre2_get_ovector_pointer(ndx_match);
|
||||
+#elif defined(HAVE_PCRE_H)
|
||||
int found_ndx[3];
|
||||
#endif
|
||||
|
||||
@@ -840,7 +850,13 @@ int netsnmp_access_interface_include(con
|
||||
|
||||
|
||||
for (if_ptr = include_list; if_ptr; if_ptr = if_ptr->next) {
|
||||
-#if defined(HAVE_PCRE_H)
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+ if (pcre2_match(if_ptr->regex_ptr, name, strlen(name), 0, 0,
|
||||
+ ndx_match, NULL) >= 0) {
|
||||
+ pcre2_match_data_free(ndx_match);
|
||||
+ return TRUE;
|
||||
+ }
|
||||
+#elif defined(HAVE_PCRE_H)
|
||||
if (pcre_exec(if_ptr->regex_ptr, NULL, name, strlen(name), 0, 0,
|
||||
found_ndx, 3) >= 0)
|
||||
return TRUE;
|
||||
@@ -853,6 +869,9 @@ int netsnmp_access_interface_include(con
|
||||
#endif
|
||||
}
|
||||
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+ pcre2_match_data_free(ndx_match);
|
||||
+#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -964,7 +983,13 @@ _parse_include_if_config(const char *tok
|
||||
{
|
||||
netsnmp_include_if_list *if_ptr, *if_new;
|
||||
char *name, *st;
|
||||
-#if defined(HAVE_PCRE_H)
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+ //we can only get the message upon calling pcre2_error_message.
|
||||
+ // so an additional variable is required.
|
||||
+ int pcre2_err_code;
|
||||
+ unsigned char pcre2_error[128];
|
||||
+ int pcre2_error_offset;
|
||||
+#elif defined(HAVE_PCRE_H)
|
||||
const char *pcre_error;
|
||||
int pcre_error_offset;
|
||||
#elif defined(HAVE_REGEX_H)
|
||||
@@ -996,7 +1021,15 @@ _parse_include_if_config(const char *tok
|
||||
config_perror("Out of memory");
|
||||
goto err;
|
||||
}
|
||||
-#if defined(HAVE_PCRE_H)
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+ if_new->regex_ptr = pcre2_compile(if_new->name, PCRE2_ZERO_TERMINATED, 0,
|
||||
+ &pcre2_err_code, &pcre2_error_offset, NULL);
|
||||
+ if (!if_new->regex_ptr) {
|
||||
+ pcre2_get_error_message(pcre2_err_code, pcre2_error, 128);
|
||||
+ config_perror(pcre2_error);
|
||||
+ goto err;
|
||||
+ }
|
||||
+#elif defined(HAVE_PCRE_H)
|
||||
if_new->regex_ptr = pcre_compile(if_new->name, 0, &pcre_error,
|
||||
&pcre_error_offset, NULL);
|
||||
if (!if_new->regex_ptr) {
|
||||
@@ -1032,7 +1065,7 @@ _parse_include_if_config(const char *tok
|
||||
|
||||
err:
|
||||
if (if_new) {
|
||||
-#if defined(HAVE_PCRE_H) || defined(HAVE_REGEX_H)
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H) || defined(HAVE_REGEX_H)
|
||||
free(if_new->regex_ptr);
|
||||
#endif
|
||||
free(if_new->name);
|
||||
@@ -1047,7 +1080,7 @@ _free_include_if_config(void)
|
||||
|
||||
while (if_ptr) {
|
||||
if_next = if_ptr->next;
|
||||
-#if defined(HAVE_PCRE_H)
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
free(if_ptr->regex_ptr);
|
||||
#elif defined(HAVE_REGEX_H)
|
||||
regfree(if_ptr->regex_ptr);
|
||||
--- a/agent/mibgroup/struct.h
|
||||
+++ b/agent/mibgroup/struct.h
|
||||
@@ -30,7 +30,7 @@ struct extensible {
|
||||
|
||||
struct myproc {
|
||||
char name[STRMAX];
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
netsnmp_regex_ptr regexp;
|
||||
#endif
|
||||
char fixcmd[STRMAX];
|
||||
--- a/agent/mibgroup/ucd-snmp/proc.c
|
||||
+++ b/agent/mibgroup/ucd-snmp/proc.c
|
||||
@@ -39,7 +39,10 @@
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#ifdef HAVE_PCRE2_H
|
||||
+#define PCRE2_CODE_UNIT_WIDTH 8
|
||||
+#include <pcre2.h>
|
||||
+#elifdef HAVE_PCRE_H
|
||||
#include <pcre.h>
|
||||
#endif
|
||||
|
||||
@@ -108,7 +111,7 @@ init_proc(void)
|
||||
REGISTER_MIB("ucd-snmp/proc", extensible_proc_variables, variable2,
|
||||
proc_variables_oid);
|
||||
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
#define proc_parse_usage "process-name [max-num] [min-num] [regexp]"
|
||||
#else
|
||||
#define proc_parse_usage "process-name [max-num] [min-num]"
|
||||
@@ -134,7 +137,7 @@ proc_free_config(void)
|
||||
for (ptmp = procwatch; ptmp != NULL;) {
|
||||
ptmp2 = ptmp;
|
||||
ptmp = ptmp->next;
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
free(ptmp2->regexp.regex_ptr);
|
||||
#endif
|
||||
free(ptmp2);
|
||||
@@ -208,7 +211,7 @@ proc_parse_config(const char *token, cha
|
||||
if (*procp == NULL)
|
||||
return; /* memory alloc error */
|
||||
numprocs++;
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
(*procp)->regexp.regex_ptr = NULL;
|
||||
#endif
|
||||
/*
|
||||
@@ -220,18 +223,31 @@ proc_parse_config(const char *token, cha
|
||||
cptr = skip_not_white(cptr);
|
||||
if ((cptr = skip_white(cptr))) {
|
||||
(*procp)->min = atoi(cptr);
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
cptr = skip_not_white(cptr);
|
||||
if ((cptr = skip_white(cptr))) {
|
||||
+ DEBUGMSGTL(("ucd-snmp/regexp_proc", "Loading regex %s\n", cptr));
|
||||
+#ifdef HAVE_PCRE2_H
|
||||
+ unsigned char pcre2_error_msg[128];
|
||||
+ int pcre2_err_code;
|
||||
+ int pcre2_error_offset;
|
||||
+
|
||||
+ (*procp)->regexp.regex_ptr =
|
||||
+ pcre2_compile(cptr, PCRE2_ZERO_TERMINATED, 0, &pcre2_err_code, &pcre2_error_offset, NULL);
|
||||
+ pcre2_get_error_message(pcre2_err_code, pcre2_error_msg, 128);
|
||||
+ if ((*procp)->regexp.regex_ptr == NULL) {
|
||||
+ config_perror(pcre2_error_msg);
|
||||
+ }
|
||||
+#elifdef HAVE_PCRE_H
|
||||
const char *pcre_error;
|
||||
int pcre_error_offset;
|
||||
|
||||
- DEBUGMSGTL(("ucd-snmp/regexp_proc", "Loading regex %s\n", cptr));
|
||||
(*procp)->regexp.regex_ptr =
|
||||
pcre_compile(cptr, 0, &pcre_error, &pcre_error_offset, NULL);
|
||||
if ((*procp)->regexp.regex_ptr == NULL) {
|
||||
config_perror(pcre_error);
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
@@ -390,7 +406,7 @@ sh_count_myprocs(struct myproc *proc)
|
||||
if (proc == NULL)
|
||||
return 0;
|
||||
|
||||
-#if defined(USING_HOST_DATA_ACCESS_SWRUN_MODULE) && defined(HAVE_PCRE_H)
|
||||
+#if defined(USING_HOST_DATA_ACCESS_SWRUN_MODULE) && (defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H))
|
||||
if (proc->regexp.regex_ptr != NULL)
|
||||
return sh_count_procs_by_regex(proc->name, proc->regexp);
|
||||
#endif
|
||||
@@ -406,7 +422,7 @@ sh_count_procs(char *procname)
|
||||
return swrun_count_processes_by_name( procname );
|
||||
}
|
||||
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
netsnmp_feature_require(swrun_count_processes_by_regex);
|
||||
int
|
||||
sh_count_procs_by_regex(char *procname, netsnmp_regex_ptr regexp)
|
||||
--- a/agent/mibgroup/ucd-snmp/proc.h
|
||||
+++ b/agent/mibgroup/ucd-snmp/proc.h
|
||||
@@ -12,7 +12,7 @@ config_require(util_funcs);
|
||||
extern WriteMethod fixProcError;
|
||||
int sh_count_myprocs(struct myproc *);
|
||||
int sh_count_procs(char *);
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
int sh_count_procs_by_regex(char *, netsnmp_regex_ptr);
|
||||
#endif
|
||||
|
||||
--- a/configure.d/config_os_libs1
|
||||
+++ b/configure.d/config_os_libs1
|
||||
@@ -97,6 +97,32 @@ LIBS="$netsnmp_save_LIBS"
|
||||
#
|
||||
# regex in process table
|
||||
#
|
||||
+if test "x$with_pcre2" != "xno"; then
|
||||
+ AC_CHECK_HEADER([pcre2.h], [
|
||||
+ AC_DEFINE([HAVE_PCRE2_H], [1], [Define to 1 if you have <pcre2.h>.])
|
||||
+ pcre2_h=yes
|
||||
+ ],
|
||||
+ [pcre2_h=no], [#define PCRE2_CODE_UNIT_WIDTH 8]
|
||||
+ )
|
||||
+fi
|
||||
+if test "x$pcre2header_h" = "xno" -o "x$pcre2_h" = "xno" ; then
|
||||
+ if test "x$with_pcre2" = "xyes" ; then
|
||||
+ AC_MSG_ERROR([Could not find the pcre2 header file needed and was specifically asked to use pcre2 support])
|
||||
+ else
|
||||
+ with_pcre2=no
|
||||
+ fi
|
||||
+fi
|
||||
+
|
||||
+if test "x$with_pcre2" != "xno"; then
|
||||
+ NETSNMP_SEARCH_LIBS([pcre2_match_8], [pcre2-8], [
|
||||
+ LMIBLIBS="$LMIBLIBS -lpcre2-8"
|
||||
+ ],,, LAGENTLIBS)
|
||||
+ AC_SUBST(LAGENTLIBS)
|
||||
+ AC_SUBST(LMIBLIBS)
|
||||
+fi
|
||||
+
|
||||
+if test "x$with_pcre2" != "xyes"; then
|
||||
+
|
||||
if test "x$with_pcre" != "xno"; then
|
||||
AC_CHECK_HEADER([pcre.h], [
|
||||
AC_DEFINE([HAVE_PCRE_H], [1], [Define to 1 if you have <pcre.h>.])
|
||||
@@ -123,3 +149,4 @@ if test "x$with_pcre" != "xno"; then
|
||||
AC_SUBST(LAGENTLIBS)
|
||||
AC_SUBST(LMIBLIBS)
|
||||
fi
|
||||
+fi
|
||||
--- a/configure.d/config_project_with_enable
|
||||
+++ b/configure.d/config_project_with_enable
|
||||
@@ -160,6 +160,10 @@ NETSNMP_ARG_WITH(rpm,
|
||||
management system when building the host MIB
|
||||
module.])
|
||||
|
||||
+NETSNMP_ARG_WITH(pcre2-8,
|
||||
+[ --without-pcre2 Don't include pcre2 process searching
|
||||
+ support in the agent.],
|
||||
+ with_pcre2="$withval", with_pcre2="maybe")
|
||||
|
||||
NETSNMP_ARG_WITH(pcre,
|
||||
[ --without-pcre Don't include pcre process searching
|
||||
--- a/include/net-snmp/data_access/interface.h
|
||||
+++ b/include/net-snmp/data_access/interface.h
|
||||
@@ -10,7 +10,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
-#if defined(HAVE_PCRE_H)
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+#define PCRE2_CODE_UNIT_WIDTH 8
|
||||
+#include <pcre2.h>
|
||||
+#elif defined(HAVE_PCRE_H)
|
||||
#include <pcre.h>
|
||||
#elif defined(HAVE_REGEX_H)
|
||||
#include <regex.h>
|
||||
@@ -211,7 +214,9 @@ typedef struct _conf_if_list {
|
||||
typedef netsnmp_conf_if_list conf_if_list; /* backwards compat */
|
||||
|
||||
typedef struct _include_if_list {
|
||||
-#if defined(HAVE_PCRE_H)
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+ pcre2_code *regex_ptr;
|
||||
+#elif defined(HAVE_PCRE_H)
|
||||
pcre *regex_ptr;
|
||||
#elif defined(HAVE_REGEX_H)
|
||||
regex_t *regex_ptr;
|
||||
--- a/include/net-snmp/data_access/swrun.h
|
||||
+++ b/include/net-snmp/data_access/swrun.h
|
||||
@@ -90,7 +90,7 @@ extern "C" {
|
||||
int swrun_count_processes_by_name( char *name );
|
||||
|
||||
#if !defined(NETSNMP_FEATURE_REMOVE_SWRUN_COUNT_PROCESSES_BY_REGEX) \
|
||||
- && defined(HAVE_PCRE_H)
|
||||
+ && (defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H))
|
||||
int swrun_count_processes_by_regex(char *name, netsnmp_regex_ptr regexp);
|
||||
#endif
|
||||
|
||||
--- a/include/net-snmp/types.h
|
||||
+++ b/include/net-snmp/types.h
|
||||
@@ -63,7 +63,7 @@ typedef long ssize_t;
|
||||
typedef unsigned long int nfds_t;
|
||||
#endif
|
||||
|
||||
-#ifdef HAVE_PCRE_H
|
||||
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
/*
|
||||
* Abstract the pcre typedef such that not all *.c files have to include
|
||||
* <pcre.h>.
|
||||
185
net-snmp-ssl/patches/201-Run-autoreconf.patch
Normal file
185
net-snmp-ssl/patches/201-Run-autoreconf.patch
Normal file
@ -0,0 +1,185 @@
|
||||
From 48b313ca34dbdf303fb232191d4f74e1d0fc9f06 Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Sun, 21 May 2023 16:20:15 -0700
|
||||
Subject: [PATCH] Run autoreconf
|
||||
|
||||
---
|
||||
configure | 126 ++++++++++++++++++++++++++
|
||||
include/net-snmp/net-snmp-config.h.in | 3 +
|
||||
2 files changed, 129 insertions(+)
|
||||
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -928,6 +928,8 @@ with_dnssec
|
||||
enable_dnssec
|
||||
with_rpm
|
||||
enable_rpm
|
||||
+with_pcre2_8
|
||||
+enable_pcre2_8
|
||||
with_pcre
|
||||
enable_pcre
|
||||
with_install_prefix
|
||||
@@ -1851,6 +1853,8 @@ Compiler Options:
|
||||
--without-rpm Don't include support for the RPM package
|
||||
management system when building the host MIB
|
||||
module.
|
||||
+ --without-pcre2 Don't include pcre2 process searching
|
||||
+ support in the agent.
|
||||
--without-pcre Don't include pcre process searching
|
||||
support in the agent.
|
||||
--with-install-prefix=PATH Just for installing, prefix all
|
||||
@@ -5259,6 +5263,21 @@ fi
|
||||
|
||||
|
||||
|
||||
+# Check whether --with-pcre2-8 was given.
|
||||
+if test ${with_pcre2_8+y}
|
||||
+then :
|
||||
+ withval=$with_pcre2_8; with_pcre2="$withval"
|
||||
+else $as_nop
|
||||
+ with_pcre2="maybe"
|
||||
+fi
|
||||
+
|
||||
+ # Check whether --enable-pcre2-8 was given.
|
||||
+if test ${enable_pcre2_8+y}
|
||||
+then :
|
||||
+ enableval=$enable_pcre2_8; as_fn_error $? "Invalid option. Use --with-pcre2-8/--without-pcre2-8 instead" "$LINENO" 5
|
||||
+fi
|
||||
+
|
||||
+
|
||||
|
||||
# Check whether --with-pcre was given.
|
||||
if test ${with_pcre+y}
|
||||
@@ -26477,6 +26496,112 @@ LIBS="$netsnmp_save_LIBS"
|
||||
#
|
||||
# regex in process table
|
||||
#
|
||||
+if test "x$with_pcre2" != "xno"; then
|
||||
+ ac_fn_c_check_header_compile "$LINENO" "pcre2.h" "ac_cv_header_pcre2_h" "#define PCRE2_CODE_UNIT_WIDTH 8
|
||||
+
|
||||
+"
|
||||
+if test "x$ac_cv_header_pcre2_h" = xyes
|
||||
+then :
|
||||
+
|
||||
+
|
||||
+printf "%s\n" "#define HAVE_PCRE2_H 1" >>confdefs.h
|
||||
+
|
||||
+ pcre2_h=yes
|
||||
+
|
||||
+else $as_nop
|
||||
+ pcre2_h=no
|
||||
+fi
|
||||
+
|
||||
+fi
|
||||
+if test "x$pcre2header_h" = "xno" -o "x$pcre2_h" = "xno" ; then
|
||||
+ if test "x$with_pcre2" = "xyes" ; then
|
||||
+ as_fn_error $? "Could not find the pcre2 header file needed and was specifically asked to use pcre2 support" "$LINENO" 5
|
||||
+ else
|
||||
+ with_pcre2=no
|
||||
+ fi
|
||||
+fi
|
||||
+
|
||||
+if test "x$with_pcre2" != "xno"; then
|
||||
+
|
||||
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing pcre2_match_8" >&5
|
||||
+printf %s "checking for library containing pcre2_match_8... " >&6; }
|
||||
+if test ${netsnmp_cv_func_pcre2_match_8_LAGENTLIBS+y}
|
||||
+then :
|
||||
+ printf %s "(cached) " >&6
|
||||
+else $as_nop
|
||||
+ netsnmp_func_search_save_LIBS="$LIBS"
|
||||
+ netsnmp_target_val="$LAGENTLIBS"
|
||||
+ netsnmp_temp_LIBS="${netsnmp_target_val} ${LIBS}"
|
||||
+ netsnmp_result=no
|
||||
+ LIBS="${netsnmp_temp_LIBS}"
|
||||
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
+/* end confdefs.h. */
|
||||
+
|
||||
+/* Override any GCC internal prototype to avoid an error.
|
||||
+ Use char because int might match the return type of a GCC
|
||||
+ builtin and then its argument prototype would still apply. */
|
||||
+char pcre2_match_8 ();
|
||||
+int
|
||||
+main (void)
|
||||
+{
|
||||
+return pcre2_match_8 ();
|
||||
+ ;
|
||||
+ return 0;
|
||||
+}
|
||||
+_ACEOF
|
||||
+if ac_fn_c_try_link "$LINENO"
|
||||
+then :
|
||||
+ netsnmp_result="none required"
|
||||
+else $as_nop
|
||||
+ for netsnmp_cur_lib in pcre2-8 ; do
|
||||
+ LIBS="-l${netsnmp_cur_lib} ${netsnmp_temp_LIBS}"
|
||||
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
+/* end confdefs.h. */
|
||||
+
|
||||
+/* Override any GCC internal prototype to avoid an error.
|
||||
+ Use char because int might match the return type of a GCC
|
||||
+ builtin and then its argument prototype would still apply. */
|
||||
+char pcre2_match_8 ();
|
||||
+int
|
||||
+main (void)
|
||||
+{
|
||||
+return pcre2_match_8 ();
|
||||
+ ;
|
||||
+ return 0;
|
||||
+}
|
||||
+_ACEOF
|
||||
+if ac_fn_c_try_link "$LINENO"
|
||||
+then :
|
||||
+ netsnmp_result=-l${netsnmp_cur_lib}
|
||||
+ break
|
||||
+fi
|
||||
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
|
||||
+ conftest$ac_exeext conftest.$ac_ext
|
||||
+ done
|
||||
+fi
|
||||
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
|
||||
+ conftest$ac_exeext conftest.$ac_ext
|
||||
+ LIBS="${netsnmp_func_search_save_LIBS}"
|
||||
+ netsnmp_cv_func_pcre2_match_8_LAGENTLIBS="${netsnmp_result}"
|
||||
+fi
|
||||
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $netsnmp_cv_func_pcre2_match_8_LAGENTLIBS" >&5
|
||||
+printf "%s\n" "$netsnmp_cv_func_pcre2_match_8_LAGENTLIBS" >&6; }
|
||||
+ if test "${netsnmp_cv_func_pcre2_match_8_LAGENTLIBS}" != "no" ; then
|
||||
+ if test "${netsnmp_cv_func_pcre2_match_8_LAGENTLIBS}" != "none required" ; then
|
||||
+ LAGENTLIBS="${netsnmp_result} ${netsnmp_target_val}"
|
||||
+ fi
|
||||
+
|
||||
+ LMIBLIBS="$LMIBLIBS -lpcre2-8"
|
||||
+
|
||||
+
|
||||
+ fi
|
||||
+
|
||||
+
|
||||
+
|
||||
+fi
|
||||
+
|
||||
+if test "x$with_pcre2" != "xyes"; then
|
||||
+
|
||||
if test "x$with_pcre" != "xno"; then
|
||||
ac_fn_c_check_header_compile "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_pcre_h" = xyes
|
||||
@@ -31486,6 +31611,7 @@ printf "%s\n" "#define pid_t $ac_pid_typ
|
||||
|
||||
|
||||
fi
|
||||
+fi
|
||||
|
||||
|
||||
|
||||
--- a/include/net-snmp/net-snmp-config.h.in
|
||||
+++ b/include/net-snmp/net-snmp-config.h.in
|
||||
@@ -727,6 +727,9 @@
|
||||
/* Define to 1 if you have the <pci/pci.h> header file. */
|
||||
#undef HAVE_PCI_PCI_H
|
||||
|
||||
+/* Define to 1 if you have <pcre2.h>. */
|
||||
+#undef HAVE_PCRE2_H
|
||||
+
|
||||
/* Define to 1 if you have <pcre.h>. */
|
||||
#undef HAVE_PCRE_H
|
||||
|
||||
152
net-snmp-ssl/patches/202-Improve-pcre2-support.patch
Normal file
152
net-snmp-ssl/patches/202-Improve-pcre2-support.patch
Normal file
@ -0,0 +1,152 @@
|
||||
From 346b6f8959513320e5b674fd670c49ba2cd43af5 Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Sun, 21 May 2023 16:18:56 -0700
|
||||
Subject: [PATCH] Improve pcre2 support
|
||||
|
||||
Fix compiler warnings. Convert C++ comments to C comments. Make sure that
|
||||
declarations occur before statements.
|
||||
---
|
||||
agent/mibgroup/host/data_access/swrun.c | 17 ++++------
|
||||
agent/mibgroup/if-mib/data_access/interface.c | 32 ++++++++++---------
|
||||
agent/mibgroup/ucd-snmp/proc.c | 13 +++++---
|
||||
3 files changed, 31 insertions(+), 31 deletions(-)
|
||||
|
||||
--- a/agent/mibgroup/host/data_access/swrun.c
|
||||
+++ b/agent/mibgroup/host/data_access/swrun.c
|
||||
@@ -111,10 +111,7 @@ swrun_count_processes_by_regex( char *na
|
||||
netsnmp_iterator *it;
|
||||
int i = 0;
|
||||
#ifdef HAVE_PCRE2_H
|
||||
- pcre2_match_data *ndx_match;
|
||||
- int *found_ndx;
|
||||
- ndx_match = pcre2_match_data_create(30, NULL);
|
||||
- found_ndx = pcre2_get_ovector_pointer(ndx_match);
|
||||
+ pcre2_match_data *ndx_match = pcre2_match_data_create(30, NULL);
|
||||
#elif defined(HAVE_PCRE_H)
|
||||
int found_ndx[30];
|
||||
#endif
|
||||
@@ -122,22 +119,20 @@ swrun_count_processes_by_regex( char *na
|
||||
char fullCommand[64 + 128 + 128 + 3];
|
||||
|
||||
netsnmp_cache_check_and_reload(swrun_cache);
|
||||
- if ( !swrun_container || !name || !regexp.regex_ptr )
|
||||
+ if ( !swrun_container || !name || !regexp.regex_ptr ) {
|
||||
#ifdef HAVE_PCRE2_H
|
||||
- {
|
||||
pcre2_match_data_free(ndx_match);
|
||||
- return 0;
|
||||
- }
|
||||
-#else
|
||||
- return 0; /* or -1 */
|
||||
#endif
|
||||
+ return 0; /* or -1 */
|
||||
+ }
|
||||
|
||||
it = CONTAINER_ITERATOR( swrun_container );
|
||||
while ((entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) != NULL) {
|
||||
/* need to assemble full command back so regexps can get full picture */
|
||||
sprintf(fullCommand, "%s %s", entry->hrSWRunPath, entry->hrSWRunParameters);
|
||||
#ifdef HAVE_PCRE2_H
|
||||
- found = pcre2_match(regexp.regex_ptr, fullCommand, strlen(fullCommand), 0, 0, ndx_match, NULL);
|
||||
+ found = pcre2_match(regexp.regex_ptr, (unsigned char *)fullCommand,
|
||||
+ strlen(fullCommand), 0, 0, ndx_match, NULL);
|
||||
#elif HAVE_PCRE_H
|
||||
found = pcre_exec(regexp.regex_ptr, NULL, fullCommand, strlen(fullCommand), 0, 0, found_ndx, 30);
|
||||
#endif
|
||||
--- a/agent/mibgroup/if-mib/data_access/interface.c
|
||||
+++ b/agent/mibgroup/if-mib/data_access/interface.c
|
||||
@@ -828,12 +828,8 @@ int netsnmp_access_interface_max_reached
|
||||
int netsnmp_access_interface_include(const char *name)
|
||||
{
|
||||
netsnmp_include_if_list *if_ptr;
|
||||
-#if defined(HAVE_PCRE2_H)
|
||||
- //pcre_exec->pcre2_match
|
||||
- //ovector->pcre2_match_data
|
||||
- pcre2_match_data *ndx_match;
|
||||
- ndx_match = pcre2_match_data_create(3, NULL);
|
||||
- int *found_ndx = pcre2_get_ovector_pointer(ndx_match);
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+ pcre2_match_data *ndx_match = pcre2_match_data_create(3, NULL);
|
||||
#elif defined(HAVE_PCRE_H)
|
||||
int found_ndx[3];
|
||||
#endif
|
||||
@@ -851,8 +847,8 @@ int netsnmp_access_interface_include(con
|
||||
|
||||
for (if_ptr = include_list; if_ptr; if_ptr = if_ptr->next) {
|
||||
#if defined(HAVE_PCRE2_H)
|
||||
- if (pcre2_match(if_ptr->regex_ptr, name, strlen(name), 0, 0,
|
||||
- ndx_match, NULL) >= 0) {
|
||||
+ if (pcre2_match(if_ptr->regex_ptr, (const unsigned char *)name,
|
||||
+ strlen(name), 0, 0, ndx_match, NULL) >= 0) {
|
||||
pcre2_match_data_free(ndx_match);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -984,11 +980,13 @@ _parse_include_if_config(const char *tok
|
||||
netsnmp_include_if_list *if_ptr, *if_new;
|
||||
char *name, *st;
|
||||
#if defined(HAVE_PCRE2_H)
|
||||
- //we can only get the message upon calling pcre2_error_message.
|
||||
- // so an additional variable is required.
|
||||
+ /*
|
||||
+ * We can only get the message upon calling pcre2_error_message.
|
||||
+ * so an additional variable is required.
|
||||
+ */
|
||||
int pcre2_err_code;
|
||||
- unsigned char pcre2_error[128];
|
||||
- int pcre2_error_offset;
|
||||
+ char pcre2_error[128];
|
||||
+ size_t pcre2_error_offset;
|
||||
#elif defined(HAVE_PCRE_H)
|
||||
const char *pcre_error;
|
||||
int pcre_error_offset;
|
||||
@@ -1022,10 +1020,14 @@ _parse_include_if_config(const char *tok
|
||||
goto err;
|
||||
}
|
||||
#if defined(HAVE_PCRE2_H)
|
||||
- if_new->regex_ptr = pcre2_compile(if_new->name, PCRE2_ZERO_TERMINATED, 0,
|
||||
- &pcre2_err_code, &pcre2_error_offset, NULL);
|
||||
+ if_new->regex_ptr = pcre2_compile((const unsigned char *)if_new->name,
|
||||
+ PCRE2_ZERO_TERMINATED, 0,
|
||||
+ &pcre2_err_code, &pcre2_error_offset,
|
||||
+ NULL);
|
||||
if (!if_new->regex_ptr) {
|
||||
- pcre2_get_error_message(pcre2_err_code, pcre2_error, 128);
|
||||
+ pcre2_get_error_message(pcre2_err_code,
|
||||
+ (unsigned char *)pcre2_error,
|
||||
+ sizeof(pcre2_error));
|
||||
config_perror(pcre2_error);
|
||||
goto err;
|
||||
}
|
||||
--- a/agent/mibgroup/ucd-snmp/proc.c
|
||||
+++ b/agent/mibgroup/ucd-snmp/proc.c
|
||||
@@ -226,15 +226,17 @@ proc_parse_config(const char *token, cha
|
||||
#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
|
||||
cptr = skip_not_white(cptr);
|
||||
if ((cptr = skip_white(cptr))) {
|
||||
- DEBUGMSGTL(("ucd-snmp/regexp_proc", "Loading regex %s\n", cptr));
|
||||
#ifdef HAVE_PCRE2_H
|
||||
- unsigned char pcre2_error_msg[128];
|
||||
+ char pcre2_error_msg[128];
|
||||
int pcre2_err_code;
|
||||
- int pcre2_error_offset;
|
||||
+ size_t pcre2_error_offset;
|
||||
|
||||
+ DEBUGMSGTL(("ucd-snmp/regexp_proc", "Loading regex %s\n", cptr));
|
||||
(*procp)->regexp.regex_ptr =
|
||||
- pcre2_compile(cptr, PCRE2_ZERO_TERMINATED, 0, &pcre2_err_code, &pcre2_error_offset, NULL);
|
||||
- pcre2_get_error_message(pcre2_err_code, pcre2_error_msg, 128);
|
||||
+ pcre2_compile((const unsigned char *)cptr, PCRE2_ZERO_TERMINATED, 0, &pcre2_err_code, &pcre2_error_offset, NULL);
|
||||
+ pcre2_get_error_message(pcre2_err_code,
|
||||
+ (unsigned char *)pcre2_error_msg,
|
||||
+ sizeof(pcre2_error_msg));
|
||||
if ((*procp)->regexp.regex_ptr == NULL) {
|
||||
config_perror(pcre2_error_msg);
|
||||
}
|
||||
@@ -242,6 +244,7 @@ proc_parse_config(const char *token, cha
|
||||
const char *pcre_error;
|
||||
int pcre_error_offset;
|
||||
|
||||
+ DEBUGMSGTL(("ucd-snmp/regexp_proc", "Loading regex %s\n", cptr));
|
||||
(*procp)->regexp.regex_ptr =
|
||||
pcre_compile(cptr, 0, &pcre_error, &pcre_error_offset, NULL);
|
||||
if ((*procp)->regexp.regex_ptr == NULL) {
|
||||
@ -0,0 +1,30 @@
|
||||
From e5aadf1e78c624a8e4147d4b70a7795497a50e73 Mon Sep 17 00:00:00 2001
|
||||
From: Niels Baggesen <nba@users.sourceforge.net>
|
||||
Date: Mon, 22 May 2023 18:44:36 +0200
|
||||
Subject: [PATCH] if-mib/data_access/interface.c: plug a leak with pcre2
|
||||
|
||||
---
|
||||
agent/mibgroup/if-mib/data_access/interface.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/agent/mibgroup/if-mib/data_access/interface.c
|
||||
+++ b/agent/mibgroup/if-mib/data_access/interface.c
|
||||
@@ -829,7 +829,7 @@ int netsnmp_access_interface_include(con
|
||||
{
|
||||
netsnmp_include_if_list *if_ptr;
|
||||
#if defined(HAVE_PCRE2_H)
|
||||
- pcre2_match_data *ndx_match = pcre2_match_data_create(3, NULL);
|
||||
+ pcre2_match_data *ndx_match;
|
||||
#elif defined(HAVE_PCRE_H)
|
||||
int found_ndx[3];
|
||||
#endif
|
||||
@@ -844,6 +844,9 @@ int netsnmp_access_interface_include(con
|
||||
*/
|
||||
return TRUE;
|
||||
|
||||
+#if defined(HAVE_PCRE2_H)
|
||||
+ ndx_match = pcre2_match_data_create(3, NULL);
|
||||
+#endif
|
||||
|
||||
for (if_ptr = include_list; if_ptr; if_ptr = if_ptr->next) {
|
||||
#if defined(HAVE_PCRE2_H)
|
||||
6166
net-snmp-ssl/patches/750-ieee802dot11.patch
Normal file
6166
net-snmp-ssl/patches/750-ieee802dot11.patch
Normal file
File diff suppressed because it is too large
Load Diff
10
net-snmp-ssl/patches/751-gcc-14-fix.patch
Normal file
10
net-snmp-ssl/patches/751-gcc-14-fix.patch
Normal file
@ -0,0 +1,10 @@
|
||||
--- a/agent/mib_modules.c
|
||||
+++ b/agent/mib_modules.c
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <net-snmp/agent/table.h>
|
||||
#include <net-snmp/agent/table_iterator.h>
|
||||
#include "mib_module_includes.h"
|
||||
+#include "mibgroup/ieee802dot11.h"
|
||||
|
||||
static int need_shutdown = 0;
|
||||
|
||||
13
net-snmp-ssl/patches/900-musl-compat.patch
Normal file
13
net-snmp-ssl/patches/900-musl-compat.patch
Normal file
@ -0,0 +1,13 @@
|
||||
--- a/agent/mibgroup/iwlib.h
|
||||
+++ b/agent/mibgroup/iwlib.h
|
||||
@@ -92,6 +92,10 @@
|
||||
#elif !defined(__GLIBC__) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
|
||||
#define GENERIC_HEADERS
|
||||
|
||||
+/* Musl */
|
||||
+#elif !defined(__GLIBC__) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
|
||||
+#define GENERIC_HEADERS
|
||||
+
|
||||
/* Unsupported combination */
|
||||
#else
|
||||
#error "Your kernel/libc combination is not supported"
|
||||
130
net-snmp-ssl/patches/990-remove-semicolon-check-in-macros.patch
Normal file
130
net-snmp-ssl/patches/990-remove-semicolon-check-in-macros.patch
Normal file
@ -0,0 +1,130 @@
|
||||
--- a/configure.d/config_modules_agent
|
||||
+++ b/configure.d/config_modules_agent
|
||||
@@ -27,8 +27,6 @@ done
|
||||
#
|
||||
AC_MSG_CHECKING([for and configuring mib modules to use])
|
||||
|
||||
-AH_TOP([#define NETSNMP_REQUIRE_SEMICOLON extern void netsnmp_unused_function(void)])
|
||||
-
|
||||
# set up the CPP command
|
||||
MODULECPP="$CPP $PARTIALTARGETFLAGS $CPPFLAGS -DNETSNMP_FEATURE_CHECKING -I${srcdir}/include -I${srcdir}/agent/mibgroup"
|
||||
if test "x$enable_mfd_rewrites" = "xyes"; then
|
||||
@@ -194,7 +192,7 @@ while test "x$new_module_list" != "x"; d
|
||||
# - mib_module => libnetsnmpmibs (default)
|
||||
# - agent_module => libnetsnmpagent
|
||||
#
|
||||
- AH_TOP([#define config_belongs_in(x) NETSNMP_REQUIRE_SEMICOLON])
|
||||
+ AH_TOP([#define config_belongs_in(x)])
|
||||
module_type=mib_module
|
||||
if test -f $srcdir/$mibdir/$i.h; then
|
||||
changequote(, )
|
||||
@@ -279,7 +277,7 @@ while test "x$new_module_list" != "x"; d
|
||||
#
|
||||
# check if $i has any conflicts
|
||||
#
|
||||
- AH_TOP([#define config_exclude(x) NETSNMP_REQUIRE_SEMICOLON])
|
||||
+ AH_TOP([#define config_exclude(x)])
|
||||
new_list_excl=`$MODULECPP module_tmp_header.h | \
|
||||
$SED -n 's/.*config_exclude(\(.*\)).*/\1/p'`
|
||||
if test "x$new_list_excl" != "x"; then
|
||||
@@ -308,7 +306,7 @@ while test "x$new_module_list" != "x"; d
|
||||
#
|
||||
# check if $i has any architecture specific requirements
|
||||
#
|
||||
- AH_TOP([#define config_arch_require(x,y) NETSNMP_REQUIRE_SEMICOLON])
|
||||
+ AH_TOP([#define config_arch_require(x,y)])
|
||||
changequote(, )
|
||||
new_list_arch=`$MODULECPP module_tmp_header.h | \
|
||||
$SED -n 's/.*config_arch_require( *\([^ ]*\) *, *\([^ ]*\) *).*/\1-xarchx-\2/p'`
|
||||
@@ -330,7 +328,7 @@ while test "x$new_module_list" != "x"; d
|
||||
# macro: config_version_require((base, version, version-modules, ...))
|
||||
# - lists alternative modules used from different versions.
|
||||
#
|
||||
- AH_TOP([#define config_version_require(x) NETSNMP_REQUIRE_SEMICOLON])
|
||||
+ AH_TOP([#define config_version_require(x)])
|
||||
[new_list_alt3=`$MODULECPP module_tmp_header.h | \
|
||||
$AWK '
|
||||
BEGIN {
|
||||
@@ -372,7 +370,7 @@ while test "x$new_module_list" != "x"; d
|
||||
#
|
||||
# check if $i has any other required modules
|
||||
#
|
||||
- AH_TOP([#define config_require(x) NETSNMP_REQUIRE_SEMICOLON])
|
||||
+ AH_TOP([#define config_require(x)])
|
||||
new_list="$new_list `$MODULECPP module_tmp_header.h | \
|
||||
$SED -n 's/.*config_require(\(.*\)).*/\1/p'`"
|
||||
AC_MSG_MODULE_DBG(" $i will test: $new_list")
|
||||
@@ -409,7 +407,7 @@ while test "x$new_module_list" != "x"; d
|
||||
#
|
||||
# check if $i has any mibs to add
|
||||
#
|
||||
- AH_TOP([#define config_add_mib(x) NETSNMP_REQUIRE_SEMICOLON])
|
||||
+ AH_TOP([#define config_add_mib(x)])
|
||||
new_mibs=`$MODULECPP module_tmp_header.h | \
|
||||
$SED -n 's/.*config_add_mib(\(.*\)).*/\1/p'`
|
||||
if test "x$new_mibs" != "x"; then
|
||||
@@ -456,7 +454,7 @@ while test "x$new_module_list" != "x"; d
|
||||
# check for config_parse_dot_conf
|
||||
# (generally not used any longer; old auto-load a .conf token)
|
||||
#
|
||||
- AH_TOP([#define config_parse_dot_conf(w,x,y,z) NETSNMP_REQUIRE_SEMICOLON])
|
||||
+ AH_TOP([#define config_parse_dot_conf(w,x,y,z)])
|
||||
changequote(, )
|
||||
$MODULECPP module_tmp_header.h | \
|
||||
$SED -n 's@.*config_parse_dot_conf(\([^)]*\), *\([^),]*\), *\([^),]*\), *\([^),]*\)).*@register_config_handler("snmpd",\1, \2, \3, \4);@p' >> $mibdir/mib_module_dot_conf.h
|
||||
@@ -468,7 +466,7 @@ while test "x$new_module_list" != "x"; d
|
||||
#
|
||||
# check if $i has any errors, or warnings
|
||||
#
|
||||
- AH_TOP([#define config_error(x) NETSNMP_REQUIRE_SEMICOLON])
|
||||
+ AH_TOP([#define config_error(x)])
|
||||
error=`$MODULECPP module_tmp_header.h | \
|
||||
$SED -n 's/.*config_error(\(.*\)).*/\1/p'`
|
||||
if test "x$error" != "x"; then
|
||||
@@ -481,7 +479,7 @@ while test "x$new_module_list" != "x"; d
|
||||
# macro: config_warning(warning text)
|
||||
# - used to signal a configuration "warning" to be printed to the user
|
||||
#
|
||||
- AH_TOP([#define config_warning(x) NETSNMP_REQUIRE_SEMICOLON])
|
||||
+ AH_TOP([#define config_warning(x)])
|
||||
warning=`$MODULECPP module_tmp_header.h | \
|
||||
$SED -n 's/.*config_warning(\(.*\)).*/\1/p'`
|
||||
if test "x$warning" != "x"; then
|
||||
--- a/include/net-snmp/net-snmp-config.h.in
|
||||
+++ b/include/net-snmp/net-snmp-config.h.in
|
||||
@@ -36,25 +36,25 @@
|
||||
|
||||
/* definitions added by configure on-the-fly */
|
||||
|
||||
-#define config_parse_dot_conf(w,x,y,z) NETSNMP_REQUIRE_SEMICOLON
|
||||
+#define config_parse_dot_conf(w,x,y,z)
|
||||
|
||||
-#define config_error(x) NETSNMP_REQUIRE_SEMICOLON
|
||||
+#define config_error(x)
|
||||
|
||||
-#define config_warning(x) NETSNMP_REQUIRE_SEMICOLON
|
||||
+#define config_warning(x)
|
||||
|
||||
-#define NETSNMP_REQUIRE_SEMICOLON extern void netsnmp_unused_function(void)
|
||||
+#define extern void netsnmp_unused_function(void)
|
||||
|
||||
-#define config_belongs_in(x) NETSNMP_REQUIRE_SEMICOLON
|
||||
+#define config_belongs_in(x)
|
||||
|
||||
-#define config_exclude(x) NETSNMP_REQUIRE_SEMICOLON
|
||||
+#define config_exclude(x)
|
||||
|
||||
-#define config_arch_require(x,y) NETSNMP_REQUIRE_SEMICOLON
|
||||
+#define config_arch_require(x,y)
|
||||
|
||||
-#define config_version_require(x) NETSNMP_REQUIRE_SEMICOLON
|
||||
+#define config_version_require(x)
|
||||
|
||||
-#define config_require(x) NETSNMP_REQUIRE_SEMICOLON
|
||||
+#define config_require(x)
|
||||
|
||||
-#define config_add_mib(x) NETSNMP_REQUIRE_SEMICOLON
|
||||
+#define config_add_mib(x)
|
||||
|
||||
/* Define to 1 if using 'alloca.c'. */
|
||||
#undef C_ALLOCA
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user