Remapped PROG to Esc, now cannot flash firmware (Resolved)

I remapped the PROG key to Esc as outlined in the introduction. Now when I try to make flash from the command line, I get these messages:

~/.../Arduino/Model01-Firmware (master) $ make flash
BOARD_HARDWARE_PATH="/Users/ian/Documents/Arduino/hardware" /Users/ian/Documents/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder flash
Building output/Model01-Firmware/Model01-Firmware (0.0.0-gv1.13-58-g76f5-dirty) ...
Press ENTER when ready...
^[
stty: 1200: No such file or directory
make: *** [flash] Error 1

The ^[ string appears when I hold PROG and pressing Enter produces the 1200 error. How do I flash my keyboard if PROG is remapped?

I think what’s happening is that the escape-enter sequence is being parsed as a malformed escape sequence, so you may need to prevent the escape key from being parsed in this way. Have you tried typing ctrl-v immediately before escape/prog?

Same issue occurs, but I do see a ^ appear when I press ctrl-v. Pressing prog/esc causes the ^[ to appear immediately and then will repeat if I continue to hold it down before pressing enter. I’m using macOS Sierra and this happens in both iTerm and Terminal.app.

So either ctrl-v isn’t enough, or it only neutralises the first escape in the repeating sequence. Plan B!

I think the best thing to do is make sure you’re nowhere near the terminal window when pressing Escape. Maybe something like ‘(sleep 60; echo) | make’ in the terminal, and then clicking in another window before holding down prog?

Now no characters appear but it still gives the error message.

I think in this case the remapped key might be a red herring, and there’s something else wrong with your setup.

stty: 1200: no such file or directory implies that stty thinks 1200 is where your keyboard is plugged in. Which is probably because an empty string was passed as the argument to -f. I think this is where I hand this over to someone better versed in the internals of the build system…!

Thanks for the help in any case. Flashing was working immediately before I changed the prog key and the keyboard still functions otherwise. I’m holding off on finding the reset button inside the enclosure in case this is something valuable to document for the future. I was a little surprised that the intro docs would cover the topic if it seemingly broke the ability to flash firmware later, but it seems like my situation is not normal.

Before going that far, I’d recommend holding Prog while connecting the keyboard to the computer - this results in a ‘failsafe’ mode where the keyboard stays in the bootloader and doesn’t load the user sketch (so the Esc mapping wouldn’t have any effect). ‘failsafe’ mode is a way flash a new firmware in the event the current flashed firmware has problems. See Help getting Model01-Firmware to compile (flashed non-working firmware to board)

2 Likes

For future reference, something that can help avoid this sort of thing is using the TapDance plugin to make your Prog key act as normal when tapped once but do nothing if double-tapped-and-held.

(e.g. https://bitbucket.org/jamesnvc/keyboardiolayout/src/3adfbb9dce112504bbd8fb3bc92b213ed8d09304/james_layout.ino?at=master&fileviewer=file-view-default#james_layout.ino-168, then putting TD(TD_F21) on the Prog key in the keymap in my example)

1 Like

This had no effect. The prog key stays lit for 5-10 seconds, but make flash still gives the same error. My steps are:

  1. Unplug the cable from the model 01
  2. With normal keyboard, make flash
  3. When prompted for Enter key, hold prog and plug in cable
  4. While light is red, press Enter on normal kb

Pressing keys on the model 01 while the prog key was lit did nothing until after some timeout and then the keyboard behaved normally (with prog producing an esc).

It’s looking more and more like the key remap is a red herring. I found a closed issue on GitHub about a very similar issue: https://github.com/keyboardio/Model01-Firmware/issues/11. Seems like it might have to do with serial port detection on my computer.

1 Like

For what it’s worth, I generally find that hitting enter before prog (as long as it’s very fast in between) works fine.