marmolak / gray386linux

Linux distribution for i386 machines only.
BSD 2-Clause "Simplified" License
73 stars 5 forks source link

Pocket386 - It seems like the keyboard doesn't work. #4

Open marmolak opened 3 months ago

marmolak commented 3 months ago

Based on: https://github.com/marmolak/gray386linux/issues/3#issuecomment-2077724725

It seems like the keyboard doesn't work.

According datasheets of M6117, there is keyboard controller in SoC which should be compatible with 8042 controller (hope I have right datasheet - i don't have access to device).

Original linux for M6117 is still around, but it's build on 2.4 kernel so kernel config file looks very different. Original linux for M6117: https://www.dmp.com.tw/tech/os-xlinux/r54.htm

Note: i8042 have some nice kernel options:

       i8042.debug    [HW] Toggle i8042 debug mode
        i8042.direct    [HW] Put keyboard port into non-translated mode
        i8042.dumbkbd   [HW] Pretend that controller can only read data from
                             keyboard and cannot control its state
                             (Don't attempt to blink the leds)
        i8042.noaux     [HW] Don't check for auxiliary (== mouse) port
        i8042.nokbd     [HW] Don't check/create keyboard port
        i8042.noloop    [HW] Disable the AUX Loopback command while probing
                             for the AUX port
        i8042.nomux     [HW] Don't check presence of an active multiplexing
                             controller
        i8042.nopnp     [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX
                             controllers
        i8042.notimeout [HW] Ignore timeout condition signalled by controller
        i8042.reset     [HW] Reset the controller during init and cleanup
        i8042.unlock    [HW] Unlock (ignore) the keylock
Doridian commented 3 months ago

Just grabbed the M6117 Linux from that site and loaded it with loadlin, and, indeed, the keyboard does work now. However, the below message in that Linux's dmesg confuses me. How is the keyboard working if it timed out?

IMG_1390

//EDIT: Hopefully I'll be able to be more helpful with the modern kernel once my ISA serial adapter arrives, such that I can hopefully get a serial console up to actually run commands on the keyboard-less linux

marmolak commented 3 months ago

Hello. I enabled XT keyboard and PS/2 mice support.

You can find it here (sorry for zipped file of already bzipped kernel image, but github is github :)): bzImage.zip

Also I found some interesting keyboard issues here: https://forum.vcfed.org/index.php?threads/pocket-386.1247640/#post-1380143

Doridian commented 3 months ago

@marmolak Sadly, this kernel still does not make the internal keyboard work. I have a PS/2 keyboard coming in to test with the external adatper (as none of my keyboards seem to work with a USB to PS/2 adapter at all).

marmolak commented 3 months ago

Thank you for test.

Would be possible to dump full dmesg output from: 1) xlinux from vendor 2) gray386linux

?

Not sure how to evade it from system itself.

Doridian commented 3 months ago

@marmolak I think with the XLinux rootfs and your kernel I can probably make an init script that puts the dmesg on the DOS FAT partition....Please stand by

Doridian commented 3 months ago

Mh, this kernel seems to be ignoring basically all command line args I'm trying to pass into it. Not sure what's going on

Doridian commented 3 months ago

I have modified the rc file to mount a partition and copy the dmesg in. Here you go!

gray386linux: dmesg-gray386.log xlinux: dmesg-xlinux.log

gray386linux with i8042.debug=1 i8042.reset=1 dmesg-gray386-debug.log

marmolak commented 3 months ago

Hi. Wow. Thank you very much.

Here is kernel with new features:

+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
+CONFIG_PCSPKR_PLATFORM=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_COMPAT_BRK=y
+CONFIG_RT_MUTEXES=y
+CONFIG_VM86=y
+CONFIG_PNPBIOS=y
+CONFIG_PNPBIOS_PROC_FS=y
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_EVDEV=y
+CONFIG_KEYBOARD_XTKBD=y
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_PS2_ALPS=y
+CONFIG_MOUSE_PS2_LOGIPS2PP=y
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+CONFIG_MOUSE_PS2_TRACKPOINT=y
+CONFIG_MOUSE_SERIAL=y
+CONFIG_SERIO_CT82C710=y
+CONFIG_SERIO_PARKBD=y
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_DETECT_IRQ=y
+CONFIG_I8253_LOCK=y

I enabled 8250 irq sharing which is not set in gray but it's set in xlinux. Also wider support of pnp is enabled now. PS: some changes are not necessary for now, however I would like to release new build which is not that much featureless.

According to datasheets and message: [ 9.929086] serio: i8042 KBD port at 0x60,0x64 irq 1 seems like keyboard is detected, but not sure for now why it not working.

bzImage.zip

Doridian commented 3 months ago

@marmolak I wonder if the i8042 is only for the external PS/2 interface, and not the internal keyboard?

Either way, I tried your new kernel from the link and no change with the internal keyboard. Still waiting on the cheap PS/2 keyboard, I think it got stuck in shipping somewhere...

