After spending some time yesterday working on Lilytiny here, I think it might be interesting to have a look at its USB code and bootloader.
As far as I know, use Arduino IDE to interactive with ATMega328P devices would mainly have two methods * use FTDI USB chip - this is quite expensive chip, as FTDI takes considerable high license fee * wch 340g chip - this is produced by a company in Jiangs Su, China.
Majority of Arduino-compatible devices use FTDI usb chip long time ago, and there are large portion of these devices use fake FTDI chips intentionally or unintentionally. From 2014, FTDI released new drivers, which actively “kill” fake chips, story here. Because of this, lots of low-end “compatible” boards switched to cheaper alternatives, wch 340g.
Nevertheless, a USB chip is mandatory for Arduino IDE, but if you have a look at original digispark schema, there is no USB chip. Of course this would make the board “invisible” in Arduino IDE’s port list, but how Arduino IDE program this chip then?
Based on digistump/digispark document, it looks like LilyTiny should be using a bootloader called micronucleus. That’s a bootloader specifically designed for AVR ATtiny family, including ATtiny85/65 etc.
uploader for hex file
micronucleus/commandline includes command line program to upload compiled hex file to ATtiny85 devices.
First, uploader connects to device around L164. This
micronucleus_connect is defined in micronucleus_lib.c.
Third, it erases flash in device via
Finally, it writes data via
micronucleus_writeFlash to device and start via
The whole upload process finishes here.