chipKIT32 / PIC32-avrdude-bootloader

The 'new' bootloader for MPIDE/chipKIT PIC32 boards
44 stars 62 forks source link

Various USB related changes #29

Closed majenkotech closed 8 years ago

majenkotech commented 8 years ago

The .rodata for the USB code now goes into split text where the .text for the same code is. Makes much more room for the actual bootloader code to reside in the bootflash area.

The split flash linker scripts have hard coded locations for the split area. That was residing in the wrong place on chips with different amounts of memory. A special 256kb linker script for the MX170 and MX270 has been adapted from the original MX1-2-USB one with the correct address specified for split flash.

Defining the capability blCapUSBSerialNumber changes the USB string descriptor to reside in RAM not Flash, and a default serial number string is added. During boot time the bootloader populates that string with the contents of the DEVID and the USERID registers. This creates a serial number that is keyed both on the type and revision of the chip as well as any value loaded into the USERID field at programming time.

It is now possible to define custom string descriptors for the USB manufacturer and product. See the Lenny configuration in configs/majenko.h for an example. These are override values, and if not specified the original cpustick and stk500 strings are used.

EmbeddedMan commented 8 years ago

Holy cow Matt - this looks awesome. I'm going to look through the changes this weekend. Sweet!

majenkotech commented 8 years ago

They are mostly simple and straightforward. I have tried to keep it so that if nothing has been changed in a config it will act exactly as before. Pretty much everything relies on something being defined to change from the default behaviour. The only exception is the shuffling of the rodata to split flash on the MX1/2 USB linker script, which will happen for all USB mx1/2 chips. I'm using it live though on the Lenny boards right now.

majenkotech commented 8 years ago

Oh, and here's a sample from my dmesg:

[19052.736524] usb 6-2: USB disconnect, device number 80
[19053.635970] usb 6-2: new full-speed USB device number 81 using uhci_hcd
[19053.793245] usb 6-2: New USB device found, idVendor=0403, idProduct=a662
[19053.793250] usb 6-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[19053.793252] usb 6-2: Product: chipKIT Lenny
[19053.793254] usb 6-2: Manufacturer: Majenko Technologies
[19053.793256] usb 6-2: SerialNumber: CK1660A0530008
majenkotech commented 8 years ago

We have a call for the MX270 linker script that is in this PR. Can we get this reviewed and pulled ASAP?