Skip to content

Captures and replays signals on a PS/2 interface (DATA and CLOCK lines). A "capture" is a sequence of GPIO readings taken at short intervals, effectively logging the entire timeline of PS/2 pin states during recording. Each capture can be replayed - emulating the original signal.

License

Notifications You must be signed in to change notification settings

therealdreg/pico-ps2-diagnostic-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pico-ps2-diagnostic-tool

Tool designed to capture and replay signals on a PS/2 interface, specifically targeting the DATA and CLOCK lines.

In the image above, the top section displays the original PS/2 signals from a keyboard, while the bottom section shows the replayed signals previously stored in flash memory on the Raspberry Pi Pico. A short pulse was captured on the original CLOCK signal, and the replayed signal successfully reproduced it.

A "capture" refers to a sequence of GPIO readings taken at short intervals, effectively logging the entire state timeline of the PS/2 pins during the recording session. These captures can be replayed to emulate the original signals, stored in flash memory, deleted, or exported for further analysis.

The tool supports multiple captures in flash memory, enabling operations such as recording, replaying, deleting, importing, and exporting. This makes it a versatile diagnostic solution for analyzing PS/2 device signals or debugging signal issues.

The captures can be exported from the Raspberry Pi Pico flash to COM port and new captures can be imported from the PC to the Raspberry Pi Pico internal flash through the COM port.

Additionally, the tool includes a glitch detector that monitors and flags extremely short pulses on the PS/2 clock line. (made by some PS2-USB adapters)


I developed this project to assist my customers in providing more detailed reports about the behavior of problematic PS/2-to-USB adapters, including glitches and other anomalies, for my okhi project (Open Keylogger Hardware Implant – USB & PS/2 Keyboards) https://github.com/therealdreg/okhi

Download last firmware

Download the latest firmware from the releases section:

https://github.com/therealdreg/pico-ps2-diagnostic-tool/releases/latest

Flashing the firmware

To flash the firmware, you need to put the Raspberry Pi Pico in bootloader mode. To do this, press and hold the button while connecting the USB cable to the PC. The Pico will appear as a USB mass storage device. Drag and drop the "pico_ps2_diagnostic_tool.uf2" firmware file to the Pico.

Requirements

To record PS/2 signals, you will need a Raspberry Pi Pico (or my okhi implant) with the following connections:

  • DATA on GPIO20
  • CLOCK on GPIO21

To replay these signals, use the following connections:

  • DATA on GPIO0
  • CLOCK on GPIO1

Example of use

Connect to the COM port of the Raspberry Pi Pico and run the following commands. Use Windows Device Manager to identify the correct COM port. (Baud Rate 9600, 8 data bits, 1 stop bit, no parity, no flow control):

pico_ps2_diagnostic_tool started! v1 Build Date Jan 27 2025 12:07:25
https://github.com/therealdreg/pico-ps2-diagnostic-tool
MIT License David Reguera Garcia aka Dreg
X @therealdreg [email protected]
---------------------------------------------------------------
overclocked 250mhz: false
Total captures stored in flash: 10
-
Options:
0: Glitch detector
1: Record, replay and store
2: Delete all captures stored in flash
3: Play all captures stored in flash
4: Export all captures stored in flash
5: Play one capture stored in flash
6: Import all captures to flash
7: Nuke PICO FLASH (erase full flash)
8: Enable/Disable Overclock 250mhz

Capturing and replaying signals

Select option 1 to record, replay, and store captures.

Quickly press the Caps Lock key on the PS/2 keyboard multiple times to generate several captures.

The captures are now stored in the Raspberry Pi Pico flash memory.

To replay the captures, select option 3.

Exporting captures

To export the captures to the COM port, first select File -> Log in Tera Term:

  • New / Overwrite
  • Text
  • Plain Text

Click OK.

Then, select menu option 4. This option exports all captures stored in the Raspberry Pi Pico flash memory to the COM port (as C arrays). You can send these captures to me for further analysis.

Checking the exported captures

Ensure that the exported capture adheres to the correct format before sending. Verify the captures using the check/check.py script (requires Python 3).

Run the script as follows:

python check.py exported_captures.txt

If you receive this output:

OK: All lines have the correct size.

Exported captures are correct. If you encounter an "ERROR" message, it indicates that the captures are incorrect, and you should re-export them with overclocking enabled. In some cases, you may need to export several times to obtain a correct export.

NOTE: Connect the Raspberry Pi Pico directly to the PC using a short, high-quality USB cable. Avoid using USB hubs.

Importing captures

To import captures from the PC to the Raspberry Pi Pico internal flash through the COM port, select option 6.

You can paste the C arrays from the exported captures into the terminal and send them to the Raspberry Pi Pico. However, it is better to use File -> Send File... in Tera Term.

  • Send in the same way as Tera Term 4

The file must contain the C arrays of the captures.

You can use the file stuff/samples.zip as an example.

Now you can replay the imported captures using option 3. (GPIO0 and GPIO1 is the replayed PS/2 interface)

PS2 Captures

For the okhi project, I have collected an extensive set of PS/2 captures from various motherboards, keyboards and PS/2-to-USB adapters. If you require PS/2 captures for testing purposes, feel free to use these samples.

https://github.com/therealdreg/okhi?tab=readme-ov-file#ps2-captures

Related

About

Captures and replays signals on a PS/2 interface (DATA and CLOCK lines). A "capture" is a sequence of GPIO readings taken at short intervals, effectively logging the entire timeline of PS/2 pin states during recording. Each capture can be replayed - emulating the original signal.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published