Changing bootloader in Teensy 2.0 (atmega32U4)?

I'm thinking about trying to load an optiboot variant in a Teensy 2.0 board so I can upload microcode via the UART rather than the USB. The existing Teensy loader is locked in via the lock bits, but it only takes a small amount of the total memory which could be marked as a bootloader. Does anyone know if I could (theoretically) load an alternate bootloader just before the Teensy HalfKay bootloader, then simply change the fuses to tell the chip the bootloader is bigger? (Just thinking about ways to avoid erasing the chip). I don't see anything that says the fuses are locked by the lock bits (but then I haven't memorized the entire 433 page datasheet either :-). This is all just theory at the moment...

normally, you can't program anything into the chip via ISP without doing a full chip erase first. If the area immediately before the current bootloader is still "erased" (contains 0xFFFF) since the last time the bootloader was loaded, you might be able to just program there and change the fuses as you describe. (but only once!)

Claghorn: Does anyone know if I could (theoretically) load an alternate bootloader just before the Teensy HalfKay bootloader, then simply change the fuses to tell the chip the bootloader is bigger?

In principle your idea should work. I don't know whether changing fuses counts towards the erase cycle, surely it must consume some resource.

Well, I whipped out a little sketch to read the lock bits and fuses and print them to the serial monitor and I found that the lock bits are 0xCC, which (if I’m reading the manual right) means that the fuses (among other things) are locked, so my silly idea won’t work since I can’t change the fuses that set the boot loader size. So I guess if I want to experiment with a custom boot loader on a Teensy, I’ll need to erase the chip and start from a blank slate. (Kind of makes sense with the existing boot loader being proprietary - if I could have grown the boot loader, I could probably have read out the contents of the existing loader as well :-).