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

CDC BootLoader not Leonardo Compatible #42

Open
NicoHood opened this Issue Nov 24, 2014 · 6 comments

Comments

Projects
None yet
2 participants
@NicoHood
Copy link
Contributor

NicoHood commented Nov 24, 2014

I tried to compile the latest CDC BootLoader for my Pro Micro(well not a leo but a 32u4) and it turn out that i cannot reupload sketches to the board. The Arduino software tries to touch the Serial at 1200 and tries to reupload the Code. But its not working:

Connecting to programmer: .avrdude: Send: . [1b] 
avrdude: Send: S [53] 
avrdude: ser_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

With the older Pro Micro source (recompiled with the older Lufa) its working fine.
I am trying to figure out why this happens.

I also have a similar problem with my HoodLoader2 project. After a serial touch the leds start flickering, usb is detached but no sketch and no bootloader starts. Just the leds are flickering. I am wondering if i set the Watchdog timer wrong in my source.

Any Idea?

@abcminiuser

This comment has been minimized.

Copy link
Owner

abcminiuser commented Nov 26, 2014

That looks like the bootloader isn't responding to any commands from the host -- are you sure the programmer is using the correct virtual COM port number?

@NicoHood

This comment has been minimized.

Copy link
Contributor

NicoHood commented Nov 26, 2014

I think the problem is that the Arduino Software uses a special Bootkey on a specific address:
https://github.com/arduino/Arduino/blob/master/hardware/arduino/bootloaders/caterina/Caterina.c#L69
yours:
https://github.com/abcminiuser/lufa/blob/master/Bootloaders/CDC/BootloaderCDC.c#L64
So what the bootloader does is to start the sketch again. And the sketch has no bootloader protocol implemented of course.

They write this key inside the sketch, do a watchdog reset and then the bootloader knows that it should execute the bootloader code and not start the application. Because both read the same memory location.
So you'd have to change this to suit for an Arduino Leonardo/Micro.

I am also developing a CDC BootLoader and i am wondering why they used exactly this address. I am programming a 16u2 and a 32u2 and dont know what ram address is the best for this bootloader. Mabe the last, but how can i find the last one. I read some stuff about the stack etc. I somehow has to pass the information to the bootloader so i cannot simply use your no init trick. Any suggestions?

@NicoHood

This comment has been minimized.

Copy link
Contributor

NicoHood commented Nov 29, 2014

To add leonardo compatibility you definitely have to set the bootloader key to exactly 0x0800.
Thats how i did it with a 8 bit key and another address.
https://github.com/NicoHood/HoodLoader2

Its not perfect, it would be better to define the specific address as reserved but therefore you need compiler flags and the arduino ide wont take these flags. I also filed a bug there too.

@abcminiuser

This comment has been minimized.

Copy link
Owner

abcminiuser commented Dec 1, 2014

Hrm, I guess they have their reasons. I can fix the address of the boot key by placing it into its own section and forcing the start address of the section to 0x800, but they also use their own different key value. I suppose I can either make my version accept either, or have a compile time option to change the key to match the Caterina bootloader.

@NicoHood

This comment has been minimized.

Copy link
Contributor

NicoHood commented Dec 1, 2014

yeah, the fixed section sounds good. the only reason why i didnt use it was that the hex converter from nick gammon for the atmega board programm couldnt convert my hex file then.

Passing the magic bootkey in the makefile would be nice. and an option for the address and maybe size (8 or 16 bit) as well, if possible.

@NicoHood

This comment has been minimized.

Copy link
Contributor

NicoHood commented Jul 22, 2015

https://github.com/abcminiuser/lufa/blob/master/Bootloaders/CDC/BootloaderCDC.c#L64
The Key can be stored in RAMEND, see this discussion:
arduino/Arduino#2474

This way the application can restart the program and run the bootloader.

@NicoHood NicoHood referenced a pull request that will close this issue May 22, 2016

Open

Make CDC Bootloader Arduino compatible #86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment