Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 86c0a38

Browse files
author
radiomanV
committedJul 9, 2019
Update firmware updater
1 parent a4e4e8f commit 86c0a38

File tree

8 files changed

+105
-7
lines changed

8 files changed

+105
-7
lines changed
 

‎TL866_Updater/C#/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("2.51")]
36+
[assembly: AssemblyFileVersion("2.52")]

‎TL866_Updater/C#/firmware.cs

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public enum PROGRAMMER_TYPE
4343
public const int UNENCRYPTED_FIRMWARE_SIZE = 0x1E400;
4444
public const int FIRMWARE_SIGNATURE_OFFSET = 0x1E3FC;
4545
public const uint FIRMWARE_SIGNATURE = 0x5AA5AA55;
46+
public const uint CP0_ADDRESS = 0x1FFF9;
4647
public const int DEVCODE_LENGHT = 8;
4748
public const int SERIALCODE_LENGHT = 24;
4849

‎TL866_Updater/C#/mainform.Designer.cs

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎TL866_Updater/C#/mainform.cs

+10
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,9 @@ private void SaveHex(byte[] data)
784784
if (!OptionFull.Checked)
785785
for (int i = Firmware.BOOTLOADER_SIZE; i < Firmware.XOR_TABLE_OFFSET; i++)
786786
data[i] = 0xFF;
787+
//Disable the CP0 bit if necessary
788+
if (!cp0.Checked)
789+
data[Firmware.CP0_ADDRESS] |= 0x04;
787790
////Writing serial code
788791
byte[] info = new byte[Firmware.BLOCK_SIZE];
789792
string s1 = TxtDevcode.Text + new string(' ', Firmware.DEVCODE_LENGHT - TxtDevcode.Text.Length);
@@ -871,5 +874,12 @@ private enum led_action
871874
private delegate void SetProgressBarCallBack(int percentage);
872875

873876
private delegate void SetMessageCallBack(string message);
877+
878+
private void cp0_CheckedChanged(object sender, EventArgs e)
879+
{
880+
if (!cp0.Checked)
881+
MessageBox.Show("Disabling the CP0 bit will disable switch to bootloader function in the latest firmware versions!\r\nThis bit should be disabled only for debugging purposes.", "TL866",
882+
MessageBoxButtons.OK, MessageBoxIcon.Warning);
883+
}
874884
}
875885
}

‎TL866_Updater/QT/firmware.h

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define XOR_TABLE_SIZE 0x100
99
#define XOR_TABLE_OFFSET 0x1FC00
1010
#define FIRMWARE_SIGNATURE_OFFSET 0x1E3FC
11+
#define CP0_ADDRESS 0x1FFF9
1112
#define FIRMWARE_SIGNATURE 0x5AA5AA55
1213

1314
#define SERIAL_OFFSET 0x1FD00

‎TL866_Updater/QT/mainwindow.cpp

+22-5
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,16 @@ void MainWindow::on_btnSave_clicked()
338338
{
339339
//Prepare data to be saved.
340340
QByteArray temp = get_resource(ui->radiofA->isChecked() ? A_FIRMWARE_RESOURCE : CS_FIRMWARE_RESOURCE, FLASH_SIZE);
341+
342+
//Writing the main firmware or empty on choice
341343
if(ui->optionBoot->isChecked())
342344
memset(&temp.data()[BOOTLOADER_SIZE], 0xFF, UNENCRYPTED_FIRMWARE_SIZE);//if the option bootloader only is selected then clear the main firmware area(0x1800-0x1FBFF)
345+
346+
//Disable the CP0 bit if necessary
347+
if(!ui->cp0->isChecked())
348+
temp.data()[CP0_ADDRESS] |= 0x04;
349+
350+
//Writing serial code
343351
memset(&temp.data()[SERIAL_OFFSET],' ',32);//add trailing spaces
344352
memcpy(&temp.data()[SERIAL_OFFSET], ui->txtDevcode->text().toLatin1().data(), static_cast<size_t>(ui->txtDevcode->text().size()));//copy devcode to key array
345353
memcpy(&temp.data()[SERIAL_OFFSET+8], ui->txtSerial->text().toLatin1().data(), static_cast<size_t>(ui->txtSerial->text().size()));//copy serial to key array
@@ -376,6 +384,14 @@ void MainWindow::on_btnSave_clicked()
376384
}
377385
}
378386

