Skip to content

[DO NOT MERGE] Fix bootloader and USB improvements on 32u4 #4793

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

Closed
wants to merge 3 commits into from

Conversation

facchinm
Copy link
Member

@facchinm facchinm commented Apr 1, 2016

Various fixes for USB-enabled AVR devices (32u4).
Commit 197fe07 needs some community testing (to make sure that "advertising" as USB2.1 has no side affect on any platform)

@beaufortfrancois
Copy link

#endif
// Clean up RAMEND key
*(uint16_t *)magic_key_pos = 0x0000;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is an error. You need to add an #if around the bracket too.

@facchinm facchinm force-pushed the avr_usb_bootloader branch from cc773bf to cc1e835 Compare April 2, 2016 08:05
@facchinm
Copy link
Member Author

facchinm commented Apr 2, 2016

@NicoHood , I fixed the bug you spotted and squashed it, thanks for taking a look!

@NicoHood
Copy link
Contributor

NicoHood commented Apr 2, 2016

Great! It compiles now fine. It adds some overhead to the older bootloader boards, but removes it for newer boards.

@beaufortfrancois
Copy link

@facchinm @NicoHood You may want to update usbVersion comment to 0x210 to indicate 2.1 instead of 2.0 at https://github.com/facchinm/Arduino/blob/cc773bf60cb498c5afe96e3e4652e2ca484b277b/hardware/arduino/avr/cores/arduino/USBCore.h#L133

How about

uint16_t usbVersion; // 0x200
also?

@facchinm facchinm changed the title Fix bootloader and USB improvements on 32u4 [DO NOT MERGE] Fix bootloader and USB improvements on 32u4 Apr 6, 2016
@facchinm
Copy link
Member Author

facchinm commented Apr 6, 2016

@beaufortfrancois
Declaring as USB 2.1 and not providing BOS descriptor will hang enumeration on Win 8.1 and newer, so I'd let the patchset here until we have a viable solution.

Replaces arduino#4280, only checks for the bootloader once

Tested with Hoodloader2, should work with every LUFA-derived bootloader released after 2014 (.apitable_signatures section must be placed at end of the flash)

BootloaderAPITable.S :

.global BootloaderAPI_Signatures
BootloaderAPI_Signatures:

    .long BOOT_START_ADDR ; Start address of the bootloader
    .word 0xDF00 ; Signature for the CDC class bootloader
    .word 0xDCFB ; Signature for a LUFA class bootloader

makefile:

BOOT_API_LD_FLAGS    += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures,  BootloaderAPI_Signatures,  8)
@facchinm facchinm force-pushed the avr_usb_bootloader branch from cc1e835 to e6026dc Compare April 6, 2016 14:35
@beaufortfrancois
Copy link

@reillyeon Does that make sense?

@NicoHood
Copy link
Contributor

NicoHood commented May 22, 2016

I thought those fixes were applied already?

@facchinm I made the official lufa bootloader Arduino compatible with a few changes. I think this is a better idea than modifying HoodLoader2, as I've changes a lot to non standard to get the maximum size reduction.

lufa has also additional fetures as eeprom, lock bit etc support (as it has more room without the serial bridge). The leds blink a bit different, but to be honest this is totally fine to me, as it will use the usb tx/rx leds which I think is quite a good idea anyways.

I have not added the old magic key support, as people who use the new bootloader will use the new ide. I wanted to keep lufa at least simple, feel free to add this little patch yourself.

Link: abcminiuser/lufa#86

@facchinm
Copy link
Member Author

@NicoHood , the latest patch (runtime discovery of bootloader version) was cherrypicked, 197fe07 instead brings some headache on win10 (if we are declaring as USB 2.1 we must provide a BOS descriptor, otherwise the drivers won't load at all). I still had no time to tackle this and find a good workaround.

@facchinm
Copy link
Member Author

BTW, the LUFA patches are very clever and we could really think about integrating them to be as mainline as possible 👍

@reillyeon
Copy link
Contributor

Couldn't we just fix this on Windows 10 by responding with a basic BOS descriptor with a container ID?

@facchinm
Copy link
Member Author

The ram/flash usage overhead was quite high when I coded a basic BOS response, and in a resource constrained device like 32u4 it's a huge problem losing 500bytes for a WIN10 specific issue.
But if you have a patch for adding a light (and overridable by a PluggableUSB library) BOS descriptor I'll be really happy to merge it

@reillyeon
Copy link
Contributor

I'll see what I can do to shrink it. That seems like a lot of bytes.

@NicoHood
Copy link
Contributor

NicoHood commented May 23, 2016

If "runtime discovery of bootloader version" was cherry picked, why is the commit still shown in this PR?

It would be nice if you could also test my Lufa patch and add a comment if it works. I really would like to see this as new bootloader, as this would be the simplest and clearest option with the most features (and further bugfixes from lufa) we can get.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants