Touchpad, Keyboard, I2C oh my.
#13
(01-15-2020, 05:17 PM)resistanceisfutile Wrote: How I suspect the keyboard and touchpad firmware update process works:
  1. A firmware fw_tp_update.hex is flashed to the SH68F83. This firmware appears to be named XW-TPUTOOL_TV3-US-H1-12-00.
  2. The touchpad update firmware receives tpfw.bin over USB and then flashes it to the touchpad IC (likely over i2c at 400KHz, but could be some OOB bitbang over the i2c bus)
  3. The fw_ansi.hex or fw_iso.hex are then flashed back to the SH68F83.
According to the SH68F83 datasheet, two flashing modes are described. ICP (JTAG) after an undocumented waveform is modulated - followed by the flash - the protocol also undocumented. Another mode, SSP (Self-Sector Programming) is described. This mode is performed by code running on the 8051 MCU, and would thus require said code to be part of the firmware image.
Dissassembly of the 8051 code in the available images has so far been fruitless. The SH68F83 has many application-specific SFRs that - while listed in the datasheet - do not appear in any of the dissassemblies I have tried (after modifying a disassembler to print their names).

If SSP mode is being used, then there should be code in the firmware images that more or less does the following:
  • Get a block of data from the USB transceiver. Using the TX* and RX* SFRs.
  • Fill XPAGE, IB_OFFSET, and IB_DATA SFRs with the flash sector, offset into the sector, and data to write.
  • Kick off a state "gate" by sequentially filling IB_CON1, IB_CON2, IB_CON3, IB_CON4, and IB_CON5 with a magic numbers.
Another theory is that there is perhaps an undocumented USB flashing mode and the updater tool (which I've been told was derived from a mysterious reverse-engineered? windows-based flash tool).

I've been attempting to understand the disassembled firmware and have made some progress in understanding the update mechanism. I'm documenting in detail what I've done in my fork of Jack Humbert's fork of the keyboard updater utility where he started doing some disassembly and reverse engineering mostly to understand the keycodes and generate custom mappings.

I've determined that 0x3000 - 0x4000 in the keyboard firmware is responsible for handling the firmware updates and specifically the function at 0x3D3C starts the SSP mode, going through all the IB_CON steps. I'm trying to get a better idea of the whole update procedure before I go on trying to understand the touchpad communication  since the update mechanism will determine how risky updating the firmware with custom code will be. Having access to the ICP documentation would definitely make this less necessary but right now I feel this is the only way to determine how easily we can test new firmware that touches actual logic (as opposed to just the mostly data patches made so far by Jack Humbert) without bricking the keyboard and touchpad.


Messages In This Thread
RE: Touchpad, Keyboard, I2C oh my. - by C_Elegans - 01-15-2020, 06:03 PM
RE: Touchpad, Keyboard, I2C oh my. - by C_Elegans - 01-15-2020, 06:33 PM
RE: Touchpad, Keyboard, I2C oh my. - by C_Elegans - 01-16-2020, 10:03 AM
RE: Touchpad, Keyboard, I2C oh my. - by C_Elegans - 01-16-2020, 12:01 PM
RE: Touchpad, Keyboard, I2C oh my. - by akirakyle - 04-05-2020, 08:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Yet another new Pinebook keyboard problem MikoBob 3 386 09-11-2024, 07:05 AM
Last Post: MikoBob
  Pinebook Pro Revised Keyboard Firmware jackhumbert 73 145,779 09-13-2023, 03:43 AM
Last Post: k3dAR
  Separate ISO keyboard for PBP Besouro 0 998 06-04-2023, 02:51 PM
Last Post: Besouro
  Touchpad Issues - August 2022 Run SteveCaruso 5 3,637 12-14-2022, 11:00 PM
Last Post: doug
Information Keyboard Duplicate Keypress Fix RjraymondDuplicate 0 1,278 02-17-2022, 11:52 PM
Last Post: RjraymondDuplicate
  keyboard and usb ports not working User 24565 3 3,181 02-15-2022, 10:12 AM
Last Post: wdt
  Replacing the Keyboard gabb 6 7,389 01-11-2022, 07:39 AM
Last Post: Valenoern
  power on PBP if your keyboard is dead? stozi 0 1,526 11-29-2021, 01:55 PM
Last Post: stozi
  Replacement scissor switches (ANSI keyboard)? zackw 3 4,409 08-09-2021, 09:20 PM
Last Post: tllim
  Touchpad notchy on new 2021 pinebook pro Neilcob 21 22,462 07-28-2021, 09:14 AM
Last Post: dsimic

Forum Jump:


Users browsing this thread: 1 Guest(s)