I've flashed an Arduino Leo and a Pro Micro clone both using AVRdude too. The Pro Micro clones are great because they're about €2.50. Their drawback is that it's difficult to get into their bootloaders...

USBaspLoader, AVRUSBBoot and BootloaderHID are all V-USB based (low speed 1.5MHz). This means they are meant to be used on AVRs that don't have hardware USB (all AVRs with names not ending with u2, u4 or begining with at90usb). ATmega32u4 has hardware USB (full speed 12MHz) so using V-USB on these is possible, but kinda pointless.

Teensy Halfkay is not only closed source but also unavailable - you can't download the Halfkay bootloader HEX file anywhere. It's PJRC's "trade secret" and only PJRC can burn a Halfkay bootloader into an AVR.

I'd go with LUFA HID. No drivers are needed for windows, and there is an open source command line program for the PC side. I've made a Windows GUI for it a while ago, but never used it. It should be working, let me know if you need it and I'll clean it up and upload it somewhere.

USBaspLoader is very useful on Mega AVR, I used it for my keyboard project and it worked perfectly. You can use V-USB bootloaders on USB AVR like ATMega32U4 and AT90USB but it is virtually useless that you use V-USB instead of hardware USB support the chips have.

After I play with a Teensy for a while I've used stock Atmel DFU loader with dfu-programmer on Windows and Linux for a year or two. No problem except for its size. It is a factory default bootloader you don't need to flash to get the bootloader. This is a good score.

Yes, with Leonardo bootloader I also had very bad experience, even with Arduino IDE. I would replace it with LUFA DFU bootloader if I get those cheap compatible boards. LUFA DFU bootloader worked flawlessly for me with dfu-programmer and it looks compatible with Atmel DFU.

Halfkay and HID based bootloaders don't required driver install this will be good point as well as its size. But I don't have a experience with these bootloaders except for Teensy.

hasu wrote:How difficult is writing USB bootloader within 512 bytes? It looks to me PJRC HalfKay is a magic.A decent engineer can do this job? We need a Wizard?

Pretty much. Even a 1K USB bootloader would be a stretch. Halfkay is written in AVR assembler and you would need to be a seasoned assembler programmer to pull it off. I've never done any assembler, but I know enough to imagine how hard it would be.

kile wrote:I'd go with LUFA HID. No drivers are needed for windows, and there is an open source command line program for the PC side. I've made a Windows GUI for it a while ago, but never used it. It should be working, let me know if you need it and I'll clean it up and upload it somewhere.

That's what I'll try then. I'll get back to you about the Windows GUI when the Miniguru is finished, thank you. I still have to do this some day (if it will fit, can be unbranded too).

