BootloadHID

Registered forum users can contribute their rating for projects based on V-USB in this forum.

Please rate BootloadHID on a scale from 0 (worst) to 5 (best):

(0)
0
No votes
(1) *
0
No votes
(2) **
0
No votes
(3) ***
0
No votes
(4) ****
1
7%
(5) *****
13
93%
 
Total votes: 14

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

BootloadHID

Postby christian » Mon Jun 25, 2007 5:19 pm

Registered forum users can rate BootloadHID in the poll above.

To comment on the project, reply to this topic.

butrus

A little comment.

Postby butrus » Wed Jun 27, 2007 10:27 am

It's very nice project. Maybe one idea: it would be nice to have user configurable macro for a function, that would be called each time the bootloader is leaved. That would allow the bootLoaderCondition be a EEPROM flag, which would be than cleared after uploading the new firmware (so that one doesn't need a hardware pin at all)...

Something like:

Code: Select all

--- main.c.orig 2007-06-27 10:11:48.000000000 +0200
+++ main.c      2007-06-27 10:23:08.000000000 +0200
@@ -58,6 +58,13 @@
 static void leaveBootloader() __attribute__((__noreturn__));
 static void leaveBootloader()
 {
+/*
+ * Call custom function when leaving the boot loader (e.g. clearing flag
+ * in the EEPROM)
+ */
+#ifdef bootLoaderLeave()
+    bootLoaderLeave();
+#endif
     DBG1(0x01, 0, 0);
     cli();
     boot_rww_enable();

butrus

avr-gcc 4.2.0 generates too big code :-((((

Postby butrus » Wed Jun 27, 2007 10:28 am

Code: Select all

avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -c usbdrv/usbdrv.c -o usbdrv/usbdrv.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -x assembler-with-cpp -c usbdrv/usbdrvasm.S -o usbdrv/usbdrvasm.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -c usbdrv/oddebug.c -o usbdrv/oddebug.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -c main.c -o main.o
main.c:65:23: warning: extra tokens at end of #ifdef directive
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -o main.bin usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o -Wl,--section-start=.text=1800
/usr/lib/gcc/avr/4.1.2/../../../../avr/bin/ld: address 0x202e of main.bin section .text is not within region text
make: *** [main.bin] Error 1


:-((

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

Postby christian » Wed Jun 27, 2007 1:45 pm

gcc 4 generates slightly bigger code. I would have expected that the code still fits into the 2k boot loader section.

How big is the code you use to determine the boot loader condition? Does this code link any additional libraries?

If you need to use gcc 4 and can't optimize the code any further, you could consider switching to 16 MHz crystal clock rate. The 16 MHz assembler module is ~ 100 bytes smaller.

Grendel
Rank 4
Rank 4
Posts: 167
Joined: Sat Dec 16, 2006 9:53 pm
Location: Oregon, USA
Contact:

Postby Grendel » Thu Jun 28, 2007 1:54 am

Whoops. Unchanged project w/ WinAVR 20070122

Code: Select all

C:\Data\AVR-USB\bootloadHID\firmware>make all
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -c usbdrv/usbdrv.c -o usbdrv/usbdrv.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -x assembler-with-cpp -c usbdrv/usbdrvasm.S -o usbdrv/usbdrvasm.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -c usbdrv/oddebug.c -o usbdrv/oddebug.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -c main.c -o main.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -o main.bin usbdrv/usbdrv.o usbdrv
/usbdrvasm.o usbdrv/oddebug.o main.o -Wl,--section-start=.text=1800
c:\tools\winavr\bin\..\lib\gcc\avr\4.1.1\..\..\..\..\avr\bin\ld.exe: address 0x2024 of main.bin section .text is not within region text
make: *** [main.bin] Error 1


Works w/ 16MHz code:

Code: Select all

C:\Data\AVR-USB\bootloadHID\firmware>make all
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -c usbdrv/usbdrv.c -o usbdrv/usbdrv.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -x assembler-with-cpp -c usbdrv/usbdrvasm.S -o usbdrv/usbdrvasm.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -c usbdrv/oddebug.c -o usbdrv/oddebug.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -c main.c -o main.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8  -o main.bin usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o -Wl,--section-start=.text=1800
rm -f main.hex main.eep.hex
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
avr-size main.bin
   text    data     bss     dec     hex filename
   1960      12      62    2034     7f2 main.bin


After adding

Code: Select all

#define   F_CPU   16000000L

#define USB_CFG_CLOCK_KHZ       (F_CPU/1000)


to usbconfig.h

Edit: one suggestion -- allow leaving the bootloader via commandline flag -r in the windows app.

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

Postby christian » Thu Jun 28, 2007 1:10 pm

Would be interesting WHY gcc 4 generates so much bigger code than gcc 3. Maybe we can make simple changes in the C code to get better code size even with gcc 4.

Is there anybody with insight to gcc's optimization techniques?

Grendel
Rank 4
Rank 4
Posts: 167
Joined: Sat Dec 16, 2006 9:53 pm
Location: Oregon, USA
Contact:

Postby Grendel » Fri Jun 29, 2007 1:37 am

Well, try adding the ,-Map=main.map to the LDFLAGS in the Makefile and compare the map w/ the one below. Would be interesting to see if that could be nailed down to a specific section of code..

Code: Select all

Archive member included because of file (symbol)

c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_copy_data.o)
                              usbdrv/usbdrv.o (__do_copy_data)
c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_clear_bss.o)
                              usbdrv/usbdrv.o (__do_clear_bss)

Allocating common symbols
Common symbol       size              file

usbTxBuf            0xb               usbdrv/usbdrv.o
usbTxBuf1           0xb               usbdrv/usbdrv.o
usbDeviceAddr       0x1               usbdrv/usbdrv.o
usbRxToken          0x1               usbdrv/usbdrv.o
usbInputBufOffset   0x1               usbdrv/usbdrv.o
usbMsgPtr           0x2               usbdrv/usbdrv.o
usbRxLen            0x1               usbdrv/usbdrv.o
usbNewDeviceAddr    0x1               usbdrv/usbdrv.o
usbCurrentTok       0x1               usbdrv/usbdrv.o
usbConfiguration    0x1               usbdrv/usbdrv.o
usbRxBuf            0x16              usbdrv/usbdrv.o

Discarded input sections

 .stabstr       0x00000000        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o

Memory Configuration

Name             Origin             Length             Attributes
text             0x00000000         0x00002000         xr
data             0x00800060         0x0000ffa0         rw !x
eeprom           0x00810000         0x00010000         rw !x
*default*        0x00000000         0xffffffff

Linker script and memory map

LOAD c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o
LOAD usbdrv/usbdrv.o
LOAD usbdrv/usbdrvasm.o
LOAD usbdrv/oddebug.o
LOAD main.o
Address of section .text set to 0x1800
LOAD c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a
LOAD c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4\libc.a
LOAD c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a

.hash
 *(.hash)

.dynsym
 *(.dynsym)

.dynstr
 *(.dynstr)

.gnu.version
 *(.gnu.version)

.gnu.version_d
 *(.gnu.version_d)

.gnu.version_r
 *(.gnu.version_r)

.rel.init
 *(.rel.init)

.rela.init
 *(.rela.init)

.rel.text
 *(.rel.text)
 *(.rel.text.*)
 *(.rel.gnu.linkonce.t*)

.rela.text
 *(.rela.text)
 *(.rela.text.*)
 *(.rela.gnu.linkonce.t*)

.rel.fini
 *(.rel.fini)

.rela.fini
 *(.rela.fini)

.rel.rodata
 *(.rel.rodata)
 *(.rel.rodata.*)
 *(.rel.gnu.linkonce.r*)

.rela.rodata
 *(.rela.rodata)
 *(.rela.rodata.*)
 *(.rela.gnu.linkonce.r*)

.rel.data
 *(.rel.data)
 *(.rel.data.*)
 *(.rel.gnu.linkonce.d*)

.rela.data
 *(.rela.data)
 *(.rela.data.*)
 *(.rela.gnu.linkonce.d*)

.rel.ctors
 *(.rel.ctors)

.rela.ctors
 *(.rela.ctors)

.rel.dtors
 *(.rel.dtors)

.rela.dtors
 *(.rela.dtors)

.rel.got
 *(.rel.got)

.rela.got
 *(.rela.got)

.rel.bss
 *(.rel.bss)

.rela.bss
 *(.rela.bss)

.rel.plt
 *(.rel.plt)

.rela.plt
 *(.rela.plt)

.text           0x00001800      0x824
 *(.vectors)
 .vectors       0x00001800       0x26 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o
                0x00001800                __vectors
                0x00001800                __vector_default
 *(.vectors)
 *(.progmem.gcc*)
 *(.progmem*)
 .progmem.data  0x00001826       0x5a usbdrv/usbdrv.o
                0x0000184c                usbDescriptorDevice
                0x00001826                usbDescriptorString0
                0x0000185e                usbDescriptorConfiguration
                0x0000182a                usbDescriptorStringVendor
                0x0000183c                usbDescriptorStringDevice
 .progmem.data  0x00001880       0x21 main.o
                0x00001880                usbDescriptorHidReport
                0x000018a2                . = ALIGN (0x2)
 *fill*         0x000018a1        0x1 00
                0x000018a2                __trampolines_start = .
 *(.trampolines)
 .trampolines   0x000018a2        0x0 linker stubs
 *(.trampolines*)
                0x000018a2                __trampolines_end = .
 *(.jumptables)
 *(.jumptables*)
 *(.lowtext)
 *(.lowtext*)
                0x000018a2                __ctors_start = .
 *(.ctors)
                0x000018a2                __ctors_end = .
                0x000018a2                __dtors_start = .
 *(.dtors)
                0x000018a2                __dtors_end = .
 SORT(*)(.ctors)
 SORT(*)(.dtors)
 *(.init0)
 .init0         0x000018a2        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o
                0x000018a2                __init
 *(.init0)
 *(.init1)
 *(.init1)
 *(.init2)
 .init2         0x000018a2        0xc c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o
 *(.init2)
 *(.init3)
 *(.init3)
 *(.init4)
 .init4         0x000018ae       0x16 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_copy_data.o)
                0x000018ae                __do_copy_data
 .init4         0x000018c4       0x10 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_clear_bss.o)
                0x000018c4                __do_clear_bss
 *(.init4)
 *(.init5)
 *(.init5)
 *(.init6)
 *(.init6)
 *(.init7)
 *(.init7)
 *(.init8)
 *(.init8)
 *(.init9)
 .init9         0x000018d4        0x2 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o
 *(.init9)
 *(.text)
 .text          0x000018d6        0x2 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o
                0x000018d6                __vector_12
                0x000018d6                __bad_interrupt
                0x000018d6                __vector_6
                0x000018d6                __vector_3
                0x000018d6                __vector_11
                0x000018d6                __vector_13
                0x000018d6                __vector_17
                0x000018d6                __vector_7
                0x000018d6                __vector_5
                0x000018d6                __vector_4
                0x000018d6                __vector_9
                0x000018d6                __vector_2
                0x000018d6                __vector_15
                0x000018d6                __vector_8
                0x000018d6                __vector_14
                0x000018d6                __vector_10
                0x000018d6                __vector_16
                0x000018d6                __vector_18
 .text          0x000018d8      0x2ac usbdrv/usbdrv.o
                0x000018ec                usbPoll
                0x00001b40                usbSetInterrupt
                0x000018d8                usbInit
 .text          0x00001b84      0x300 usbdrv/usbdrvasm.o
                0x00001bbe                __vector_1
                0x00001b84                usbCrc16
                0x00001bb6                usbCrc16Append
 .text          0x00001e84        0x0 usbdrv/oddebug.o
 .text          0x00001e84      0x1a0 main.o
                0x00001e84                usbFunctionSetup
                0x00001fc8                main
                0x00001eb8                usbFunctionWrite
 .text          0x00002024        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_copy_data.o)
 .text          0x00002024        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_clear_bss.o)
                0x00002024                . = ALIGN (0x2)
 *(.text.*)
 .text.libgcc   0x00002024        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_copy_data.o)
 .text.libgcc   0x00002024        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_clear_bss.o)
                0x00002024                . = ALIGN (0x2)
 *(.fini9)
 *(.fini9)
 *(.fini8)
 *(.fini8)
 *(.fini7)
 *(.fini7)
 *(.fini6)
 *(.fini6)
 *(.fini5)
 *(.fini5)
 *(.fini4)
 *(.fini4)
 *(.fini3)
 *(.fini3)
 *(.fini2)
 *(.fini2)
 *(.fini1)
 *(.fini1)
 *(.fini0)
 *(.fini0)
                0x00002024                _etext = .

