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

CDC BootLoader not Leonardo Compatible #42

Open
NicoHood opened this issue Nov 24, 2014 · 6 comments · May be fixed by #86
Open

CDC BootLoader not Leonardo Compatible #42

NicoHood opened this issue Nov 24, 2014 · 6 comments · May be fixed by #86

Comments

@NicoHood
Copy link
Contributor

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
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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 linked a pull request May 22, 2016 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants