geekhack Projects > Making Stuff Together!
Hacking HHKB Professional Classic
Applet:
Very exciting stuff! It would be fantastic if it is possible to run open source software TMK/QMK on the stock controller :D
Thanks for the work hasu!
crsayen:
--- Quote ---- Firmware update protocol of PFU tool
--- End quote ---
--- Code: ---private async Task<bool> FirmupSend(uint dataNumber, byte[] data)
{
KeyboardDriver keyboardDriver1 = this;
System.Diagnostics.Debug.WriteLine("[FirmupSend] 1");
dataNumber -= 2U;
data = ((IEnumerable<byte>) data).Skip<byte>(2).ToArray<byte>();
System.Diagnostics.Debug.WriteLine("[FirmupSend] 3");
uint numberOfPacket = (uint) ((int) dataNumber + 57 - 1) / 57U;
uint completedByteLength = 0;
for (ushort packetNumber = 0; (uint) packetNumber < numberOfPacket; ++packetNumber)
{
KeyboardDriver keyboardDriver = keyboardDriver1;
System.Diagnostics.Debug.WriteLine(string.Format("[FirmupSend] 4 ({0}", (object) packetNumber));
uint num1 = (uint) packetNumber * 57U;
uint num2 = (uint) (((int) packetNumber + 1) * 57);
if (dataNumber <= num2)
num2 = dataNumber;
uint length = num2 - num1;
byte[] input = new byte[ConstDefinition.BufferSizeUSB];
input[0] = input[1] = (byte) 170;
input[2] = (byte) 226;
input[4] = (byte) (length + 2U);
byte[] packetNumberByte = keyboardDriver1.toolUtility.ConvertUshortToBytes(packetNumber);
input[5] = packetNumberByte[0];
input[6] = packetNumberByte[1];
for (int index = 0; (long) index < (long) length; ++index)
input[7 + index] = data[(long) num1 + (long) index];
byte[] output = new byte[0];
System.Diagnostics.Debug.WriteLine(string.Format("[FirmupSend] 5 ({0}", (object) packetNumber));
await Task.Run((Action) (() => output = keyboardDriver.WriteReadCheck(input, new byte[6]
{
(byte) 85,
(byte) 85,
(byte) 226,
(byte) 0,
(byte) 0,
(byte) 2
}, "0xE2")));
System.Diagnostics.Debug.WriteLine(string.Format("[FirmupSend] 6 ({0}", (object) packetNumber));
if (output == null)
return false;
if ((int) output[6] != (int) packetNumberByte[0] || (int) output[7] != (int) packetNumberByte[1])
{
System.Diagnostics.Debug.WriteLine(string.Format("Keyboard Communication Error 0xE2 (format error)"));
System.Diagnostics.Debug.WriteLine(string.Format("receiveData = {0}", (object) BitConverter.ToString(output)));
return false;
}
completedByteLength += length;
int completedRate = 10 + (int) (completedByteLength * 80U / dataNumber);
keyboardDriver1.eventAggregator.GetEvent<NortificateFirmupProgressEvent>().Publish(new NortificateFirmupProgressEventEntity(completedRate));
packetNumberByte = (byte[]) null;
}
System.Diagnostics.Debug.WriteLine("[FirmupSend] 7");
return true;
}
--- End code ---
This looks like it gives a good idea of how the data is sent. Prior to sending firmware data, the tool sends this:
--- Code: ---private bool FirmupStart(uint firmSize, byte[] crc)
{
byte[] input = new byte[ConstDefinition.BufferSizeUSB];
input[0] = input[1] = (byte) 170;
input[2] = (byte) 225;
input[3] = (byte) 0;
input[4] = (byte) 8;
byte[] bytes = this.toolUtility.ConvertUintToBytes(firmSize);
for (int index = 0; index < 4; ++index)
input[5 + index] = bytes[index];
input[9] = crc[0];
input[10] = crc[1];
return this.WriteReadCheck(input, new byte[6]
{
(byte) 85,
(byte) 85,
(byte) 225,
(byte) 0,
(byte) 0,
(byte) 0
}, "0xE1") != null;
}
--- End code ---
and to finish the firmware upload:
--- Code: --- private bool FirmupEnd()
{
byte[] input = new byte[ConstDefinition.BufferSizeUSB];
input[0] = input[1] = (byte) 170;
input[2] = (byte) 227;
return this.WriteReadCheck(input, new byte[6]
{
(byte) 85,
(byte) 85,
(byte) 227,
(byte) 0,
(byte) 0,
(byte) 0
}, "0xE3") != null;
}
--- End code ---
I am looking into whether we can just trick the tool into uploading custom firmware for us.
If not, I will modify it to do so.
vffems2529:
Does this mean there is a chance of programmability of these boards (Hybrid/Classic) using VIA?
How can the community help with these efforts?
power_ranger:
Really awesome work! So is it possible to port QMK/TMK to the stock controller of Pro Classic?
hasu:
Yes
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version