.data           0x00800060        0xc load address 0x00002024
                0x00800060                PROVIDE (__data_start, .)
 *(.data)
 .data          0x00800060        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o
 .data          0x00800060        0x3 usbdrv/usbdrv.o
                0x00800060                usbMsgLen
                0x00800062                usbTxLen1
                0x00800061                usbTxLen
 .data          0x00800063        0x0 usbdrv/usbdrvasm.o
 .data          0x00800063        0x0 usbdrv/oddebug.o
 .data          0x00800063        0x8 main.o
 .data          0x0080006b        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_copy_data.o)
 .data          0x0080006b        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_clear_bss.o)
 *(.data*)
 *(.rodata)
 *(.rodata*)
 *(.gnu.linkonce.d*)
                0x0080006c                . = ALIGN (0x2)
 *fill*         0x0080006b        0x1 00
                0x0080006c                _edata = .
                0x0080006c                PROVIDE (__data_end, .)

.bss            0x0080006c       0x3e
                0x0080006c                PROVIDE (__bss_start, .)
 *(.bss)
 .bss           0x0080006c        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o
 .bss           0x0080006c        0x1 usbdrv/usbdrv.o
 .bss           0x0080006d        0x0 usbdrv/usbdrvasm.o
 .bss           0x0080006d        0x0 usbdrv/oddebug.o
 .bss           0x0080006d        0x8 main.o
 .bss           0x00800075        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_copy_data.o)
 .bss           0x00800075        0x0 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/avr4\libgcc.a(_clear_bss.o)
 *(.bss*)
 *(COMMON)
 COMMON         0x00800075       0x35 usbdrv/usbdrv.o
                0x00800075                usbTxBuf
                0x00800080                usbTxBuf1
                0x0080008b                usbDeviceAddr
                0x0080008c                usbRxToken
                0x0080008d                usbInputBufOffset
                0x0080008e                usbMsgPtr
                0x00800090                usbRxLen
                0x00800091                usbNewDeviceAddr
                0x00800092                usbCurrentTok
                0x00800093                usbConfiguration
                0x00800094                usbRxBuf
                0x008000aa                PROVIDE (__bss_end, .)
                0x00002024                __data_load_start = LOADADDR (.data)
                0x00002030                __data_load_end = (__data_load_start + SIZEOF (.data))