Doridian commented 3 months ago

Just reporting back here. My ISA serial adapter arrived and it works perfectly via console=ttyS0,115200 so now I have a workable shell on the device at least for debugging

Doridian commented 3 months ago

Finally, I have finally managed to figure it out! i8042.dumbkbd=1. Turns out when Linux tries to change the keyboard LEDs, this causes the controller to send the control to a real PS/2 keyboard, which isn't connected. So i8042 times out and never works. Disabling the LED control like this makes the keyboard work perfectly. I assume i8042.notimeout to work similarly.

The reason I fianlly tried this? I noticed that in X-Linux whenever I accidently hit capslock, the keyboard stopped responding for a short bit and I got timeouts in dmesg. So eventually I realized "what if this is all just the LED control, this laptop doesn't have built-in keyboard LEDs sooo...."

marmolak commented 2 months ago

Wow. Great finding! I can try to set i8042.notimeout on a real 386 machine, do some research and then I can build in this into kernel as a default kernel cli.

marmolak commented 2 months ago

Hey cool.

Based on: https://lkml.iu.edu/hypermail/linux/kernel/1102.1/03252.html

It looks like I can add to drivers/input/serio/i8042-x86ia64io.h 589: static const struct dmi_system_id __initconst i8042_dmi_notimeout_table[] = {

and there is will be quirk for this system forever.

Would you please provide something like:

                /* Dell Vostro V13 */
                .matches = {
                        DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
                        DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V13"),
                },

? Hope it can be found in /proc/ or I can try to compile dmidecode and provide it.

Doridian commented 2 months ago

After some more testing, it seems like (sadly) notimeout does not fix it. Only dumbkbd does. Linux seems to really get hung up trying to set the keyboard's lights if it isn't explicitly told not to... The old 2.6 driver of X-Linux seems to eventually just time out and give up after like 5-10 seconds, but not this one...

Doridian commented 2 months ago

@marmolak Does this kernel support /sys? None of the ways I know how to write mount -t sysfs sysfs /sys works? If I can get /sys mounted I should be able to get DMI/HW info out

marmolak commented 2 months ago

Hello.

sysfs wasn't enabled.

I just added sysfs and, for example, the PC speaker to the newest build. It's enjoyable to delve into history, especially since there's no DMI available. Now, we need to figure out how to identify this pocker386 machine so that I can attempt to create a kernel patch.

Alternatively, documenting this could serve as a short-term solution.

Doridian commented 2 months ago

@marmolak Okay, now /sys is mounted, but /sys/firmware is entirely empty. Is this also a missing driver, like DMI/ACPI or something? Does that even exist on 386-class machines?

marmolak commented 2 months ago

There is no DMI on 386 class machines.

Just idea: @Doridian Are you able to dump BIOS of Pocket386 machine and provide it? For example debug.com from DOS can be used.

Or maybe I can enable and provide /dev/mem which should contain BIOS memory block. I would like to try searching for uniq string (ideally something like Pocket386) from kernel itself and change flags in i8042 driver if Pocket386 were detected.

Doridian commented 2 months ago

I followed this instruction I found here: http://mess.redump.net/dumping/dump_bios_using_debug The first part produces two files, which I've attached as a zip here so GitHub doesn't mangle anything

Archive.zip

marmolak commented 2 months ago

Thank you very much.

I found some interesting strings:

ALI M6117

ALI M6117

AMIBIOS 0626    07/15/95(C)1996 American Megatrends Inc., All Rights Reserved
(C)1996 American Megatrends Inc.,
50-0505-004444-01010111-071595-ALI6117
000-0-0000-00-00-0000-00-00-000
000-0-0000-00-00-0000-00-00-00-7
_TG_001_10_CHIPSET
AMIBIOS (C)1996 American Megatrends Inc.,

50-0505-004444-01010111-071595-ALI6117 seems promising, however I'm not sure if every Pocket386 device have same id (should have).

EDIT: Found list of boards: https://theretroweb.com/bios/?chipsetId=182

Another thing is, that I would like to wait for external PS/2 keyboard, because this quirk can affect how external keyboard work (no LEDs).

Doridian commented 2 months ago

@marmolak So with a PS/2 keyboard, as expected, I do not need the dumbkbd flag. And when I type on the onboard keyboard with an external connected, I get "Spurious ACK" alerts, so I assume the internal keyboard just injects events into the i8042 controller or something

marmolak commented 2 months ago

Hello.

https://github.com/marmolak/gray386linux/commit/b52211719d2d116fd479e223ad3e118c00ee315d contains note for pocket386 users.

According to scheme here: http://www.8086cpu.com/lm4/100.html

Internal keyboard is connected directly to: STC8G2K32S2 and then it should lead to M6117 SOC. It doesn't look like there is another logic for external keyboard so maybe it's just 2 keyboards work at a same time.