Git Product home page Git Product logo

hoodloader2's Introduction

HoodLoader2.0.5

header

HoodLoader2 is a CDC BootLoader with self reprogramming and Fast USB-Serial function.

An Arduino Uno/Mega board has two Microcontroller of which one(16u2) is normally used for USB-Serial translation. But we can also use it as standalone AVR Microcontroller with (or without) USB functions as well.

HoodLoader2 gives you the option to reprogram the 16u2 of a normal Arduino Uno/Mega R3 with custom sketches. This means you can use the 16u2 as a normal USB AVR like a Leonardo. You have a full compatible USB-HID core, CDC Serial and you can also use the 7 i/o pins of the 16u2. The extended HID devices of the HID Project also apply for the HoodLoader2.

The 16u2 is somehow limited in its functions but still a great addition if you know how to use it. It also compatible with FastLED and IRLremote(with PCINT) for example.

The great thing about this is that you actually have two fully Arduino compatible Microcontrollers in one Arduino Uno/Mega board – the board most of you already own. Your IO MCU (328/2560) is still reprogrammable if you enter bootloader mode. All you need for this is a normal Arduino Uno/Mega R3 and some cables to install the new HoodLoader2.

With version 2.0.5 you can now use HoodLoader2 also on a 32u4 which gives you even more power.

Please read the wiki carefully to avoid any problems. You will find most of the answers to your questions already in the wiki.

Buy Me A Coffee

Wiki

All documentation moved to the wiki page (most up to date documentation).

An offline snapshot (also for older versions) is available in releases

Contact

Contact information can be found here:

www.nicohood.de

Version History

2.0.5 Release (26.09.2015)
* No need for HID-Project anymore, PR3640 added u2 support to IDE 1.6.6
* Added up to 2M baud support (thx to https://github.com/urjaman/fast-usbserial)
* Improved USART reconfiguration
* Changed Magic Key to RAMEND
  (requires new HID-Project IDE patch, but is still backwards compatible)
* Saved a lot of ram by moving descriptors to PROGMEM (8/16u2)
* Added 32u4 support with saver bootkey option and backwards compatibility
* Added at90usb82 support
* Added EEPROM program support for 32u2
* Switch to U2Xn=0 if needed
* Added USB reconnect support
* General improvements to reduce flash size
* Updated and improved Installation sketch
* Added standard Uno/Mega bootloaders
* Removed /tools folder and added information to wiki instead
* Added recompile option to change single/double tab reset
* Added recompile option to change power on behavior
* Added optional old Atmega328 bootloader compatibility(baud 57600),
  only when compiled with a different baud
* Note: Can only be (re)compiled with AVR-GCC 5.1 and LTO (see wiki)

2.0.4 Release (20.03.2015)
* HoodLoader2.0.4
 * Upload verification on USB hubs fix in bootloader
 * Fixed 1 byte buffer overflow
 * Improved installation sketch
 * Moved to Lufa Board definition (with a fix)
* Added HID-Project 2.2 compatibility
 * Added boards.txt for Uno/Mega + HID-Bridge
 * Improved Uno/Mega uploading (no double tab needed any more)
 * Updated USB drivers for better PC side recognition
   (Each USB core has a different PID + Windows driver)
 * Fixed wrong PIDs in boards.txt

2.0.3 Release (28.01.2015)
* Added HID Project 2.1 board definition compatibility
* Fixed usb flag pass via boards.txt (instead of pins_arduino.h)
* Fixed 16u2 4 pin header pinout picture
* DFU burn bootloader fix
* HoodLoader2.0.3 released (minor firmware CDC identifier fix)
* Added 32u2 bootloader to the installation sketch as well
* Improved flash.bat file and included avrdude for windows
* Improved Readme instructions
* Updated USB drivers with 4 different PIDs
* Moved documentation to the wiki

2.0.2 Release (30.11.2014)
* HID Project 2.0 official released:
 * Added Arduino IDE Integration for HoodLoader2
 * See official changelog for more information.
* HoodLoader2.0.2 released (led off fix)

2.0.1 Pre-Release (29.11.2014)
* HoodLoader2.0.1 Release
 * Better, full reset after bootloader execution with watchdog
 * This fixes the "No-USB" workaround with the USB clock
 * Fixed fuse bug
 * Fixed magic key passed from Arduino core (HID Project)
 * Changed some descriptor names, bugfix above freed some space
 * Special case 57600 baud for compatibility with the ATmega328 bootloader TODO resolved (baud reserved for cdc)
 * Reset of 328 when leaving Bootloader mode resolved (not possible to fix)
 * _delay_loop_2() instead delay function resolved (saves 2 bytes, more confusing + inaccurate than useful)
 * CPU_PRESCALE resolved (not needed for bootloader, watchdog will reset it anyways)
 * Re enabled LOCK_BYTE_WRITE_SUPPORT function (due to flash improvements)
 * Increased TX/RX EP_SIZE to 64 bytes
 * Increased Serial->USB Buffer to 128 bytes
* HID Project dev update related to the magic key bugfix
* Updated Atmega board programmer sketch with the new firmware and fuses

2.0.0 Beta-6 Release (05.11.2014)
* Added Arduino-IDE integration workaround for non USB usage

2.0.0 Beta-5 Release (05.11.2014)
* Improved Atmega Bootloader (added stop programming feature)

2.0.0 Beta-4 Release (04.11.2014)
* Improved Atmega Bootloader (Self flashing now works properly)

2.0.0 Beta-3 Release (03.11.2014)
* Improved Atmega Bootloader (DFU now possible)

2.0.0 Beta-2 Release (02.11.2014)
* Added Atmega Bootloader code (no DFU back possible)

2.0.0 Beta-1 Release (02.11.2014)
* Added CDC Bootloader
* Added USB-Serial function
* Made Repository Public

2.0.0 Alpha Release (22.10.2014)
* Added private Github repository with readme
* Added basic functions with dev states

License and Copyright

If you use this library for any cool project let me know!

Copyright (c) 2014-2015 NicoHood
See the readme for credit to other people.

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

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

hoodloader2's People

Contributors

lily-mara avatar nicohood avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hoodloader2's Issues

V-USB support

Can it be used with V-USB for chips without hardware USB?

Remove CDC

You explain: "Once you've uploaded your custom program it is possible that you don't have the CDC Serial any more. That might happen if you want to deactivate the USB functions or upload a custom firmware. "

How can I remove the CDC Serial so the device is really only acting as a keyboard, without the CDC serial?
Would removing the include HID.h do that?

16u2 to burn atmega328p bootloader

Hello, I read with interest and I'm wondering if is possible to use the 16u2 to burn a traditional atmega328p bootloader. It would be amazing, I mean to use 16u2 as ISP.
thanks

Mega2560 'successfully' flashed with HL2 but can't use Mouse

I flashed HL2 on a Mega2560 using a Leonardo, on an iMac. Everything seems fine (see transcript below). Note: I did not use a 100nF cap between Reset and Ground. I read somewhere along that it is not necessary. But this 'requirement' appeared in the output.

On an iMac, it is not clear how I could verify that it worked. The System profile shows: HoodLoader2 Uno.

I am using IDE1.6.9.

When I tried to compile a program with mouse functions for the Mega, the following appeared:
geninput:158: error: 'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?
Mouse.press(MOUSE_LEFT);
^

I included Mouse.h but the compiler can't seem to find it. The IDE "manage library" shows that Keyboard, Mouse, and HID are all installed, although these don't seem to show up in "libraries".

Additionally, I tried including HID-project.h and the following error turned up:
--- BEGIN
In file included from /Users/....ino:2:0:
/Users/.../Arduino/libraries/HID-Project/src/HID-Project.h:35:2: error: #error HID Project can only be used with an USB MCU.
#error HID Project can only be used with an USB MCU.
^
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
--- END

Transcript of HL2 process:

Atmega chip programmer.
Written by Nick Gammon, modified by NicoHood.
Version 1.32-HL205-B
Compiled on Jun 18 2016 at 14:12:22 with Arduino IDE 10609.

Welcome to the HoodLoader2 installation sketch!
This version will install HoodLoader2 on your Arduino

You selected number 3 as bootloader.
If this is not correct upload the program again with different settings

Make sure all wires are connected as written in the documentation.
Please now insert the 100nF capacitor between Reset and Ground on a standalon
e Arduino.
In some cases the Arduino will reset then and display these messages again.

On a standalone Arduino you will no longer see any messages here.
If you uploaded this sketch to a 2nd Aruino you will see some debug output.

If the installation was successfull the on board Led will start blinking fast
(every 100ms).
If the installation failed the on board Led will start blinking slow (every s
econd).

Starting programming in 10 seconds, please be patient and wait some time.

10
9
8
7
6
5
4
3
2
1
0

Attempting to enter programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x94 0x89
Processor = ATmega16U2
Flash memory size = 16384 bytes.
LFuse = 0xFF
HFuse = 0xD9
EFuse = 0xF4
Lock byte = 0xCF
Clock calibration = 0x51
Bootloader address = 0x3000
Bootloader length = 4096 bytes.
Programming the chip with the bootloader ...
Fixing low fuse setting ...
Attempting to enter programming mode ...
Entered programming mode OK.
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x3000
Committing page starting at 0x3080
Committing page starting at 0x3100
Committing page starting at 0x3180
Committing page starting at 0x3200
Committing page starting at 0x3280
Committing page starting at 0x3300
Committing page starting at 0x3380
Committing page starting at 0x3400
Committing page starting at 0x3480
Committing page starting at 0x3500
Committing page starting at 0x3580
Committing page starting at 0x3600
Committing page starting at 0x3680
Committing page starting at 0x3700
Committing page starting at 0x3780
Committing page starting at 0x3800
Committing page starting at 0x3880
Committing page starting at 0x3900
Committing page starting at 0x3980
Committing page starting at 0x3A00
Committing page starting at 0x3A80
Committing page starting at 0x3B00
Committing page starting at 0x3B80
Committing page starting at 0x3C00
Committing page starting at 0x3C80
Committing page starting at 0x3D00
Committing page starting at 0x3D80
Committing page starting at 0x3E00
Committing page starting at 0x3E80
Committing page starting at 0x3F00
Committing page starting at 0x3F80
Written.
Verifying ...
No errors found.
Writing fuses ...
LFuse = 0xEF
HFuse = 0xD8
EFuse = 0xFC
Lock byte = 0xCF
Clock calibration = 0x51
Done.
Programming mode off.

Can't install hoodloader2 on UNO r3

at every 10 seconds led blink slowly then the 100ms blink again slow led......and it goes on....
using 100nf capacitor connected exactly as diagram....Don't know what is wrong..

Double-press reset doesn't enter bootloader mode?

UPDATE: I just realized it's not the "RESET BUTTON" but the "RESET PIN" that needs to be double-shorted. Could that be clarified in the How to use reset documentation (since there's a big button graphic up top that a lazy reader like myself could misunderstand?)

I've flashed the 16u2 with HoodLoader2, then flashed a compiled LUFA "Generic HID" demo. The USB enumerates for the demo, and all is well. However, there is no HoodLoader2 serial port enumerating (which is to be expected) and so I tried double-pressing the reset button to get out of LUFA and into HoodLoader2. The "L" LED flashes a bit, but nothing happens.

issue with uno and avr g++

Hi,

I'm on a arduino uno, HoodLoader2 16u2
and i'v an issue : Cannot run program "{runtime.tools.avr-gcc.path}/bin/avr-g++":

HL2 displayed as Teensy Serial

If the Teensy drivers are installed it is displayed as Teensy USB-Serial under Windows.
Is this a Windows or bootloader bug?

Arduino Due support

If desired I could add this feature, but I currently do not own the hardware.

Arduino Clones

Hello, I know issues are not the best way to contact you, but anyways.
I have an arduino UNO that is not retail, and have some different pins.

It has some pins named ISCF.

What do I have to do so I can flash the hoodloader bootloader once it has been loaded as an sketch?
Thanks,

Pedro.
whatsapp image 2016-09-29 at 20 15 29 1
whatsapp image 2016-09-29 at 20 15 29

Unable to upload sketches from Arduino IDE with HoodLoader2 16u2

Hey.
When I choose HoodLoader2 16u2 HoodLoader2 Uno ad board, and press upload, the IDE "fakes" an upload, i.e it uploads as usual, showing the Found programmer: Id = "HL2.0.5"; type = S message, the arduino RX and TX blink for like a tenth of a second and then the old program runs.

I have an Arduino Uno (from arduino.org, not .cc. Does that matter ?) with HoodLoader2.

Output of udevadm monitor --subsystem-match=usb --property | grep -E "REVISION|VENDOR|MODEL" :

ID_VENDOR_FROM_DATABASE=Arduino SA
ID_VENDOR_FROM_DATABASE=Arduino SA
ID_MODEL=HoodLoader2_16u2
ID_MODEL_ENC=HoodLoader2\x2016u2
ID_MODEL_ID=484c
ID_REVISION=0100
ID_VENDOR=Arduino_LLC
ID_VENDOR_ENC=Arduino\x20LLC
ID_VENDOR_FROM_DATABASE=Arduino SA
ID_VENDOR_ID=2341
ID_MODEL=HoodLoader2_16u2
ID_MODEL_ENC=HoodLoader2\x2016u2
ID_MODEL_ID=484c
ID_REVISION=0100
ID_VENDOR=Arduino_LLC
ID_VENDOR_ENC=Arduino\x20LLC
ID_VENDOR_FROM_DATABASE=Arduino SA
ID_VENDOR_ID=2341

Output of lsusb -d 2341::

Bus 003 Device 068: ID 2341:484c Arduino SA 

Am I doing something wrong, or is this an issue ?

Not an Issue: Just Need Some Clarification

I was wondering if I could get some clarification as to what HoodLoader2 fully does and to see if it is something that I can use on my current project.

I am currently assisting, (the company I work for) , other Developer on his project, which is a very large multi-touch system that works with some high-end multi-windowing video processors.

Here is our YouTube Channel that shows a little more about how the system works:
https://www.youtube.com/channel/UCer1F-ILyv_KjnaAtsIPw0g
http://boisolutions.com/#layer-logic

To get to the point: Currently, this programmer has written a Virtual HID Driver and Application that would be installed and run on each of the desktop computers (that are connected , via video, to the multi-windowing processor) you wish to control. Each PC would connect to a server over IP.

However, the need to develop an USB Adapter/Dongle solution, to facilitate those same functions without the need to install any software, has come up.

I began trying to develop an AVR (Atmel) based solution similar to what you are doing with the Arduino Uno R3 (328P/16U2) using AtmelStudio 6 with the LUFA framework. However, I have run into frustrations with UART bottle-necks/buffer issue between the two controllers. I was next going to try to use just a ATmega32U4, (but then concern on how I would then implement the ethernet support for a W5100...nothing you need to think about or answer to).

So, some of my questions are:

  1. Where is the HID Report Descriptor held (in the 328P or the 16U2 firmware).
  2. Would / Could I create a custom HID Report Descriptor (with in the Arduino IDE) that would be loaded on to the IO MCU? If so, do you have any example work?
  3. Can your solution support a HID Report descriptor for Multi-touch?
  4. Is there a size limitation I would need to worry about for the HID Report Descriptor?
  5. Based on some of the previous questions, to get what I want, would I have to modify the source code for the 16U2 (USB MCU) or will it work as is?
    (6. have you made any progress of the HID-Bridge example that is to be shown with in the Wiki pages for your project)

Once I can get pass this hurdle, the back end will be a lot easier as I am going to build an ethernet client that will connect to our server (using a raw socket) so that the server can push HID report messages such as keyboard presses, mouse movements, finger touch locations, etc...

One kind of important thing to mention: I am very GREEN as to developing native code for any kind of MCU such as an AVR or PIC. I am primarily a web / software application developer, but on my own time been developing some of my own hardware solutions based on Arduino boards such as the Uno, Pro Mini, and Micro, as well as the ESP-12E (ESP8266)...now that is a sweet little SoC board for the price.

Thanks in advance for any insight you can provide or maybe directions I can go to find another alternative if this one does not work out.

Problem while converting Wire.h library for the board HoodLoader2 16u2

Hey, and thank you very much for providing such a great software, but now i got a problem:

Im working with an MPU-6050 sensorboard and wanted to run the basic raw data output sketch but I have compiling issues :/

Here's my error output:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_init':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:76:16: error: 'SDA' undeclared (first use in this function)

digitalWrite(SDA, 1);

            ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:76:16: note: each undeclared identifier is reported only once for each function it appears in

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:77:16: error: 'SCL' undeclared (first use in this function)

digitalWrite(SCL, 1);

            ^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:7: error: 'TWSR' undeclared (first use in this function)

cbi(TWSR, TWPS0);

   ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:3: note: in expansion of macro 'cbi'

cbi(TWSR, TWPS0);

^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:13: error: 'TWPS0' undeclared (first use in this function)

cbi(TWSR, TWPS0);

         ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:80:3: note: in expansion of macro 'cbi'

cbi(TWSR, TWPS0);

^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:81:13: error: 'TWPS1' undeclared (first use in this function)

cbi(TWSR, TWPS1);

         ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:81:3: note: in expansion of macro 'cbi'

cbi(TWSR, TWPS1);

^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:82:3: error: 'TWBR' undeclared (first use in this function)

TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;

^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:3: error: 'TWCR' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);

^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:14: error: 'TWEN' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);

          ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:26: error: 'TWIE' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);

                      ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:90:38: error: 'TWEA' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);

                                  ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_disable':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:3: error: 'TWCR' undeclared (first use in this function)

TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));

^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:17: error: 'TWEN' undeclared (first use in this function)

TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));

             ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:29: error: 'TWIE' undeclared (first use in this function)

TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));

                         ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:102:41: error: 'TWEA' undeclared (first use in this function)

TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));

                                     ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:105:16: error: 'SDA' undeclared (first use in this function)

digitalWrite(SDA, 0);

            ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:106:16: error: 'SCL' undeclared (first use in this function)

digitalWrite(SCL, 0);

            ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_setAddress':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:118:3: error: 'TWAR' undeclared (first use in this function)

TWAR = address << 1;

^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_setFrequency':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:129:3: error: 'TWBR' undeclared (first use in this function)

TWBR = ((F_CPU / frequency) - 16) / 2;

^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_readFrom':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:187:7: error: 'TWDR' undeclared (first use in this function)

   TWDR = twi_slarw;

   ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:188:13: error: 'TWCR' undeclared (first use in this function)

 } while(TWCR & _BV(TWWC));

         ^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:188:24: error: 'TWWC' undeclared (first use in this function)

 } while(TWCR & _BV(TWWC));

                    ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:16: error: 'TWINT' undeclared (first use in this function)

 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

            ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:29: error: 'TWEA' undeclared (first use in this function)

 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                         ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:41: error: 'TWEN' undeclared (first use in this function)

 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                                     ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:189:53: error: 'TWIE' undeclared (first use in this function)

 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                                                 ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:193:65: error: 'TWSTA' undeclared (first use in this function)

 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);

                                                             ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_writeTo':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:269:7: error: 'TWDR' undeclared (first use in this function)

   TWDR = twi_slarw;    

   ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:270:13: error: 'TWCR' undeclared (first use in this function)

 } while(TWCR & _BV(TWWC));

         ^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:270:24: error: 'TWWC' undeclared (first use in this function)

 } while(TWCR & _BV(TWWC));

                    ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:271:16: error: 'TWINT' undeclared (first use in this function)

 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

            ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:271:29: error: 'TWEA' undeclared (first use in this function)

 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                         ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:271:41: error: 'TWEN' undeclared (first use in this function)

 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                                     ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:271:53: error: 'TWIE' undeclared (first use in this function)

 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                                                 ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:275:65: error: 'TWSTA' undeclared (first use in this function)

 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA); // enable INTs

                                                             ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_reply':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:357:5: error: 'TWCR' undeclared (first use in this function)

 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);

 ^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:357:16: error: 'TWEN' undeclared (first use in this function)

 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);

            ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:357:28: error: 'TWIE' undeclared (first use in this function)

 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);

                        ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:357:40: error: 'TWINT' undeclared (first use in this function)

 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);

                                    ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:357:53: error: 'TWEA' undeclared (first use in this function)

 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);

                                                 ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_stop':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:3: error: 'TWCR' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:14: error: 'TWEN' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

          ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:26: error: 'TWIE' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

                      ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:38: error: 'TWEA' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

                                  ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:50: error: 'TWINT' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

                                              ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:372:63: error: 'TWSTO' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

                                                           ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'twi_releaseBus':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:393:3: error: 'TWCR' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);

^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:393:14: error: 'TWEN' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);

          ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:393:26: error: 'TWIE' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);

                      ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:393:38: error: 'TWEA' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);

                                  ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:393:50: error: 'TWINT' undeclared (first use in this function)

TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);

                                              ^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\compat\twi.h:36:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:27:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c: In function 'TWI_vect':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWSR' undeclared (first use in this function)