.noinit         0x008000aa        0x0
                0x008000aa                PROVIDE (__noinit_start, .)
 *(.noinit*)
                0x008000aa                PROVIDE (__noinit_end, .)
                0x008000aa                _end = .
                0x008000aa                PROVIDE (__heap_start, .)

.eeprom         0x00810000        0x0
 *(.eeprom*)
                0x00810000                __eeprom_end = .

.stab           0x00000000      0x36c
 *(.stab)
 .stab          0x00000000      0x36c c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o

.stabstr        0x00000000       0x84
 *(.stabstr)
 .stabstr       0x00000000       0x84 c:/tools/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr4/crtm8.o

.stab.excl
 *(.stab.excl)

.stab.exclstr
 *(.stab.exclstr)

.stab.index
 *(.stab.index)

.stab.indexstr
 *(.stab.indexstr)

.comment
 *(.comment)

.debug
 *(.debug)

.line
 *(.line)

.debug_srcinfo
 *(.debug_srcinfo)

.debug_sfnames
 *(.debug_sfnames)

.debug_aranges
 *(.debug_aranges)

.debug_pubnames
 *(.debug_pubnames)

.debug_info
 *(.debug_info)
 *(.gnu.linkonce.wi.*)

.debug_abbrev
 *(.debug_abbrev)

