12.8mhz usbasploader

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
charliefreck

12.8mhz usbasploader

Post by charliefreck » Sat Nov 01, 2008 6:22 am

i would love nothing more than to be able use usbasp loader on an atmega168 with the internal resonator. i was able to compile the bootloader with the new 12.8 code, but it's about 140 bytes too big. i turned off the extra options like eeprom access stuff, and i'm building it with avr-gcc 3.4.6. can anyone find some fat to cut out, and make this fit? please. :lol:

charliefreck

Post by charliefreck » Sun Nov 02, 2008 12:52 am

i also tried the slightly less desirable bootloadhid which claims "Code size optimization to make this boot loader usable with the 12.8 MHz module." it compiled at 2161 bytes. :x am i missing something?

bearing
Posts: 10
Joined: Mon Oct 27, 2008 6:06 pm
Location: Sweden

Post by bearing » Mon Nov 03, 2008 5:00 am

Did you turn off debugging?
Without debugging I got slightly below 2000 bytes when using bootloadHID at 12.8 MHz, using the same GCC version.

charliefreck

Post by charliefreck » Thu Nov 13, 2008 10:18 am

grr. i just can't make it work. bootloadHID compiles at 2161 with target atmega168 12.8mhz. 2071 bytes for atmega8. debugging seems to be off by default. the comments say it will not work if you turn it on. is there another option i missed. i'm putting off a really cool project because i need a watch crystal to keep accurate time, and would need to add a second ic to the circuit if i were to use a 16mhz for the bootloader.
bearing: might you post the makefile or even a hexfile? i really wish i could make this happen. thanks at any rate. ;)

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Fri Nov 14, 2008 5:06 pm

Which size is this? The size of RAM plus FLASH, or the flash only? You get the flash size with

avr-size main.hex

With a minimum boot loader condition and BOOTLOADER_CAN_EXIT defined to 1 I get 2012 bytes for an ATMega8 with 12.8 MHz RC, including the following clock adjustment code in usbconfig.h:

Code: Select all

macro tuneOsccal
    push    YH                              ;[0]
    clr     YH                              ;[2]
    in      YL, TCNT0                       ;[3]
    out     TCNT0, YH                       ;[4]
    subi    YL, EXPECTED_TIMER0_INCREMENT   ;[5]
#if OSCCAL > 0x3f
    lds     YH, OSCCAL                      ;[6]
#else
    in      YH, OSCCAL                      ;[6]
#endif
    cpi     YL, TOLERATED_DEVIATION + 1     ;[7]
    brmi    notTooHigh                      ;[8]
    subi    YH, 1                           ;[9] clock rate was too high
    rjmp    osctuneDone                     ;[10]
notTooHigh:
    cpi     YL, -TOLERATED_DEVIATION        ;[10]
    brpl    osctuneDone                     ;[11] not too low
    inc     YH                              ;[12] clock rate was too low
osctuneDone:
#if OSCCAL > 0x3f
    sts     OSCCAL, YH                      ;[12-13] store tuned value
#else
    out     OSCCAL, YH                      ;[12-13] store tuned value
#endif
tuningOverflow:
    pop     YH                              ;[14]
    endm                                    ;[16] max number of cycles
#endif
#if F_CPU == 12800000
#   define USB_SOF_HOOK        tuneOsccal
#endif

charliefreck

Post by charliefreck » Sat Nov 15, 2008 1:16 am

yeah. i guess i was looking at it wrong. i don't have any mega8's on hand, but i'll get some, and see if i can make that work. thanks a lot. great project!

Post Reply