V-USB Bootloader w/ AVRStudio Code Optimization Problems
Posted: Wed Oct 27, 2010 7:23 am
So I've had some success with getting the bootloader project working.
By some success I mean, that I've gotten it to a point where my PC detects the device and installs it and I can connect to it and flash the firmware from HIDBootFlash.
However my success ends there because I can only get this to work by compiling my project with optimizations turned off -O0 which results in a 6.5k program which doesn't fit into the bootloader area of the flash memory.
If I set optimizations to -Os to get the nice, tidy 2K app, I start getting the "USB Device Not Recognized" message repeatedly and I hear the windows USB device connect/disconnect noise over and over again.
When I try to debug through this it appears as if the device is continuously restarting or that somehow execution is jumping back to main right after it the bootLoaderCondition() test succeeds.
It seems that some crucial part of the code is getting optimized out. I'm wondering if I'm missing some compiler options somewhere. I've tried poking through the make file and getting my options in AVRStudio to match as closely as I can but haven't had any luck so far..
My build options look like this
avr-gcc -mmcu=atmega328p -Wall -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -DDEBUG_LEVEL=0 -gdwarf-2 -std=gnu99 -DF_CPU=12000000UL -Os -fsigned-char -MD -MP -MT main.o -MF dep/main.o.d -c ../main.c
i'm using avr-gcc version 4.3.2
By some success I mean, that I've gotten it to a point where my PC detects the device and installs it and I can connect to it and flash the firmware from HIDBootFlash.
However my success ends there because I can only get this to work by compiling my project with optimizations turned off -O0 which results in a 6.5k program which doesn't fit into the bootloader area of the flash memory.
If I set optimizations to -Os to get the nice, tidy 2K app, I start getting the "USB Device Not Recognized" message repeatedly and I hear the windows USB device connect/disconnect noise over and over again.
When I try to debug through this it appears as if the device is continuously restarting or that somehow execution is jumping back to main right after it the bootLoaderCondition() test succeeds.
It seems that some crucial part of the code is getting optimized out. I'm wondering if I'm missing some compiler options somewhere. I've tried poking through the make file and getting my options in AVRStudio to match as closely as I can but haven't had any luck so far..
My build options look like this
avr-gcc -mmcu=atmega328p -Wall -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -DDEBUG_LEVEL=0 -gdwarf-2 -std=gnu99 -DF_CPU=12000000UL -Os -fsigned-char -MD -MP -MT main.o -MF dep/main.o.d -c ../main.c
i'm using avr-gcc version 4.3.2