I've been playing around with using the new Caterina LUFA based bootloader from Arduino 1.0.1 . As noted in the other thread at viewtopic.php?f=27&t=660 it doesn't solve all the issues (Tone etc) but it makes a few things easier. Side effect is though that the Bootloader changed from "arduino" to "avr109", and will require the native Leonardo drivers as it resets the VID/PID to use the official Leonardo ones. Not a huge issue, but technically speaking, only official products from Arduino are allowed to run the Arduino VID/PID, so as a learning experience I set about re mapping it all back to be Freetronics. This meant recompiling the Bootloader and updating the Board profile.
EDIT: On reflection, I guess this means the best path forward maybe to stop confusion for end-users etc might be that similar to what I think Arduino are doing is using a new PID for the new bootloader and a new PID for the sketches - that way "old" bootloaders could work with old .inf and "new" bootloaders can automatically be detected using the newer .inf (among other things). This is a last minute thought before bed.. anyway..
The biggest thing that changes is that it now uses the two serial port setup like the official Arduino (a bootloader comport and a sketch comport) but the release drivers use two different PIDs for this. The original Freetronics driver from what I can tell uses just one PID? So taking lead from the Arduino team, dropped the leading digit from the PID used by the Bootloader makefile (making it 0x0151 ?) and have updated the Freetronics driver to use the new Arduino Leonardo .inf format and new VID/PIDs . I also noticed that the release Leonardo Board Profile uses lfuses of ff, where as the Leostick has de . This is to do with the bootloader delay I think? Anyway, I wanted to have the full Leonardo experience, but rename it back to Leostick, so went with ff.
I am posting this info for anyone else curious about how to do this. I did it and it works fine and would love some feedback on if there is anything I've done wrong/stupid - particularly the made up PID.
I'm attaching my arduino-sketches\hardware\LeoStick directory which I believe you can replace with your existing one and the below should all be done except for the Driver update (include as a separate attachment). But NONE of this is anything but my own hackish attempts - those unfamiliar should probably wait for guidance from Jon !

Remember the second comport will only appear once you load a sketch - reloading the compiled bootloader will leave it sitting forever at the Bootloader waiting for upload as there is no sketch loaded (The shipped 'bootloader' includes a sketch, hence its larger size) To build the bootloader yourself and get the Freetronics Leostick names/drivers back you need to do the following under Win7:
1) download LUFA-111009 and unpack it into the same directory as your Arduino IDE (e.g, if in c:\arduino-1.0.1, place the LUFA-111009 directory in c:\LUFA-111009 as well). You need the previous release, not the latest: http://lufa-lib.googlecode.com/files/LUFA-111009.zip
1a) OPTIONAL - edit to \arduino-1.0.1\hardware\arduino\bootloaders\caterina\Descriptors.c - which sets the 'unknown' driver details which appear when plugging in to a new computer. The default Unknown for non Arduino boards is a little ugly personally, so I added an entry for Freetronics. Starting Line 196 through 215:
Code: Select all
const USB_Descriptor_String_t ProductString =
{
#if DEVICE_PID == 0x0036
.Header = {.Size = USB_STRING_LEN(16), .Type = DTYPE_String},
.UnicodeString = L"Arduino Leonardo"
#elif DEVICE_PID == 0x0151
.Header = {.Size = USB_STRING_LEN(20), .Type = DTYPE_String},
.UnicodeString = L"Freetronics LeoStick"
#else
.Header = {.Size = USB_STRING_LEN(12), .Type = DTYPE_String},
.UnicodeString = L"USB IO board"
#endif
};
const USB_Descriptor_String_t ManufNameString =
{
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
#if DEVICE_VID == 0x2341
.UnicodeString = L"Arduino LLC"
#elif DEVICE_VID == 0x20A0
.UnicodeString = L"Freetronics"
#else
.UnicodeString = L"Unknown "
#endif
};
Code: Select all
set BASEDIR=c:\arduino-1.0.1\hardware
set DIRAVRUTIL=%BASEDIR%\tools\avr\utils\bin
set DIRAVRBIN=%BASEDIR%\tools\avr\bin
set DIRAVRAVR=%BASEDIR%\tools\avr\avr\bin
set DIRLIBEXEC=%BASEDIR%\tools\avr\libexec\gcc\avr\4.3.2
set OLDPATH=%PATH%
@path %DIRAVRUTIL%;%DIRAVRBIN%;%DIRAVRAVR%;%DIRLIBEXEC%;%PATH%
cd %BASEDIR%\arduino\bootloaders\caterina
%DIRAVRUTIL%\make.exe clean
%DIRAVRUTIL%\make.exe all VID=0x20A0 PID=0x0151
copy Caterina.hex Caterina-Leostick.hex
%DIRAVRUTIL%\make.exe clean
@path %OLDPATH%
I got errors initially about pins_arduino.h, so I re copied the \arduino-1.0.1\hardware\arduino\cores to \arduino-sketches\hardware\leostick\cores .
4) Remove the old LeoStick_Bootloader_Driver and prepare a new one. To use the new avr109 based drivers/ports etc, I initially had problems. I ended up uninstalling and choosing delete the driver file as well? when removing the existing Freetronics Bootloader driver (remember to press reset to get to bot com ports if you already have the two comports installed) and then using a modified one from the \arduino-1.0.1\drivers\Arduino_Leonardo.inf file . All I did was update the Vendor details to be the Freetronics VID/PID and Details, and added the 0151 PID for the bootloader. My version is also attached for anyone brave (_v2.inf) .
The modified section from LeoStick_Bootloader_Driver_v1.inf is line 88 through 94 which I altered to:
Code: Select all
[DeviceList]
%DESCRIPTION%=DriverInstall, USB\VID_20A0&PID_0151
%DESCRIPTION%=DriverInstall, USB\VID_20A0&PID_4151&MI_00
[DeviceList.NTamd64]
%DESCRIPTION%=DriverInstall, USB\VID_20A0&PID_0151
%DESCRIPTION%=DriverInstall, USB\VID_20A0&PID_4151&MI_00
Code: Select all
################################
leostick.name=Freetronics LeoStick
leostick.upload.protocol=avr109
leostick.upload.maximum_size=28672
leostick.upload.speed=57600
leostick.upload.disable_flushing=true
leostick.bootloader.low_fuses=0xff
leostick.bootloader.high_fuses=0xd8
leostick.bootloader.extended_fuses=0xcb
leostick.bootloader.path=caterina
leostick.bootloader.file=Caterina-Leostick.hex
leostick.bootloader.unlock_bits=0x3F
leostick.bootloader.lock_bits=0x2F
leostick.build.mcu=atmega32u4
leostick.build.f_cpu=16000000L
leostick.build.vid=0x20A0
leostick.build.pid=0x4151
leostick.build.core=arduino
leostick.build.variant=leostick

Code: Select all
C:\arduino-1.0.1\hardware/tools/avr/bin/avrdude -CC:\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega32u4 -cbuspirate -P\\.\COM2 -e -Ulock:w:0x3F:m -Uefuse:w:0xcb:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xff:m
C:\arduino-1.0.1\hardware/tools/avr/bin/avrdude -CC:\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega32u4 -cbuspirate -P\\.\COM2 -Uflash:w:C:\arduino-sketches\hardware\LeoStick\bootloaders\caterina\Caterina-Leostick.hex:i -Ulock:w:0x2F:m
8) Have Fun with your 1.0.1 Leonardo/LeoStick !

Can someone please review the above and give me any comments/advice. Love to know if my blind attempts at doing this are remotely correct? (USB, WinDriver.inf newbie!)