BRT Community

General Category => Discussion - EVE => Topic started by: david on June 17, 2021, 06:23:49 PM

Title: Updating Capacitive Touch Controller Firmware of BT815
Post by: david on June 17, 2021, 06:23:49 PM
Hello, I am Trying to flash a new firmware for the capacitive touch controller. I am using the BT815 with the EVE Asset Builder 2.2.
I was not successfull with my code in the first place, I sniffed the I2C traffic between the BT815 and the touch controller and it did not address and send the correct data.
That's why I tried to simplify it by removing the whole I2C communication and just reporting static values to the BT815. This is the code I am compiling:
Code: [Select]
int i2c_addr()
{
  return 0x38; // does not matter for my test
}

int setup()
{
  setWAKE(0);
  delay_ms(5);
  setWAKE(1);
  delay_ms(300);
}

void loop()
{
report_touch(0, 400, 300);
delay_ms(5); // also tried without those delays and with id 1 as well
report_touch(0, 200, 100);
delay_ms(5);
}

which results in this:
Code: [Select]
26,255,255,255,32,32,48,0,4,0,0,0,2,0,0,0,26,255,255,255,0,176,48,0,4,0,0,0,5,2,0,0,34,255,255,255,238,178,48,0,120,218,37,142,177,75,195,80,16,198,239,154,182,168,25,204,251,3,58,60,16,165,24,39,59,56,222,209,69,40,217,197,233,189,182,70,180,89,156,20,117,184,172,18,72,157,197,81,40,205,191,32,14,78,29,187,56,73,233,226,238,232,34,196,151,56,220,241,187,143,239,227,59,101,246,233,78,31,66,102,148,163,54,237,152,107,62,35,207,118,38,55,184,43,3,80,166,79,222,80,153,92,191,16,92,62,96,110,67,167,30,72,150,108,186,129,24,197,27,53,229,17,143,36,51,247,46,239,11,36,202,38,188,103,79,185,51,241,157,247,137,127,1,177,199,61,222,16,239,42,31,130,204,120,206,43,66,153,97,197,129,157,51,242,10,124,137,160,74,67,12,18,88,20,24,45,180,178,39,220,167,192,54,169,37,112,254,174,111,233,24,202,18,98,111,220,149,1,109,59,247,22,125,232,174,68,53,127,234,204,148,238,159,37,66,186,100,101,214,85,227,197,26,209,93,95,216,168,55,200,148,91,82,184,246,41,135,105,1,175,236,148,52,76,159,107,21,100,33,99,249,231,55,252,230,31,142,210,130,218,141,63,227,110,93,240,0,0,26,255,255,255,32,32,48,0,4,0,0,0,0,0,0,0
But when I try to get the touch values (the raw ones from REG_TOUCH_RAW_XY) I just get x: 0, y: 0 or x: 65535, y: 65535.
I can see that the BT815 is not communicating via I2C anymore, so the transfer of the firmware seems to work at least in some parts.

I have also a few more questions:
- is the response of int i2c_addr() used over the one in REG_TOUCH_CONFIG (REG_CYA_TOUCH) or which one is priorized?

- is it possible to configure the I2C frequency?

For uploading the Firmware my code looks like this:
Code: [Select]
Gpu_Hal_WaitCmdfifo_empty(host);
Gpu_Hal_WrCmdBuf(host, TOUCH_DATA, sizeof(TOUCH_DATA));
Gpu_Hal_WaitCmdfifo_empty(host);
I tried it right after GPU_ACTIVE_M in setup and also after getting the BT815 ID via REG_ID.
I also tried to reset the touch component with Gpu_Hal_Wr32(host, REG_CPURESET, 2); followed by Gpu_Hal_Wr32(host, REG_CPURESET, 0);

The real code which I tried to compile and run at the first place is this one:
Code: [Select]
int i2c_addr()
{
  return 0x41;
}

int setup()
{
  setWAKE(0);
  delay_ms(5);
  setWAKE(1);
  delay_ms(300);
}

void loop()
{
  while (getINT() == 1) // wait for INT to go low
    ;
  i2c_startread(0x10);
  int n_touches = i2c_read8();
  int touch_index = 0;
  int x_raw;
  while (touch_index < n_touches) {
x_raw = i2c_read16le();
report_touch(touch_index, i2c_read16le(), x_raw & 0x3fff);
touch_index = touch_index + 1;
  }
  i2c_stop();
}

