From 75b06ac90a0da735fc5db422a24deeb4ce5fafea Mon Sep 17 00:00:00 2001 From: chriz Date: Tue, 10 Feb 2026 22:52:03 +0100 Subject: [PATCH 1/7] Add support for HiSource K0402WS-V3.0 --- machine.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- machine.h | 1 + 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/machine.c b/machine.c index 460dae1..bb164c5 100644 --- a/machine.c +++ b/machine.c @@ -2,6 +2,7 @@ #include "rtl837x_pins.h" #include "rtl837x_leds.h" #include "rtl837x_regs.h" +#include "rtl837x_common.h" #ifdef MACHINE_KP_9000_6XHML_X2 __code const struct machine machine = { @@ -231,4 +232,53 @@ __code const struct machine machine = { void machine_custom_init(void) { } -#endif +#elif defined MACHINE_HI_K0402WS +__code const struct machine machine = { + .machine_name = "HiSource HI-K0402WS", + .isRTL8373 = 0, + .min_port = 3, + .max_port = 8, + .n_sfp = 2, + .log_to_phys_port = {0, 0, 0, 6, 1, 2, 3, 4, 5}, + .phys_to_log_port = {4, 5, 6, 7, 8, 3, 0, 0, 0}, + .is_sfp = {0, 0, 0, 2, 0, 0, 0, 0, 1}, + + // Left SFP port + .sfp_port[0].pin_detect = GPIO38, + .sfp_port[0].pin_los = GPIO_NA, + .sfp_port[0].sds = 1, + .sfp_port[0].i2c = { .sda = GPIO39_I2C_SDA4, .scl = GPIO40_I2C_SCL3_MDC1 }, + + // Right SFP port + .sfp_port[1].pin_detect = GPIO37, + .sfp_port[1].pin_los = GPIO_NA, + .sfp_port[1].sds = 0, + .sfp_port[1].i2c = { .sda = GPIO41_I2C_SDA3_MDIO1, .scl = GPIO40_I2C_SCL3_MDC1 }, + + .reset_pin = GPIO_NA, + .high_leds = { .mux = LED_28 | LED_29, .enable = LED_27 | LED_28 | LED_29 }, + .port_led_set = { 0, 0, 0, 1, 0, 0, 0, 0, 1}, + .led_sets = { + { + LEDS_2G5 | LEDS_LINK | LEDS_10M | LEDS_ACT, + LEDS_1G | LEDS_100M | LEDS_10M | LEDS_LINK | LEDS_ACT | LEDS_10G, + LEDS_1G | LEDS_LINK, + 0 + }, + { + LEDS_10G | LEDS_2G5 | LEDS_1G | LEDS_100M | LEDS_10M | LEDS_LINK, + LEDS_10G | LEDS_2G5 | LEDS_1G | LEDS_100M | LEDS_10M | LEDS_ACT, + 0, + 0 + }, + }, + .led_mux_custom = 1, + .led_mux = { + 0x00,0x01,0x04,0x05,0x08,0x09,0x0c,0x3f,0x0d,0x10,0x11,0x0e,0x14,0x11,0x12,0x15,0x15,0x16,0x18,0x19,0x1a,0x19,0x1d,0x1e,0x1c,0x1d,0x20,0x21 + }, + }; + +void machine_custom_init(void) { + reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6); +} +#endif \ No newline at end of file diff --git a/machine.h b/machine.h index cba1ac8..1d4cf76 100644 --- a/machine.h +++ b/machine.h @@ -13,6 +13,7 @@ // #define MACHINE_HORACO_ZX_SG4T2 // #define MACHINE_TRENDNET_TEG_S562 // #define MACHINE_HG0402XG_V1_1 +// #define MACHINE_HI_K0402WS // #define DEFAULT_8C_1SFP // #define DEFAULT_5C_1SFP From 98f3f15e7e3fa9efe1a752bbb7499b2209e15790 Mon Sep 17 00:00:00 2001 From: chriz Date: Wed, 11 Feb 2026 20:03:22 +0100 Subject: [PATCH 2/7] Fix sfp marker. --- machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine.c b/machine.c index ca394af..44868cb 100644 --- a/machine.c +++ b/machine.c @@ -275,7 +275,7 @@ __code const struct machine machine = { .n_sfp = 2, .log_to_phys_port = {0, 0, 0, 6, 1, 2, 3, 4, 5}, .phys_to_log_port = {4, 5, 6, 7, 8, 3, 0, 0, 0}, - .is_sfp = {0, 0, 0, 2, 0, 0, 0, 0, 1}, + .is_sfp = {0, 0, 0, 1, 0, 0, 0, 0, 1}, // Left SFP port .sfp_port[0].pin_detect = GPIO38, From a2ce5550fcbd5fa435ab81ba023cae3d8bc5fd57 Mon Sep 17 00:00:00 2001 From: chriz Date: Wed, 11 Feb 2026 22:30:40 +0100 Subject: [PATCH 3/7] Add documentation file. --- doc/devices/HI-K0402WS.md | 59 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 doc/devices/HI-K0402WS.md diff --git a/doc/devices/HI-K0402WS.md b/doc/devices/HI-K0402WS.md new file mode 100644 index 0000000..cf49bfd --- /dev/null +++ b/doc/devices/HI-K0402WS.md @@ -0,0 +1,59 @@ +# Hisource Hi-KO4022WS + +Following is documentation for unmanaged switch marked as `Hi-KO4022WS` . +Original software is running UART on 9600 baud rate. +Using SPI clamp in-board is the only method for initial installation. + +The board has two flash chips `BY25Q16BS` with 16M-bit size. The front switch, switches between the two flash chips. +These can be programed independently by using said switch - so it is e.g. possible to run the original and new firmware in parallel. + +### Label specifications + +- **Name**: 2.5G Ethernet Switch +- **Model**: Hi-KO4022WS +- **Ports**: + - 4 × RJ45: 10/100/1000/2500 Mbps + - 2 × SFP: 1000 / 2500 / 10000 Mbps + +### What works (expected from label + similar devices) + +- All four 2.5GBASE-T RJ45 ports at 10/100/1000/2500 Mbps +- Both SFP ports supporting 1G, 2.5G and 10G modules +- LEDs + +### PCB overview + +**Board markings** +- Top silkscreen: PCB-KO4022W-V3.0 / DIP-KO4022WS-V3.0 + +Top side + + + +Bottom + + + +### T2, serial console + +| `J2` pin | Signal | +| -------- | ----------- | +| 1 | 3V3 | +| 2 | RX (Input) | +| 3 | TX (Output) | +| 4 | GND | + + +## Power supply + +Input power is delivered via barell plug, `12V 1A` adapter was provided. +Board has two supply rails. `0.95` and `3.3` volt. + +### `0.95` Core Voltage + +Voltage is made by a `Techcode TD1720` . + +### `3.3` Voltage + +Voltage is created by chip marked as `Techcode TD1720`. +There seems to have been a miscalculation when choosing the inductor and the device is ~25% more efficient with an 5V power supply. \ No newline at end of file From bea162962e3f814b56a57504562b9d1cffda9d27 Mon Sep 17 00:00:00 2001 From: TylerDurden-23 Date: Wed, 11 Feb 2026 22:32:37 +0100 Subject: [PATCH 4/7] Correct model name in HI-K0402WS documentation --- doc/devices/HI-K0402WS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/devices/HI-K0402WS.md b/doc/devices/HI-K0402WS.md index cf49bfd..0b8c869 100644 --- a/doc/devices/HI-K0402WS.md +++ b/doc/devices/HI-K0402WS.md @@ -10,7 +10,7 @@ These can be programed independently by using said switch - so it is e.g. possib ### Label specifications - **Name**: 2.5G Ethernet Switch -- **Model**: Hi-KO4022WS +- **Model**: Hi-K0402WS - **Ports**: - 4 × RJ45: 10/100/1000/2500 Mbps - 2 × SFP: 1000 / 2500 / 10000 Mbps @@ -56,4 +56,4 @@ Voltage is made by a `Techcode TD1720` . ### `3.3` Voltage Voltage is created by chip marked as `Techcode TD1720`. -There seems to have been a miscalculation when choosing the inductor and the device is ~25% more efficient with an 5V power supply. \ No newline at end of file +There seems to have been a miscalculation when choosing the inductor and the device is ~25% more efficient with an 5V power supply. From 9918a6267ca56fd77f97d9d8b0ddac7b619a3f7e Mon Sep 17 00:00:00 2001 From: TylerDurden-23 Date: Wed, 11 Feb 2026 22:33:02 +0100 Subject: [PATCH 5/7] Update documentation for Hi-KO4022WS switch Added information about UART baud rate and installation method. --- doc/devices/HI-K0402WS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/devices/HI-K0402WS.md b/doc/devices/HI-K0402WS.md index 0b8c869..9feadef 100644 --- a/doc/devices/HI-K0402WS.md +++ b/doc/devices/HI-K0402WS.md @@ -1,7 +1,9 @@ # Hisource Hi-KO4022WS -Following is documentation for unmanaged switch marked as `Hi-KO4022WS` . +Following is documentation for unmanaged switch marked as `Hi-KO4022WS`. + Original software is running UART on 9600 baud rate. + Using SPI clamp in-board is the only method for initial installation. The board has two flash chips `BY25Q16BS` with 16M-bit size. The front switch, switches between the two flash chips. From 3e1031b0f09194e441119fc3f94dfb8595432134 Mon Sep 17 00:00:00 2001 From: TylerDurden-23 Date: Wed, 11 Feb 2026 22:33:59 +0100 Subject: [PATCH 6/7] Highlight efficiency with 5V power supply Emphasize the efficiency improvement with 5V power supply. --- doc/devices/HI-K0402WS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/devices/HI-K0402WS.md b/doc/devices/HI-K0402WS.md index 9feadef..3062584 100644 --- a/doc/devices/HI-K0402WS.md +++ b/doc/devices/HI-K0402WS.md @@ -58,4 +58,5 @@ Voltage is made by a `Techcode TD1720` . ### `3.3` Voltage Voltage is created by chip marked as `Techcode TD1720`. -There seems to have been a miscalculation when choosing the inductor and the device is ~25% more efficient with an 5V power supply. + +**There seems to have been a miscalculation when choosing the inductor and the device is ~25% more efficient with an 5V power supply.** From 8bd07ee6493c10a719640964c1757e35440e1015 Mon Sep 17 00:00:00 2001 From: TylerDurden-23 Date: Wed, 11 Feb 2026 22:34:55 +0100 Subject: [PATCH 7/7] Correct device name from Hi-KO4022WS to Hi-K0402WS --- doc/devices/HI-K0402WS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/devices/HI-K0402WS.md b/doc/devices/HI-K0402WS.md index 3062584..15b62a0 100644 --- a/doc/devices/HI-K0402WS.md +++ b/doc/devices/HI-K0402WS.md @@ -1,6 +1,6 @@ -# Hisource Hi-KO4022WS +# Hisource Hi-K0402WS -Following is documentation for unmanaged switch marked as `Hi-KO4022WS`. +Following is documentation for unmanaged switch marked as `Hi-K0402WS`. Original software is running UART on 9600 baud rate.