switch(TW_STATUS){

      ^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWS7' undeclared (first use in this function)

switch(TW_STATUS){

      ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWS6' undeclared (first use in this function)

switch(TW_STATUS){

      ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWS5' undeclared (first use in this function)

switch(TW_STATUS){

      ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWS4' undeclared (first use in this function)

switch(TW_STATUS){

      ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:401:10: error: 'TWS3' undeclared (first use in this function)

switch(TW_STATUS){

      ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:406:7: error: 'TWDR' undeclared (first use in this function)

   TWDR = twi_slarw;

   ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:426:4: error: 'TWCR' undeclared (first use in this function)

TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

^

In file included from d:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:25:

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:426:15: error: 'TWINT' undeclared (first use in this function)

TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

           ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:426:28: error: 'TWSTA' undeclared (first use in this function)

TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

                        ^

D:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:426:40: error: 'TWEN' undeclared (first use in this function)

TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

                                    ^

exit status 1
Error compiling for board HoodLoader2 16u2.

And this is the Sketch i wrote, heavily inspired by this one:
http://www.mschoeffler.de/2017/10/05/tutorial-how-to-use-the-gy-521-module-mpu-6050-breakout-board-with-the-arduino-uno/

// (c) Michael Moser 2017

#include "Wire.h" // Lib for I2C communication

const int mpu_adress = 0x68; // I2C adress of the MPU-6050

int16_t acc_x, acc_y, acc_z; // Variables for accelerometer raw data
int16_t gyro_x, gyro_y, gyro_z; // Variables for gyroscope raw data
int16_t temp; // Variable for temperature data

char tmp_str[7]; // Temporary variable for converting function

char* convert_int16_to_str(int16_t i) // Converts int16 to string. Here used to get strings with the same length in the debug window.
{
sprintf(tmp_str, "%6d", i);
return tmp_str;
}

void setup()
{
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(mpu_adress); // Begins a transmission to the I2C slave (MPU-6050)
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);

}

void loop()
{
Wire.beginTransmission(mpu_adress);
Wire.write(0x3B); // Starting with register 0x3B (ACCEL_XOUT_H) [Register Map and Descriptions Revision 4.2, p.40]
Wire.endTransmission(false); // Arduino will send a restart, thus keeping the connection active
Wire.requestFrom(mpu_adress, 72, true); // Request all 14 registers (72=14)

// Here, two registers are read and stored in the same variable
acc_x = Wire.read() << 8 | Wire.read(); // reading registers: 0x3B (ACCEL_XOUT_H) and 0x3C (ACCEL_XOUT_L)
acc_y = Wire.read() << 8 | Wire.read(); // reading registers: 0x3D (ACCEL_YOUT_H) and 0x3E (ACCEL_YOUT_L)
acc_z = Wire.read() << 8 | Wire.read(); // reading registers: 0x3F (ACCEL_ZOUT_H) and 0x40 (ACCEL_ZOUT_L)
temp = Wire.read() << 8 | Wire.read(); // reading registers: 0x41 (TEMP_OUT_H) and 0x42 (TEMP_OUT_L)
gyro_x = Wire.read() << 8 | Wire.read(); // reading registers: 0x43 (GYRO_XOUT_H) and 0x44 (GYRO_XOUT_L)
gyro_y = Wire.read() << 8 | Wire.read(); // reading registers: 0x45 (GYRO_YOUT_H) and 0x46 (GYRO_YOUT_L)
gyro_z = Wire.read() << 8 | Wire.read(); // reading registers: 0x47 (GYRO_ZOUT_H) and 0x48

//Data is printed to the Debug Window
Serial.print(" | aX = "); Serial.print(convert_int16_to_str(acc_x));
Serial.print(" | aY = "); Serial.print(convert_int16_to_str(acc_y));
Serial.print(" | aZ = "); Serial.print(convert_int16_to_str(acc_z));
Serial.print(" | gX = "); Serial.print(convert_int16_to_str(gyro_x));
Serial.print(" | gY = "); Serial.print(convert_int16_to_str(gyro_y));
Serial.print(" | gZ = "); Serial.print(convert_int16_to_str(gyro_z));
Serial.print(" | tmp = "); Serial.print(temp/340.00+36.53);
Serial.println();

delay(1000);

}

I really hope you can help me with this and that i don't annoy you with a possibly very simple problem.
I just recently started working with the Arduino Uno R3 and have no previous experience but a lot of motivation. ^^

Greetings, Mike.

Problem with 8u2 (uno)

I have been trying to upload the HoodLoader2_NoUSB_Blink to the 8u2 (since i do not have the space to fit the HID library for keyboard). but every time it fails to verify. here is the output from Arduino 1.6.1

Sketch uses 646 bytes (15%) of program storage space. Maximum is 4 096 bytes.
Global variables use 9 bytes (1%) of dynamic memory, leaving 503 bytes for local variables. Maximum is 512 bytes.
Forcing reset using 1200bps open/close on port COM14
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
PORTS {COM1, COM14, } / {COM1, COM14, } => {}
Uploading using selected port: COM14
C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf -v -patmega8u2 -cavr109 -PCOM14 -b57600 -D -Uflash:w:C:\Users\Marcus\AppData\Local\Temp\build3428156613028146164.tmp/HoodLoader2_NoUSB_Blink.cpp.hex:i 

avrdude: Version 6.0.1, compiled on Jan 15 2015 at 16:58:43
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : COM14
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega8U2
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC6
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no        512    4    128  9000  9000 0x00 0x00
           flash         65     6    64    0 yes      8192   64    128  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .
Found programmer: Id = "HL2.0.4"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

avrdude: devcode selected: 0x44
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9389
avrdude: reading input file "C:\Users\Marcus\AppData\Local\Temp\build3428156613028146164.tmp/HoodLoader2_NoUSB_Blink.cpp.hex"
avrdude: writing flash (646 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 646 bytes of flash written
avrdude: verifying flash memory against C:\Users\Marcus\AppData\Local\Temp\build3428156613028146164.tmp/HoodLoader2_NoUSB_Blink.cpp.hex:
avrdude: load data flash data from input file C:\Users\Marcus\AppData\Local\Temp\build3428156613028146164.tmp/HoodLoader2_NoUSB_Blink.cpp.hex:
avrdude: input file C:\Users\Marcus\AppData\Local\Temp\build3428156613028146164.tmp/HoodLoader2_NoUSB_Blink.cpp.hex contains 646 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x11 != 0x0c
avrdude: verification error; content mismatch

avrdude done.  Thank you."

4 USB endpoints?

In the Overview wiki page, it says:

4 usable USB Endpoints: CDC Serial, HID, MIDI (not all at once)

What does the "4" here refer to? Does one of the the 3 listed endpoints double as a something else?

After 1st time, 16u2 doesn't reset when serial monitor is opened

After paring down some of my code, I realized that the 16u2 behaves differently in response to the serial monitor DTR reset than when using the serial monitor on the main chip (328p): after the initial serial monitor connection, the 16u2 won't reset in response to subsequent serial monitor connections. Is this intended behavior?

For instance:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);  delay(200);
  digitalWrite(LED_BUILTIN, HIGH); delay(200);
  digitalWrite(LED_BUILTIN, LOW);  delay(200);
  digitalWrite(LED_BUILTIN, HIGH); delay(200);
  digitalWrite(LED_BUILTIN, LOW);  delay(200);
  digitalWrite(LED_BUILTIN, HIGH);

  while(!Serial);
  Serial.begin(115200);
  Serial.println("I blinked");
}

void loop() {
}

I expected the above sketch to blink thrice, and send "I blinked" over serial, for each time I open the serial monitor.

Arduino Nano

Hello,
I want to use your project with an arduino nano is it possible ? I haven't really understood that part.

I actually tried to use it anyway but get this error : #error HID Project can only be used with an USB MCU.

Thanks in advance !

"Failed to enter programming mode" @ Installation Sketch

I am following this guide from the wiki, with an Arduino Uno. When running Installation_Sketch.ino this gets printed on serial:

Attempting to enter programming mode ......................................................
Failed to enter programming mode. Double-check wiring!
Next attempt in 10 seconds.
Programming mode off.

How do I fix this?

IO MCU resets on USB MCU reprogramming

The Reset pin is floating for a few seconds on a USB MCU selfprogramming reset. This also causes the IO MCU to reset. I did not find any solution for this. Help appreciated.

Magic Key not defined

I have read through the previous comments regarding how to fix the Magic Key not defined issue (Hoodloader2); however, being new to this whole programming thing with Arduino IDE, I am totally lost. What file am I supposed to be editing and with what line of code? Thanks

.h files exsist but not found

I followed the procedures, including to add the board via the boards manager.
The HoodLoader2 Mega2560 is selected, as well as the comport.

I am able to simply upload the blink to the normal I/O MCU and the LED blinks fine then.

When I load the sample from avr/examples/SerialKeyboard and only try to compile, it says:

In file included from C:\...\Arduino\sketch_may10a\sketch_may10a.ino:16:0:

C:\...\arduino-1.8.2\libraries\Keyboard\src/Keyboard.h:29:2: warning: #warning "Using legacy HID core (non pluggable)" [-Wcpp]

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

  ^

C:\...\Arduino\sketch_may10a\sketch_may10a.ino: In function 'void setup()':

sketch_may10a:28: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
   Keyboard.begin();

   ^

C:\...\Arduino\sketch_may10a\sketch_may10a.ino: In function 'void loop()':

sketch_may10a:53: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
     Keyboard.print(F("This message was sent with my Arduino."));

     ^

exit status 1
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

There is a Keyboard.h file under my libraries folder.

Back to original firmware

Hello

I would like to restore the original bootloader of my Arduino UNO R3, but Flip doesn't recognize arduino, same for dfu-programmer on linux. What I should do? And what information you need for help me?

MAGIC_KEY not defined when building for 16u2

After a recent Arduino IDE update, code for 16u2 fails to compile because MAGIC_KEY is not defined.

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os  -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega16u2 -DF_CPU=16000000L -DARDUINO=10609 -DARDUINO_HOODLOADER2 -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x484C '-DUSB_MANUFACTURER="Nico Hood"' '-DUSB_PRODUCT="HoodLoader2 16u2"' -DMAGIC_KEY_POS=(RAMEND-1) -DUSB_EP_SIZE=16 "-IC:\Users\Tarjei\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.11\cores\arduino" "-IC:\Users\Tarjei\AppData\Local\Arduino15\packages\HoodLoader2\hardware\avr\2.0.5\variants\HoodLoader2" "C:\Users\Tarjei\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.11\cores\arduino\CDC.cpp" -o "C:\Users\Tarjei\AppData\Local\Temp\buildf6aa37d3ca1ba04de8acf1acc6efd411.tmp\core\CDC.cpp.o"
C:\Users\Tarjei\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.11\cores\arduino\CDC.cpp: In function 'bool CDC_Setup(USBSetup&)':

C:\Users\Tarjei\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.11\cores\arduino\CDC.cpp:129:34: error: 'MAGIC_KEY' was not declared in this scope

     *(uint16_t *)magic_key_pos = MAGIC_KEY; 

It's defined in variants/leonardo/pins_arduino.h, but this doesn't seem to get included where it needs to.

grep -r "MAGIC_KEY" *
variants/leonardo/pins_arduino.h:#ifndef MAGIC_KEY
variants/leonardo/pins_arduino.h:#define MAGIC_KEY 0x7777

Modifying boards.txt fixes the build, but I'm not sure if this is the correct magic key?

HoodLoader2atmega16u2.build.extra_flags={build.usb_flags} -DMAGIC_KEY=0x7777 -DMAGIC_KEY_POS=(RAMEND-1) -DUSB_EP_SIZE=16

My environment:

  • Arduino IDE 1.6.9
  • AVR package 1.6.11

what should I do if I want to change arduino leonardo's vid&pid?

HoodLoader2 gives a option to reprogram the 16u2 of a normal Arduino Uno/Mega R3 with custom sketches.

what should I do if I want to change arduino leonardo's vid&pid?
Because in windows7 , I must first install the driver to use arduino leonardo be a HID device, I want to change arduino leonardo's vid&pid to a HID device.

Name does not change

I have a UNO R3 with a 16u2. I burned Hoodloader2, and the name didn't change. What do I do?

warning: deprecated conversion in installation sketch

fyi: i'm getting a lot of warnings uploading the installation sketch to an UNO

/HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 };  // end of signatures
 ^
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:462:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino: In function 'void showHex(byte, boolean, boolean)':
 /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:511:38: warning: narrowing conversion of '((((int)(b >> 4)) & 255) | 48)' from 'int' to 'char' inside { } [-Wnarrowing]
   char buf [4] = { ((b >> 4) & 0x0F) | '0', (b & 0x0F) | '0', ' ' , 0 };
                                      ^
                                      /HoodLoader2-master/avr/examples/Installation_Sketch/Installation_Sketch.ino:511:56: warning: narrowing conversion of '((((int)b) & 15) | 48)' from 'int' to 'char' inside { } [-Wnarrowing]
   char buf [4] = { ((b >> 4) & 0x0F) | '0', (b & 0x0F) | '0', ' ' , 0 };

'HID' core not installed

I have been trying to make an arduino keyboard. I am living in Ethiopia, and i can't get my hand on other arduinos except the one I got as a gift, which happens to be UNO. so I read the wiki thoroughly. and installed the hoodloader2 on the board. then I installed the hid library using the library manager, and the board definitions using the board manager. and i tried to compile the Improvedkeyboard example. but I got this error.
Selected board depends on 'HID' core (not installed).
i chose the hoodloader2 16u2 form the board. I have checked the sketchbook folder and it looks like this

root@NateDawg:/sketchbook/libraries# ls
HID readme.txt
root@NateDawg:
/sketchbook/libraries# ls HID
examples extras header.jpg keywords.txt library.properties Readme.md src
root@NateDawg:~/sketchbook/libraries#

can u pls help me I don't seem to understand my problem.

ps. I am using arduino 1.6.7

Error in picture

When I tested HID upptäkte I picture "Arduino-unomega-16u2-pinout" and my "Arduino UNO R3 / Arduino-Compatible 'does not match with each other.
The difference is the 4 pins PB4, PB5, PB6 and PB7 are exchanged.

/BG

Serial1 buffer size

My test code is:

void loop() {
  if (Serial1.available()) {
      delay(5000);
      while(Serial1.available()) {
        Keyboard.write(Serial1.read());
      }
  }
}

I am sending 40 counting bytes, like 1234567890123456789012345678901234567890
I expected all 40 bytes to be buffered during the delay(5000) and then retrieved.
But the result is only:

123456789012345

Edit: In addition, I noticed that I needed to send my bytes slowly into Serial1, I had to add a delay(2) between each byte at the sender. (Sender is just another arduino style board)

PlatformIO

Is there any chance for some kind of PlatformIO support?
I noticed all your other libraries are on there, so it kind of makes sense that this is on there as well :)

Esplora?

I actually have an Arduino Esplora. I know that putting the Leonardo loader into it won't really affect it but what about an Esplora-specific version that still have the correct VID/PID?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.