.debug_line
 *(.debug_line)

.debug_frame
 *(.debug_frame)

.debug_str
 *(.debug_str)

.debug_loc
 *(.debug_loc)

.debug_macinfo
 *(.debug_macinfo)
OUTPUT(main.bin elf32-avr)
LOAD linker stubs


Map generated w/ out-of-the-box project.

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

Postby christian » Sat Jun 30, 2007 12:33 pm

I have both, gcc 3 and 4 installed and already compared the assembler code generated from the C module. There are many differences because gcc 4 assigns registers in a different way. This saves moves on one end and requires other moves on the other end. In summary, the code is bigger. But I can't nail it down to a particular function, expression or statement.

squeeze

USB_PUBLIC

Postby squeeze » Sun Jul 01, 2007 7:26 pm

christian wrote:I have both, gcc 3 and 4 installed and already compared the assembler code generated from the C module. There are many differences because gcc 4 assigns registers in a different way. This saves moves on one end and requires other moves on the other end. In summary, the code is bigger. But I can't nail it down to a particular function, expression or statement.


By doing the '#define USB_PUBLIC static and #include ""usbdrv/usbdrv.c"'-trick I managed to put the bootloader into an atmega16.

Regards
Mario

Grendel
Rank 4
Rank 4
Posts: 167
Joined: Sat Dec 16, 2006 9:53 pm
Location: Oregon, USA
Contact:

