randyrossi / bmc64

A bare metal Commodore 64 emulator for the Raspberry Pi with true 50hz/60hz smooth scrolling, low input latency and better audio/video sync.
GNU General Public License v3.0
474 stars 56 forks source link

C64 kb not working - Keyrah v3 + Rasp Pi 3B + BMC64 #235

Open yackx opened 1 year ago

yackx commented 1 year ago

Configuration: BCM64 3.9 running on Raspberry Pi 3B with a C64 keyboard attached to a Keyrah v3. The C64 LED flashes then stays on as BMC64 boots up to the READY prompt. But nothing happens when I type though.

But the combo Keyrah v3 + Rasp Pi 3B + BMC64 refuses to work.

No undervoltage warning (PSU 5.0V 3.6A).

I raised the issue on icomp.de and, in case it would be relevant, the following was pointed out:

Keyrah V3 implements a "HID device with multiple interfaces" (2 Keyboards, 2 Game controllers, 1 Multimedia Control, 1 ACPI Power Control) - so that is what BMC64 needs to support. If it can't deal with 2 Keyboards, it should probably ignore the second one (which will be used for n-key rollover, ie when you press many keys at the same time)

Is there any setting or config file I can adapt?

mcgurk commented 1 year ago

BMC64 supports only "HID device with single interface". And if I understand correctly, it is because BMC64 (like almost every Raspberry Pi baremetal project) uses Circle for RPi hardware access: https://github.com/rsta2/circle https://github.com/smuehlst/circle-stdlib

You can connect keyboard directly to gpio-pins: https://github.com/randyrossi/bmc64/blob/master/README.md#gpio-config-2--gpio-keyboard-and-joysticks Or make USB-adapter from Arduino: https://github.com/mcgurk/Arduino-USB-HID-RetroJoystickAdapter/tree/master/C64_keyboard

yackx commented 1 year ago

You can connect keyboard directly to gpio-pins

These are very neat projects, but as a matter of personal convenience, I'd prefer to use the Keyrah.

BMC64 supports only "HID device with single interface". And if I understand correctly, it is because BMC64 (like almost every Raspberry Pi baremetal project) uses Circle for RPi hardware access

In that case, I wonder if BMC64 or Circle could be patched or configured to use (or expose) only one interface? It would be nice if BMC64 and Keyrah v3 could play together. Any pointer in that direction would be welcome.

mcgurk commented 1 year ago

I have a feeling that USB without underlying operating system is very unefficient and complicated way to connect stuff. It is big thing to have any kind of support for USB-devices in baremetal environment. If support for multiple-interface-usb-devices would be easy, it probably would be done already. But this is just speculation and Circle is open source so anyone is free to do it.

Here is some instructions for debugging and testing: https://github.com/randyrossi/bmc64/issues/233#issuecomment-1481850909

And I found confirmation that support depends from Circle: https://github.com/randyrossi/bmc64/issues/211#issuecomment-1030945338

yackx commented 1 year ago

Thank you for the insights and the links. Obviously it is not trivial. "HID device with multiple interfaces" seems like a generic use case, so indeed someone would have done it already if it were easy.

Do you mind leaving this issue open for a bit, in case someone would make other suggestions?

randyrossi commented 1 year ago

I can take a look at what circle has in terms of support for multiple interfaces. It could be it's just using the last interface it finds. Might be difficult for me to test any changes though since I don't have a V3.

On Fri, May 12, 2023 at 1:47 AM Youri Ackx @.***> wrote:

Thank you for the insights and the links. Obviously it is not trivial. "HID device with multiple interfaces" seems like a generic use case, so indeed someone would have done it already if it were easy.

Do you mind leaving this issue open for a bit, in case someone would make other suggestions?

— Reply to this email directly, view it on GitHub https://github.com/randyrossi/bmc64/issues/235#issuecomment-1545200824, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3HKCBDNJ35VEMJPKPUKDXFXFI3ANCNFSM6AAAAAAX5F7K2Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Randy Rossi

yackx commented 1 year ago

My v3 is (remotely) at your disposal @randyrossi. Let me know what commands you want me to run (Win/Linux/macOS). I can build and test a patched version of BMC64 as well.

K-rnivoro commented 1 year ago

Give my project a try. It's far superior than Keyrah regarding Keyboard productivity. Foe example it also emulates Plus/4, C128 and PET, both business and graphics keyboard. BMC64 tested of course. www.pimmodore.com

ibisal commented 5 months ago

I also have the same problem: RPi3 + Keyrah v3 + BMC64 and the original C64 keyboard not working. I may test the BMC64 version with Keyrah v3 implementation in the future.

Kikkokat77 commented 5 months ago

Hi, are there any news about this issue?

DorkyHorse commented 5 months ago

I'd also like to offer my support for testing any change. I have RPi2 + Keyrah v3 + BMC64 plus original keyboard not working.

irtimiDo commented 3 months ago

hi, I have the same problem, raspy+keyrahv3+BMC64... I also tried to overwrite the vkm files in BMC64 with those of the Keyrah... but to no avail.

randyrossi commented 3 months ago

Would either of you be able to try this sample from the circle library?

https://github.com/rsta2/circle/tree/master/sample/08-usbkeyboard

It's a standalone kernel test program that exercises circle's usb keyboard support. Since BMC64 uses circle, it depends on that library's support for the device. It takes a bit of development experience to build and install though.

On Fri, Mar 29, 2024 at 5:06 AM Dimitri @.***> wrote:

hi, I have the same problem, raspy+keyrahv3+BMC64... I also tried to overwrite the vkm files in BMC64 with those of the Keyrah... but to no avail.

— Reply to this email directly, view it on GitHub https://github.com/randyrossi/bmc64/issues/235#issuecomment-2026914496, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3HKGSUJNYDG5TKIG7HN3Y2UOIXAVCNFSM6AAAAAAX5F7K22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRWHEYTINBZGY . You are receiving this because you were mentioned.Message ID: @.***>

-- Randy Rossi

irtimiDo commented 3 months ago

Hi, thanks for the answer to the problem, but I don't think I understood how to do with those files:

Makefile kernel.cpp kernel.h main.cpp

do I have to modify something or just copy them into a BMC64 directory?

(I'm not a programmer, I dabble, but I do other things in life....)

K-rnivoro commented 3 months ago

Not related, but QMK Library https://qmk.fm/ seems to work OK with BMC64, as I did with my project Pimmodore64 http://www.pimmodore.com

Maybe Keryah does not have a complete HID implementation.

El dom, 31 mar 2024 a las 19:11, randyrossi @.***>) escribió:

Would either of you be able to try this sample from the circle library?

https://github.com/rsta2/circle/tree/master/sample/08-usbkeyboard

It's a standalone kernel test program that exercises circle's usb keyboard support. Since BMC64 uses circle, it depends on that library's support for the device. It takes a bit of development experience to build and install though.

On Fri, Mar 29, 2024 at 5:06 AM Dimitri @.***> wrote:

hi, I have the same problem, raspy+keyrahv3+BMC64... I also tried to overwrite the vkm files in BMC64 with those of the Keyrah... but to no avail.

— Reply to this email directly, view it on GitHub https://github.com/randyrossi/bmc64/issues/235#issuecomment-2026914496,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAI3HKGSUJNYDG5TKIG7HN3Y2UOIXAVCNFSM6AAAAAAX5F7K22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRWHEYTINBZGY>

. You are receiving this because you were mentioned.Message ID: @.***>

-- Randy Rossi

  • "There are only two things that are hard about computer science; Naming things, Cache Invalidation, and Off-by-one errors."

— Reply to this email directly, view it on GitHub https://github.com/randyrossi/bmc64/issues/235#issuecomment-2028928863, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGTSRKGRKQ3JARQ77SFM46TY3CCY3AVCNFSM6AAAAAAX5F7K22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYHEZDQOBWGM . You are receiving this because you commented.Message ID: @.***>

