Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve guide for XH-HK4401 #1306

Open
Ultranium opened this issue Apr 21, 2024 · 1 comment
Open

Improve guide for XH-HK4401 #1306

Ultranium opened this issue Apr 21, 2024 · 1 comment

Comments

@Ultranium
Copy link

Ultranium commented Apr 21, 2024

I'd like to share my experience using what seems to be a slightly newer version of the XH-HK4401 4-port switch.

The main difference is it uses 3.3V non-inverted UART protocol for the remote control.
This is actually great, because it eliminates need of using an inverting FTDI adapter, and also allows to connect the switch control interface directly to Pi's UART without using any extra circuitry.

The markings on PCBs are:

  • HDMI switch board: PCB-HK4501-V0.2-A1-HDMI
  • USB/Control board: PCB-HK4401-V2.0-B-USB

Connecting this switch using the current guide for the XH-HK4401 won't work because of the different control interface implementation, so here are some instructions on how to do it.
I think, adding this information to the docs may help people with newer HK4401 switches.

Before interfacing the switch with Raspberry using the following guide, one should first check the voltage levels on the control interface, because the manufacturer can change the implementation at any moment!!! If you accidentally connect a 5V version to your Pi, you can permanently damage it!

Using with FTDI adapter

I successfully used a $1 fake FTDI adapter from Aliexpress which looks like this:

FTDI adapter

image

  1. Switch the jumper on the FTDI adapter to the position 3.3V
  2. Connect wires:
  • GND to USB GND (and shield, if present on cable)
  • TX to USB D- (white)
  • RX to USB D+ (green)
  1. Remount the filesystem in read-write mode using the rw command
  2. Append the following lines to /etc/kvmd/override.yaml:
override.yaml
kvmd:
    gpio:
        drivers:
            hk:
                type: xh_hk4401
                protocol: 2
                device: /dev/ttyAMA0
        scheme:
            ch0_led:
                driver: hk
                pin: 0
                mode: input
            ch1_led:
                driver: hk
                pin: 1
                mode: input
            ch2_led:
                driver: hk
                pin: 2
                mode: input
            ch3_led:
                driver: hk
                pin: 3
                mode: input
            ch0_button:
                driver: hk
                pin: 0
                mode: output
                switch: false
            ch1_button:
                driver: hk
                pin: 1
                mode: output
                switch: false
            ch2_button:
                driver: hk
                pin: 2
                mode: output
                switch: false
            ch3_button:
                driver: hk
                pin: 3
                mode: output
                switch: false
        view:
            table:
                - ["#Input 1", ch0_led, ch0_button]
                - ["#Input 2", ch1_led, ch1_button]
                - ["#Input 3", ch2_led, ch2_button]
                - ["#Input 4", ch3_led, ch3_button]

  1. Remount the filesystem back to read-only mode using the command ro
  2. Run systemctl restart kvmd

Using with direct UART connection

  1. Remount the filesystem in read-write mode using the rw command
  2. Remove the console=serial0,115200 parameter from /boot/cmdline.txt
  3. Append the following lines to /etc/kvmd/override.yaml:
override.yaml
kvmd:
    gpio:
        drivers:
            hk:
                type: xh_hk4401
                protocol: 2
                device: /dev/ttyAMA0
        scheme:
            ch0_led:
                driver: hk
                pin: 0
                mode: input
            ch1_led:
                driver: hk
                pin: 1
                mode: input
            ch2_led:
                driver: hk
                pin: 2
                mode: input
            ch3_led:
                driver: hk
                pin: 3
                mode: input
            ch0_button:
                driver: hk
                pin: 0
                mode: output
                switch: false
            ch1_button:
                driver: hk
                pin: 1
                mode: output
                switch: false
            ch2_button:
                driver: hk
                pin: 2
                mode: output
                switch: false
            ch3_button:
                driver: hk
                pin: 3
                mode: output
                switch: false
        view:
            table:
                - ["#Input 1", ch0_led, ch0_button]
                - ["#Input 2", ch1_led, ch1_button]
                - ["#Input 3", ch2_led, ch2_button]
                - ["#Input 4", ch3_led, ch3_button]

  1. Reboot
  2. Connect wires:
  • GPIO pin 6 to USB GND (and shield, if present on cable)
  • GPIO pin 8 to USB D- (white)
  • GPIO pin 10 to USB D+ (green)
@arch1mede
Copy link
Contributor

Hi, Thank you for this feedback, This has been added to the existing documentation as additional follow-up. This issue will be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants