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

LUFA stack using 10-20% CPU in "System Interrupts" (windows) #223

Closed
tocklime opened this issue May 21, 2015 · 8 comments
Closed

LUFA stack using 10-20% CPU in "System Interrupts" (windows) #223

tocklime opened this issue May 21, 2015 · 8 comments

Comments

@tocklime
Copy link

So I noticed in resmon.exe that "System Interrupts" or "Deferred Procedure Calls and Interrupt Service Routines" was taking 10-20% CPU nearly all the time.

Unplugging my ergodox (with TMK/LUFA stack) made the problem go away.

Out of interest, I recompiled the firmware with the PJRC stack, and the problem went away as well (although the PJRC stack has other issues).

I've made 2 traces I recorded using USBPcap - in both recordings I pressed the windows key a couple times then Ctrl-Ced the recording. You can see the LUFA one is constantly raising interrupts, but the PJRC one only raised a handful.

I don't know how to read USB/HID frames. Any idea what the LUFA firmware is trying to do? Or a better way of inspecting the traffic?

LUFA recording
PJRC recording

Let me know if you'd rather I raised this on @cub-uanic 's ergodox branch, but he has said in another issue that he hasn't played with the USB stacks.

@tmk
Copy link
Owner

tmk commented May 21, 2015

Most of that LUFA data is probably 'debug console data'(Endpoint 4 IN), uneeded empty data seems to be sent every 1ms. Console_Task of protocol/lufa/lufa.c may be a cause.

Build firmware with commenting out CONSOLE_ENABLE line of your Makefile to see the difference of CPU usage.

@tocklime
Copy link
Author

Commenting out CONSOLE_ENABLE seems to produce a firmware which doesn't work at all (well, Magic-Space-B got me back to the bootloader, but it didn't work as a keyboard.)

@tocklime
Copy link
Author

...actually, it works a bit more than that. Layer switching works, and my bootloader keystroke works, and power. But none of the normal keys seem to.

@tmk
Copy link
Owner

tmk commented May 21, 2015

You are on Windows? If so remove device drivers of your keyboard from Device Manager.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Build#2-remove-drivers-from-device-managerwindows

@tocklime
Copy link
Author

Thanks. I'm now running LUFA without the cpu drain, but also without the console. I don't really need the console for day to day use (although I did have an idea to make a layer visualiser using a wrapped hid_listen.exe).

@tmk
Copy link
Owner

tmk commented May 21, 2015

I'll look into Console_Task code later.

BTW, What's your OS actually? I don't see this problem on my Windows 7.

@tmk tmk added the TODO label May 21, 2015
@tocklime
Copy link
Author

Windows 8.1 Pro. I've got another win 8.1 pro machine at home. I'll try it on that later and see if I get the same behaviour.

tmk added a commit that referenced this issue May 22, 2015
Old console sent unneeded empty data every one milli sencond.
After this fix console flushes endpoint data bank every 50ms only when needed.
@tmk
Copy link
Owner

tmk commented May 22, 2015

Hopefully fixed at fdce0c9

@tmk tmk removed the TODO label May 22, 2015
@tmk tmk closed this as completed May 26, 2015
tmk added a commit that referenced this issue Sep 24, 2015
57d27a8 Merge branch 'core_update_150924' into core
024abe3 core: Fix NKRO ifdef
7aa2d30 core: Fix for disabling NKRO in Boot protocol
95651fd core: Fix message print of debug command
c20cd29 lufa: Fix endpoint bank mode for ATMega32u2
82ac21f next_usb: Fix next_kbd_set_leds()
537d9c7 Change to KC_BOOTLOADER(KC_BTLD)
f2b3772 Add an assignable RESET key
fc99257 Fix parenthesis
e852582 Fix weak modifier clear in action macro
c2a6c5c core: Fix lufa suspend callback(#234)
fa548c5 usb_usb: Ignore error usage(0x01-03) report
513d95c usb_usb: Support locking key indicator LED
cd78802 core: Add keymap section ldscript for ATMega32U2
70c9abd Add description for non-US keys on keycode.h
538c192 lufa: Fix console flush #223
87628c9 Revert "Make action_for_key a weak symbol"
3c0a1ba Make action_for_key a weak symbol
6bb0d7d ibm4704_usb: Fix protocol handling
b6ef5cf Add keyboard_setup() and matrix_setup()
f4bb8b2 ibm4704_usb: Fix interrupt of clock(rising edge)
0c1fcc1 usb_usb: Change debug LED pin config
595710d Reduce code size of magic commands
6bed174 Add description of AVR bootloader and boot section
54c6a01 Merge commit 'f6d56675f9f981c5464f0ca7a1fbb0162154e8c5'
d18d42e Merge branch 'core-update2' into core
febec88 Add compile options '-fdata-sections'

git-subtree-dir: tmk_core
git-subtree-split: 57d27a8
tmk added a commit that referenced this issue Sep 24, 2015
Old console sent unneeded empty data every one milli sencond.
After this fix console flushes endpoint data bank every 50ms only when needed.
kairyu pushed a commit to kairyu/tmk_keyboard that referenced this issue Jun 14, 2016
Old console sent unneeded empty data every one milli sencond.
After this fix console flushes endpoint data bank every 50ms only when needed.
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

No branches or pull requests

2 participants