387+
//Click the CP0 checkbox
388+
void MainWindow::on_cp0_stateChanged(int arg1)
389+
{
390+
if(arg1 == Qt::Unchecked)
391+
QMessageBox::warning(this, "TL866", "Disabling the CP0 bit will disable switch to bootloader function in the latest firmware versions!\nThis bit should be disabled only for debugging purposes.",
392+
QMessageBox::Ok);
393+
}
394+
379395
//Helper function to get a binary resource
380396
QByteArray MainWindow::get_resource(const QString &resource_path, int size)
381397
{
@@ -683,9 +699,9 @@ void MainWindow::gui_updated(const QString &message, bool eraseLed, bool writeLe
683699
}
684700

685701
//This procedure is called automatically by the usb device change. Call this function to refresh the info.
686-
MainWindow::DeviceInfo MainWindow::DeviceChanged(bool arrived)
702+
MainWindow::DeviceInfo MainWindow::DeviceChanged(bool arrived)
687703
{
688-
DeviceInfo device_info = {"", "", 0};
704+
DeviceInfo device_info = {"", "", 0};
689705

690706
if(!arrived && reset_flag)//ignore unplug events if the device was resetted by us.
691707
return device_info;
@@ -801,14 +817,14 @@ void MainWindow::gui_updated(const QString &message, bool eraseLed, bool writeLe
801817
else//no device connected
802818
SetBlank();
803819
return device_info;
804-
}
820+
}
805821

806822
//Helper function to get formated device and serial code
807823
const QString MainWindow::GetFormatedString(const QString &devcode, const QString &serial)
808824
{
809825
return QString("Device code: %1\nSerial number: %2").arg(devcode.trimmed() +
810-
(Firmware::IsBadCrc(devcode, serial) ? " (Bad device code)" : "")) .arg(serial.trimmed() +
811-
(Firmware::IsBadCrc(devcode, serial) ? " (Bad serial code)" : ""));
826+
(Firmware::IsBadCrc(devcode, serial) ? " (Bad device code)" : "")) .arg(serial.trimmed() +
827+
(Firmware::IsBadCrc(devcode, serial) ? " (Bad serial code)" : ""));
812828
}
813829

814830

@@ -957,3 +973,4 @@ bool MainWindow::AdvQuestion()
957973
return(QMessageBox::warning(advdlg, "TL866", "Warning! this operation may brick your device.\nDo you want to continue?",
958974
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes);
959975
}
976+

‎TL866_Updater/QT/mainwindow.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ private slots:
6868
void WriteInfo(const QString &device_code, const QString &serial_number);
6969

7070

71+
void on_cp0_stateChanged(int arg1);
72+
7173
signals:
7274
void reflash_status(const QString &result);
7375
void dump_status(const QString &result);
@@ -108,7 +110,7 @@ private slots:
108110
#define A_FIRMWARE_RESOURCE ":/firmware/firmwareA.bin"
109111
#define CS_FIRMWARE_RESOURCE ":/firmware/firmwareCS.bin"
110112
#define DUMPER_RESOURCE ":/firmware/dumper.bin"
111-
#define VERSION "2.5"
113+
#define VERSION "2.52"
112114
};
113115

114116
#endif // MAINWINDOW_H

‎TL866_Updater/QT/mainwindow.ui

+37
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,43 @@
809809
</item>
810810
</layout>
811811
</widget>
812+
<widget class="QCheckBox" name="cp0">
813+
<property name="geometry">
814+
<rect>
815+
<x>273</x>
816+
<y>90</y>
817+
<width>231</width>
818+
<height>17</height>
819+
</rect>
820+
</property>
821+
<property name="text">
822+
<string>Code protection bit(CP0)</string>
823+
</property>
824+
<property name="checked">
825+
<bool>true</bool>
826+
</property>
827+
</widget>
828+
</widget>
829+
<widget class="QLabel" name="label_8">
830+
<property name="geometry">
831+
<rect>
832+
<x>210</x>
833+
<y>130</y>
834+
<width>361</width>
835+
<height>16</height>
836+
</rect>
837+
</property>
838+
<property name="font">
839+
<font>
840+
<pointsize>11</pointsize>
841+
</font>
842+
</property>
843+
<property name="styleSheet">
844+
<string notr="true">color: rgb(0, 0, 255);</string>
845+
</property>
846+
<property name="text">
847+
<string>Generated firmware version 3.2.82 (Minipro 6.71)</string>
848+
</property>
812849
</widget>
813850
</widget>
814851
</widget>

0 commit comments

Comments
 (0)
Please sign in to comment.