Unsure what happened to USBCore.cpp

Hello!

I've been making a custom keyboard device for low latency, and would really like to change the polling rate of my Arduino from default to 1kHz polling. I've found that you can modify the USBCore.cpp file in order to achieve this- however- I am unable to find the USBCore file or another file I can modify for the same purpose. (I'm using the Arduino IDE's Apple Silicon 2.3.6 version.)
Does anybody know where the file I am looking for is?

Thanks for your time!

Hi @itextury. Because the code in this file is architecture-specific, it is part of the Arduino core that implements the Arduino API for a given set of boards. This means the location (and existence) of the relevant file depends on which board you are compiling for.

So please tell us the exact selection you are using in Arduino IDE's Tools > Board menu. That information should allow us to answer your question.

Thanks for the information!

Apparently, I am not even using an actual Arduino. The microcontroller I'm using is a SparkFun Pro Micro clone that shows up as "Arduino Leonardo" in the IDE. (The actual chip is a ATmega32U4.) It makes sense why I have not been able to find USBCore.cpp.

No, it does not make sense. For Windows: C:\Users\yourUsername\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino

For other operating systems, consult https://support.arduino.cc/hc/en-us/articles/4415103213714-Find-sketches-libraries-board-cores-and-other-files-on-your-computer#boards for the location of the Arduino15 directory.

Thanks, but I should have clarified, I am on a MacBook, and the entire Arduino15 directory is missing in the Library folder, which is why I can't find USBCore. I think I'll switch to a windows laptop and try to find the file.

I'm going to ask you to provide the full verbose output from a compilation on the MacBook.


:red_exclamation_mark: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Open your sketch in Arduino IDE.
  2. Select the board you have been using from Arduino IDE's Tools > Board menu.
  3. Select Arduino IDE > Settings... from the Arduino IDE menus.
    The "Preferences" dialog will open.
  4. Check the box next to "Show verbose output during: ☐ compile" in the "Preferences" dialog.
  5. Click the "OK" button.
    The "Preferences" dialog will close.
  6. Select Sketch > Verify/Compile from the Arduino IDE menus.
  7. Wait for the compilation to finish.
  8. Right click on the black "Output" panel at the bottom of the Arduino IDE window.
    A context menu will open.
  9. Select Copy All from the menu.
  10. Open a reply here on this forum topic by clicking the "Reply" button.
  11. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  12. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the compilation output into the code block.
  13. Move the cursor outside of the code block markup before you add any additional text to your reply.
  14. Click the "Reply" button to publish the post.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.

Click here for attachment instructions

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a reply here on this forum topic by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:

    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

Here's the output (I censored my name):

FQBN: arduino:avr:leonardo
Using board 'leonardo' from platform in folder: /Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6
Using core 'arduino' from platform in folder: /Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6

Detecting libraries used...
/Users/myname/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/leonardo /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch/sketch_aug31aofficial.ino.cpp -o /dev/null
Alternatives for HID-Project.h: [HID-Project@2.8.4]
ResolveLibrary(HID-Project.h)
  -> candidates: [HID-Project@2.8.4]
/Users/myname/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/leonardo -I/Users/myname/Documents/Arduino/libraries/HID-Project/src /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch/sketch_aug31aofficial.ino.cpp -o /dev/null
Alternatives for HID.h: [HID@1.0]
ResolveLibrary(HID.h)
  -> candidates: [HID@1.0]
/Users/myname/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/leonardo -I/Users/myname/Documents/Arduino/libraries/HID-Project/src -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/libraries/HID/src /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch/sketch_aug31aofficial.ino.cpp -o /dev/null
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/MultiReport/AbsoluteMouse.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/MultiReport/Consumer.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/MultiReport/Gamepad.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/MultiReport/ImprovedKeyboard.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/MultiReport/ImprovedMouse.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/MultiReport/NKROKeyboard.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/MultiReport/SurfaceDial.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/MultiReport/System.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/BootKeyboard.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/BootMouse.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/RawHID.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/SingleAbsoluteMouse.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/SingleConsumer.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/SingleGamepad.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/SingleNKROKeyboard.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/SingleSystem.cpp
Using cached library dependencies for file: /Users/myname/Documents/Arduino/libraries/HID-Project/src/port/samd.cpp
Using cached library dependencies for file: /Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/libraries/HID/src/HID.cpp
Generating function prototypes...
/Users/myname/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/leonardo -I/Users/myname/Documents/Arduino/libraries/HID-Project/src -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/libraries/HID/src /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch/sketch_aug31aofficial.ino.cpp -o /private/var/folders/r2/qmbn5s7x391_4j3ml09yqqdw0000gn/T/3598526141/sketch_merged.cpp
/Users/myname/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /private/var/folders/r2/qmbn5s7x391_4j3ml09yqqdw0000gn/T/3598526141/sketch_merged.cpp

Compiling sketch...
/Users/myname/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Leonardo\"" -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/leonardo -I/Users/myname/Documents/Arduino/libraries/HID-Project/src -I/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/libraries/HID/src /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch/sketch_aug31aofficial.ino.cpp -o /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch/sketch_aug31aofficial.ino.cpp.o
In file included from /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/../HID-APIs/KeyboardAPI.h:29:0,
                 from /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/../HID-APIs/DefaultKeyboardAPI.h:27,
                 from /Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/BootKeyboard.h:30,
                 from /Users/myname/Documents/Arduino/libraries/HID-Project/src/HID-Project.h:50,
                 from /Users/myname/Documents/Arduino/sketch_aug31aofficial/sketch_aug31aofficial.ino:1:
/Users/myname/Documents/Arduino/libraries/HID-Project/src/SingleReport/../HID-APIs/../KeyboardLayouts/ImprovedKeylayouts.h:54:21: note: #pragma message: Using default ASCII layout for keyboard modules
     #pragma message "Using default ASCII layout for keyboard modules"
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiling libraries...
Compiling library "HID-Project"
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/MultiReport/Consumer.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/MultiReport/AbsoluteMouse.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/MultiReport/Gamepad.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/SingleReport/RawHID.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/SingleReport/SingleAbsoluteMouse.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/MultiReport/ImprovedKeyboard.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/SingleReport/SingleSystem.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/MultiReport/NKROKeyboard.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/SingleReport/SingleGamepad.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/port/samd.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/MultiReport/System.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/SingleReport/BootMouse.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/MultiReport/ImprovedMouse.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/SingleReport/BootKeyboard.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/SingleReport/SingleNKROKeyboard.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/MultiReport/SurfaceDial.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/SingleReport/SingleConsumer.cpp.o
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/HID-Project.a
Compiling library "HID"
Using previously compiled file: /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID/HID.cpp.o
Compiling core...
Using precompiled core: /Users/myname/Library/Caches/arduino/cores/arduino_avr_leonardo_bca13ddfca9706eb420c534bf6cae500/core.a
Linking everything together...
/Users/myname/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega32u4 -o /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch_aug31aofficial.ino.elf /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch/sketch_aug31aofficial.ino.cpp.o /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID-Project/HID-Project.a /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/libraries/HID/HID.cpp.o /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/../../cores/arduino_avr_leonardo_bca13ddfca9706eb420c534bf6cae500/core.a -L/Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62 -lm
/Users/myname/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch_aug31aofficial.ino.elf /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch_aug31aofficial.ino.eep
/Users/myname/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -R .eeprom /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch_aug31aofficial.ino.elf /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch_aug31aofficial.ino.hex
Using library HID-Project at version 2.8.4 in folder: /Users/myname/Documents/Arduino/libraries/HID-Project 
Using library HID at version 1.0 in folder: /Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/libraries/HID 
/Users/myname/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-size -A /Users/myname/Library/Caches/arduino/sketches/5829290715E98C77387C351E35595F62/sketch_aug31aofficial.ino.elf
Sketch uses 6200 bytes (21%) of program storage space. Maximum is 28672 bytes.
Global variables use 221 bytes (8%) of dynamic memory, leaving 2339 bytes for local variables. Maximum is 2560 bytes.

Apparently, I was dumb enough to look in the wrong library folder, but regardless, the library folder I was supposed to be looking in doesn't exist under the Users directory.

This tells us that the core is located at the following path on your computer:

/Users/myname/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/arduino

You will find the file USBCore.cpp in that folder.


:red_exclamation_mark: The /Users/myname/Library folder is hidden by default. You can make it visible by pressing the Command+Shift+. keyboard shortcut.


Thank you so much! It was there! Never in a million years would I have considered that hidden folders on Mac were even a thing, lol.

You are welcome. I'm glad if I was able to be of assistance.

Regards, Per