Commit a4890bc2 authored by Eberhard Stoll's avatar Eberhard Stoll

Flashing possible with jenson ft6336g chip

command to use: ./ft5x06-tool -b 1 -i FST000FT6336G_CTP-JT60255-01A_Z05D_20201116_app.bin
If program can't detect the device (for example wrong firmware) use additionally '-c 0x64' parameter

After programming the tool complains about wrong ecc values. But after reboot the new firmware is in!
parent 00830208
......@@ -56,6 +56,7 @@
#define FT_FW_START_REG 0xbf
#define FT_REG_ECC 0xcc
#define FT_RST_CMD_REG1 0xfc
#define FT_RST_CMD_REG2 0xbc
/* Undocumented firmware update values */
#define FT_UPGRADE_AA 0xAA
......@@ -77,6 +78,7 @@
#define FT5x06_ID 0x55
#define FT5x16_ID 0x0a
#define FT5x26_ID 0x54
#define JENSON_FT6336G_ID 0x64
/* Print macros */
#define LOG(fmt, arg...) fprintf(stdout, "[%s]: " fmt "\n" , __func__ , ## arg)
......@@ -108,7 +110,7 @@ struct ft5x06_fw_update_info {
uint8_t upgrade_id_2; /*upgrade id 2 */
uint16_t delay_readid; /*delay of read id */
uint16_t delay_erase_flash; /*delay of erase flash*/
uint32_t flash_offset;
uint32_t flash_offset; /* unused ?! */
};
/*
......@@ -117,6 +119,16 @@ struct ft5x06_fw_update_info {
*/
struct ft5x06_fw_update_info ft5x06_fwu_info[] = {
{FT5x26_ID, "ft5x26", 5, 0, 4, 250, 0x54, 0x2c, 10, 3000, 0x1800},
{JENSON_FT6336G_ID, "ft6x36",
.tpd_max_points = 2,
.auto_clb = 0,
.delay_aa = 50,
.delay_55 = 250/*0*/,
.upgrade_id_1 = 0x79,
.upgrade_id_2 = 0x1c,
.delay_readid = 10,
.delay_erase_flash = 2000,
.flash_offset = 0x1800 /*??*/},
};
static int ft5x06_i2c_read(struct ft5x06_ts *ts, uint8_t *wrbuf, uint16_t wrlen,
......@@ -240,9 +252,9 @@ static void ft5x06_reset_ctpm(struct ft5x06_ts *ts)
{
struct ft5x06_fw_update_info *info = ft5x06_get_info(ts);
ft5x06_write_reg(ts, FT_RST_CMD_REG1, FT_UPGRADE_AA);
ft5x06_write_reg(ts, FT_RST_CMD_REG2, FT_UPGRADE_AA);
msleep(info->delay_aa);
ft5x06_write_reg(ts, FT_RST_CMD_REG1, FT_UPGRADE_55);
ft5x06_write_reg(ts, FT_RST_CMD_REG2, FT_UPGRADE_55);
msleep(info->delay_55);
}
......@@ -264,6 +276,7 @@ static int ft5x06_init_upgrade(struct ft5x06_ts *ts)
/* Step 1: Reset CTPM */
LOG("Reset CTPM");
ft5x06_reset_ctpm(ts);
msleep(20 + i*2);
/* Step 2: Enter upgrade mode */
LOG("Enter upgrade mode");
......@@ -391,6 +404,13 @@ static int ft5x06_fw_upgrade(struct ft5x06_ts *ts, const uint8_t *data,
if (ret < 0)
return ret;
packet_buf[0] = FT_READ_ID_REG;
packet_buf[1] = 0;
packet_buf[2] = 0;
packet_buf[3] = 0;
packet_buf[4] = 0;
ft5x06_i2c_write(ts, packet_buf, 5);
LOG("Erase current app");
packet_buf[0] = FT_ERASE_APP_REG;
ft5x06_i2c_write(ts, packet_buf, 1);
......@@ -400,12 +420,25 @@ static int ft5x06_fw_upgrade(struct ft5x06_ts *ts, const uint8_t *data,
}
msleep(info->delay_erase_flash);
/* Prepare the system to receive a new firmware? */
packet_buf[0] = 0xB0;
packet_buf[1] = (uint8_t)((data_len >> 16) & 0xFF);
packet_buf[2] = (uint8_t)((data_len >> 8) & 0xFF);
packet_buf[3] = (uint8_t)(data_len & 0xFF);
ft5x06_i2c_write(ts, packet_buf, 4);
for(i = 0;i < 200;i++)
{
packet_buf[0] = 0x6a;
packet_buf[1] = 0x00;
packet_buf[2] = 0x00;
packet_buf[3] = 0x00;
reg_val[0] = 0x00;
reg_val[1] = 0x00;
ft5x06_i2c_read(ts, packet_buf, 4, reg_val, 2);
if(0xb0 == reg_val[0] && 0x02 == reg_val[1]){
LOG("Erase finished");
break;
}
msleep(50);
}
if (i >= 200){
LOG("Erase failed");
return -EIO;
}
LOG("Write firmware to CTPM flash");
for (i = 0; i < data_len; i += FT_FW_PKT_LEN) {
......@@ -524,6 +557,7 @@ int main(int argc, const char *argv[])
/* If chip ID isn't forced, detect it */
if (ts.chip_id == 0xff) {
LOG("Detecting chip ID");
wbuf = ID_G_CIPHER;
ret = ft5x06_i2c_read(&ts, &wbuf, 1, &rbuf, 1);
if (ret < 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment