bootloadHID - timing - program optimisation
bootloadHID - timing - program optimisation
I have problems with bootloadHID, but I think it is the same for all other projects. The reset of USB ( pull of both data lines low for longer then 10 ms ) has two while loops for timing ( file main.c, line 189 ) In bootloadHID project the compiler removes the empty loops, then after reset reenumeration is not working. Adding simple asm("nop"); into inner loop helps, but increases the code too much - it will not fit into 2kB. Also the loop for stabilisation of pull up resistor on bootloader jumper ( in file bootloaderconfig.h, line 104 ) is optimized - deleted. How to fit to 2kB with loops ?
Use _delay_ms() from util/delay.h as in the latest examples included in the new avr-usb driver package. If it does not fit into 2k, upgrade to the latest driver, this version should save enough bytes so that it fits. If it still does not fit, consider using gcc 3 instead of gcc 4, it compiles smaller code (and does not optimize away delay loops).
Thank You. Unbeliavable how much can do new version of driver ( like in windows ). First I use the last avrusb, and then replace the delay loops with _delay_ms(20). To improve the bootloader, I replaced also the loop in the bootLoaderInit(), but it makes the program again too big. A little trick - I move this delay to main(), just exactly behind the "call" ( it is inline ) of bootloaderinit(). So logically the same, but it saves some other bytes. The most important - I was working with mega16, this proc have larger program than mega8. Mega8 users do not need such things. So final size 2032B/ mega16@12MHz. Works great, thank You for tips.
I have not seen a single upgrade on Windows (or any other major OS) where the memory consumption was actually decreased
I think the delay in bootLoaderInit() is not absolutely required, it should work without it.
And as a bonus, the next driver release will even have a couple of bytes less when compiled with gcc 4 (the gcc 3 code size will stay the same).
I think the delay in bootLoaderInit() is not absolutely required, it should work without it.
And as a bonus, the next driver release will even have a couple of bytes less when compiled with gcc 4 (the gcc 3 code size will stay the same).