During my personal development (honestly, I started with AVRs two months ago) I came to the point I would like to resolve following issues. I've tried already to search for answers but no luck, so I will ask here if I can.
Currently I'm using Nano but would like to switch to 32u4 (Leonardo) for added direct USB_DEVICE through LUFA and USB Shield as USB_HOST.
Target application would/should accept device from USB_HOST, filter/add messages and send it via USB_DEVICE.
Is it possible / does someone did it before / do you know of some project which successfully implemented/ported/drivered LUFA to MAX3421e USB Shield? - doing so would reduce code space due to duplicate implementation of USB stacks - I haven't tried this so far, but duplicate USB.h from USBHostShieldLibrary makes me suspicious of a lot of problems, and it will add Arduino framework dependence which is something I would like to avoid at the final stage of development (yes, I'm using part of it as for now, but trying to eliminate code dependent on it) - could be possible to add 3421e comm module and incorporate build switch for LUFA use it as USB_HOST together with 32u4 as USB_DEVICE? - any directions?
- ported on HOST side of LUFA. Now 32u4 is device, MAX is host.
2. Smaller bootloader for 32u4 - 4kB for bootloader is quite too much as I see progress and code size of my project - do exists some smaller bootloaders? I've so far haven't found any smaller for 32u4 - ideal would be to have very small bootloader which can be used solely for main program upload via serial (as usually) through Atmel Studio - here comes the idea
3. Unified program/upload code - as most probably bootloader and main program use the same code, would it be possible to incorporate upload/reflash code into main program to have needed routines/functions to reside only once in a flash? - some kind of upload code with needed functions relocated to upper(?) bound of flash which would be then not erased while flashing main program and shared with main program - this is just an idea worth of ~3kB of flash and honestly, I'm not able to do it, but maybe someone can/got experience/got this idea further
- gave up on this, figured how to use another arduino asi isp programmer. Bootloader on Leonardo is gone anyway.
- finally USBasp ISP programmer works with avrdude, so no need for another Arduino for ISP programming. Don't know why, but this DOESN'T WORK WITHOUT erase flash option in avrdude. Be prepared to loose bootloader.
4. Advice how to use ISP programmer with USB Host Shield attached to Leonardo - in case of a need of additional 4kB of bootloader to be used for main program, there isn't much more chance to reflash than using ISP - ISP header is occupied with shield - removing shield/attach ISP/upload/attach shield procedure is a complete no-go - any ideas?
- resoldered another 'pass-through' ICSP header - gonna try this if ISP will passthrough
- seems thato connecting USB Shield SS to active HIGH (5V) before first upload will make it work for avrdude to flash program.
5. How to upload code to Leonardo using Atmel Studio - by clicking just Run-without-Debugging as it is (for me) standard procedure - I was using Nano with VisualMicro for Arduino an this worked this way - When I've tried LUFA example, this way was not working, only when I've tried new Arduino sketch from File-New it was working
- added custom external tools buttons with avrdude commands. I don't know why, but upload didn't work from Atmel studio when -D parameter has been set. Arduino IDE with same avrdude command haven't touched bootloader, but Atmel Studio did. So I'm finally without bootloader on Lenoardo so I gave up on bootloader issues (one problem solved ;) )
Thanks a lot for any help.
it's been a long day. Afterall make MAX3421e chip on USB host shield to work with LUFA is the greatest challenge of all of these.
- It was.