Author Topic: TMK keyboard firmware  (Read 428454 times)

0 Members and 5 Guests are viewing this topic.

Offline felixer

  • Posts: 1
Re: TMK keyboard firmware
« Reply #1900 on: Mon, 01 January 2018, 21:14:48 »
Finally building my own keyboard, it's 6 rows 19 columns, also trying to use a teensy 3.2. After putting in all the work to make the keyboard_common.h and keyboard_plain.c look like i thought it needed to it doesn't compile. I realized after looking at the one key example it don't think this is how these two files are supposed to work for the teensy 3.2? Does any one have an example of a keyboard configuration for the teensy 3.x or LC?
 
here is what probably would have worked for teensy 2.0 s:
Code: [Select]
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "action_util.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H


/* felix1 proto */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,      K0E,                     \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, \
    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,      K3D, K3E, K3F, K3G, K3H,      \
    K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A,      K4C, K4D, K4E, K4F, K4G, K4H, K4I, \
    K50, K51, K52,           K55,                K59, K5A,      K5C, K5D, K5E, K5F,      K5H,      \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_NO   , KC_##0E, KC_NO  , KC_NO  , KC_NO  , KC_NO   }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##1E, KC_##1F, KC_##1G, KC_##1H, KC_##1I }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##2E, KC_##2F, KC_##2G, KC_##2H, KC_##2I }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_NO   , KC_##K3D, KC_##3E, KC_##3F, KC_##3G, KC_##3H, KC_NO }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##C44, KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_NO   , KC_##K4C, KC_##K4D, KC_##4E, KC_##4F, KC_##4G, KC_##4H, KC_##4I }, \
    { KC_##K50, KC_##K51, KC_##K52, KC_NO,    KC_NO,    KC_##K55, KC_NO   ,    KC_NO,    KC_NO, KC_##K59, KC_##K5A, KC_NO   , KC_##K5C, KC_##K5D, KC_##5E, KC_##5F, KC_NO  , KC_##5H, KC_NO }  \
}

#endif

#endif

and keyboard_plain.c :

Code: [Select]
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* Layer 0: Default Layer
     * ,--------------------------------------------------------------------------------------------.
     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|         |  DEL |
     * |--------------------------------------------------------------------------------------------|
     * | ` |  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|    BSp  |  PSRC|     |  /  |  *  |  -  |
     * |--------------------------------------------------------------------------------------------|
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \  | PGUP |  7  |  8  |  9  |
     * |---------------------------------------------------------------------------------------  +  |
     * |Contro|  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Enter     | PGDN |  4  |  5  |  6  |
     * |--------------------------------------------------------------------------------------------|
     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift | UP  |      |  1  |  2  |  3  |
     * |---------------------------------------------------------------------------------------  -  |
     * | Ctrl |Gui|Alt  |      Space      |Alt|    Ctrl |LEFT | DOWN | RIGHT|     0     |  .  |
     * `--------------------------------------------------------------------------------------------'
     */
    KEYMAP(ESC,    F1,   F2,   F3,  F4,   F5,  F6,  F7,   F8,    F9,   F10,  F11,  F12,            DEL ,                         \
           GRV,     1,    2,    3,   4,    5,   6,   7,    8,     9,     0,  MINS,  EQL,   BSPC,   PSRC, NMLK, KPDV, KPMU, KPMN, \
           TAB,     Q,    W,    E,   R,    T,   Y,   U,    I,     O,     P,  LBRC, RBRC,   BSLS,   PGUP, KP_7, KP_8, KP_9, KPAD, \
           LCTL,    A,    S,    D,   F,    G,   H,   J,    K,     L,  SCLN,  QUOT,          ENT,   PGDN, KP_4, KP_5, KP_6,       \
           LSFT,    Z,    X,    C,   V,    B,   N,   M, COMM,   DOT,  SLSH,        RSFT,    UP ,       , KP_1, KP_2, KP_3, KPEN, \
           LCTL, LGUI, LALT,             SPC,                  RALT,  RCTL,        LEFT,   DOWN, RIGHT , KP_0      , KPDT       ),
};

