VOGONS


Reply 240 of 307, by rasteri

User metadata
Rank Oldbie
Rank
Oldbie
Eivind wrote on 2024-05-14, 19:39:

I don't have the two UART0 pins connected to anything on the TL 2.1 (pins 7 and 4, right?). I could always solder on something if needed, but if it's relatively simple for you to make a fw version that spits out relevant info on the PS/2 keyb lines, that would be easier for me! 😜

OK latest commit has hub info in the debug output.

Note that if you haven't used the menu in a while the process has changed - you have to hold down the button for a few seconds to make the menu appear.

Also pressing the button without holding it will cycle through AT/XT/Amstrad modes so be careful!

Reply 241 of 307, by Eivind

User metadata
Rank Oldbie
Rank
Oldbie
rasteri wrote on 2024-05-14, 20:57:

OK latest commit has hub info in the debug output.

Note that if you haven't used the menu in a while the process has changed - you have to hold down the button for a few seconds to make the menu appear.

Also pressing the button without holding it will cycle through AT/XT/Amstrad modes so be careful!

Thanks!

Here's what was printed after starting the HID logging, unplugging the working direct-attached keyboard and plugging in the HHKB keyboard/hub:

Found hub
3 port hub
ps- 0x101 pc- 0x01
port 0 attached
fullspeed
enum.fail
ps- 0x100 pc- 0x00
ps- 0x100 pc- 0x00

The LlamaBlaster sound card
ITX-Llama motherboard
TinyLlama SBC

Reply 242 of 307, by rasteri

User metadata
Rank Oldbie
Rank
Oldbie
Eivind wrote on 2024-05-14, 21:14:
Here's what was printed after starting the HID logging, unplugging the working direct-attached keyboard and plugging in the HHKB […]
Show full quote

Here's what was printed after starting the HID logging, unplugging the working direct-attached keyboard and plugging in the HHKB keyboard/hub:

fullspeed

Aha, as we suspected it's a fullspeed device therefore won't be susceptible to the lowspeed issue. So there's no reason why your HHKB shouldn't work on the hidman if it works on other USB1.1 hosts (your RP2040). I suspect that is a bug in hidman.

BTW, I've tested your RP2040 code on a pico board and it has the exact same issue as hidman/my old pc with lowspeed devices on USB2 hubs. So good news, the lowspeed issue isn't because of a bug in hidman. Bad news, I suppose we'll just have to accept that certain hub and device combinations won't work.

Anyway, the latest commit dumps even more hub debugging info to the keyboard. If you could grab me a dump of your HHKB again that would be great. Maybe do it 3-4 times just to see if it's failing in the same place each time.

Reply 243 of 307, by Eivind

User metadata
Rank Oldbie
Rank
Oldbie
rasteri wrote on 2024-05-15, 19:57:

Aha, as we suspected it's a fullspeed device therefore won't be susceptible to the lowspeed issue. So there's no reason why your HHKB shouldn't work on the hidman if it works on other USB1.1 hosts (your RP2040). I suspect that is a bug in hidman.

BTW, I've tested your RP2040 code on a pico board and it has the exact same issue as hidman/my old pc with lowspeed devices on USB2 hubs. So good news, the lowspeed issue isn't because of a bug in hidman. Bad news, I suppose we'll just have to accept that certain hub and device combinations won't work.

Yeah, that's something we can live with I suppose!

rasteri wrote on 2024-05-15, 19:57:

Anyway, the latest commit dumps even more hub debugging info to the keyboard. If you could grab me a dump of your HHKB again that would be great. Maybe do it 3-4 times just to see if it's failing in the same place each time.

Here's the dump from the latest firmware, I ran it 4 times and checked that it was identical each time:

gdd ok 8
mps 64
addr ok 1
gddfull ok 18
0x0409 0x005A 0x0100
gcd ok 25

Found hub
3 port hub
ps- 0x101 pc- 0x01
port 0 attached
fullspeed
gdd.fail
enum.fail
ps- 0x100 pc- 0x00
ps- 0x100 pc- 0x00

The LlamaBlaster sound card
ITX-Llama motherboard
TinyLlama SBC

Reply 244 of 307, by rasteri

User metadata
Rank Oldbie
Rank
Oldbie
Eivind wrote on 2024-05-15, 20:41:

Here's the dump from the latest firmware, I ran it 4 times and checked that it was identical each time:

Oh interesting, looks like it's just not able to speak to the device at all. My crappy hubs fail much later in the process.

I had a look through the tinyUSB code and it looks like the only major thing it's doing differently is retrying the enumeration process several times if it fails. Apparently this is needed because some devices glitch out when power is first applied.

Because hidman re-enumerates ALL ports every time you add a device, you can force the enumeration process by connecting a second device to hidman.

So can you try this - put the hidman in debug dump mode as before, then connect your HHKB (it'll fail), then connect a second device to the other CH559 USB port and see if that wakes up the HHKB?

Thanks for all your help.

(if this doesn't work I'll spin a new version of the code that JUST retries enumeration of the hub ports, rather than everything).

Reply 245 of 307, by Eivind

User metadata
Rank Oldbie
Rank
Oldbie
rasteri wrote on 2024-05-16, 10:47:
Oh interesting, looks like it's just not able to speak to the device at all. My crappy hubs fail much later in the process. […]
Show full quote

Oh interesting, looks like it's just not able to speak to the device at all. My crappy hubs fail much later in the process.

I had a look through the tinyUSB code and it looks like the only major thing it's doing differently is retrying the enumeration process several times if it fails. Apparently this is needed because some devices glitch out when power is first applied.

Because hidman re-enumerates ALL ports every time you add a device, you can force the enumeration process by connecting a second device to hidman.

So can you try this - put the hidman in debug dump mode as before, then connect your HHKB (it'll fail), then connect a second device to the other CH559 USB port and see if that wakes up the HHKB?

Thanks for all your help.

(if this doesn't work I'll spin a new version of the code that JUST retries enumeration of the hub ports, rather than everything).

Didn't seem to do anything new with the HHKB once I plugged in another device (a logitech keyboard).
Here's the log - I added comments in parentheses:

Logging HID Data. Press ESC to stop...
I0 L8- 0 0 0 0 0 0 0 0
(remove logitech keyboard)
(plug in logitech keyboard)
gdd ok 8
mps 8
addr ok 1
gddfull ok 18
0x046D 0xC30E 0x0180
gcd ok 59


Interface 0 Report Descriptor -

05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
75 01 95 08 81 02 95 01 75 08 81 01 95 03 75 01
05 08 19 01 29 03 91 02 95 05 75 01 91 01 95 06
75 08 26 FF 00 05 07 19 00 29 91 81 00 C0



Interface 1 Report Descriptor -

05 0C 09 01 A1 01 85 01 15 01 26 5E 00 75 08 95
02 0A 25 02 09 B6 09 B5 09 B7 09 CD 09 EA 09 E9
09 E2 0A 92 01 0A 8A 01 0A 21 02 0A 23 02 0A 2A
02 0A 24 02 0A 83 01 1B 01 00 09 00 2B 4C 00 09
00 05 0C 0A 27 02 0A 26 02 09 B8 81 60 C0 05 01
09 80 A1 01 85 02 15 01 25 03 75 02 95 01 09 82
09 81 09 83 81 60 75 06 81 03 C0

(remove logitech keyboard)
(plug in HHKB)
gdd ok 8
mps 64
addr ok 1
gddfull ok 18
0x0409 0x005A 0x0100
gcd ok 25

Found hub
3 port hub
ps- 0x101 pc- 0x01
port 0 attached
fullspeed
gdd.fail
enum.fail
ps- 0x100 pc- 0x00
ps- 0x100 pc- 0x00
(plug in logitech keyboard)
gdd ok 8
mps 8
addr ok 6
gddfull ok 18
0x046D 0xC30E 0x0180
gcd ok 59


Interface 0 Report Descriptor -

Show last 17 lines
05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01 
75 01 95 08 81 02 95 01 75 08 81 01 95 03 75 01
05 08 19 01 29 03 91 02 95 05 75 01 91 01 95 06
75 08 26 FF 00 05 07 19 00 29 91 81 00 C0



Interface 1 Report Descriptor -

05 0C 09 01 A1 01 85 01 15 01 26 5E 00 75 08 95
02 0A 25 02 09 B6 09 B5 09 B7 09 CD 09 EA 09 E9
09 E2 0A 92 01 0A 8A 01 0A 21 02 0A 23 02 0A 2A
02 0A 24 02 0A 83 01 1B 01 00 09 00 2B 4C 00 09
00 05 0C 0A 27 02 0A 26 02 09 B8 81 60 C0 05 01
09 80 A1 01 85 02 15 01 25 03 75 02 95 01 09 82
09 81 09 83 81 60 75 06 81 03 C0

The LlamaBlaster sound card
ITX-Llama motherboard
TinyLlama SBC

Reply 246 of 307, by rasteri

User metadata
Rank Oldbie
Rank
Oldbie
Eivind wrote on 2024-05-16, 11:05:

Didn't seem to do anything new with the HHKB once I plugged in another device (a logitech keyboard).

Damn sorry, there's a bit of code that detects if a device is already enumerated and won't enumerate it again.

Latest commit fixes it and has a new feature - if you press the button it will enumerate all ports/devices, no need to re-plug anything (you'll need to be in HID dump mode as before)

You might have to do the re-enumeration 3 or 4 times to get it to detect, one of my hubs does that as it turns out...

Reply 247 of 307, by Eivind

User metadata
Rank Oldbie
Rank
Oldbie
rasteri wrote on 2024-05-16, 20:43:
Damn sorry, there's a bit of code that detects if a device is already enumerated and won't enumerate it again. […]
Show full quote
Eivind wrote on 2024-05-16, 11:05:

Didn't seem to do anything new with the HHKB once I plugged in another device (a logitech keyboard).

Damn sorry, there's a bit of code that detects if a device is already enumerated and won't enumerate it again.

Latest commit fixes it and has a new feature - if you press the button it will enumerate all ports/devices, no need to re-plug anything (you'll need to be in HID dump mode as before)

You might have to do the re-enumeration 3 or 4 times to get it to detect, one of my hubs does that as it turns out...

Forcing re-enumeration by pressing the button works fine, but apparently the HHKB is only detected every other time. Still fails as before, though.
Here's a new log, my comments inserted in parentheses as before:

HIDMAN v0.1 Main Menu

1. Adv.Keyboard - No
2. Adv.Mouse - No
3. Intellimouse - No

8. Log HID Data
9. Dump PS2 mouse status
ESC to exit menu

Logging HID Data. Press ESC to stop...
I0 L8- 0 0 0 0 0 0 0 0

(removing logitech keyboard)
(plugging in HHKB)

reenumerating all ports
port 0
gdd.fail
port 1
gdd ok 8
mps 64
addr ok 6
gddfull ok 18
0x0409 0x005A 0x0100
gcd ok 25

Found hub
3 port hub
ps- 0x101 pc- 0x01
port 0 attached
fullspeed
gdd.fail
enum.fail
ps- 0x100 pc- 0x00
ps- 0x100 pc- 0x00

(clicking button)

reenumerating all ports
port 0
gdd.fail
port 1
gdd.fail

(clicking button)

reenumerating all ports
port 0
gdd.fail
port 1
gdd ok 8
mps 64
addr ok 6
gddfull ok 18
0x0409 0x005A 0x0100
gcd ok 25

Found hub
3 port hub
Show last 101 lines
ps- 0x101 pc- 0x01
port 0 attached
fullspeed
gdd.fail
enum.fail
ps- 0x100 pc- 0x00
ps- 0x100 pc- 0x00

(clicking button)

reenumerating all ports
port 0
gdd.fail
port 1
gdd.fail

(clicking button)

reenumerating all ports
port 0
gdd.fail
port 1
gdd ok 8
mps 64
addr ok 6
gddfull ok 18
0x0409 0x005A 0x0100
gcd ok 25

Found hub
3 port hub
ps- 0x101 pc- 0x01
port 0 attached
fullspeed
gdd.fail
enum.fail
ps- 0x100 pc- 0x00
ps- 0x100 pc- 0x00

(clicking button)

reenumerating all ports
port 0
gdd.fail
port 1
gdd.fail

(clicking button)

reenumerating all ports
port 0
gdd.fail
port 1
gdd ok 8
mps 64
addr ok 6
gddfull ok 18
0x0409 0x005A 0x0100
gcd ok 25

Found hub
3 port hub
ps- 0x101 pc- 0x01
port 0 attached
fullspeed
gdd.fail
enum.fail
ps- 0x100 pc- 0x00
ps- 0x100 pc- 0x00

(clicking button)

reenumerating all ports
port 0
gdd.fail
port 1
gdd.fail

(clicking button)

reenumerating all ports
port 0
gdd.fail
port 1
gdd ok 8
mps 64
addr ok 6
gddfull ok 18
0x0409 0x005A 0x0100
gcd ok 25

Found hub
3 port hub
ps- 0x101 pc- 0x01
port 0 attached
fullspeed
gdd.fail
enum.fail
ps- 0x100 pc- 0x00
ps- 0x100 pc- 0x00

The LlamaBlaster sound card
ITX-Llama motherboard
TinyLlama SBC

Reply 248 of 307, by rasteri

User metadata
Rank Oldbie
Rank
Oldbie
Eivind wrote on 2024-05-16, 21:04:

Forcing re-enumeration by pressing the button works fine, but apparently the HHKB is only detected every other time. Still fails as before, though.

Hmm that's unfortunate.

Thankfully I now have a pico with tinyUSB to compare it to, so I'll get the logic analyzer out and compare its power/reset sequencing with what hidman does.

(BTW I've actually got tinyUSB to compile in sdcc. I suspect by the time I've got everything working it's not going to fit in the CH559's memory, but we'll see).

Reply 249 of 307, by Eivind

User metadata
Rank Oldbie
Rank
Oldbie
rasteri wrote on 2024-05-17, 00:29:

Thankfully I now have a pico with tinyUSB to compare it to, so I'll get the logic analyzer out and compare its power/reset sequencing with what hidman does.

Sounds difficult, but I have very little experience using LAs 😀 Do you have one with built-in support for decoding all sorts of USB protocol things?

rasteri wrote on 2024-05-17, 00:29:

(BTW I've actually got tinyUSB to compile in sdcc. I suspect by the time I've got everything working it's not going to fit in the CH559's memory, but we'll see).

oooh, that's interesting! Maybe it's possible to strip out stuff not needed for this project from the stack, like the whole Device sub-stack...?

The LlamaBlaster sound card
ITX-Llama motherboard
TinyLlama SBC

Reply 250 of 307, by rasteri

User metadata
Rank Oldbie
Rank
Oldbie
Eivind wrote on 2024-05-17, 06:17:

Sounds difficult, but I have very little experience using LAs 😀 Do you have one with built-in support for decoding all sorts of USB protocol things?

It's actually not too hard, it can output pcap format that imports right into wireshark so it's pretty easy to read. As I've been familiarizing myself with tinyUSB I've noticed some other stuff my (or rather WCH's) USB code doesn't do so maybe it'll be something simple.

oooh, that's interesting! Maybe it's possible to strip out stuff not needed for this project from the stack, like the whole Device sub-stack...?

Yeah certainly a lot of stuff will need to be stripped out (an initial attempt to link the code used 80KB...). There are also sections of code that push a lot of stuff on the stack, which is not ideal on a device with 256 byte stack. I still don't think it's feasible to do a complete port, but porting just the USB enumeration stuff and leaving the rest of my code to do the low level stuff is likely possible.

BTW do you know what USB hub chip your keyboard uses? I can maybe find a hub that uses the same chip to test. (I ain't spending $100s on a keyboard with half the keys missing 🤣 )

Reply 251 of 307, by Eivind

User metadata
Rank Oldbie
Rank
Oldbie
rasteri wrote on 2024-05-17, 10:06:

It's actually not too hard, it can output pcap format that imports right into wireshark so it's pretty easy to read. As I've been familiarizing myself with tinyUSB I've noticed some other stuff my (or rather WCH's) USB code doesn't do so maybe it'll be something simple.

Nice!

rasteri wrote on 2024-05-17, 10:06:

Yeah certainly a lot of stuff will need to be stripped out (an initial attempt to link the code used 80KB...). There are also sections of code that push a lot of stuff on the stack, which is not ideal on a device with 256 byte stack. I still don't think it's feasible to do a complete port, but porting just the USB enumeration stuff and leaving the rest of my code to do the low level stuff is likely possible.

Yeah, maybe that's something worth looking into!

rasteri wrote on 2024-05-17, 10:06:

BTW do you know what USB hub chip your keyboard uses? I can maybe find a hub that uses the same chip to test. (I ain't spending $100s on a keyboard with half the keys missing 🤣 )

Haha yeeeeah, it's not for everyone. I think I've spent like $400 for mine, it's got extra dampening rings and pads and lubed key stems and whatnot. Makes it extremely nice to type on, with satisfyingly deep and fat thock-sounds... 😁
I'll open her up and see what's inside!

The LlamaBlaster sound card
ITX-Llama motherboard
TinyLlama SBC

Reply 252 of 307, by Eivind

User metadata
Rank Oldbie
Rank
Oldbie

Here's the USB hub chip:

IMG_1263.jpeg
Filename
IMG_1263.jpeg
File size
1.61 MiB
Views
256 views
File license
Fair use/fair dealing exception

From what I can tell, it's a NEC μPD720114 (datasheet).

Edit: btw, nice silkscreen - unusually clear and with helpful arrows where needed. Topre knew what they were doing... 😌

The LlamaBlaster sound card
ITX-Llama motherboard
TinyLlama SBC

Reply 253 of 307, by rasteri

User metadata
Rank Oldbie
Rank
Oldbie
Eivind wrote on 2024-05-17, 10:46:

NEC μPD720114

Thanks for finding that out. Hopefully I can find another hub with the same chip, or even order the chip myself and build a lil USB hub...

Meantime I'm poring over logic analyzer logs. I've seen a few differences during device reset that could perhaps affect it.

Failing that, I had another idea for how we could debug this without you having a logic analyzer - I could modify your RP2040 code to printf info about the USB enumeration process. ITXllama has access to UART0 of the RP2040 yeah?

Reply 254 of 307, by Eivind

User metadata
Rank Oldbie
Rank
Oldbie
rasteri wrote on 2024-05-17, 12:20:

Thanks for finding that out. Hopefully I can find another hub with the same chip, or even order the chip myself and build a lil USB hub...

Meantime I'm poring over logic analyzer logs. I've seen a few differences during device reset that could perhaps affect it.

Failing that, I had another idea for how we could debug this without you having a logic analyzer - I could modify your RP2040 code to printf info about the USB enumeration process. ITXllama has access to UART0 of the RP2040 yeah?

Yep, I routed the default uart tx to pin 12 (add_compile_definitions(PICO_DEFAULT_UART_TX_PIN=12) in CMakeLists.txt), which goes to a pin header. I've used that to look at printfs before.

The LlamaBlaster sound card
ITX-Llama motherboard
TinyLlama SBC

Reply 255 of 307, by rasteri

User metadata
Rank Oldbie
Rank
Oldbie
Eivind wrote on 2024-05-17, 13:25:

Yep, I routed the default uart tx to pin 12 (add_compile_definitions(PICO_DEFAULT_UART_TX_PIN=12) in CMakeLists.txt), which goes to a pin header. I've used that to look at printfs before.

I just did some playing with the rp2040 again. If you set CFG_TUSB_DEBUG to 3 in tusb_config.h then the output of that will likely contain everything I need.

Thanks again!

Reply 258 of 307, by Eivind

User metadata
Rank Oldbie
Rank
Oldbie
rasteri wrote on 2024-05-17, 13:38:

I just did some playing with the rp2040 again. If you set CFG_TUSB_DEBUG to 3 in tusb_config.h then the output of that will likely contain everything I need.

Thanks again!

Debug level 3 was insanely busy, I got over 800 lines when plugging in the HHKB 😁
I've attached both a level 2 and 3 log of plugging the HHKB into the native USB port of the rp2040.
Excited to see if you can make sense of any of this!

Attachments

  • Filename
    tusb_debug_3.txt
    File size
    27.19 KiB
    Downloads
    5 downloads
    File license
    Fair use/fair dealing exception
  • Filename
    tusb_debug_2.txt
    File size
    7.73 KiB
    Downloads
    6 downloads
    File license
    Fair use/fair dealing exception

The LlamaBlaster sound card
ITX-Llama motherboard
TinyLlama SBC

Reply 259 of 307, by rasteri

User metadata
Rank Oldbie
Rank
Oldbie
Eivind wrote on 2024-05-18, 10:31:

Excited to see if you can make sense of any of this!

Yup this is perfect! Thanks!

Main difference I noticed so far is that hidman proactively checks each hub port for devices during enumeration, whereas tinyusb just powers each port on and then waits for the hub itself to send a change interrupt. Maybe your hub chip or keyboard takes a while to wake up. I'll modify hidman so it does the same thing as tinyusb (which will also give us the ability to hotplug USB hub devices - it's a feature I had started working on in another branch anyway)

One of my hubs that intermittently fails actually does the same thing : (hidman on left, tinyusb on right)

Attachments