Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial whitefox support #987

Merged
merged 10 commits into from
Jan 15, 2017

Conversation

belak
Copy link
Contributor

@belak belak commented Jan 4, 2017

I realize this isn't really ready, but I figured I'd throw it up as a proof of concept. This was based on the infinity60 support, grabbing settings from https://github.com/tmk/whitefox

I'd like to get the LED controller working, but as far as I can tell the support in the other repo is hacky at best.

I'd be interested in ideas for improvements as well, as I'm sort of new to this.

Copy link
Contributor Author

@belak belak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also added the default and matt3o keymaps from the whitefox repo...

#define KINETIS_MCG_MODE KINETIS_MCG_MODE_PEE
#define KINETIS_PLLCLK_FREQUENCY 96000000UL
#define KINETIS_SYSCLK_FREQUENCY 48000000UL
#define KINETIS_XTAL_FREQUENCY 16000000UL
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be here... I added the value from lib/chibios-contrib/os/hal/boards/PJRC_TEENSY_3_1/board.h to fix a compliation error.

@jackhumbert
Copy link
Member

Nice! What all is needed for this to be merge-ready?

@belak
Copy link
Contributor Author

belak commented Jan 5, 2017

It would be nice to have someone other than me test it... I'm also having a weird issue (with both TMK and this, on only one of my two boards) where the escape key and `~ are reversed... which doesn't happen when using the official firmware.

Considering this is pretty much just a straight port of the tmk whitefox code with the LED control removed, I'd feel alright with this being merged as-is... someone already did the hard work of adding support for ChibiOS, so there's actually not a ton of work here.

I'll add a link to the whitefox folder with the other community maintained keyboards and as long as you don't have anything that's obvious, I'd be comfortable merging this...

@belak
Copy link
Contributor Author

belak commented Jan 5, 2017

After a few hours of debugging, I finally figured out that swap_grave_esc was stuck on, so I held space and backspace when starting up to clear the EEPROM... and that part is all good. Boot magic is just that, magic.

The LED controller can come later.

@fredizzimo
Copy link
Contributor

I think the Whitefox should share much of the LED stuff with the Infinity Ergodox, as both uses the same controller.

The Infinity Ergodox already have a driver in the keyboards\ergodox\infinity\drivers\gdisp\IS31FL3731C folder, for uGFX It's currently not enabled though, as I'm still working on the effect system and getting everything wired up for QMK. But it was working in my fork of TMK.

Things have gone slowly since, I had a bit too big ambitions for the effect system and I kept iterating my design back and forth, and not that much time available either. But I now have something much more simple (not described in the proposal), almost working. Almost only the final integration and the communication protocol, which is discussed here is missing. However since I have constantly missed the deadlines I have promised, I won't say anything now.

@belak
Copy link
Contributor Author

belak commented Jan 5, 2017

That's another reason I'll leave the LED controller for later. I noticed that the code was shared in other projects and figured I'd try to integrate with that and do it right... however this really isn't my expertise, so I couldn't get it working - I guess this sort of explains why. :P

The controller which ships with tmk (for the WhiteFox) is a bit of a hack, and I'd rather attempt a better solution before giving up and porting that over.

EDIT: I've also got an ergodox infinity coming from massdrop but I don't think that's due until March... It'll be nice to compare the two.

@belak
Copy link
Contributor Author

belak commented Jan 8, 2017

I've been using this since I opened this PR and it seems to be working well. I'd be comfortable having this merged if you are.

@fredizzimo
Copy link
Contributor

One thing that you might want to do is to apply this type of patch. Without this the wait_us(1), that you have in the matrix scan doesn't really wait for one microsecond, it waits for one millisecond. And that is for each row, so a full scan with 9 rows takes 9 milliseconds. This together with the debouncing could make it take up to 50ms for the keyboard to respond to keypresses.

All the Infinity based keyboards originates from the same source, so they all have that bug.

You could also increase the clock speed to 72Mhz instead of 48Mhz, which could come in handy when doing complicated LED effects. For this you need to change the mcuconf.h, see the Infinity Ergodox for an example of that. But it's probably not important yet.

@belak
Copy link
Contributor Author

belak commented Jan 9, 2017

  • KEYMAP macro has been updated to remove KC_ from the key definitions, because I'm pretty sure that doesn't work with some qmk features.
  • Tick frequency was changed, as mentioned by fredizzimo in that PR.
  • Updated clock speed to 72Mhz (copied settings from Infinity Ergodox)

Let me know if there's anything else which needs to be done. I've got a friend of mine testing this too, so I can be a little more confident that it works well.

EDIT: Not sure if you want anything squashed, so just let me know

@@ -69,7 +69,7 @@ uint8_t matrix_scan(void)
case 8: palSetPad(GPIOC, 11); break;
}

wait_us(1); // need wait to settle pin state
wait_us(10); // need wait to settle pin state
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that you change this to 20 us, like it's on the Ergodox. It probably works with 10us right now, but if you spawn other threads, it might stop working. 20us is still very fast, as you can do a full scan in 9 * 20us = 180us. For a comparison, the Ergodox Ez takets 3.15 ms, so it's still 7.5 times faster than that.

I don't know the exact reason why the delay has to be at minimum two ticks, but I suspsect it's due to how the context switching is implemented internally in ChibiOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch. I missed that change.

@jsvana
Copy link

jsvana commented Jan 11, 2017

As another data point, I've patched this and have been running it for the past day with no issues.

@jackhumbert
Copy link
Member

Awesome - thanks all!

@jackhumbert jackhumbert merged commit 6f44885 into qmk:master Jan 15, 2017
@kevinmost
Copy link

I'm having some trouble with this keymap. Compilation succeeds, but when I try to flash it with dfu-util (using version 0.9), the keyboard is rendered unusable until I flash another firmware that works for me, like TMK.

I've tried building it both in my local environment on OS X 10.12, and using Docker with the instructions provided (docker run -e keyboard=whitefox -e subproject= --rm -v $('pwd'):/qmk:rw edasque/qmk_firmware). Here's the output of running this:

 $ docker run -e keyboard=whitefox -e subproject= --rm -v $('pwd'):/qmk:rw edasque/qmk_firmware
Making whitefox with keymap default and target clean

Making whitefox with keymap default

arm-none-eabi-gcc (4.8.4-1+11-1) 4.8.4 20141219 (release)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Size before:
   text	   data	    bss	    dec	    hex	filename
      0	  24500	      0	  24500	   5fb4	whitefox_default.hex

Compiling: keyboards/whitefox/matrix.c [OK]
Compiling: keyboards/whitefox/led.c [OK]
Compiling: ./tmk_core/protocol/chibios/usb_main.c [OK]
Compiling: ./tmk_core/protocol/chibios/main.c [OK]
Compiling: keyboards/whitefox/whitefox.c [OK]
Compiling: keyboards/whitefox/keymaps/default/keymap.c [OK]
Compiling: quantum/quantum.c [OK]
Compiling: quantum/keymap_common.cIn file included from ./tmk_core/common/action_macro.h:20:0,
                 from ./tmk_core/common/action.h:25,
                 from quantum/keymap.h:23,
                 from quantum/keymap_common.c:18:
quantum/keymap_common.c: In function 'keymap_function_id_to_action':
quantum/keymap_common.c:179:34: warning: array subscript is above array bounds [-Warray-bounds]
  return pgm_read_word(&fn_actions[function_id]);
                                  ^
./tmk_core/common/progmem.h:9:46: note: in definition of macro 'pgm_read_word'
 #   define pgm_read_word(p)     *((uint16_t*)p)
                                              ^
 [OK]