const action_t PROGMEM fn_actions[] = {};

Offline Giorgio

  • Posts: 1764
  • Location: Italy
Re: TMK keyboard firmware
« Reply #1901 on: Wed, 07 March 2018, 06:36:18 »
Hello, I'm thinking of purchasing the usb to usb controller from Hasu. Does it recognize multiple keyboards and change layout according to predefined chosen layouts? Is it possible to have additional memory on the controller, for example 1Mega Byte? thanks

Offline hasu

  • Thread Starter
  • Posts: 2727
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1902 on: Wed, 07 March 2018, 18:19:57 »
Hello, I'm thinking of purchasing the usb to usb controller from Hasu. Does it recognize multiple keyboards and change layout according to predefined chosen layouts? Is it possible to have additional memory on the controller, for example 1Mega Byte? thanks

USB-USB converter can recognize four keyboards by default and remap them depeding on your keymap definition. But note that you can have just one keymap, not four.
No USB memory  support.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline Giorgio

  • Posts: 1764
  • Location: Italy
Re: TMK keyboard firmware
« Reply #1903 on: Thu, 08 March 2018, 02:09:24 »
Hello, I'm thinking of purchasing the usb to usb controller from Hasu. Does it recognize multiple keyboards and change layout according to predefined chosen layouts? Is it possible to have additional memory on the controller, for example 1Mega Byte? thanks

USB-USB converter can recognize four keyboards by default and remap them depeding on your keymap definition. But note that you can have just one keymap, not four.
No USB memory  support.

How much free space is there after flashing one layout? Would it be possible to install a bigger chip? Thanks
« Last Edit: Thu, 08 March 2018, 02:18:43 by Giorgio »

Offline hasu

  • Thread Starter
  • Posts: 2727
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1904 on: Thu, 08 March 2018, 09:09:43 »
Hello, I'm thinking of purchasing the usb to usb controller from Hasu. Does it recognize multiple keyboards and change layout according to predefined chosen layouts? Is it possible to have additional memory on the controller, for example 1Mega Byte? thanks

USB-USB converter can recognize four keyboards by default and remap them depeding on your keymap definition. But note that you can have just one keymap, not four.
No USB memory  support.

How much free space is there after flashing one layout? Would it be possible to install a bigger chip? Thanks

Around 2.5-6.0KB, It depends on build configuration.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md#2-features
https://geekhack.org/index.php?topic=69169.msg2569912#msg2569912
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline Giorgio

  • Posts: 1764
  • Location: Italy
Re: TMK keyboard firmware
« Reply #1905 on: Fri, 09 March 2018, 03:43:43 »
Sorry to bother you again, could you build the controller with a bigger chip, for example a 128k one (or bigger), to have more storage writable space? How much would it cost? thank you.

Someone was considering to use the ATxmega128A4U https://deskthority.net/keyboards-f2/atxmega-keyboard-controller-t9106.html
« Last Edit: Fri, 09 March 2018, 03:56:44 by Giorgio »

Offline hasu

  • Thread Starter
  • Posts: 2727
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1906 on: Fri, 09 March 2018, 04:23:20 »
Sorry to bother you again, could you build the controller with a bigger chip, for example a 128k one (or bigger), to have more storage writable space? How much would it cost? thank you.

Someone was considering to use the ATxmega128A4U https://deskthority.net/keyboards-f2/atxmega-keyboard-controller-t9106.html
No, I wont' do that for you. Though, if you willing to pay me 500USD I may consider :D
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline vvp

  • Posts: 722
Re: TMK keyboard firmware
« Reply #1907 on: Fri, 09 March 2018, 04:54:34 »
Someone was considering to use the ATxmega128A4U https://deskthority.net/keyboards-f2/atxmega-keyboard-controller-t9106.html
It was me. Depends what firmware you are starting with. If you have a LUFA based ATmega firmware (and no port layer for ARM for it) then it is easy to port it to ATXmega. Otherwise go with some ARM. They are cheaper and bigger.