jdcarpe, I think I found the root of our Pro Micro woes - in order to get into the bootloader, you need to short the RST pin _twice_ as it starts up. Soarer and someone else (can't remember who, sorry!) on IRC helped me to figure this out.

hasu wrote:How difficult is writing USB bootloader within 512 bytes? It looks to me PJRC HalfKay is a magic.A decent engineer can do this job? We need a Wizard?

Pretty much. Even a 1K USB bootloader would be a stretch. Halfkay is written in AVR assembler and you would need to be a seasoned assembler programmer to pull it off. I've never done any assembler, but I know enough to imagine how hard it would be.

I got annoyed w/ Flip when I was debugging a 40% board running on a 32U4 so I reverse engineered the Teensy BL protocol and wrote a loader from scratch, emulating it in order to use the Teensy app. Since I needed it fast I stuck to C, it came out bigger than 512b but less than a k. I probably could pull the 512b of by switching to 100% assembler, but I won't do it -- takes time and I'm fine w/ a 1k loader plus I don't want to get on the wrong side w/ Paul (of PJRC). I still need Teensy's in the future... Although I have been using it for that 40% board, it's not tested beyond that. I've attached the hex image in case someone would like to take it for a spin (and please report back if you have problems.) Please use at your own risk!

(Since the hex files aren't allowed as attachment (why?), here's the contens. Just copy and save it as OneKay.hex)

Edit: forgot -- this is for an ATMega32U4 w/ a 16MHz oscillator, fuses I'm using it w/ are: 0:0x5E 1:0xDD 2:0xF1

lowpoly wrote:The LUFA HID bootloader also needs 4K. Here it compiles to 2222 bytes code and data so it is very close to 2K but close is not enough.

I checked and it turns out -flto has no effect at all. But if you do what Dean (author of LUFA's) suggests here https://groups.google.com/forum/#!topic/lufa-support/Gq4RTLqiMRA you will get bellow 2k. I have just tried it with avr-gcc 4.8.1 (which you can get in the latest AVR toolchain from Atmel) and it went from 2092 down to 1966 bytes.

grendel wrote:I probably could pull the 512b of by switching to 100% assembler, but I won't do it -- takes time and I'm fine w/ a 1k loader plus I don't want to get on the wrong side w/ Paul (of PJRC). I still need Teensy's in the future...

Now that I think about it, I think you are more likely to get on Paul's wrong side if you write a bootloader that can use the TeensyLoader than if you get below 512b. I think the most appealing feature for the majority of the Teensy users is the loader PC program and not the fact that the bootloader fits in 512b. The loader's GUI has large, colourful bitmapped buttons and there aren't any confusing options to select. And for how many will the extra 1.5k or 0.5k really make a difference?

Besides, getting on Paul's wrong side already happened with LUFA and the TeensyHID. And that was with a 2K bootloader, imagine how happy he will be with 1k?

But to be fair, Paul's hard work has helped a lot of people get projects up and running and he should be rewarded for it. The entire mechanical keyboard community probably wouldn't be half as big if it wasn't for the Teensy.

Grendel wrote:Why, indeed I did.

That was a nice project, btw. I found it about the time I started playing with AVRs. Learned quite a few things from it too. Thanks for that!

Edit: Updated to 4.8.1 but got the same size (2222). Now to the optimizations.

kile wrote:I checked and it turns out -flto has no effect at all. But if you do what Dean (author of LUFA's) suggests here https://groups.google.com/forum/#!topic/lufa-support/Gq4RTLqiMRA you will get bellow 2k. I have just tried it with avr-gcc 4.8.1 (which you can get in the latest AVR toolchain from Atmel) and it went from 2092 down to 1966 bytes.

Thank you. Will try that now.

kile wrote: I think the most appealing feature for the majority of the Teensy users is the loader PC program and not the fact that the bootloader fits in 512b.

Paul's command line interface is under the GNU GPL and the modified version still contained in LUFA. Converting that to a windowed application should be trivial (and legal)?

lowpoly wrote:Paul's command line interface is under the GNU GPL and the modified version still contained in LUFA. Converting that to a windowed application should be trivial (and legal)?

Sure it is, that's what I did for that Win GUI I mentioned. But doing the same for Win/Linux/Mac? And making it look and work identical on all three? And it has to be tested and it has to work on all the available USB host controllers and all OS versions. That is not as trivial, and certainly not as much fun. Sure, it is possible and doable. But otherwise... naaah..

kile wrote:Sure it is, that's what I did for that Win GUI I mentioned. But doing the same for Win/Linux/Mac? And making it look and work identical on all three? And it has to be tested and it has to work on all the available USB host controllers and all OS versions. That is not as trivial, and certainly not as much fun. Sure, it is possible and doable. But otherwise... naaah..

Tested and it seems to work. No complaints during flashing this time, fuses set to 2K (1K words), makefiles of bootloader and firmware set to 2K. I think the last one is only for displaying correct sizes after linking.

On a sidenote, I remember at some point in time I used BootloadHID for an earlier version of the 3DPro converter. Should be easy to port to the U2/U4 modules, I'll take a look. May be able to squeeze that into 1k as well

Edit: would probably end up w/ 2k, but doable. I'll take a closer look tonight.

Well, guess it took two evenings FWIIW, I got the BootloadHID compatible loader working, tested w/ the above mentioned 32U4. Adding the necessary string descriptors and report1 data pushed the size above 1k again, so it chews 2k of the flash (still better than Atmel's 4k loader..) Maybe one day I'll replace the libc vector table w/ a custom one, should bring it back to 1k..

Again, if someone wants to take it for a spin... Please report back if you do. Image is for a ATMega32U4, 16MHz oscillator, fuses as above but w/ 2kb boot section. Ask if you want the source.

Give me another evening, just finished hooking in a custom vector table, but I need to test that and I'm about ready to go to bed If this works (and is reasonably safe across different CPU's) it'll bring the size down to < 1k again.

Here we go. BootHID v02 for 1k boot sections can be found at drive.google.com/ under file{slash}d/0ByFalc_WhYoscVphMmxhRnFLVXM/edit{quest.mk.}usp=sharing (sorry, you will have to assemble that link yourself, I don't want bots to easily pick up on it. Mind the text in {}.)

A few words (of mostly warnings to scare you ) -- I tested the code with a Mega32U4 @ 16MHz w/ the HWBE fuse programmed. The AVRS project is configured for this and the hex file is included. I used AVR Studio 4.19 730 (since I don't need the added features of later versions yet and it's less of a hog..), so the included project file is from that version. ISP used is an Atmel AVRISP mkII. Before doing anything you should read the (lengthy, sorry) Release Notes and the beginning of usb_hid.c, it explains how to reconfigure the project for different chips. Note that I used avr-libc 1.8.0, the linker scripts may not work w/ older (or possibly newer) versions!

What else.. the black magic level of the code is medium, don't change things around arbitrary, it will break! Esp. don't add any code in main() after the call to usb_init() and don't enable any other interrupts w/o exactly knowing how the code works and what else to change -- you will bring unending misery upon you! Ah, yes, of course -- use of this code is at the sole responsibility of yourself, I can not hold responsible for anything that happens while it is active !

Addendum: If you want to invoke the boot loader from w/in your application (because the user pressed the forbidden key combination eg.) I would suggest to use the jmp_bootloader() macro found in includes.h -- it'll look at the BOOTSZ fuses and thus work with any size boot loader.

Edit: updated to v02. Forgot to leash the watchdog...

Last edited by Grendel on 27 Mar 2014, 21:28, edited 2 times in total.