irtimiDo commented 3 months ago

ok, but I want BMC64 on a c=128 machine, so either we can make BMC64 recognize the USB keyboard (keyrahv3.0) or we study the way to directly connect the pins of the c128 keyboard to the raspberry, configuring it as was done for that of the c64

mcgurk commented 3 months ago

Root causes of this problem are already discussed at the beginning, but this is wrong place for discussing Keyrah V3 and other "multiple interface"-devices. There is nothing wrong with HID implementation of those devices other than Circle doesn't (or didn't) support those. Circle supports only one interface per USB-device.

There are other devices also that doesn't support multiple interface USB devices and thats why I originally made my joystick and keyboard adapters as single device (https://github.com/mcgurk/Arduino-USB-HID-RetroJoystickAdapter/tree/master/C64_keyboard). e.g. any adapter made with Arduino IDE without proper external libraries and modifications doesn't work (I learned this hard way).

As mentioned, if someone tests that current Circle supports those problematic devices, then we can discuss if Circle could be updated to BMC64. If Circle doesn't support those, then right place is to raise issue to Circle: https://github.com/rsta2/circle

Kikkokat77 commented 3 months ago

Hi, thanks for the answer to the problem, but I don't think I understood how to do with those files:

Makefile kernel.cpp kernel.h main.cpp

do I have to modify something or just copy them into a BMC64 directory?

(I'm not a programmer, I dabble, but I do other things in life....)

It's a test suite but it needs to be compiled and executed on the Pi. The instructions are in the readme file of the suite.

I'll try to give it a shot, and if I have any results worth mentioning, I'll report them here.

irtimiDo commented 3 months ago

Hi, thanks for the answer to the problem, but I don't think I understood how to do with those files: Makefile kernel.cpp kernel.h main.cpp do I have to modify something or just copy them into a BMC64 directory? (I'm not a programmer, I dabble, but I do other things in life....)

It's a test suite but it needs to be compiled and executed on the Pi. The instructions are in the readme file of the suite.

I'll try to give it a shot, and if I have any results worth mentioning, I'll report them here.

OK look forward!!!

Kikkokat77 commented 3 months ago

I can take a look at what circle has in terms of support for multiple interfaces. It could be it's just using the last interface it finds. Might be difficult for me to test any changes though since I don't have a V3. On Fri, May 12, 2023 at 1:47 AM Youri Ackx @.> wrote: Thank you for the insights and the links. Obviously it is not trivial. "HID device with multiple interfaces" seems like a generic use case, so indeed someone would have done it already if it were easy. Do you mind leaving this issue open for a bit, in case someone would make other suggestions? — Reply to this email directly, view it on GitHub <#235 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3HKCBDNJ35VEMJPKPUKDXFXFI3ANCNFSM6AAAAAAX5F7K2Y . You are receiving this because you are subscribed to this thread.Message ID: @.> -- Randy Rossi - "There are only two things that are hard about computer science; Naming things, Cache Invalidation, and Off-by-one errors."

I managed to run some tests, here are the results. Below is the log with the original C64 keyboard connected to the Keyrah V3 and an old serial joystick d64 connected to the Keyrah V3. In this case, if I typed something on the keyboard, I couldn't see anything on the screen.

WITH KEYRAH V3 ATTACHED