Offline senso

  • Posts: 44
  • Location: Portugal
Re: TMK keyboard firmware
« Reply #1908 on: Fri, 09 March 2018, 05:45:12 »
I'm waiting for the PSoC 6 BLE to be a bit more widespread/for Cypress to release one of those 10-20$ dev-board, USB, BLE, battery charger, and a lot more goodies all in one nice package.

Atmega32u4 is way too expensive for what it is, and after Atmel was bought by Microchip I cant stand it, always hated Microchip, got screwed over by erratas one too many times, analog chips that didn't meet the specs(well they did, I just cant skim a Microchip datasheet, either read it all or better not touch them), a stupid PicKit3 that cost me 60€ that never worked, waited 1 month to get a new one shipped because mine was one of the early batches with a botched bootloader that killed itself when updating the firmware.

Microchip will slowly kill the atmega, that and having a massive project built around the RFA2 and see the price jump from 4€ to 10€ a piece, thanks for killing 1 year of work with a price jack-up..

Offline Giorgio

  • Posts: 1764
  • Location: Italy
Re: TMK keyboard firmware
« Reply #1909 on: Fri, 09 March 2018, 11:06:38 »
Would it be possible to add some external eeprom storage?

Offline senso

  • Posts: 44
  • Location: Portugal
Re: TMK keyboard firmware
« Reply #1910 on: Fri, 09 March 2018, 16:08:03 »
To run code?

No, the atmega only executes code from its internal flash.

Offline Giorgio

  • Posts: 1764
  • Location: Italy
Re: TMK keyboard firmware
« Reply #1911 on: Fri, 09 March 2018, 16:16:42 »
To run code?

No, the atmega only executes code from its internal flash.

To store data

Offline ErgoMacros

  • Posts: 150
  • Location: SF Bay Area
Re: TMK keyboard firmware
« Reply #1912 on: Fri, 09 March 2018, 17:12:36 »
Adding external EEPROM looks doable... requires 2 IO pins, see here for 32K bytes:
  http://www.hobbytronics.co.uk/arduino-external-eeprom

That could be a lot of layers!
Not fast to switch in a new set of layers, but all you need.
Today's quote: '...“but then the customer successfully broke that.”

Offline slava

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1913 on: Sat, 24 March 2018, 09:59:51 »
Is it possible to control lock lights using TMK converter (e.g. PS/2)? E.g. I want to use when a certain layer is enabled.

Offline hasu

  • Thread Starter
  • Posts: 2727
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1914 on: Sat, 24 March 2018, 11:49:02 »
Is it possible to control lock lights using TMK converter (e.g. PS/2)? E.g. I want to use when a certain layer is enabled.

You can control them with 'ps2_host_set_led()'.
This is code for default behaivour for lock lights.
https://github.com/tmk/tmk_keyboard/blob/master/converter/ps2_usb/led.c#L23-L33
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline slava

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1915 on: Sun, 25 March 2018, 12:16:05 »
Is it possible to control lock lights using TMK converter (e.g. PS/2)? E.g. I want to use when a certain layer is enabled.

You can control them with 'ps2_host_set_led()'.
This is code for default behaivour for lock lights.
https://github.com/tmk/tmk_keyboard/blob/master/converter/ps2_usb/led.c#L23-L33

Thanks!

A small update to my problem: I decided to modify my ADB-USB converter firmware first.
macOS does not support num lock, so I decided to solve this problem with the TMK. See layers 5 and 6 in the attached file.
All works ok, but, as I already said, I want to control the num lock to highlight the current layer.

As far as I understand I need to write a custom 'action_layer' function, like I did with the 'action_function' to support spacecadet-style shift key.

In this custom 'action_layer'  function I need to call 'led_set'  to turn on or off the num lock light.
Which is a but puzzling for me. Do you have an example of such custom function or could you help me here?
« Last Edit: Sun, 25 March 2018, 12:18:30 by slava »

Offline hasu

  • Thread Starter
  • Posts: 2727
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1916 on: Sun, 25 March 2018, 18:29:54 »
« Last Edit: Sun, 25 March 2018, 18:32:10 by hasu »
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline slava

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1917 on: Mon, 26 March 2018, 02:56:54 »
You are right but in this case you can also use hook API to control the LED when layer state is changed.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/hook.txt
https://github.com/tmk/tmk_keyboard/blob/51326077b085ad5c82cb0ea7c63405364c052cd5/tmk_core/common/hook.h

This code is for my FC660C controller which lights up its LED when Layer1 is turned on.
https://github.com/tmk/tmk_keyboard/blob/22f6cb273e347214bee1c31182764155a584a942/keyboard/fc660c/unimap_emu.c#L57-L65

Ok, thx

Is it how it should look like? I want to enable the LED if layer 2 is on, and disable it if layer 0 is on.

Code: [Select]
void hook_layer_change(uint32_t layer_state)
{
    if (layer_state & (2L<<1)) {
      // turn num lock on if layer 2 is enabled
    } else if (layer_state & (0L<<1)) {
      // turn num lock off if layer 0 is enabled
    }
}

I also looked into the source code of 'led_set'
Code: [Select]
void led_set(uint8_t usb_led)
{
    adb_host_kbd_led(ADB_ADDR_KEYBOARD, ~usb_led);
}

and 'adb_host_kbd_led'

Code: [Select]
// send state of LEDs
void adb_host_kbd_led(uint8_t addr, uint8_t led)
{
    // Listen Register2
    //  upper byte: not used
    //  lower byte: bit2=ScrollLock, bit1=CapsLock, bit0=NumLock
    adb_host_listen(addr, 2, 0, led & 0x07);
}

I'm not good on low-level programming. Could you give an example when 'led_set' turns on and off the num lock  LED for and ADB keyboard?

Thanks.

Offline slava

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1918 on: Tue, 27 March 2018, 07:06:17 »
Looks like I found how to control lock lights for my case, but I still don't know where is the current state of LED is stored or how to get it.
My code turn all LEDs off except the num lock as you can see from the code.

Code: [Select]
void hook_layer_change(uint32_t layer_state)
{
    if (layer_state & (2L<<1)) {
      // turn num lock on if layer 2 is enabled
      led_set(0x1);
    } else if (~layer_state & (2L<<1)) {
      led_set(0x0);
      // turn num lock off if layer 0 is enabled
    }
}

Offline slava

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1919 on: Tue, 27 March 2018, 11:47:09 »
If somebody is interested how I solved the problem:

Code: [Select]
void hook_layer_change(uint32_t layer_state) {
    uint8_t current_led_state = host_keyboard_leds();
    // If the 2nd layer is enabled then set
    // the numlock state to ON in the LED state byte
    if((default_layer_state | layer_state) == 1<<2) {
      current_led_state = current_led_state | 0x1);
    }
    led_set(current_led_state);
}

// When you trun the capslock off then
// the numlock LED will be turned off as well
// Thus we need to modify this function to prevent this
void hook_keyboard_leds_change(uint8_t led_status) {
  uint8_t adjusted_led_status = led_status;
  if((default_layer_state | layer_state) == 1<<2)
  {
    // Again if the 2nd layer is enabled, then we need
    // to set the numlock LED state to ON in the LED state byte
    adjusted_led_status = led_status | 0x1;
  }
  keyboard_set_leds(adjusted_led_status);
}

Offline Giorgio

  • Posts: 1764
  • Location: Italy
Re: TMK keyboard firmware
« Reply #1920 on: Wed, 09 May 2018, 11:43:41 »
How do I program the usb2usb converter? It will take days to understand the stuff...

What keyboard editor do you use to configure your layouts?
Which one?
https://tkg.io/
http://www.tmk-kbd.com/tmk_keyboard/
http://kb.sized.io/

Then you download the .c file, you replace the file that you find in the downloaded github tmk mirror, and you flash the firmware using a dfu-programmer?

Currently on windows cygwin with no administrator rights :-)

thanks
« Last Edit: Wed, 09 May 2018, 11:49:10 by Giorgio »

Offline Giorgio

  • Posts: 1764
  • Location: Italy
Re: TMK keyboard firmware
« Reply #1921 on: Thu, 10 May 2018, 14:12:13 »
I managed to install an ubuntu virtual machine.
The atmel chip is seen by the system, it shows up in dmesg (new fulls speed device found etc atm32u4dfu, but there's no method known to man to program it.
avrdude not working
make dfu not working
nothing

Offline hasu

  • Thread Starter
  • Posts: 2727
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1922 on: Thu, 10 May 2018, 18:37:15 »
I managed to install an ubuntu virtual machine.
The atmel chip is seen by the system, it shows up in dmesg (new fulls speed device found etc atm32u4dfu, but there's no method known to man to program it.
avrdude not working
make dfu not working
nothing

how did you run 'avrdude' and what error message did you get?
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline JianYang

  • Posts: 83
Re: TMK keyboard firmware
« Reply #1923 on: Fri, 11 May 2018, 03:27:06 »
I managed to install an ubuntu virtual machine.
The atmel chip is seen by the system, it shows up in dmesg (new fulls speed device found etc atm32u4dfu, but there's no method known to man to program it.
avrdude not working
make dfu not working
nothing

make dfu never worked for me. I assume that you have installed dfu-programmer?

I always just program manually:
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build
Code: [Select]
$ sudo dfu-programmer atmega32u4 erase --force
$ sudo dfu-programmer atmega32u4 flash your.hex
$ sudo dfu-programmer atmega32u4 reset

Offline RollyRee

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1924 on: Sat, 12 May 2018, 09:50:48 »
Hey @Hasu, thanks for making this great software! Unfortunately, I'm having some problems with flashing the firmware. I'm using an OSOYOO Pro Micro (5V/16 mHz) on OS X. When using dfu-programmer to flash, the command "sudo dfu-programmer atmega32u4 flash adb_usb_lufa.hex" results in an error of "no device found".

When using AVRdude to flash, "sudo avrdude -patmega32u4 -cavr109 -P/dev/tty.usbmodem1411  -b57600   -D -Uflash:w:adb_usb_leonardo.hex:i -v" results in the error of "avrdude: ser_open(): can't open device /dev/tty.usbmodem1411": Device not configured".

Any idea what's going on? Could it be because my Pro Micro is currently running Blinky while I'm trying to flash the firmware?


Offline JianYang

  • Posts: 83
Re: TMK keyboard firmware
« Reply #1925 on: Sun, 13 May 2018, 04:45:41 »
Hey @Hasu, thanks for making this great software! Unfortunately, I'm having some problems with flashing the firmware. I'm using an OSOYOO Pro Micro (5V/16 mHz) on OS X. When using dfu-programmer to flash, the command "sudo dfu-programmer atmega32u4 flash adb_usb_lufa.hex" results in an error of "no device found".

When using AVRdude to flash, "sudo avrdude -patmega32u4 -cavr109 -P/dev/tty.usbmodem1411  -b57600   -D -Uflash:w:adb_usb_leonardo.hex:i -v" results in the error of "avrdude: ser_open(): can't open device /dev/tty.usbmodem1411": Device not configured".

Any idea what's going on? Could it be because my Pro Micro is currently running Blinky while I'm trying to flash the firmware?



You can only upload when the device is in the bootloader. IIRC, with DFU, it will be in the bootloader for about 2 seconds after powerup/reset. During this window, you need to run "sudo dfu-programmer atmega32u4 erase". Keep in mind that it will only work after the os has registered the device, so you probably have less than a 1 second window to do this. I recommend spamming this command until it succeeds. Then you can flash and reset with the commands in my previous post.

If you want to use avrdude, you would need to have the ISP connected with a AVRISP or an arduino to simulate one. But this method could wipe your bootloader, so I do not recommend it.

How did you manage to program blinky?

Offline Giorgio

  • Posts: 1764
  • Location: Italy
Re: TMK keyboard firmware
« Reply #1926 on: Tue, 15 May 2018, 10:36:55 »
Fantastic usb_usb converter. Now it works perfectly. I had some trouble because it was in a virtual machine, with an old vmware version.

I can't understand how can I have a key to reboot the converter without pressing the button on the device. How do I define in keymap.c an fn0 key to enter into program mode? I've tried many examples but they all fail. Thanks

Offline hasu

  • Thread Starter
  • Posts: 2727
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1927 on: Thu, 17 May 2018, 18:47:46 »
Fantastic usb_usb converter. Now it works perfectly. I had some trouble because it was in a virtual machine, with an old vmware version.

I can't understand how can I have a key to reboot the converter without pressing the button on the device. How do I define in keymap.c an fn0 key to enter into program mode? I've tried many examples but they all fail. Thanks

If you use Keymap file BTLD keycode should work for you. You don't have to define FN0 yourself, just use BTLD.

Meanwhile, BTLD code doesn't work in Actionmap or Unimap this will be fixed later. The issue was filed in github. https://github.com/tmk/tmk_keyboard/issues/557
Workaround for this is to define a function like below.
Code: [Select]
diff --git a/converter/usb_usb/unimap.c b/converter/usb_usb/unimap.c
index 0f34ece..70a9c84 100644
--- a/converter/usb_usb/unimap.c
+++ b/converter/usb_usb/unimap.c
@@ -15,9 +15,13 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "unimap_trans.h"
+#include "wait.h"
+#include "bootloader.h"
 
 
 #define AC_FN0 ACTION_LAYER_MOMENTARY(1)
+#undef  AC_BTLD
+#define AC_BTLD ACTION_FUNCTION(1)
 
 #ifdef KEYMAP_SECTION_ENABLE
 const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
@@ -39,7 +43,20 @@ const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
     ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL,      TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS,
     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP,  INS,      TRNS,     TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS,
     TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,TRNS,TRNS,HOME,PGUP,LEFT,RGHT,     TRNS,TRNS,                        TRNS,TRNS,TRNS,TRNS,
-    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,END, PGDN,DOWN,     TRNS,TRNS,          PGUP,         TRNS,TRNS,TRNS,TRNS,
+    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,BTLD,TRNS,TRNS,END, PGDN,DOWN,     TRNS,TRNS,          PGUP,         TRNS,TRNS,TRNS,TRNS,
     TRNS,TRNS,TRNS,TRNS,          TRNS,          TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     HOME,PGDN,END,     TRNS,     TRNS,TRNS
     ),
 };
+
+
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+    switch (id) {
+        case 1:
+            clear_keyboard();
+            wait_ms(50);
+            bootloader_jump(); // not return
+            break;
+    }
+}
+
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline Giorgio

  • Posts: 1764
  • Location: Italy