Compiling: quantum/keycode_config.c [OK]
Compiling: quantum/process_keycode/process_leader.c [OK]
Compiling: ./tmk_core/common/host.c [OK]
Compiling: ./tmk_core/common/keyboard.c [OK]
Compiling: ./tmk_core/common/action.c [OK]
Compiling: ./tmk_core/common/action_tapping.c [OK]
Compiling: ./tmk_core/common/action_macro.c [OK]
Compiling: ./tmk_core/common/action_layer.c [OK]
Compiling: ./tmk_core/common/action_util.c [OK]
Compiling: ./tmk_core/common/print.c [OK]
Compiling: ./tmk_core/common/debug.c [OK]
Compiling: ./tmk_core/common/util.c [OK]
Compiling: ./tmk_core/common/eeconfig.c [OK]
Compiling: ./tmk_core/common/chibios/suspend.c [OK]
Compiling: ./tmk_core/common/chibios/timer.c [OK]
Compiling: ./tmk_core/common/chibios/bootloader.c [OK]
Compiling: ./tmk_core/common/chibios/printf.c [OK]
Compiling: ./tmk_core/common/chibios/eeprom.c [OK]
Compiling: ./tmk_core/common/bootmagic.c [OK]
Compiling: ./tmk_core/common/mousekey.c [OK]
Compiling: ./tmk_core/common/command.c [OK]
Compiling: lib/chibios/os/common/startup/ARMCMx/compilers/GCC/crt1.c [OK]
Compiling: lib/chibios/os/common/startup/ARMCMx/compilers/GCC/vectors.c [OK]
Compiling: lib/chibios/os/rt/src/chsys.c [OK]
Compiling: lib/chibios/os/rt/src/chdebug.c [OK]
Compiling: lib/chibios/os/rt/src/chtrace.c [OK]
Compiling: lib/chibios/os/rt/src/chvt.c [OK]
Compiling: lib/chibios/os/rt/src/chschd.c [OK]
Compiling: lib/chibios/os/rt/src/chthreads.c [OK]
Compiling: lib/chibios/os/rt/src/chtm.c [OK]
Compiling: lib/chibios/os/rt/src/chstats.c [OK]
Compiling: lib/chibios/os/rt/src/chregistry.c [OK]
Compiling: lib/chibios/os/rt/src/chsem.c [OK]
Compiling: lib/chibios/os/rt/src/chmtx.c [OK]
Compiling: lib/chibios/os/rt/src/chcond.c [OK]
Compiling: lib/chibios/os/rt/src/chevents.c [OK]
Compiling: lib/chibios/os/rt/src/chmsg.c [OK]
Compiling: lib/chibios/os/rt/src/chdynamic.c [OK]
Compiling: lib/chibios/os/common/oslib/src/chmboxes.c [OK]
Compiling: lib/chibios/os/common/oslib/src/chmemcore.c [OK]
Compiling: lib/chibios/os/common/oslib/src/chheap.c [OK]
Compiling: lib/chibios/os/common/oslib/src/chmempools.c [OK]
Compiling: lib/chibios/os/common/ports/ARMCMx/chcore.c [OK]
Compiling: lib/chibios/os/common/ports/ARMCMx/chcore_v7m.c [OK]
Compiling: lib/chibios/os/hal/osal/rt/osal.c [OK]
Compiling: lib/chibios/os/hal/src/hal.c [OK]
Compiling: lib/chibios/os/hal/src/hal_buffers.c [OK]
Compiling: lib/chibios/os/hal/src/hal_queues.c [OK]
Compiling: lib/chibios/os/hal/src/hal_mmcsd.c [OK]
Compiling: lib/chibios/os/hal/src/hal_adc.c [OK]
Compiling: lib/chibios/os/hal/src/hal_can.c [OK]
Compiling: lib/chibios/os/hal/src/hal_dac.c [OK]
Compiling: lib/chibios/os/hal/src/hal_ext.c [OK]
Compiling: lib/chibios/os/hal/src/hal_gpt.c [OK]
Compiling: lib/chibios/os/hal/src/hal_i2c.c [OK]
Compiling: lib/chibios/os/hal/src/hal_i2s.c [OK]
Compiling: lib/chibios/os/hal/src/hal_icu.c [OK]
Compiling: lib/chibios/os/hal/src/hal_mac.c [OK]
Compiling: lib/chibios/os/hal/src/hal_mmc_spi.c [OK]
Compiling: lib/chibios/os/hal/src/hal_pal.c [OK]
Compiling: lib/chibios/os/hal/src/hal_pwm.c [OK]
Compiling: lib/chibios/os/hal/src/hal_qspi.c [OK]
Compiling: lib/chibios/os/hal/src/hal_rtc.c [OK]
Compiling: lib/chibios/os/hal/src/hal_sdc.c [OK]
Compiling: lib/chibios/os/hal/src/hal_serial.c [OK]
Compiling: lib/chibios/os/hal/src/hal_serial_usb.c [OK]
Compiling: lib/chibios/os/hal/src/hal_spi.c [OK]
Compiling: lib/chibios/os/hal/src/hal_st.c [OK]
Compiling: lib/chibios/os/hal/src/hal_uart.c [OK]
Compiling: lib/chibios/os/hal/src/hal_usb.c [OK]
Compiling: lib/chibios/os/hal/src/hal_wdg.c [OK]
Compiling: lib/chibios/os/hal/ports/common/ARMCMx/nvic.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/K20x/hal_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/LLD/hal_pal_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/LLD/hal_serial_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/K20x/hal_spi_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/LLD/hal_i2c_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/LLD/hal_ext_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/LLD/hal_adc_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/LLD/hal_gpt_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/K20x/hal_pwm_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/LLD/hal_st_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/ports/KINETIS/LLD/hal_usb_lld.c [OK]
Compiling: lib/chibios-contrib/os/hal/boards/PJRC_TEENSY_3_1/board.c [OK]
Compiling: lib/chibios/os/hal/lib/streams/chprintf.c [OK]
Compiling: lib/chibios/os/hal/lib/streams/memstreams.c [OK]
Compiling: lib/chibios/os/hal/lib/streams/nullstreams.c [OK]
Assembling: lib/chibios/os/common/startup/ARMCMx/compilers/GCC/crt0_v7m.S [OK]
Assembling: lib/chibios/os/common/ports/ARMCMx/compilers/GCC/chcoreasm_v7m.S [OK]
Linking: .build/whitefox_default.elf [OK]
Creating load file for Flash: .build/whitefox_default.hex [OK]