It would be nice, if there are some more information about updating the touch firmware or if someone could test the firmware on top to check if the uploading is the problem.
If it helps I can also provied sniffed I2C traffic of one of the compiled firmwares.
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: david on June 24, 2021, 07:13:49 AM
I would be very grateful for any help. Did anyone successfully transfer a self compiled touch firmware binary yet?
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: BRT Community on June 24, 2021, 12:59:20 PM
Hi David,

We will try out your code and will post back here with the results,

Best Regards, BRT Community
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: BRT Community on July 02, 2021, 11:29:29 AM
Hi David,
Just to update you, we tried your code and could see the same result, we're just investigating and will post an update soon,
Best Regards, BRT Community
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: david on July 16, 2021, 02:52:32 PM
Do you have any new information? I am comparing a few different touch controllers (also with host mode) and it would help a lot to have more information about that topic. Did you also try the sample code on a BT817, does it work there (I could not get one yet)?
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: david on September 06, 2021, 09:39:40 AM
I am still interested in that. It would be very nice, if I can get an update about it. Is it a bug in the compiler or with BT815 or am I not using it correctly?
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: karst.drenth on November 30, 2021, 11:23:56 AM
Hi,

I have a similar need. The CTP of my display seems to be pretty noisy...  :'( ( many false touches detected )

It has the GT11 chip on there. Reading the GT11 Manual/Programming guide, there is a setting for noise reduction. ( and some more settings that cope with ESD and noise problems )

Question 1: what are the BT815 factory firmware's settings for the GT11
Question 2: is the "custom firmware" method also able to only have a "setup" function and let "loop" just be done by the original firmware ?
Question 3: if 2) not is possible, what is the ROM's firmware source for the "loop" equivalent ?

Grtzz,
Karst
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: karst.drenth on November 30, 2021, 03:50:24 PM
Hi,

Self-answer to Question 2:

Code: [Select]
----------------------------------------------------------------------
GT911-Custom.eab compilation is in progress...
Microcode 'capcs.fs' uses 1100 bytes.
Loader command stream is 368 bytes
350 new bytes in firmware
Compilation is done.
----------------------------------------------------------------------
GT911-Custom.eab compilation is in progress...

Cross-compilation failed - exiting

in file included from *the terminal*:0
in file included from *the terminal*:-1
in file included from cross.fs:242
capcs.fs:361: error: Undefined word
begin loop
Backtrace:
0 $FFA47D28 throw
1 $FFA4A1F0 no.extensions 
Compilation failed!

I tried to compile this:

Code: [Select]
/*

The tiny language resembles C in syntax.

It allows:
  - functions, of "void" and "int" type
  - constructs, if .. else, while and do .. while loops
  - local variables, of "int" type only
  - integer arithmetic (no / or %)

The end-user defines three functions:
  - i2c_addr() which returns the I2C address
  - setup() one-time initialization
  - loop() poll the CTP and update the touch sensing registers

In addition a number of built-in functions are available for IO in the user's code. Together these form a simple HAL.

  - void delay_ms(n)              // delay for n milliseconds
  - void delay_us(n)              // delay for n microseconds
  - void i2c_regwr(u, v)          // write value v to register u
  - void i2c_startread(u)         // start a read from register u
  - int i2c_read16le()            // read 16 bits from I2C, little-endian
  - int i2c_read16be()            // read 16 bits from I2C, big-endian
  - int i2c_read8()               // read 8 bit from I2C
  - void i2c_stop()               // end the I2C read
  - void report_touch(id, x, y)   // set the touch sensing registers
  - int getINT()                  // get the INT input
  - void setINT(u)                // set INT open-drain
  - void setWAKE(u)               // set WAKE output
  - int getCYA()                  // get the CYA register value
*/


/* This code assumes CTP reports n_touches = 0 during last touch interrupt at finger-up */
int i2c_addr()
{
  return 0x38;
}

int setup()
{
  setWAKE (0);
  delay_ms(3);
  setWAKE (1);
  delay_ms(300);
}

//void rtouch()
//{
//  int x    = i2c_read16be() & 0xFFF;
//  int id_y = i2c_read16be();
//
//  report_touch(id_y >> 12, x, id_y & 0xFFF);
//}
//
//void loop()
//{
//  while (getINT() == 1) // wait for INT to go low
//    ;
//
//  i2c_startread(0x02);
//
//  int n_touches = i2c_read8();
//
//  while (n_touches != 0) {
//    rtouch();
//    n_touches = n_touches - 1;
//  }
//
//  i2c_stop();
//}

So loop() is mandatory.  :(

@BRT Community

Is it possible to post the source code of the ROM-micro-code for the GT911 ?

Greetz,
Karst
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: BRT Community on December 01, 2021, 04:31:35 PM
Hello Karst,

I will contact the developers to see if they can provide the GT911 source code.

Although if you are only trying to alter one register setting in the GT911 you could try the following method denoted in section 4.8.6 of the BT81x datasheets:

Code: [Select]
- Hold the touch engine in reset (set REG_CPURESET = 2)
- Write the CTPM configure register address and value to the BT815 designated memory location
- Up to 10 register address/value can be added
- Release the touch engine reset (set REG_CPURESET = 0)

Best Regards,
BRT Community
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: karst.drenth on December 02, 2021, 03:42:59 PM
Hi,

Thanks @BRT Community

That is exactly what I planned to do :)

But...

"...Write the CTPM configure register address and value to the BT815 designated memory location..."

Big question: Which is BT815 designated memory location ??  ;)

Greetz,
Karst

P.S. my "problem" is no longer urgent, since I switched to another Display which has a way better CTP ;) But it will emerge again at the moment I want to (re-)use the old display
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: BRT Community on December 02, 2021, 03:59:12 PM
Hello,

I am just waiting on the developers clarifying exactly which memory location is the correct designation, however I believe that RAM_JTBOOT is the intended location (30 B000h to 30 B7FFh).

Please see below for an example:

Code: [Select]
#define FW_RD(a) VC.rd16(RAM_JTBOOT + 2 * (a))
#define FW_WR(a, v) VC.wr16(RAM_JTBOOT + 2 * (a), (v))
void init_custom_touch(size_t num_regs, uint8_t *reg_value)
{
 while (VC.rd(REG_CPURESET) != 0)
 ;
 VC.wr(REG_CPURESET, 2);
 uint16_t main = FW_RD(0) & 0xfff;
 uint16_t i_set = 0x4000 | (main - 4);
 uint16_t patch = main + 1;
 uint16_t i_eol = FW_RD(patch);
 while (num_regs--) {
 uint8_t reg = *reg_value++;
 uint8_t val = *reg_value++;
 FW_WR(patch++, 0x8000 | val);
 FW_WR(patch++, 0x8000 | reg);
FW_WR(patch++, i_set);
 }
 FW_WR(patch, i_eol);
 VC.wr(REG_CPURESET, 0);
}

Best Regards,
BRT Community
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: BRT Community on December 06, 2021, 02:40:54 PM
Hello,

I have had it confirmed from the development team that RAM_JTBOOT is the correct memory location.


Best Regards,
BRT Community
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: karst.drenth on December 09, 2021, 09:15:01 AM
Hi,

Thanks for the info (y)

I will try and let you know the result :)

Greets,
Karst
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: david on April 22, 2022, 10:39:25 AM
Hi David,
Just to update you, we tried your code and could see the same result, we're just investigating and will post an update soon,
Best Regards, BRT Community

Did you get any response about that?
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: BRT Community on May 02, 2022, 08:58:56 AM
Hi David,

Which model of CTP are you currently using for your testing?

Best Regards, BRT Community
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: david on May 02, 2022, 03:12:01 PM
I used the Ili2511, but also tried without any touch controller and just used fixed numbers instead of i2c connection which seemed also not to work (Described it in the first post of this thread).
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: david on May 10, 2022, 06:45:09 AM
This really gets frustrating at some point, I am waiting for an answer for close to one year now. Besides the initials answer that you could reproduce it on your side I never got something back. Could you please check that? If it is reproducable on your side, it would help a lot to know if this feature is not working at all or if there are just specific cases. I provided test code without any specific hardware needed to reproduce the issue.
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: BRT Community on May 10, 2022, 03:42:37 PM
Hi David,

Sorry for the delay in replying,

We did a further test with a code snippet based on your earlier test and we could see the correct coordinates.
This was with BT817, we will check with BT815 too.

The code used was:

Code: [Select]
int i2c_addr()
{
  return 0x38; // does not matter for my test
}

int setup()
{
  setWAKE(0);
  delay_ms(5);
  setWAKE(1);
  delay_ms(300);
}

void loop()
{
      report_touch(0, 400, 300);
      delay_ms(5); // also tried without those delays and with id 1 as well
      //report_touch(0, 200, 100);
      //delay_ms(5);
}

The application code used was:

