User avatar
HermannSW
Posts: 4665
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Request: dump your official Pi Keyboard USB HID descriptors #7

Wed Oct 13, 2021 8:09 pm

Gadgetoid asks for help of usbhid-dump outputs for different Pi400/Pi keyboards:
https://github.com/Gadgetoid/pi400kb/issues/7
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

andrum99
Posts: 1521
Joined: Fri Jul 20, 2012 2:41 pm

Re: Request: dump your official Pi Keyboard USB HID descriptors #7

Thu Oct 14, 2021 1:34 am

They've solved it.

It seems that instead of using the standard method of the bCountryCode field, Raspberry Pi have invented their own scheme for reporting the layout of the keyboard in the Pi keyboard, and yet another for the Pi 400. Not sure why when there's a standard interface available, but there you go.

See https://www.usb.org/sites/default/files ... id1_11.pdf - page 32 and 33 of the PDF, which are labelled as pages 22 and 23. It seems only Sun ever bothered to use it though, so unless you're running Solaris there's no autoconfiguration built into the OS :(
Last edited by andrum99 on Tue Oct 19, 2021 1:57 am, edited 1 time in total.

cleverca22
Posts: 4742
Joined: Sat Aug 18, 2012 2:33 pm

Re: Request: dump your official Pi Keyboard USB HID descriptors #7

Thu Oct 14, 2021 2:30 am

i think the pi400 has the country-code in the bcm2711 OTP, and it then gets exposed to linux somewhere in `/proc/device-tree/`

i suspect that was done, because the holtek MCU driving the keyboard, is programmed with 1 image for every single variant

and then once the keytop is chosen, they use a special uSD card or some pogo-pins to burn the OTP in ths SoC, and finalize that configuration

the holtek mcu may not allow further programming, and to simplify the whole production like, they just didnt bother with the bCountryCode

trejan
Posts: 3735
Joined: Tue Jul 02, 2019 2:28 pm

Re: Request: dump your official Pi Keyboard USB HID descriptors #7

Thu Oct 14, 2021 4:11 am

cleverca22 wrote:
Thu Oct 14, 2021 2:30 am
i think the pi400 has the country-code in the bcm2711 OTP
33
cleverca22 wrote:
Thu Oct 14, 2021 2:30 am
gets exposed to linux somewhere in `/proc/device-tree/`
/proc/device-tree/chosen/rpi-country-code
cleverca22 wrote:
Thu Oct 14, 2021 2:30 am
and then once the keytop is chosen, they use a special uSD card or some pogo-pins to burn the OTP in ths SoC, and finalize that configuration
I assume it'd be done at the same time they're burning the unique MAC addresses.
cleverca22 wrote:
Thu Oct 14, 2021 2:30 am
the holtek mcu may not allow further programming
Yes. It is OTP.
cleverca22 wrote:
Thu Oct 14, 2021 2:30 am
to simplify the whole production like, they just didnt bother with the bCountryCode
I expect it is the same reason why nobody else uses bCountryCode. The defined values for bCountryCode aren't exhaustive and there are keyboard layouts which don't fit any them e.g. Vietnamese. The standards compliant option is to set bCountryCode to 0 and then assume the user will select the correct layout.

cleverca22
Posts: 4742
Joined: Sat Aug 18, 2012 2:33 pm

Re: Request: dump your official Pi Keyboard USB HID descriptors #7

Thu Oct 14, 2021 4:56 am

trejan wrote:
Thu Oct 14, 2021 4:11 am
Yes. It is OTP.
the spot in the holtek OTP for the country-code could have been left blank
and then flash it in a second pass

some OTP lets you flash multiple times, and it will store the logical OR of the current and new value

but i can see how flashing just one chip is simpler then flashing 2 chips when doing things in bulk

trejan
Posts: 3735
Joined: Tue Jul 02, 2019 2:28 pm

Re: Request: dump your official Pi Keyboard USB HID descriptors #7

Thu Oct 14, 2021 5:32 am

cleverca22 wrote:
Thu Oct 14, 2021 4:56 am
some OTP lets you flash multiple times, and it will store the logical OR of the current and new value

but i can see how flashing just one chip is simpler then flashing 2 chips when doing things in bulk
These Holtek OTP parts appears to be EPROM as it needs a 12V VPP supply for programming and the blank state is all 1s. You're not going to want to do two programming cycles in a production environment and it can't program itself.

Besides, there are undocumented switches on the standalone keyboard PCB so the firmware may be the same for all standalone models. I don't have a Pi keyboard so can't test it. Pi 400 stores the country code in OTP so no need for any additional parts.
Last edited by trejan on Thu Oct 14, 2021 11:31 am, edited 1 time in total.

cleverca22
Posts: 4742
Joined: Sat Aug 18, 2012 2:33 pm

Re: Request: dump your official Pi Keyboard USB HID descriptors #7

Thu Oct 14, 2021 5:43 am

trejan wrote:
Thu Oct 14, 2021 5:32 am
The Holtek OTP parts appears to be EPROM as it needs a 12V VPP supply for programming and the blank state is all 1s. You're not going to want to do two programming cycles in a production environment and it can't program itself.
ahh, that 12v thing explains more, now i can see why the bcm2711 otp is far more favorable

User avatar
HermannSW
Posts: 4665
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Request: dump your official Pi Keyboard USB HID descriptors #7

Thu Oct 14, 2021 8:16 am

trejan wrote:
Thu Oct 14, 2021 4:11 am
cleverca22 wrote:
Thu Oct 14, 2021 2:30 am
gets exposed to linux somewhere in `/proc/device-tree/`
/proc/device-tree/chosen/rpi-country-code
Empty on my Pi400:

Code: Select all

pi@raspberrypi400:~ $ cat /proc/device-tree/chosen/rpi-country-code 
pi@raspberrypi400:~ $ 
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

trejan
Posts: 3735
Joined: Tue Jul 02, 2019 2:28 pm

Re: Request: dump your official Pi Keyboard USB HID descriptors #7

Thu Oct 14, 2021 11:30 am

HermannSW wrote:
Thu Oct 14, 2021 8:16 am
trejan wrote:
Thu Oct 14, 2021 4:11 am
cleverca22 wrote:
Thu Oct 14, 2021 2:30 am
gets exposed to linux somewhere in `/proc/device-tree/`
/proc/device-tree/chosen/rpi-country-code
Empty on my Pi400:

Code: Select all

pi@raspberrypi400:~ $ cat /proc/device-tree/chosen/rpi-country-code 
pi@raspberrypi400:~ $ 
The kernel is giving you the raw binary value. It doesn’t convert it to a printable numeric string for display. Do “cat /proc/device-tree/chosen/rpi-country-code | od -t x1” to show the value in hex.

Return to “Raspberry Pi 400”