Board and Setup
Before I tell you my problem, I'm using the 32u4, and the HWBE fuse is set, while BOOTRST is not. If you want to know other fuses, LOW is 0xFF, HIGH is 0xD0 and EXTENDED is 0xCB.
I should also mention I'm using the Arduino Leonardo, I do have a custom board which is running my application(haven't tried bootloader), but there is a small issue on board requiring a custom adapter for it to work on USB, and because of that it disconnects at random, so it's just easier to make sure everything connects on the Leo first.
The Leonardo also ties HWB pin low with a 10k resistor.
And lastly, in the function void Application_Jump_Check(void), specifically for the Leonardo, it checks to see if IO13 is pulled low, and if not it starts the app, I do have it pulled low.
I've been trying all day to get the DFU bootloader with no luck, it doesn't even seem to try and connect to the PC.
After I flash the Bootloader, nothing happens, it does not try to connect to my PC, and vise versa. Not even a Descriptor Failed Request Error.
I eventually want to get the device to boot to the application first, so the user has regular functionality of the device from the get go.
But if the user runs my Firmware Update Software(which I will need to make), it will send a command via USB telling the device to load the bootloader for programming.
The device will then load up the bootloader, and the user can then choose to update to newest, or they choose to update to an older version manually, if they choose to do so.
The device absolutely cannot have a switch that pulls HWB low or high, it has to be done all in software.
All I want to do right now, is have the bootloader connect to the PC, and show up in device manager, as long as I can get it to do this, I can get the rest of the way.
I am having success with Atmels DFU Bootloader, although if I want to go to my application, I need to use FLIP to manually start the application, which is completely useless to me.
I thought maybe the bootloader is just trying to go straight to the application, but since I don't have one flashed, nothing happens.
So for the last half hour I've been trying to merge hex files, I've tried 2 methods, just using a text editor, and then using srec_cat.exe.
Maybe someone can confirm if I'm doing this correctly.
Text Editor Method:
I open up both hex files in notepad++, I remove :00000001FF from the end of the bootloader, and then simply paste the application to the end? Someone said this in another post on the forum, although they did say basically, so its possible they left out some instructions.
Then I flashed the MCU in Atmel Studio via ISP, giving me this error during the flashing process.
Verifying Flash...Failed! address=0x1000 expected=0x55 actual=0x00
The device is now actually trying to connect, but it gives me a "Device Descriptor Request Failed." I didn't expect it to work, but its worth noting that its trying to do something.
I'm using this command
srec_cat DFU_Bootloader.hex -I CLASS_KEYBOARD_MOUSE_LEONARDO.hex -I -o Merged.hex -I
but I get this error, which is almost exactly the same as the text editor, except I get this while running srec_cat, and it isn't giving me a hex.
srec_cat: CLASS_KEYBOARD_MOUSE_LEONARDO.hex: 257: contradictory 00001000 value (previous = 55, this one = 80)
And then here is another thing that may be making the bootloader try and go straight to the application.
Over in this topic, https://www.avrfreaks.net/forum/atmega32u4-hwb-issue , the user Billy mentions something about BOOT_START.
He specifically says
using 0x7000 as the BOOT_START value
The only value similar to it is BOOT_START_ADDR, and its defined in assembly, which I have no experience with.
I also read another post somewhere else which I cannot seem to find again, but they mentioned something about needing to set a BootKey or something, to 0x8000, to get the bootloader to work on the Arduino Leonardo.
Other Bootloader Questions
What is the purpose of the HID bootloader, and can you flash your application with it?
Giving the new info from clawson, I merged the bootloader and application(with Notepad++, srec_cat.exe still gave me same error), this time with the application first.
I then flashed the device, and it is connecting to my PC, and I can confirm it is going straight to the application.
I should also mention that I could only get it to upload, if I didn't remove :00000001FF from the end of the application, so could it be ignoring the bootloader completely? I read that you are supposed to remove that.
So I think this means something is happening in the bootloader, and I have a feeling it has something to do with the bootkey I read about.
Does anyone know about the bootkey, I found the place I read about the bootkey, here is the link. https://github.com/abcminiuser/lufa/issues/42
If you don't want to go to the URL, here is the post, from NicoHood.
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.
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.
I may have spoke too soon, I did not read the whole issue in the URL I had posted in Edit1.
He seems to be using the Arduino IDE to upload his sketches, which I am not, so this should not affect me.