|
@@ -96,7 +96,9 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
private StringBuffer mStringBuffer = new StringBuffer();
|
|
|
private Context mContext;
|
|
|
private Button btnReadVersion;
|
|
|
- private TextView mShow;
|
|
|
+ private TextView tvS8xxxxShow;
|
|
|
+ private TextView tvGtxxxxShow;
|
|
|
+ private TextView tvCfgVersionShow;
|
|
|
private TextView tvUpDataResult;
|
|
|
private int iProductId;
|
|
|
private byte byProductType = 0;
|
|
@@ -154,8 +156,11 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
private Button btn_update;
|
|
|
private Button btn_AutoUpdate;
|
|
|
|
|
|
- private Button search_button;
|
|
|
- private TextView edit_search;
|
|
|
+ private Button btn_search_bin_button;
|
|
|
+ private TextView tv_edit_search_bin;
|
|
|
+
|
|
|
+ private Button btn_search_cfg_button;
|
|
|
+ private TextView tv_edit_search_cfg;
|
|
|
|
|
|
private Context mAlertContext;
|
|
|
|
|
@@ -167,6 +172,8 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
public String Update_log2;
|
|
|
String updateLogShow= "";
|
|
|
|
|
|
+ String StrConfigDateString = "";
|
|
|
+
|
|
|
Handler mHandler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
@@ -202,13 +209,13 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
//String d_value =Arrays.toString(mBytes[);
|
|
|
//String d_value =Arrays.hv.toString();
|
|
|
//mShow.setText( stringBuilder.toString() );//输出显示
|
|
|
- //edit_search.setText(uri.getPath().toString());
|
|
|
+ //tv_edit_search_bin.setText(uri.getPath().toString());
|
|
|
// mLog.setText(mStringBuffer.toString());
|
|
|
|
|
|
break;
|
|
|
|
|
|
case SEND_MESSAGE_SUCCESS://成功发送数据
|
|
|
- mShow.setText("");
|
|
|
+ tvS8xxxxShow.setText("");
|
|
|
break;
|
|
|
|
|
|
case DEBUG_MESSAGE_SUCCESS://成功发送数据
|
|
@@ -225,7 +232,7 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
stringBuilder.append(hv);
|
|
|
stringBuilder.append(",");
|
|
|
}
|
|
|
- mShow.setText(stringBuilder.toString());
|
|
|
+ tvS8xxxxShow.setText(stringBuilder.toString());
|
|
|
//mShow.setText(value);
|
|
|
break;
|
|
|
case DEBUG_MESSAGE_ERROR://成功发送数据
|
|
@@ -308,7 +315,9 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
//mLog = (TextView) findViewById(R.id.log);
|
|
|
btnReadVersion = (Button) findViewById(R.id.version);
|
|
|
mError = (EditText) findViewById(R.id.error);
|
|
|
- mShow = (TextView) findViewById(R.id.show);
|
|
|
+ tvS8xxxxShow = (TextView) findViewById(R.id.s8xxxxshow);
|
|
|
+ tvGtxxxxShow = (TextView) findViewById(R.id.gtxxxxshow);
|
|
|
+ tvCfgVersionShow = (TextView) findViewById(R.id.cfgversionshow);
|
|
|
//mSendMessage = (Button) findViewById(R.id.sendmessage);
|
|
|
//mlog1 = (Button) findViewById(R.id.log1);
|
|
|
//mSendCfg = (Button) findViewById(R.id.btn1);
|
|
@@ -316,8 +325,11 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
btn_AutoUpdate = (Button) findViewById(R.id.btnAutoUpdate);
|
|
|
// mShow = (EditText) findViewById(R.id.show);
|
|
|
|
|
|
- search_button = (Button) findViewById(R.id.searchbutton);
|
|
|
- edit_search = (TextView) findViewById(R.id.editsearch);
|
|
|
+ btn_search_bin_button = (Button) findViewById(R.id.searchbinbutton);
|
|
|
+ tv_edit_search_bin = (TextView) findViewById(R.id.editsearchbin);
|
|
|
+
|
|
|
+ btn_search_cfg_button = (Button) findViewById(R.id.searchcfgbutton);
|
|
|
+ tv_edit_search_cfg = (TextView) findViewById(R.id.editsearchcfg);
|
|
|
|
|
|
tvUpDataResult = (TextView) findViewById(R.id.updataresult);
|
|
|
|
|
@@ -327,7 +339,7 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
btn_update.setOnClickListener(this);
|
|
|
btn_AutoUpdate.setOnClickListener(this);
|
|
|
|
|
|
- search_button.setOnClickListener(new View.OnClickListener() {
|
|
|
+ btn_search_bin_button.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
@@ -336,6 +348,18 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
startActivityForResult(intent, 1);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ btn_search_cfg_button.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ //ActivityCompat.requestPermissions( Config.this, new String[]{android
|
|
|
+ // .Manifest.permission.READ_EXTERNAL_STORAGE}, 2);
|
|
|
+ Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
+ intent.setType("*/*");//设置类型,我这里是任意类型,任意后缀的可以这样写。
|
|
|
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
+ startActivityForResult(intent, 2);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
@Override
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
@@ -495,6 +519,7 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
int j = 0;
|
|
|
int sendLoop = 1;
|
|
|
byte addressH,addressL;
|
|
|
+ byte addrfirstbyte, addrsecondbyte, addrthirdbyte;
|
|
|
String hv = "";
|
|
|
String strpidversion = "GT";
|
|
|
switch(view.getId()) {
|
|
@@ -533,6 +558,19 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
*/
|
|
|
{
|
|
|
|
|
|
+ for (int i = 0; i < 23; i++) //Get version
|
|
|
+ {
|
|
|
+ mBytes[i] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ iicRead32Bits((byte)0x01, (byte)0x00, (byte)0x14, (byte)0x03,mBytes, 24);
|
|
|
+
|
|
|
+ strpidversion = new String(mBytes,0,24);
|
|
|
+
|
|
|
+ tvS8xxxxShow.setText(strpidversion);
|
|
|
+
|
|
|
+ strpidversion = "GT";
|
|
|
+
|
|
|
iicRead32Bits((byte)0x01, (byte)0x00, (byte)0x14, (byte)0x0f,mBytes, 23);
|
|
|
|
|
|
for (int i = 10; i < 15; i++) //Get PID
|
|
@@ -547,7 +585,7 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
|
|
|
if (strpidversion.length() < 6)
|
|
|
{
|
|
|
- mShow.setText( "Null" );//输出显示
|
|
|
+ tvGtxxxxShow.setText( "Null" );//输出显示
|
|
|
} else{
|
|
|
|
|
|
strpidversion += "_";
|
|
@@ -568,9 +606,84 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- mShow.setText(strpidversion);//输出显示
|
|
|
+ tvGtxxxxShow.setText(strpidversion);//输出显示
|
|
|
+ }
|
|
|
+
|
|
|
+ //send 0x00 0x00 0x04 0x07 0x0B 0x00 to [0x10174],通知GT29XX,要读cfg
|
|
|
+ mBytes[0] = 0x00;
|
|
|
+ mBytes[1] = 0x00;
|
|
|
+ mBytes[2] = 0x04;
|
|
|
+ mBytes[3] = 0x07;
|
|
|
+ mBytes[4] = 0x0B;
|
|
|
+ mBytes[5] = 0x00;
|
|
|
+ iicWrite32Bits((byte)0x01, (byte)0x01, (byte)0x74, mBytes,0,6);
|
|
|
+
|
|
|
+
|
|
|
+ //read [0x10175] = 0x80,config is ready
|
|
|
+ //do {
|
|
|
+ // SystemClock.sleep(30);
|
|
|
+ // iicRead32Bits((byte)0x01, (byte)0x01, (byte)0x75, mBytes, 1);
|
|
|
+ //}while(mBytes[0] != (byte)0x80);
|
|
|
+
|
|
|
+ //read [0x10174] = 0x80,config is ready
|
|
|
+ do {
|
|
|
+ SystemClock.sleep(30);
|
|
|
+ iicRead32Bits((byte)0x01, (byte)0x01, (byte)0x74, (byte)0x0f, mBytes, 1);
|
|
|
+ }while(mBytes[0] != (byte)0x80);
|
|
|
+
|
|
|
+ //SystemClock.sleep(2);
|
|
|
+
|
|
|
+ if (byProductType == GT29336) {
|
|
|
+ addrfirstbyte = (byte)0x01;
|
|
|
+ addrsecondbyte = (byte)0x3B;
|
|
|
+ addrthirdbyte = (byte)0x74;
|
|
|
+ }else {
|
|
|
+ addrfirstbyte = (byte)0x01;
|
|
|
+ addrsecondbyte = (byte)0x21;
|
|
|
+ addrthirdbyte = (byte)0x8C;
|
|
|
}
|
|
|
|
|
|
+ //read buffer [0x13B74]/[0X1218C]
|
|
|
+ iicRead32Bits(addrfirstbyte, addrsecondbyte, addrthirdbyte, (byte)0x0f, mBytes, 63); //read config head
|
|
|
+
|
|
|
+ int k = mBytes[34] & 0xFF;
|
|
|
+
|
|
|
+ hv = Integer.toHexString(k);
|
|
|
+ if (hv.length() < 2){
|
|
|
+ hv = "0" + hv;
|
|
|
+ }
|
|
|
+
|
|
|
+ strpidversion = "Config Version:0x" + hv;
|
|
|
+
|
|
|
+ SystemClock.sleep(5);
|
|
|
+
|
|
|
+ //send 0x00 0x00 0x04 0x08 0x0C 0x00 to [0x10174],通知GT29XX,通信结束
|
|
|
+ mBytes[0] = 0x00;
|
|
|
+ mBytes[1] = 0x00;
|
|
|
+ mBytes[2] = 0x04;
|
|
|
+ mBytes[3] = 0x08;
|
|
|
+ mBytes[4] = 0x0C;
|
|
|
+ mBytes[5] = 0x00;
|
|
|
+ iicWrite32Bits((byte)0x01, (byte)0x01, (byte)0x74, mBytes, 0, 6);
|
|
|
+
|
|
|
+ //read [0x10175] = 0x80,config is ready
|
|
|
+ //do {
|
|
|
+ // SystemClock.sleep(30);
|
|
|
+ // iicRead32Bits((byte)0x01, (byte)0x01, (byte)0x75, mBytes, 1);
|
|
|
+ //}while(mBytes[0] != (byte)0x80);
|
|
|
+
|
|
|
+ //read [0x10175] = 0x80,read config is over
|
|
|
+ do {
|
|
|
+ SystemClock.sleep(30);
|
|
|
+ iicRead32Bits((byte)0x01, (byte)0x01, (byte)0x74, (byte)0x0f, mBytes, 1);
|
|
|
+ }while(mBytes[0] != (byte)0x80);
|
|
|
+
|
|
|
+ //SystemClock.sleep(2);
|
|
|
+
|
|
|
+ //stMessageLog = "Read config finish!! Config Version:0x" + mConfigShow[34];
|
|
|
+
|
|
|
+ tvCfgVersionShow.setText(strpidversion);
|
|
|
+
|
|
|
/*
|
|
|
addressH = (byte)0x81;
|
|
|
addressL = (byte)0x40;
|
|
@@ -693,39 +806,39 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
|
|
|
protected void onActivityResult ( int requestCode, int resultCode, Intent data){
|
|
|
if (resultCode == Activity.RESULT_OK) {
|
|
|
- if (requestCode == 1) {
|
|
|
|
|
|
- int permission_write = ContextCompat.checkSelfPermission(FirmwareUpdate.this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
|
|
- int permission_read = ContextCompat.checkSelfPermission(FirmwareUpdate.this, Manifest.permission.READ_EXTERNAL_STORAGE);
|
|
|
+ int permission_write = ContextCompat.checkSelfPermission(FirmwareUpdate.this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
|
|
+ int permission_read = ContextCompat.checkSelfPermission(FirmwareUpdate.this, Manifest.permission.READ_EXTERNAL_STORAGE);
|
|
|
|
|
|
- if ((permission_write != PackageManager.PERMISSION_GRANTED)
|
|
|
- ||(permission_read != PackageManager.PERMISSION_GRANTED))
|
|
|
- {
|
|
|
+ if ((permission_write != PackageManager.PERMISSION_GRANTED)
|
|
|
+ ||(permission_read != PackageManager.PERMISSION_GRANTED))
|
|
|
+ {
|
|
|
|
|
|
- ActivityCompat.requestPermissions(FirmwareUpdate.this, new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
|
- android.Manifest.permission.READ_EXTERNAL_STORAGE}, 3);
|
|
|
- }
|
|
|
+ ActivityCompat.requestPermissions(FirmwareUpdate.this, new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
|
+ android.Manifest.permission.READ_EXTERNAL_STORAGE}, 3);
|
|
|
+ }
|
|
|
|
|
|
- StringBuffer buffer = new StringBuffer();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if (requestCode == 1) {
|
|
|
try {
|
|
|
|
|
|
File dir = Environment.getExternalStorageDirectory();
|
|
|
//Uri uri = data.getData();
|
|
|
File dataFile;
|
|
|
if (byProductType == GT9) { //GT9
|
|
|
- edit_search.setText(dir.getPath() + "/GT9110H.bin");
|
|
|
+ tv_edit_search_bin.setText(dir.getPath() + "/GT9110H.bin");
|
|
|
|
|
|
dataFile = new File(dir.getPath(), "GT9110H.bin");
|
|
|
}else if (byProductType == GT7){ //GT7
|
|
|
- edit_search.setText(dir.getPath() + "/GT738x.bin");
|
|
|
+ tv_edit_search_bin.setText(dir.getPath() + "/GT738x.bin");
|
|
|
|
|
|
dataFile = new File(dir.getPath(), "GT738x.bin");
|
|
|
}else if (byProductType == GT29336 || (byProductType == GT2931)) { //GT293x
|
|
|
- edit_search.setText(dir.getPath() + "/GT293x.bin");
|
|
|
+ tv_edit_search_bin.setText(dir.getPath() + "/GT293x.bin");
|
|
|
|
|
|
dataFile = new File(dir.getPath(), "GT293X.bin");
|
|
|
}else{ //other
|
|
|
- edit_search.setText(dir.getPath() + "/GTxxxx.bin");
|
|
|
+ tv_edit_search_bin.setText(dir.getPath() + "/GTxxxx.bin");
|
|
|
|
|
|
dataFile = new File(dir.getPath(), "GTxxxx.bin");
|
|
|
}
|
|
@@ -743,9 +856,63 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
btn_update.setEnabled(true);
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
- edit_search.setText(getResources().getString(R.string.invalidfile));
|
|
|
+ tv_edit_search_bin.setText(getResources().getString(R.string.invalidfile));
|
|
|
}
|
|
|
- }
|
|
|
+ }//end of if (requestCode == 1)
|
|
|
+ else if (requestCode == 2) { //本 地 文 件
|
|
|
+ StrConfigDateString = "";
|
|
|
+ Uri uri = data.getData();
|
|
|
+ String fileString = "";
|
|
|
+ try {
|
|
|
+ File dir = Environment.getExternalStorageDirectory();
|
|
|
+ //Uri uri = data.getData();
|
|
|
+ File dataFile;
|
|
|
+
|
|
|
+ fileString = dir.getPath() + "/";
|
|
|
+
|
|
|
+ if (uri.getLastPathSegment().indexOf(":") > 0){
|
|
|
+ String[] stringFileNameArr = uri.getLastPathSegment().split(":");
|
|
|
+ fileString += stringFileNameArr[1];
|
|
|
+ }else{
|
|
|
+ fileString += uri.getLastPathSegment();
|
|
|
+ }
|
|
|
+
|
|
|
+ //fileString = dir.getPath() + "/" + uri.getLastPathSegment();
|
|
|
+ //tv_edit_search_cfg.setText(dir.getPath() + "/GTxxxx_wingcool_config.cfg");
|
|
|
+
|
|
|
+
|
|
|
+ //fileString = fileString.replaceAll(":", "/"); //将:改为/,以防某些系统文件目录读出是:
|
|
|
+ tv_edit_search_cfg.setText(fileString);
|
|
|
+
|
|
|
+ //File dir = Environment.getExternalStorageDirectory();
|
|
|
+ //dataFile = new File(dir.getPath(), "GTxxxx_wingcool_config.cfg");
|
|
|
+ dataFile = new File(fileString);
|
|
|
+
|
|
|
+ FileInputStream fis = new FileInputStream(dataFile);
|
|
|
+ //byte[] bytes = new byte[fis.available()];
|
|
|
+ //fis.read(bytes);
|
|
|
+ //fis.close();
|
|
|
+ //String str = new String(bytes,"utf-8");
|
|
|
+ //tv_edit_search_cfg.setText(str);
|
|
|
+
|
|
|
+ //FileInputStream fis = new FileInputStream(uri.getPath().toString());
|
|
|
+ InputStreamReader isr = new InputStreamReader(fis, "UTF-8");//文件编码Unicode,UTF-8,ASCII,GB2312,Big5
|
|
|
+ Reader in = new BufferedReader(isr);
|
|
|
+ int ch;
|
|
|
+ while ((ch = in.read()) > -1) {
|
|
|
+ buffer.append((char) ch);
|
|
|
+ }
|
|
|
+ in.close();
|
|
|
+
|
|
|
+ StrConfigDateString = buffer.toString();
|
|
|
+
|
|
|
+ btn_update.setEnabled(true);
|
|
|
+
|
|
|
+ } catch (IOException c) {
|
|
|
+ tv_edit_search_cfg.setText(uri.getPath() + "——" + getResources().getString(R.string.invalidfile));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } //end of else if (requestCode == 2)
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -1458,7 +1625,7 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
//FileInputStream fis = new FileInputStream(filename);
|
|
|
if(bottonMode == 4)
|
|
|
{
|
|
|
- filename = edit_search.getText().toString();
|
|
|
+ filename = tv_edit_search_bin.getText().toString();
|
|
|
FileInputStream fw = new FileInputStream(filename);
|
|
|
//fw.read(mGt9FirmwareData);
|
|
|
fw.read(mGt293xFirmwareData);
|
|
@@ -2937,7 +3104,6 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
}
|
|
|
SystemClock.sleep(20);
|
|
|
|
|
|
- //if (!recallCheck32Bits(addrfirstbyte,addrsecondbyte, addrthirdbyte, mBytes,0,8))
|
|
|
if (!iicRead32Bits(addrfirstbyte, addrsecondbyte, addrthirdbyte, (byte)0x0f, mBytes, 8))
|
|
|
//if (!gpI2C1->I2CRead(BOOT_OPT_ADDR, ReadBackCheck, 8)) //todo
|
|
|
{
|
|
@@ -3181,7 +3347,7 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
private boolean DownloadBinFile() {
|
|
|
//m_bHaveDownloadLength = 0;
|
|
|
|
|
|
- Update_log2 = "[FW update]Download Bin File start......";
|
|
|
+ Update_log2 = "[FW update]Download Bin File start......\n";
|
|
|
mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
|
|
|
for (int i = 0; i < iFwCnt; i++)
|
|
@@ -3197,7 +3363,7 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
|
|
|
if (!DownloadSection(i))
|
|
|
{
|
|
|
- Update_log2 = "[FW update]Download Bin File Fail!";
|
|
|
+ Update_log = "[FW update]Download Bin File Fail!";
|
|
|
mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
return false;
|
|
|
}
|
|
@@ -3208,14 +3374,14 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
{
|
|
|
if (!DownloadSection(i))
|
|
|
{
|
|
|
- Update_log2 = "[FW update]Download Patch Code Fail!";
|
|
|
+ Update_log = "[FW update]Download Patch Code Fail!";
|
|
|
mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Update_log2 = "[FW update]Download Bin File Success";
|
|
|
+ Update_log = "[FW update]Download Bin File Success";
|
|
|
mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
return true;
|
|
|
}
|
|
@@ -3245,81 +3411,244 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- Update_log2 = "[FW update]Update Finish!!";
|
|
|
+ Update_log = "[FW update]Update Bin Finish!!";
|
|
|
mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private boolean GT29xxupdateProc() {
|
|
|
+ private boolean UpdateConfigProc() {
|
|
|
|
|
|
- //读取文件内容:
|
|
|
- /**
|
|
|
- try {
|
|
|
- readFile();
|
|
|
- } catch (IOException e) {
|
|
|
- mMessage.setText("文件不存在!");
|
|
|
- // e.printStackTrace();
|
|
|
- }
|
|
|
- */
|
|
|
+ Update_log = "[Config update]Update Config Start......";
|
|
|
+ mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
|
|
|
- ActivityCompat.requestPermissions( FirmwareUpdate.this, new String[]{android
|
|
|
- .Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); //申请权限,android6.0以上系统首次使用必须添加
|
|
|
+ String[] stringArr;
|
|
|
+ String value;
|
|
|
|
|
|
- StringBuffer buffer = new StringBuffer();
|
|
|
- StringBuilder stringBuilder = new StringBuilder("");
|
|
|
- if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
|
|
+ byte addrfirstbyte, addrsecondbyte, addrthirdbyte;
|
|
|
|
|
|
- try {
|
|
|
+ //send 0x00 to [0x10174],清除标志
|
|
|
+ mBytes[0] = 0x00;
|
|
|
+ iicWrite32Bits((byte)0x01, (byte)0x01, (byte)0x74, mBytes,0,1);
|
|
|
+ SystemClock.sleep(15);
|
|
|
+
|
|
|
+ //send 0x00 0x00 0x04 0x04 0x08 0x00 to [0x10174],通知GT29XX,send cfg
|
|
|
+ mBytes[0] = 0x00;
|
|
|
+ mBytes[1] = 0x00;
|
|
|
+ mBytes[2] = 0x04;
|
|
|
+ mBytes[3] = 0x04;
|
|
|
+ mBytes[4] = 0x08;
|
|
|
+ mBytes[5] = 0x00;
|
|
|
+ iicWrite32Bits((byte)0x01, (byte)0x01, (byte)0x74, mBytes,0,6);
|
|
|
+
|
|
|
+ //30ms一次轮询[0x10174],如果是0x80,说明GT29XX已准备好,可以send cfg
|
|
|
+ do {
|
|
|
+ SystemClock.sleep(30);
|
|
|
+ iicRead32Bits((byte)0x01, (byte)0x01, (byte)0x74, (byte)0x0f, mBytes, 1);
|
|
|
+ }while(mBytes[0] != (byte)0x80);
|
|
|
+
|
|
|
+ //value = configBuilder.toString();
|
|
|
+ value = StrConfigDateString;
|
|
|
+ value = value.replaceAll("0x", ""); //0x转换为没有
|
|
|
+ stringArr = value.split(",");
|
|
|
+
|
|
|
+ //value = value.replace(',', ' '); //逗号转换为空格
|
|
|
+
|
|
|
+ //value = value.trim(); //去除空格
|
|
|
+ //value = value.replaceAll(" ", ""); //逗号转换为空格
|
|
|
+ //char mTextData[] = value.toCharArray();
|
|
|
+ byte[] mBufferData = new byte[2048];
|
|
|
+
|
|
|
+ for (int b = 0; b < stringArr.length; b++) {
|
|
|
+ byte aByte = (byte) Integer.parseInt(stringArr[b], 16);
|
|
|
+ mBufferData[b] = aByte;
|
|
|
+ }
|
|
|
+ //mBufferData = value.getBytes();
|
|
|
+ //mSendData = new byte[2048];
|
|
|
+
|
|
|
+ //重新计算checksum
|
|
|
+
|
|
|
+ //head buffer长度为64字节,最后两个字节是checksum,低位在前存放
|
|
|
+ /*
|
|
|
+ ichecksumhead = 0;
|
|
|
+ for (int i = 0; i < 62; i++) {
|
|
|
+ int vb = mBufferData[i] & 0xFF;
|
|
|
+ ichecksumhead = ichecksumhead + vb;
|
|
|
+ }
|
|
|
|
|
|
- //String filename = Environment.getExternalStorageDirectory() + "/Download/GT9110H_2002(A2E3).BIN";
|
|
|
- String filename = "GT9110H_2002(A2E3).BIN";
|
|
|
- //mError.setText(filename);
|
|
|
- //FileInputStream fis = new FileInputStream(filename);
|
|
|
- if(bottonMode == 4)
|
|
|
- {
|
|
|
- filename = edit_search.getText().toString();
|
|
|
- FileInputStream fw = new FileInputStream(filename);
|
|
|
- //fw.read(mGt9FirmwareData);
|
|
|
- fw.read(mGt293xFirmwareData);
|
|
|
- fw.close();
|
|
|
- }
|
|
|
- else {
|
|
|
+ mBufferData[62] = (byte)(ichecksumhead & 0x00ff);
|
|
|
+ mBufferData[63] = (byte)((ichecksumhead & 0xff00) >> 8);
|
|
|
+ */
|
|
|
|
|
|
- if(bottonMode == 3) {
|
|
|
- InputStream config = getResources().openRawResource(R.raw.gt9110h_config_2018110802);
|
|
|
- //InputStream config = getResources().openRawResource(R.raw.xinjian);\
|
|
|
- config.read(mConfigData);
|
|
|
+ //配置长度(不含head buffer长度)
|
|
|
+ int iconfiglen = (int)(mBufferData[60] & 0xFF) * 256 + (mBufferData[59] & 0xFF);
|
|
|
|
|
|
- InputStream fis = getResources().openRawResource(R.raw.gt9110h_2002);
|
|
|
- //gt9110h_config_20181108
|
|
|
- fis.read(mGt9FirmwareData);
|
|
|
+ //计算配置的checksum,不含64字节的head buffer
|
|
|
+ /*
|
|
|
+ lchecksum = 0;
|
|
|
+ for (int i = 64; i < (iconfiglen + 64 - 4); i += 2) {
|
|
|
+ int vb = ((mBufferData[i + 1] & 0xFF) << 8) + (mBufferData[i] & 0xFF);
|
|
|
+ lchecksum = lchecksum + vb;
|
|
|
+ }
|
|
|
|
|
|
- config.close();
|
|
|
- fis.close();
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- Update_log = getResources().getString(R.string.invalidfile);
|
|
|
- mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
+ mBufferData[iconfiglen + 64 - 4] = (byte)(lchecksum & 0x000000ff);
|
|
|
+ mBufferData[iconfiglen + 64 - 3] = (byte)((lchecksum & 0x0000ff00) >> 8);
|
|
|
+ mBufferData[iconfiglen + 64 - 2] = (byte)((lchecksum & 0x00ff0000) >> 16);
|
|
|
+ mBufferData[iconfiglen + 64 - 1] = (byte)((lchecksum & 0xff000000) >> 24);
|
|
|
+ */
|
|
|
+
|
|
|
+ if (byProductType == GT29336) {
|
|
|
+ addrfirstbyte = (byte)0x01;
|
|
|
+ addrsecondbyte = (byte)0x3B;
|
|
|
+ addrthirdbyte = (byte)0x74;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ addrfirstbyte = (byte)0x01;
|
|
|
+ addrsecondbyte = (byte)0x21;
|
|
|
+ addrthirdbyte = (byte)0x8C;
|
|
|
+ }
|
|
|
+
|
|
|
+ iicWrite32Bits(addrfirstbyte, addrsecondbyte, addrthirdbyte, mBufferData,0,iconfiglen + 64);
|
|
|
+
|
|
|
+ SystemClock.sleep(30);
|
|
|
+
|
|
|
+ if (!recallCheck32Bits(addrfirstbyte, addrsecondbyte, addrthirdbyte, mBufferData, 0, iconfiglen + 64)) {
|
|
|
+ Update_log = "[Config update]Recall check config error!!";
|
|
|
+ mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ Update_log = "[Config update]Recall check config success!!";
|
|
|
+ mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ SystemClock.sleep(8);
|
|
|
|
|
|
+ //send 0x00 0x00 0x04 0x05 0x09 0x00 to [0x10174],通知GT29XX,cfg发送完毕
|
|
|
+ mBytes[0] = 0x00;
|
|
|
+ mBytes[1] = 0x00;
|
|
|
+ mBytes[2] = 0x04;
|
|
|
+ mBytes[3] = 0x05;
|
|
|
+ mBytes[4] = 0x09;
|
|
|
+ mBytes[5] = 0x00;
|
|
|
+ iicWrite32Bits((byte)0x01, (byte)0x01, (byte)0x74, mBytes,0,6);
|
|
|
+
|
|
|
+ //30ms一次轮询[0x10174],如果是0x80,说明GT29XX已接收配置
|
|
|
+ do {
|
|
|
+ SystemClock.sleep(30);
|
|
|
+ iicRead32Bits((byte)0x01, (byte)0x01, (byte)0x74, (byte)0x0f, mBytes, 1);
|
|
|
+ if (mBytes[0] == (byte)0x03)
|
|
|
+ {
|
|
|
+ Update_log = "[Config update]Config checksum is error!!";
|
|
|
+ mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
- catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- Update_log = "IOException";
|
|
|
+ else if (mBytes[0] == (byte)0x01)
|
|
|
+ {
|
|
|
+ Update_log = "[Config update]receive finish!!";
|
|
|
mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- return false;
|
|
|
+ }while(mBytes[0] != (byte)0x80);
|
|
|
+
|
|
|
+ SystemClock.sleep(15);
|
|
|
+
|
|
|
+ //send 0x00 0x00 0x04 0x06 0x0A 0x00 to [0x10174],通知GT29XX,流程完成
|
|
|
+ mBytes[0] = 0x00;
|
|
|
+ mBytes[1] = 0x00;
|
|
|
+ mBytes[2] = 0x04;
|
|
|
+ mBytes[3] = 0x06;
|
|
|
+ mBytes[4] = 0x0A;
|
|
|
+ mBytes[5] = 0x00;
|
|
|
+ iicWrite32Bits((byte)0x01, (byte)0x01, (byte)0x74, mBytes,0,6);
|
|
|
+
|
|
|
+ //30ms一次轮询[0x10174],如果是0x80,说明GT29XX已完成
|
|
|
+ do {
|
|
|
+ SystemClock.sleep(30);
|
|
|
+ iicRead32Bits((byte)0x01, (byte)0x01, (byte)0x74, (byte)0x0f, mBytes, 1);
|
|
|
+ if (mBytes[0] == (byte)0x01)
|
|
|
+ {
|
|
|
+ Update_log = "[Config update]receive finish!!";
|
|
|
+ mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
+ break;
|
|
|
}
|
|
|
+ }while(mBytes[0] != (byte)0x80);
|
|
|
|
|
|
- }
|
|
|
- else{
|
|
|
- Update_log = getResources().getString(R.string.nopermission);
|
|
|
- mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
+ //mShow.setText("Send cfg finish!!");
|
|
|
+ Update_log = "[Config update]Send config finish!! Config Version:0x" + Integer.toHexString(mBufferData[34]);
|
|
|
+ mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
|
|
|
- return false;
|
|
|
- }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean GT29xxupdateProc() {
|
|
|
+
|
|
|
+ if (tv_edit_search_bin.getText().length() != 0) //下载固件
|
|
|
+ {
|
|
|
+ //读取文件内容:
|
|
|
+ /**
|
|
|
+ try {
|
|
|
+ readFile();
|
|
|
+ } catch (IOException e) {
|
|
|
+ mMessage.setText("文件不存在!");
|
|
|
+ // e.printStackTrace();
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ ActivityCompat.requestPermissions(FirmwareUpdate.this, new String[]{android
|
|
|
+ .Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); //申请权限,android6.0以上系统首次使用必须添加
|
|
|
+
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ StringBuilder stringBuilder = new StringBuilder("");
|
|
|
+ if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ //String filename = Environment.getExternalStorageDirectory() + "/Download/GT9110H_2002(A2E3).BIN";
|
|
|
+ String filename = "GT9110H_2002(A2E3).BIN";
|
|
|
+ //mError.setText(filename);
|
|
|
+ //FileInputStream fis = new FileInputStream(filename);
|
|
|
+ if (bottonMode == 4) {
|
|
|
+ filename = tv_edit_search_bin.getText().toString();
|
|
|
+ FileInputStream fw = new FileInputStream(filename);
|
|
|
+ //fw.read(mGt9FirmwareData);
|
|
|
+ fw.read(mGt293xFirmwareData);
|
|
|
+ fw.close();
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (bottonMode == 3) {
|
|
|
+ InputStream config = getResources().openRawResource(R.raw.gt9110h_config_2018110802);
|
|
|
+ //InputStream config = getResources().openRawResource(R.raw.xinjian);\
|
|
|
+ config.read(mConfigData);
|
|
|
+
|
|
|
+ InputStream fis = getResources().openRawResource(R.raw.gt9110h_2002);
|
|
|
+ //gt9110h_config_20181108
|
|
|
+ fis.read(mGt9FirmwareData);
|
|
|
+
|
|
|
+ config.close();
|
|
|
+ fis.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ Update_log = getResources().getString(R.string.invalidfile);
|
|
|
+ mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
+
|
|
|
+ return false;
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ Update_log = "IOException";
|
|
|
+ mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ Update_log = getResources().getString(R.string.nopermission);
|
|
|
+ mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
|
byte addrfirstbyte = (byte)0x01;
|
|
@@ -3338,26 +3667,26 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
SystemClock.sleep(80);
|
|
|
*/
|
|
|
|
|
|
- if (!UpdateInit()) //NO1
|
|
|
- {
|
|
|
- //FwUpdateMessage(L"[FW update]Enter update mode failed", MSG_ERR);
|
|
|
- UpdateFinish();
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if (!UpdateInit()) //NO1
|
|
|
+ {
|
|
|
+ //FwUpdateMessage(L"[FW update]Enter update mode failed", MSG_ERR);
|
|
|
+ UpdateFinish();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- if (!EnterUpdateMode()) //NO2
|
|
|
- {
|
|
|
- //FwUpdateMessage(L"[FW update]Enter update mode failed", MSG_ERR);
|
|
|
- UpdateFinish();
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if (!EnterUpdateMode()) //NO2
|
|
|
+ {
|
|
|
+ //FwUpdateMessage(L"[FW update]Enter update mode failed", MSG_ERR);
|
|
|
+ UpdateFinish();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- if (!UpdateIsp()) //NO3
|
|
|
- {
|
|
|
- //FwUpdateMessage(L"[FW update]Enter update mode failed", MSG_ERR);
|
|
|
- UpdateFinish();
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if (!UpdateIsp()) //NO3
|
|
|
+ {
|
|
|
+ //FwUpdateMessage(L"[FW update]Enter update mode failed", MSG_ERR);
|
|
|
+ UpdateFinish();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
|
if (m_nConfigLen > 0 && m_nConfigLen < 4096 && m_pbConfigBuf != NULL)
|
|
@@ -3371,17 +3700,27 @@ public class FirmwareUpdate extends AppCompatActivity
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
- if (!DownloadBinFile())
|
|
|
- {
|
|
|
- //FwUpdateMessage(LS(IDS_GTXXX_DOWNLOAD_BIN_FAILED), MSG_ERR);
|
|
|
- UpdateFinish();
|
|
|
- return false;
|
|
|
+ if (!DownloadBinFile()) {
|
|
|
+ //FwUpdateMessage(LS(IDS_GTXXX_DOWNLOAD_BIN_FAILED), MSG_ERR);
|
|
|
+ UpdateFinish();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!UpdateFinish()) {
|
|
|
+ //FwUpdateMessage(LS(IDS_GTXXX_RESET_FAILED), MSG_ERR);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (!UpdateFinish())
|
|
|
+ if (tv_edit_search_cfg.getText().length() != 0) //下发配置
|
|
|
{
|
|
|
- //FwUpdateMessage(LS(IDS_GTXXX_RESET_FAILED), MSG_ERR);
|
|
|
- return false;
|
|
|
+ SystemClock.sleep(100);
|
|
|
+
|
|
|
+ if (!UpdateConfigProc())
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return true;
|