Code: [Select]
    uint32_t CoordX = 0;
    uint32_t CoordY = 0;
    uint32_t Coord = 0;

    while(1)
    {
  EVE_LIB_BeginCoProList();                                             
  EVE_CMD_DLSTART();                                                   

  EVE_CLEAR_COLOR_RGB(0, 0, 0);                                           
  EVE_CLEAR(1,1,1);                                                       

  EVE_CMD_TEXT(10, 320, 28, EVE_OPT_FORMAT, "X is %d", CoordX);
  EVE_CMD_TEXT(10, 340, 28, EVE_OPT_FORMAT, "Y is %d", CoordY);

  EVE_DISPLAY();                                                         
  EVE_CMD_SWAP();                                                         

  EVE_LIB_EndCoProList();                                                 
  EVE_LIB_AwaitCoProEmpty();                                             

  Coord = HAL_MemRead32(EVE_REG_CTOUCH_TOUCH0_XY);
  CoordY = (Coord & 0xFFFF);
  CoordX = ((Coord >>16) & 0xFFFF);
    }

Loading the custom code was similar to your description. We loaded it to the co-processor buffer after we had set up the display registers and displayed the first blank screen.

Could you advise if you see the same result if using the touch code and the application code above?
Here is the output:

X is 400
Y is 300


I'm afraid we don't have an ILI2511 available to do detailed debugging. However, as a first pass we think a custom touch code listing similar to this may work based on the datasheet:
If you are able to try it could you let us know how it reacts (and if possible to capture a logic analyser waveform of the I2C when pen-down and pen-up occur) and we can try to work towards getting it running on ILI2511.

Code: [Select]
void i2c_addr()
{
  return 0x41;
}

int setup()
{
  setWAKE(0);
  delay_ms(150);
  setWAKE(1);
  delay_ms(500);
}

void loop()
{
  while (getINT() == 1) // wait for INT to go low
    ;

  i2c_startread(0x10);

  int statusbyte = i2c_read8();

if (statusbyte != 0)
{

  int x0 = i2c_read16be();
  int y0 = i2c_read16be();
  int Pressure0 = i2c_read8();
  if ((x0 & 0x8000) == 0x8000)
    report_touch(0, (x0 & 0xfff), (y0 & 0xfff));

  int x1 = i2c_read16be();
  int y1 = i2c_read16be();
  int Pressure1 = i2c_read8();
  if ((x1 & 0x8000) == 0x8000)
    report_touch(1, (x1 & 0xfff), (y1 & 0xfff));

  int x2 = i2c_read16be();
  int y2 = i2c_read16be();
  int Pressure2 = i2c_read8();
  if ((x2 & 0x8000) == 0x8000)
    report_touch(2, (x2 & 0xfff), (y2 & 0xfff));

  int x3 = i2c_read16be();
  int y3 = i2c_read16be();
  int Pressure3 = i2c_read8();
  if ((x3 & 0x8000) == 0x8000)
    report_touch(3, (x3 & 0xfff), (y3 & 0xfff));

  int x4 = i2c_read16be();
  int y4 = i2c_read16be();
  int Pressure4 = i2c_read8();
  if ((x4 & 0x8000) == 0x8000)
    report_touch(4, (x4 & 0xfff), (y4 & 0xfff));
}
  i2c_stop();
  while (getINT() == 0); // wait for INT to go high

}



Best Regards, BRT Community
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: BRT Community on May 23, 2022, 10:34:12 AM
Hi David,

Unfortunately we have found that the custom touch code generated by the tool is not working correctly on BT815 and so is only running on BT817 at this time. It is under investigation at the moment by the authors of the tools. Do you have a BT817 available in order to try your code?

Sorry for the inconvenience caused,

Best Regards, BRT Community
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: david on May 30, 2022, 09:11:49 AM
Thanks for the answer. I will try to test it with a BT817 in the future. In the past I just used the BT815 for testing the touch firmware update. It would be fine for me, if it just works with BT817. I will switch to the newer version then.
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: david on June 03, 2022, 03:58:14 PM
I was able to test it with a BT817 now and the updating of the firmware works for me. So it seems to be an issue just on the BT815. I was able to run my old test code with fixed values and also to test it with another touch controller (to read out a register). So I am fine with just using the BT817 in the future then. For the BT815 I will fallback to host mode.
Title: Re: Updating Capacitive Touch Controller Firmware of BT815
Post by: BRT Community on June 07, 2022, 03:39:37 PM
Hi David,

Great to hear that it is working well on your BT817 and thanks for letting us know,

We will investigate the issue on BT815 compiler too

Best Regards, BRT Community