It is actually much simpler than the other answers suggest. There is no need to remove/overwrite the bootloader. You can just disable the bootloader by setting the appropriate fuse bit.
In order to do so, you need an ISP programmer. As you might know, you'll loose the ability to upload code though USB/FTDI. But you can restore that ability at any time, just by resetting the appropriate fuse bit to its original value.
Step 1: Connect your trinket through an ISP programmer
There is no ISP header on the trinket, but you can easily build one or just use jumper wires to connect the individual pins directly to the programmer. Pinout can be found at learn.adafruit.com. You need to connect MISO, MOSI, SCK, RST, VCC and GND.
Step 2: Determine current fuse configuration
avrdude -c usbtiny -p m328p
If you're using a different programmer than the USBTinyISP, replace
usbtiny with the appropriate identifier. List possible values by specifying a bogus identifier, eg.
avrdude -c foo.
Among some other things, avrdude should return a line containing the current fuse values. It should look similar to the following:
avrdude: safemode: Fuses OK (E:FD, H:D0, L:FF)
We're interested in the high fuse (H:D0).
D0 indicates that the bootloader is enabled. Actually, any even number means the bootloader is enabled.
Step 3: Calculate new fuse value
We want to set the
BOOTRST bit of the high fuse. It is the least significant bit of the fuse, which equals the number 1. So all we need to do is increment the value by 1.
In the example, the new fuse value is
If you are unsure how to calculate the fuse value, you can use the Fuse Calculator. Choose ATMega328P as your device, enter the fuse values as reported by avrdude at the very bottom under "Current settings", then click apply. Uncheck
BOOTRST in the "Manual fuse bits configuration" section, then you will see the new fuse value in the bottom section, where you entered the original value.
Step 4: Program new fuse value
avrdude -c usbtiny -p m328p -U hfuse:w:0xd1:m
usbtiny with the identifier of your programmer. If you calculated a different value than
0xd1 with your approriate value. However, if your original value for the high fuse was
D0, then your new value is