logger: Circle 46 started on Raspberry Pi 3 Model B+ 1GB logger: Revision code is a020d3, compiler has been GCC 13.2.1 00:00:00.66 timer: SpeedFactor is 1.51 00:00:01.52 usbdev0-1: Device ven424-2514, dev9-0-2 found (HS) 00:00:01.57 usbdev0-1: Interface int9-0-1 found 00:00:01.57 usbdev0-1: Function is not supported 00:00:01.57 usbdev0-1: Interface int9-0-2 found 00:00:01.57 usbdev0-1: Using device/interface int9-0-2 00:00:02.23 usbdev0-1: Device ven424-2514, dev9-0-2 found (HS) 00:00:02.28 usbdev0-1: Interface int9-0-1 found 00:00:02.29 usbdev0-1: Function is not supported 00:00:02.29 usbdev0-1: Interface int9-0-2 found 00:00:02.29 usbdev0-1: Using device/interface int9-0-2 00:00:02.44 usbdev1-3: Device ven18d8-3 found (FS) 00:00:02.45 usbdev1-3: Product: Individual Computers Keyrah V3 00:00:02.50 usbdev1-3: Interface int3-0-0 found 00:00:02.51 usbdev1-3: Using device/interface int3-0-0 00:00:02.51 usbdev1-3: Interface int3-0-0 found 00:00:02.51 usbdev1-3: Using device/interface int3-0-0 00:00:02.51 usbdev1-3: Interface int3-0-0 found 00:00:02.52 usbdev1-3: Using device/interface int3-0-0 00:00:02.52 usbdev1-3: Interface int3-0-0 found 00:00:02.52 usbdev1-3: Using device/interface int3-0-0 00:00:02.52 usbdev1-3: Interface int3-0-0 found 00:00:02.52 usbdev1-3: Using device/interface int3-0-0 00:00:02.53 usbdev1-3: Interface int3-0-0 found 00:00:02.53 usbdev1-3: Using device/interface int3-0-0 00:00:03.19 usbdev0-1: Device ven424-7800 found (HS) 00:00:03.24 usbdev0-1: Using device/interface ven424-7800 00:00:03.33 lan7800: MAC address is ----- 00:00:03.47 usbhub: Port 1: Device configured 00:00:03.47 usbhub: Port 1: Device configured 00:00:03.49 usbhub: Port 3: Device configured 00:00:03.50 dwroot: Device configured 00:00:03.50 kernel: Compile time: Apr 3 2024 13:14.12 00:00:03.50 kernel: Please attach an USB keyboard, if not already done!

Kikkokat77 commented 3 months ago

Here's the log where, compared to the previous test, I tried connecting a USB dongle of another keyboard and, from this new keyboard, I managed to type on the screen.

WITH KEYRAH V3 ATTACHED AND A WIFI DONGLE USB KEYBOARD

logger: Circle 46 started on Raspberry Pi 3 Model B+ 1GB logger: Revision code is a020d3, compiler has been GCC 13.2.1 00:00:00.66 timer: SpeedFactor is 1.51 00:00:01.52 usbdev0-1: Device ven424-2514, dev9-0-2 found (HS) 00:00:01.57 usbdev0-1: Interface int9-0-1 found 00:00:01.57 usbdev0-1: Function is not supported 00:00:01.57 usbdev0-1: Interface int9-0-2 found 00:00:01.57 usbdev0-1: Using device/interface int9-0-2 00:00:02.23 usbdev0-1: Device ven424-2514, dev9-0-2 found (HS) 00:00:02.28 usbdev0-1: Interface int9-0-1 found 00:00:02.29 usbdev0-1: Function is not supported 00:00:02.29 usbdev0-1: Interface int9-0-2 found 00:00:02.29 usbdev0-1: Using device/interface int9-0-2 00:00:02.44 usbdev1-3: Device ven18d8-3 found (FS) 00:00:02.45 usbdev1-3: Product: Individual Computers Keyrah V3 00:00:02.50 usbdev1-3: Interface int3-0-0 found 00:00:02.51 usbdev1-3: Using device/interface int3-0-0 00:00:02.51 usbdev1-3: Interface int3-0-0 found 00:00:02.51 usbdev1-3: Using device/interface int3-0-0 00:00:02.51 usbdev1-3: Interface int3-0-0 found 00:00:02.52 usbdev1-3: Using device/interface int3-0-0 00:00:02.52 usbdev1-3: Interface int3-0-0 found 00:00:02.52 usbdev1-3: Using device/interface int3-0-0 00:00:02.52 usbdev1-3: Interface int3-0-0 found 00:00:02.52 usbdev1-3: Using device/interface int3-0-0 00:00:02.53 usbdev1-3: Interface int3-0-0 found 00:00:02.53 usbdev1-3: Using device/interface int3-0-0 00:00:03.19 usbdev0-1: Device ven424-7800 found (HS) 00:00:03.24 usbdev0-1: Using device/interface ven424-7800 00:00:03.40 usbdev2-2: Device ven45e-800 found (FS) 00:00:03.41 usbdev2-2: Product: Microsoft Microsoft Nano Transceiver v2.0 00:00:03.46 usbdev2-2: Interface int3-1-1 found 00:00:03.46 usbdev2-2: Using device/interface int3-1-1 00:00:03.46 usbdev2-2: Interface int3-1-2 found 00:00:03.47 usbdev2-2: Using device/interface int3-1-2 00:00:03.47 usbdev2-2: Interface int3-0-0 found 00:00:03.47 usbdev2-2: Using device/interface int3-0-0 00:00:03.48 lan7800: MAC address is ----- 00:00:03.62 usbhub: Port 1: Device configured 00:00:03.64 usbhub: Port 2: Device configured 00:00:03.64 usbhub: Port 1: Device configured 00:00:03.66 usbhub: Port 3: Device configured 00:00:03.66 dwroot: Device configured 00:00:03.67 kernel: Compile time: Apr 3 2024 13:14.12 00:00:03.67 kernel: Please attach an USB keyboard, if not already done! 00:00:03.67 kernel: Just type something! bmc64test

mcgurk commented 3 months ago

Good test.

So it looks like latest Circle doesn't support multi-USB-HID-devices and issue can be raised to Circle: https://github.com/rsta2/circle

Kikkokat77 commented 3 months ago

Guys, I'm not an expert, but if I can help with something else, don't hesitate to ask! ;-)

Feel free to use the logs to open an issue with Circle if needed.

mcgurk commented 3 months ago

ok, but I want BMC64 on a c=128 machine, so either we can make BMC64 recognize the USB keyboard (keyrahv3.0) or we study the way to directly connect the pins of the c128 keyboard to the raspberry, configuring it as was done for that of the c64

If understood correctly, connecting C128 keyboard to GPIO is solved: https://github.com/randyrossi/bmc64/issues/201

nickgoodmanuk commented 2 months ago

ok, but I want BMC64 on a c=128 machine, so either we can make BMC64 recognize the USB keyboard (keyrahv3.0) or we study the way to directly connect the pins of the c128 keyboard to the raspberry, configuring it as was done for that of the c64

If understood correctly, connecting C128 keyboard to GPIO is solved: #201

Yes I got all the the extra keys working except the two latching keys 40/80 and Caps Lock, which are not really needed, by using 3 extra GPIO pins, much better than using KeyRah. I have a fork of the project here. : https://github.com/nickgoodmanuk/bmc64/

Kikkokat77 commented 2 days ago

hey @randyrossi, are there any updates on this issue after the logs I posted? thx

mcgurk commented 1 day ago

hey @randyrossi, are there any updates on this issue after the logs I posted? thx

Question is not pointed to me, but I answer anyway: As I said earlier, this is wrong place for this discussion. You have to open issue to Circle and continue this discussion there. After Circle supports Keyrah, then discussion can be continued here again. You have now way to test it with that keyboard test you used earlier. After it works, then we can start to think about Keyrah support in BMC64. (I don't know if support is even then easy, because I don't know how hard it is update Circle to BMC64)

https://github.com/rsta2/circle

Kikkokat77 commented 1 day ago

@mcgurk thank you for your response and clarification. Unfortunately, I am not the right person for this because I am not a programmer and do not have the necessary skills to open an issue on Circle and explain in detail what the problem is. Therefore, I am addressing @randyrossi and the users of this thread who have the necessary skills, to kindly complete the issue so that this problem can be resolved.

Thank you again for your time and patience!!