Re: TMK keyboard firmware
« Reply #1928 on: Fri, 18 May 2018, 02:29:49 »
Thanks, I can confirm that the BTLD keycode works perfectly in keymap.c, allowing to reprogram the converter with the "sudo make dfu" command.

You need first to type "sudo make dfu", and then to use the BTLD code, or the keyboard will stop working until the next replug; probably I'll hide the BTLD behind a macro or something similar.
« Last Edit: Fri, 18 May 2018, 04:16:42 by Giorgio »

Offline RollyRee

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1929 on: Sat, 19 May 2018, 18:26:53 »
Hey @Hasu, thanks for making this great software! Unfortunately, I'm having some problems with flashing the firmware. I'm using an OSOYOO Pro Micro (5V/16 mHz) on OS X. When using dfu-programmer to flash, the command "sudo dfu-programmer atmega32u4 flash adb_usb_lufa.hex" results in an error of "no device found".

When using AVRdude to flash, "sudo avrdude -patmega32u4 -cavr109 -P/dev/tty.usbmodem1411  -b57600   -D -Uflash:w:adb_usb_leonardo.hex:i -v" results in the error of "avrdude: ser_open(): can't open device /dev/tty.usbmodem1411": Device not configured".

Any idea what's going on? Could it be because my Pro Micro is currently running Blinky while I'm trying to flash the firmware?



