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

Leonardo Bootloader Corruption when I use RawHID.begin #108

Open
unicorn79 opened this issue May 22, 2017 · 6 comments
Open

Leonardo Bootloader Corruption when I use RawHID.begin #108

unicorn79 opened this issue May 22, 2017 · 6 comments

Comments

@unicorn79
Copy link

unicorn79 commented May 22, 2017

Good afternoon! I use this sketch to work with boot keyboard, mouse and USBHID (i have arduino-ide-1.8.0-windows):

#include "HID-Project.h"
#include <avr/wdt.h>

uint8_t rawhidData[255];

void setup() {
 
  // initialize mouse and keyboard control:
  BootKeyboard.begin();
  BootMouse.begin();
  RawHID.begin(rawhidData, sizeof(rawhidData));
  wdt_enable (WDTO_2S);
}

void loop() {
	wdt_reset();

}

it works, after burning, but when i load next sketch (even the same) to my Arduino Leonardo (clone), it seems to corrupt my Leonardo Bootloader or some kind.
So if i try to Load this sketch once again by pressing reset button, no "Arduino Leonardo (COM$$)" appears, so sketch loading cannot be completed.
When i reload leonardo Bootloader with USBASP (from IDE - "Load Bootloader"), and try to load sketch , where is excluded RawHID.begin(rawhidData, sizeof(rawhidData));), the Leonardo bootloader works fine and seems to be not corrupted, it appears good when i press "reset" button...

#include "HID-Project.h"
#include <avr/wdt.h>

uint8_t rawhidData[255];

void setup() {
 
  // initialize mouse and keyboard control:
  BootKeyboard.begin();
  BootMouse.begin();
  //RawHID.begin(rawhidData, sizeof(rawhidData));
  wdt_enable (WDTO_2S);
}

void loop() {
	wdt_reset();

}

Any ideas? Thanks!!

@NicoHood
Copy link
Owner

NicoHood commented May 22, 2017

I dont really understand your issue, no do i understand why you are using the watchdog?

The bootloader should always run if you press enter and then plug in the device. Which bootloader do you use? Hoodloader2 or the arduino bootloader?

@unicorn79
Copy link
Author

I use the standart arduino bootloader from IDE (Tools->write loader), not a Hoodloader2. So i loading my sketch to my Arduino Leonardo, and it works fine. As you can see it is a 2 USB HID Devices At the same time (1 USB HID Keyboard and 1 USB HID Mouse).. The code:

#include "HID-Project.h"

uint8_t rawhidData[255];

void setup() {
 
// initialize mouse and keyboard control:
  BootKeyboard.begin();
  BootMouse.begin();
}

void loop() {

}

After that i press the reset button, wait the Arduino Loader Appears in COM-ports (its OK), and then load next sketch with a 3 device At the same time (1 USB HID Keyboard, 1 USB HID Mouse, 1 Custom USB HID Device). The code is following:

#include "HID-Project.h"

uint8_t rawhidData[255];

void setup() {
 
// initialize mouse and keyboard control:
  BootKeyboard.begin();
  BootMouse.begin();
  RawHID.begin(rawhidData, sizeof(rawhidData));
}

void loop() {

}

it seems to loading OK in Leonardo, and works fine, but All my further attempts to load the any other sketches fail, because the Arduino loader does not work any more. It seems to be corrupted, when i load more than 2 devices in sketch at the same time. As you can see in the previous code - there are 3 USB HID devices in a row. I think this is the reason for the corruption of the Arduino bootloader. The Arduino Bootloader simply not appears in COM-ports after i press Reset button.

Did anyone else have such problems with the bootloader, when you load sketch with 3 devices that used at the same time (mouse + keyboard + custom USB HID)?

I will be grateful for your advice!

Thanks!

PS: Sorry for my English ((

@NicoHood
Copy link
Owner

Do you use windows? I currently have no device and time to test. Someone else would need to help you. Or you should open a bug at the arduino project. Because this should never kill a bootloader. I am really confused whats happening.

@unicorn79
Copy link
Author

unicorn79 commented May 25, 2017

I use Windows 7 x64 OS, and I'm surprised that no one before this incident has encountered such a problem. I will try myself to find out the cause of such an undesirable effect, and, in case of luck, I'll try to describe the solution there.

PS; Thank you personally, NicoHood, for such a wonderful realization of HID Boot-protocol!

@unicorn79
Copy link
Author

For those, who will be getting a similar problem: Simultaneous use of three devices in one Arduino Leonardo - 1) Boot-keyboard 2) Boot-mouse 3) Custom USB HID device
It was determined by the test method that the function RESET is working incorrectly by Pressing the Reset button on the Leonardo board. However, when you unplug the USB-connector of Leonardo and connect in back - the Bootloader appears correctly, which makes it possible to load the sketch further.

@NicoHood
Copy link
Owner

@unicorn79 Thanks for the feedback. I think I reported that issue somewhere but I can only find this as reference:
https://github.com/arduino/Arduino/issues/3756

Can you maybe try HoodLoader2? It wont cause you any additional trouble and might fix your issue. Or you can try to compile the LUFA CDC bootloader with my PR (arduino fix) applied: abcminiuser/lufa#86

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