Postby Grendel » Wed Jul 04, 2007 10:23 am

Grendel wrote:one suggestion -- allow leaving the bootloader via commandline flag -r in the windows app.

Any chance of putting that in ? I got stuck trying to compile the app w/ VS2005 (no DDK installed and I can't get it before the 6th. Missing hidusage.h, usb.h and possibly others.)

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

Postby christian » Wed Jul 04, 2007 11:15 am

Thanks for the suggestion! I'm trying to mail you a package with a private developer snapshot which implements the option, but gmail rejects a zip file including a Windows executable. Do you have an alternative e-mail or other suggestions? I don't want to make this version public before it's tested.

BTW: I compile the Windows binaries with MinGW. No DDK is needed and everything can be downloaded for free!

Grendel
Rank 4
Rank 4
Posts: 167
Joined: Sat Dec 16, 2006 9:53 pm
Location: Oregon, USA
Contact:

Postby Grendel » Wed Jul 04, 2007 11:29 am

I'll send you an email w/ an alternative address, thanks!

Since I got VS2005 installed I thought I'd give it a shot :) Maybe I could use those headers from MinGW w/ VS, if you add them that the beta I'll try it (just to see if VS would do)

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

Postby christian » Wed Jul 04, 2007 11:39 am

Give it a shot (literally) and use MinGW instead. The code was developed with gcc and you can expect the least troubles with this compiler.

I must admit, though, that MinGW installation is not trivial. Well, the installation itself is easy, but it's hard to find out which packages you really need.

6TIT
Posts: 2
Joined: Mon Mar 17, 2008 11:59 am
Contact:

Question

Postby 6TIT » Mon Mar 17, 2008 12:05 pm

Hello everybody
I'm pretty new in programming.
I need to make this for school and have some questions.
When I have the bootloader in the atmega8 I need to put some program (made in BASCOM) in it.
But I don't know how it works (which program and so on..)
Can someone help me with that ?
Best Regards

Siddharth

BootLoadHID command line tool does not works with vista.

Postby Siddharth » Thu May 22, 2008 9:11 pm

I have no problems regarding bootloadhid uptill now. I was using vista system and the commandline tool for the bootloader.

I have now switched to windows vista and the command line tool fails to identify my device!!! But my device manager shows me the device is already identified with correct VID and PID.

Anyone has tried to use commandline tool on vista?? Does it works?? or i have made any mistake??


Return to “V-USB Project Ratings”

Who is online

Users browsing this forum: No registered users and 0 guests

cron