CJMCU ATMEGA32U4 uploud fails

Hello everyone :slight_smile:
i buy CJMCU-Virtual Keyboard

when i choose leonardo and port for example :

now everythink is ok, but when i try uploud blink or somethink i see this problem :

Using board 'leonardo' from platform in folder: /home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3
Using core 'arduino' from platform in folder: /home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3
Detecting libraries used...
/home/anonim/.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/home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino -I/home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/leonardo /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/sketch/Blink.ino.cpp -o /dev/null
Generating function prototypes...
/home/anonim/.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/home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino -I/home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/leonardo /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/sketch/Blink.ino.cpp -o /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/preproc/ctags_target_for_gcc_minus_e.cpp
/home/anonim/.arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
/home/anonim/.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/home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino -I/home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/leonardo /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/sketch/Blink.ino.cpp -o /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/sketch/Blink.ino.cpp.o
Compiling libraries...
Compiling core...
Using precompiled core: /tmp/arduino-core-cache/core_arduino_avr_leonardo_1d4fdf34474d3b807a7f6bdcbc7888fc.a
Linking everything together...
/home/anonim/.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 /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/Blink.ino.elf /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/sketch/Blink.ino.cpp.o /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/../arduino-core-cache/core_arduino_avr_leonardo_1d4fdf34474d3b807a7f6bdcbc7888fc.a -L/tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D -lm
/home/anonim/.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 /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/Blink.ino.elf /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/Blink.ino.eep
/home/anonim/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -R .eeprom /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/Blink.ino.elf /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/Blink.ino.hex
/home/anonim/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-size -A /tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/Blink.ino.elf
Sketch uses 3956 bytes (13%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.

Compilation complete.
Performing 1200-bps touch reset on serial port /dev/ttyACM0
Waiting for upload port...
No upload port found, using address:"/dev/ttyACM0" protocol:"serial" as fallback
"/home/anonim/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" "-C/home/anonim/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega32u4 -cavr109 "-P/dev/ttyACM0" -b57600 -D "-Uflash:w:/tmp/arduino-sketch-0712C79A2A72A3057A356ED4E506412D/Blink.ino.hex:i"

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "/home/anonim/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
     User configuration file is "/home/anonim/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : /dev/ttyACM0
     Using Programmer              : avr109
     Overriding Baud Rate          : 57600

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

avrdude done. Thank you.

Upload error: Failed uploading: uploading error: exit status 1

and than i cant choose a port, a must open again andrino-ide and then i see the port .

I try this on Kali Linux and WIndows 10

Hi @gkmuuupil. Please run this simple test to make sure that /deve/ttyACM0 is really the port of your CJMCU-Virtual Keyboard board:

  1. Unplug your Arduino board from the computer.
  2. Select Tools > Port from the Arduino IDE's menus.
  3. Note the ports, if any, listed in the menu.
  4. Close the Tools menu.
    The ports list is only updated when the Tools menu is re-opened, so this step is essential.
  5. Plug your Arduino board into the computer.
  6. Select Tools > Port from the Arduino IDE's menus. - The new port listed in the menu is the one for your Arduino board.

If you don't see a new port appear, then we need to investigate that problem.

thanks for Your answer :slight_smile:

now i resolved the problem ( when i ploud something i must click the button on my board) but i have another ...

when i try uploud anythink with " include "DigiKeyboard.h " i cant and i see error syntax .

when a try uploud blink eveythink is work .

I'm glad to hear you found the solution for the upload problem!

I'm going to ask you to post some additional information that might help us to identify the problem.

Please do this:

  1. Right click on the black "Output" pane at the bottom of the Arduino IDE 2.x window.
  2. From the context menu, click Copy All.
  3. Open a forum reply here by clicking the Reply button.
  4. Click the </> 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.
    Code block
  5. Press Ctrl+V. This will paste the compilation output into the code block.
  6. Move the cursor outside of the code tags before you add any additional text to your reply.
  7. Click the Reply button to post the output.
In file included from /home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/Keyboard.cpp:22:0:
/home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/Keyboard.h:25:10: fatal error: HID.h: No such file or directory
 #include "HID.h"
compilation terminated.
Compilation error: Error: 13 INTERNAL: exit status 1

when i try in arduino ide 2.0.0 beta 12 i see this error.

now when i try anythink for example blink , have same error every time ....

/home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/Keyboard.h:25:10: fatal error: HID.h: No such file or directory
 #include "HID.h"
compilation terminated.
Compilation error: Error: 13 INTERNAL: exit status 1

wpisz lub wklej tutaj kod

now i try in Windows and stable 1.8.16 version and ...

when i try blink everythink is ok

but when i try script with #include "DigiKeyboard.h"

Please tell me how this "Keyboard.h" file ended up in /home/anonim/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/

The "DigiKeyboard" library is written for the ATTiny85-based DigiSpark board. It is bundled with the boards platform for the DigiSpark board. You can't use it with your ATmega32U4-based board. For your board, you should use the standard Keyboard library:

1 Like

Ok so please tell me what i must do now :slight_smile:
i can make a new OS , WIn10 or Kali Linux .

ANd here You are the code from DigiKeyboard.h


  Copyright (c) 2015, Arduino LLC
  Original code (pre-library): Copyright (c) 2011, Peter Barrett

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

#ifndef KEYBOARD_h
#define KEYBOARD_h

#include "HID.h"

#if !defined(_USING_HID)

#warning "Using legacy HID core (non pluggable)"


//  Keyboard

#define KEY_LEFT_CTRL   0x80
#define KEY_LEFT_SHIFT    0x81
#define KEY_LEFT_ALT    0x82
#define KEY_LEFT_GUI    0x83
#define KEY_RIGHT_CTRL    0x84
#define KEY_RIGHT_SHIFT   0x85
#define KEY_RIGHT_ALT   0x86
#define KEY_RIGHT_GUI   0x87

#define KEY_UP_ARROW    0xDA
#define KEY_DOWN_ARROW    0xD9
#define KEY_LEFT_ARROW    0xD8
#define KEY_RIGHT_ARROW   0xD7
#define KEY_BACKSPACE   0xB2
#define KEY_TAB       0xB3
#define KEY_RETURN      0xB0
#define KEY_ESC       0xB1
#define KEY_INSERT      0xD1
#define KEY_DELETE      0xD4
#define KEY_PAGE_UP     0xD3
#define KEY_PAGE_DOWN   0xD6
#define KEY_HOME      0xD2
#define KEY_END       0xD5
#define KEY_CAPS_LOCK   0xC1
#define KEY_F1        0xC2
#define KEY_F2        0xC3
#define KEY_F3        0xC4
#define KEY_F4        0xC5
#define KEY_F5        0xC6
#define KEY_F6        0xC7
#define KEY_F7        0xC8
#define KEY_F8        0xC9
#define KEY_F9        0xCA
#define KEY_F10       0xCB
#define KEY_F11       0xCC
#define KEY_F12       0xCD

//  Low level key report: up to 6 keys and shift, ctrl etc at once
typedef struct
  uint8_t modifiers;
  uint8_t reserved;
  uint8_t keys[6];
} KeyReport;

class Keyboard_ : public Print
  KeyReport _keyReport;
  void sendReport(KeyReport* keys);
  void begin(void);
  void end(void);
  size_t write(uint8_t k);
  size_t press(uint8_t k);
  size_t release(uint8_t k);
  void releaseAll(void);
extern Keyboard_ Keyboard;


ok when i put good script for example icnlude not DigiKeyboard.h , but Keyboard.h and then i see this problem

/tmp/.arduinoIDE-unsaved2021108-364670-f4tqs1.5r9e6/sketch_nov8a/sketch_nov8a.ino: In function 'void setup()':
/tmp/.arduinoIDE-unsaved2021108-364670-f4tqs1.5r9e6/sketch_nov8a/sketch_nov8a.ino:37:26: error: wrong type argument to unary minus
Compilation error: Error: 13 INTERNAL: exit status 1

It is not necessary to make a new OS. I am still curious about how that Keyboard.h file ended up in your core, but I guess I'll give up on solving that mystery. So let's move on.

First of all, I want to make something very clear to you because I don't think I got through yet:


Enough said about that. Now for the solution:

Your installation of the "Arduino AVR Boards" platform of the Leonardo has somehow been corrupted. The solution is to remove the bad installation. Please follow these instructions:

  1. Select Tools > Board > Boards Manager from the Arduino IDE menus.
  2. Wait for the updates to finish.
  3. Scroll down through the list of boards platforms until you see "Arduino AVR Boards by Arduino". Click on it.
  4. Click the Remove button.
  5. In the "Please confirm boards deletion" dialog, click the Yes button.
  6. Wait for the removal to finish.
  7. Click the Close button.

Next, I want you to try out one of the simple Keyboard library examples so you can get familiar with the library.

  1. Select File > Examples > 09.USB > Keyboard > KeyboardSerial from the Arduino IDE menus.
  2. Upload the sketch to your "CJMCU-Virtual Keyboard" board.
  3. Wait for the upload to finish successfully.
  4. Select Tools > Serial Monitor from the Arduino IDE menus. The Serial Monitor window will now open.
  5. Click on the input field at the top of the Serial Monitor window.
  6. Type the letter a
  7. Press Enter on your keyboard.

You should now see that the a in the input field has magically changed to b! The reason is because you sent an a to the board and it typed b. If you press Enter again, it will send that b to the board and the board will type c.

So it is just a silly example sketch that isn't good for much. But what it is good for is providing a simple demonstration of the Keyboard library to get you started. Once you have that, you can start to create your own sketches using the library, following the documentation on this page:

There are also some other example sketches for the library if you want some other demonstrations.

1 Like

thank you very much :slight_smile:
now I think I understand the basics
Thank you again for the quick replies and for your time :slightly_smiling_face:

All good for You :slight_smile:

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

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.