Size after:
   text	   data	    bss	    dec	    hex	filename
      0	  24868	      0	  24868	   6124	whitefox_default.hex

This outputs the following files:

$ ls -lAh .build
total 4528
-rwxr-xr-x   1 kmost  staff   249K Feb  9 12:47 ergodox_ez_default.elf
-rw-r--r--   1 kmost  staff    64K Feb  9 12:47 ergodox_ez_default.hex
-rw-r--r--   1 kmost  staff   245K Feb  9 12:47 ergodox_ez_default.map
drwxr-xr-x   2 kmost  staff    68B Feb  9 12:47 obj_ergodox_ez
drwxr-xr-x  26 kmost  staff   884B Feb  9 12:47 obj_ergodox_ez_default
drwxr-xr-x   6 kmost  staff   204B Feb  9 12:50 obj_whitefox
drwxr-xr-x  16 kmost  staff   544B Feb  9 12:50 obj_whitefox_default
drwxr-xr-x  16 kmost  staff   544B Feb  9 12:05 obj_whitefox_matt3o
-rwxr-xr-x   1 kmost  staff   383K Feb  9 12:50 whitefox_default.elf
-rw-r--r--   1 kmost  staff    68K Feb  9 12:50 whitefox_default.hex
-rw-r--r--   1 kmost  staff   396K Feb  9 12:50 whitefox_default.map
-rwxr-xr-x   1 kmost  staff   374K Feb  9 12:05 whitefox_matt3o.elf
-rw-r--r--   1 kmost  staff    68K Feb  9 12:05 whitefox_matt3o.hex
-rw-r--r--   1 kmost  staff   393K Feb  9 12:05 whitefox_matt3o.map

I was unsure of which one to flash, so I tried all 3 (whitefox_default.hex, .elf, and .map). All 3 leave my keyboard in DFU mode even if I unplug it and plug it back in.

Any more info that I can provide to help with this? @belak's work to get QMK running on the Whitefox are very much appreciated, and I'd really like to get it running on my own Whitefox if possible. :)

@belak
Copy link
Contributor Author

belak commented Feb 9, 2017

I need to look into the tooling behind this but what I did when I was testing this was run make with the dfu option because you need it to generate a .bin file then flash that manually because using the Makefile never worked 100% for me.

Also, if I remember correctly, when you press the button on the back, it expects either a valid firmware to be uploaded or the power cycled... So you may not need to flash tmk when it fails.

@belak
Copy link
Contributor Author

belak commented Feb 9, 2017

Ok, I just messed with it and make whitefox-matt3o-dfu-util worked. If you're still having issues and want to try debugging it, I usually idle in #input.club on freenode and I'd be happy to help there.

@kevinmost
Copy link

Thanks for the fast reply! make whitefox-matt3o-dfu-util does work (though for me it fails on flashing because dfu-util detects some other device that I can't identify, and so I have to specify a serial when I flash... not sure if there's a way for me to specify that serial from the make command). Regardless, make whitefox-matt3o-dfu-util ; dfu-util -D .build/whitefox_matt3o.bin --serial mk20dx256vlh7 is working!

Unfortunately I'm having another issue (potentially unrelated to this, because I see it on TMK as well) where my modifiers are all wonky, and whatever key I set as my GUI key isn't working. Maybe I can hop into the #input.club channel tonight to try to debug it.

Thanks again!

@belak
Copy link
Contributor Author

belak commented Feb 9, 2017

@kevinmost I think the most likely thing there is that something is stuck on in the Boot Magic (see https://github.com/tmk/tmk_keyboard#keymap). I ran into the issue with ` and ESC being swapped (#987 (comment)). The issue you describe sounds similar to some of the other Boot Magic options. So you may want to try booting it up and clearing the EEPROM (I think that's hold Space and Backspace on startup).

@kevinmost
Copy link

I don't think I ever would have guessed that that was the issue. Thanks so much for the help, @belak.

@kimkimkeren kimkimkeren mentioned this pull request Sep 3, 2017
mattpcaswell pushed a commit to mattpcaswell/qmk_firmware that referenced this pull request Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants