Page 1 of 1

Sentraq S60-X 60% DIY Keyboard Kit: Uploading TMK firmware

Posted: 21 Apr 2016, 07:57
by bgoodr
Hi,

I have successfully built the keyboard at https://www.massdrop.com/buy/sentraq-60 ... board-kit/

The TMK-based firmware I am using is:

https://github.com/VinnyCordeiro/tmk_ke ... oard/s60-x

I've managed to get a hex file built, but am running into problems getting the machine to "see" the device to upload it to the keyboard. This is a very new machine running Ubuntu 15.10, so should be very new hardware.

The problem arises in running the first dfu-programmer command after pressing the reset button on the back of the keyboard:

Code: Select all

$ sudo dfu-programmer atmega32u4 erase
dfu-programmer: no device present.
Seeing as this might be a udev issue, I examined the /var/log/syslog file after clicking the reset button which shows this:

Code: Select all

$ tail -1lf /var/log/syslog
Apr 20 22:22:07 wilddog kernel: [  600.913330] usb 1-2: SerialNumber: 1.0.0
Apr 20 22:22:33 wilddog kernel: [  627.227086] usb 1-2: USB disconnect, device number 9
Apr 20 22:22:33 wilddog kernel: [  627.727987] usb 1-2: new full-speed USB device number 10 using xhci_hcd
Apr 20 22:22:33 wilddog kernel: [  627.859101] usb 1-2: New USB device found, idVendor=03eb, idProduct=2ff4
Apr 20 22:22:33 wilddog kernel: [  627.859117] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Apr 20 22:22:33 wilddog kernel: [  627.859118] usb 1-2: Product: ATm32U4DFU
Apr 20 22:22:33 wilddog kernel: [  627.859119] usb 1-2: Manufacturer: ATMEL
Apr 20 22:22:33 wilddog kernel: [  627.859120] usb 1-2: SerialNumber: 1.0.0
After it is plugged in, I see this from lsusb output:

Code: Select all

$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 012: ID 03eb:2ff4 Atmel Corp. atmega32u4 DFU bootloader
Bus 001 Device 004: ID 046d:c52f Logitech, Inc. Unifying Receiver
Bus 001 Device 002: ID 046d:c318 Logitech, Inc. Illuminated Keyboard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
I've tried and failed all three of these approaches:

1. The "make dfu" rule which runs the erase command mentioned above (but not under sudo),
2. Manually running the commands under sudo as given by https://github.com/tmk/tmk_keyboard/wik ... ux-and-mac
3. Installing a udev rule as indicated by https://github.com/tmk/tmk_keyboard/wik ... udev-rules (not sure if a reboot is always required after making that change).

I did notice that the VENDOR_ID and PRODUCT_ID in this variant of the TMK (config.h) is different from the last udev rule, but I suspect things aren't getting that far in the process, and something more basic is amiss. My theory is that pressing the reset button erases the firmware and puts it into a state where it is announcing itself with idVendor=03eb, idProduct=2ff4 versus the ids defined in the config.h for the S60-x.

Any ideas? Should this instead go to geekhack?

Thanks,
Brent

Posted: 22 Apr 2016, 08:37
by bgoodr
I somehow was able to make this work. I had to do these steps exactly in this order:
  1. Create /etc/udev/rules.d/50-atmel-dfu.rules (see below).
  2. Create /etc/udev/rules.d/52-tmk-keyboard.rules (see below).
  3. Unplug the keyboard.
  4. Plug the keyboard back in.
  5. Click the reset button on the back of the keyboard
  6. Run the dfu-programmer commands.
I do not like having to unplug and plug in the keyboard, and I shouldn't have to IMO. But, none of the udevadm commands indicated at http://unix.stackexchange.com/questions ... out-reboot seemed to work.


/etc/udev/rules.d/50-atmel-dfu.rules :

Code: Select all

# Atmel ATMega32U4
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff4", MODE:="0666"
# Atmel USBKEY AT90USB1287
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ffb", MODE:="0666"
# Atmel ATMega32U2
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff0", MODE:="0666"
/etc/udev/rules.d/52-tmk-keyboard.rules:

Code: Select all

# tmk keyboard products     https://github.com/tmk/tmk_keyboard
SUBSYSTEMS=="usb", ATTRS{idVendor}=="F0DA", MODE:="0666"
Above, I changed the idVendor value from "feed" to "F0DA" so as to
match what I see in the tmk_keyboard/keyboard/s60-x/config.h file
(https://github.com/VinnyCordeiro/tmk_ke ... x/config.h).
But it doesn't seem to matter at all as the keyboard works. Why then
is that 52-tmk-keyboard.rules file even needed?

lsusb still shows blank after the f0da:0666 after programming it:

Code: Select all

$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 011: ID f0da:0666  
Bus 001 Device 004: ID 046d:c52f Logitech, Inc. Unifying Receiver
Bus 001 Device 002: ID 046d:c318 Logitech, Inc. Illuminated Keyboard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Right after clicking the reset button, we have:

Code: Select all

brentg@wilddog:~/bgoodr/keyboard-firmware-build-util/s60-x$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 012: ID 03eb:2ff4 Atmel Corp. atmega32u4 DFU bootloader
Bus 001 Device 004: ID 046d:c52f Logitech, Inc. Unifying Receiver
Bus 001 Device 002: ID 046d:c318 Logitech, Inc. Illuminated Keyboard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Posted: 22 Apr 2016, 08:44
by bgoodr
Even though I am able to load the firmware, the dfu rule errors out at the end:

[/code]
make -C tmk_keyboard/keyboard/s60-x KEYMAP= dfu
make[1]: Entering directory '....../tmk_keyboard/keyboard/s60-x'
dfu-programmer atmega32u4 erase
dfu-programmer atmega32u4 flash S60-X_lufa.hex
Validating...
20926 bytes used (72.98%)
dfu-programmer atmega32u4 reset
../../tmk_core/rules.mk:426: recipe for target 'dfu' failed
make[1]: *** [dfu] Error 1
[/code]

The man page for dfu-programmer for this reset command gives:

Code: Select all

       reset
              Resets microcontroller using watchdog timer
I reason this to be a bug in the dfu makefile rule: Once it has
successfully flashed the firmware, the atmel chip changes over to a
different device. Then the "dfu-programmer atmega32u4 reset" command
fails because it is no longer talking to a DFU bootloader. Manually
executing "dfu-programmer atmega32u4 reset" from the command line
after the keyboard firmware has been loaded gives me what I expect to
see:

Code: Select all

$ dfu-programmer atmega32u4 reset
dfu-programmer: no device present.