You can only upload when the device is in the bootloader. IIRC, with DFU, it will be in the bootloader for about 2 seconds after powerup/reset. During this window, you need to run "sudo dfu-programmer atmega32u4 erase". Keep in mind that it will only work after the os has registered the device, so you probably have less than a 1 second window to do this. I recommend spamming this command until it succeeds. Then you can flash and reset with the commands in my previous post.

If you want to use avrdude, you would need to have the ISP connected with a AVRISP or an arduino to simulate one. But this method could wipe your bootloader, so I do not recommend it.

How did you manage to program blinky?

I programmed Blinky using the Arduino IDE software. I just pressed compile, and uploaded it, and it worked.
Maybe something with the fact that it's an OSOYOO pro micro and incompatible with DFU? I think someone told me that...
Sorry for the late response!
« Last Edit: Sat, 19 May 2018, 18:29:23 by RollyRee »

Offline JianYang

  • Posts: 83
Re: TMK keyboard firmware
« Reply #1930 on: Sun, 20 May 2018, 06:49:41 »
If
I programmed Blinky using the Arduino IDE software. I just pressed compile, and uploaded it, and it worked.
Maybe something with the fact that it's an OSOYOO pro micro and incompatible with DFU? I think someone told me that...
Sorry for the late response!

You can see the command used to program it in arduino if you enable 'show verbose output during:' in settings. Then just modify it to upload your hex file instead.

Offline Giorgio

  • Posts: 1764
  • Location: Italy
Re: TMK keyboard firmware
« Reply #1931 on: Sun, 20 May 2018, 08:08:38 »
Is there any guide to learn more about tmk beside what's on the repository? Thanks

Offline RollyRee

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1932 on: Sun, 20 May 2018, 11:22:44 »
If
I programmed Blinky using the Arduino IDE software. I just pressed compile, and uploaded it, and it worked.
Maybe something with the fact that it's an OSOYOO pro micro and incompatible with DFU? I think someone told me that...
Sorry for the late response!

You can see the command used to program it in arduino if you enable 'show verbose output during:' in settings. Then just modify it to upload your hex file instead.

Thanks for the help! However, Bash outputs the following when I type in the command you mentioned: "Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding". What's going on?

Offline JianYang

  • Posts: 83
Re: TMK keyboard firmware
« Reply #1933 on: Mon, 21 May 2018, 01:41:08 »
Thanks for the help! However, Bash outputs the following when I type in the command you mentioned: "Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding". What's going on?

I suspect the avrdude command might be preceded by a command to reset the device or something along those lines. Does it still work when you program blinky from avrdude?

Offline RollyRee

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1934 on: Wed, 23 May 2018, 18:52:54 »
Typing in avrdude -c avrisp -p atmega32u4 -U flash:w:blink.hex

Gives an error of

avrdude: ser_open(): can't open device "unknown": No such file or directory

avrdude done.  Thank you.

Offline JianYang

  • Posts: 83
Re: TMK keyboard firmware
« Reply #1935 on: Thu, 24 May 2018, 04:07:52 »
Typing in avrdude -c avrisp -p atmega32u4 -U flash:w:blink.hex

Gives an error of

avrdude: ser_open(): can't open device "unknown": No such file or directory

avrdude done.  Thank you.


Because the command is incomplete. You did not specify the port. Copy the entire line from arduino output. Also check the preceding commands for a python script or other command that resets the avr.

Offline RollyRee

  • Posts: 5
Re: TMK keyboard firmware
« Reply #1936 on: Fri, 25 May 2018, 17:37:33 »
I just have a quick question (I think I'm pretty close to figuring it out myself  :)). When typing

make -f Makefile.<variant> clean
make -f Makefile.<variant>

What does the <variant> refer to? I'm trying to build adb_usb if that helps.

Offline JianYang

  • Posts: 83
Re: TMK keyboard firmware
« Reply #1937 on: Sat, 26 May 2018, 00:24:13 »
I just have a quick question (I think I'm pretty close to figuring it out myself  :)). When typing

make -f Makefile.<variant> clean
make -f Makefile.<variant>

What does the <variant> refer to? I'm trying to build adb_usb if that helps.

If you look in the folder, there are usually two files, Makefile.lufa and Makefile.pjrc . If you are programming to a teensy, use Makefile.pjrc, if you have a lufa-based bootloader, use Makefile.lufa.

Offline sth

  • 2 girls 1 cuprubber
  • Posts: 3400
  • ftdoc.nl
    • forthedeclineofcivilisation
Re: TMK keyboard firmware
« Reply #1938 on: Mon, 18 June 2018, 17:44:48 »
many apologies if this was posted previously but i have started noticing lately that my tmk keyboards cause a weird kb/mouse input 'lockup' on multiple Linux distros. sometimes it will work fine and then out of nowhere my mouse cursor will freeze and will not track until i click the mouse button.

i confirmed this with two tmk boards (hhkb1 controller and a gh60) and the same behavior persists across both boards. i do not experience the issue with a stock hhkb pro1 so i thought i'd start here and see if anyone else has experienced this.

unfortunately i do not have any hardware windows machines to test this on and i don't use a keyboard often with my fiance's macbook so i have no data there either.
11:48 -!- SmallFry [~SmallFry@unaffiliated/smallfry] has quit [Ping timeout: 245 seconds] ... rest in peace

Offline hasu

  • Thread Starter
  • Posts: 2727
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #1939 on: Mon, 18 June 2018, 18:19:05 »
many apologies if this was posted previously but i have started noticing lately that my tmk keyboards cause a weird kb/mouse input 'lockup' on multiple Linux distros. sometimes it will work fine and then out of nowhere my mouse cursor will freeze and will not track until i click the mouse button.

i confirmed this with two tmk boards (hhkb1 controller and a gh60) and the same behavior persists across both boards. i do not experience the issue with a stock hhkb pro1 so i thought i'd start here and see if anyone else has experienced this.

unfortunately i do not have any hardware windows machines to test this on and i don't use a keyboard often with my fiance's macbook so i have no data there either.

Any output in log files when the lockup happens?

You have used the keyboards without problem before, and you see the 'lockup' happens lately, right?
Then, did you update firmware, keymap, OS or PC hardware lately?

I'd try to use default/plain keymap first.


EDIT: and use trusty USB cable,  Ive seen people have various problems with cheap or badly crafted cables out of spec.
« Last Edit: Mon, 18 June 2018, 18:27:19 by hasu »
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline sth

  • 2 girls 1 cuprubber
  • Posts: 3400
  • ftdoc.nl
    • forthedeclineofcivilisation
Re: TMK keyboard firmware
« Reply #1940 on: Mon, 18 June 2018, 18:30:52 »
many apologies if this was posted previously but i have started noticing lately that my tmk keyboards cause a weird kb/mouse input 'lockup' on multiple Linux distros. sometimes it will work fine and then out of nowhere my mouse cursor will freeze and will not track until i click the mouse button.

i confirmed this with two tmk boards (hhkb1 controller and a gh60) and the same behavior persists across both boards. i do not experience the issue with a stock hhkb pro1 so i thought i'd start here and see if anyone else has experienced this.

unfortunately i do not have any hardware windows machines to test this on and i don't use a keyboard often with my fiance's macbook so i have no data there either.

Any output in log files when the lockup happens?

You have used the keyboards without problem before, and you see the 'lockup' happens lately, right?
Then, did you update firmware, keymap, OS or PC hardware lately?

I'd try to use default/plain keymap first.


ok i will try to reflash with a default keymap and i'll check my logs.
i have not updated firmware, keymap or hardware lately but I normally use a rolling release linux distro so my kernel and other software changes often. however, i noticed this on ubuntu as well which doesn't receive nearly as many kernel updates. it actually started happening last year but it was intermittent and then i switched to a non-tmk board for an unrelated reason so i forgot all about it :))
11:48 -!- SmallFry [~SmallFry@unaffiliated/smallfry] has quit [Ping timeout: 245 seconds] ... rest in peace