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
10%
(5) *****
9
90%
 
Total votes : 10

Postby psc » Mon Feb 02, 2009 12:17 am

hi,

would be very nice if someone can share his recipe or have a look at my partial solution. i am looking for a way to make the bootloaderHID starting from the firmware without the needs to press any button or set any jumper and then application use the bootloadHID.exe -r to update the firmware.

here's my solution, not really working cause i don't fully understand obdev usb...

bootloaderconfig.h
Code: Select all
#define USB_CFG_PULLUP_IOPORTNAME   D
#define USB_CFG_PULLUP_BIT          4
#define BOOTLOADER_CAN_EXIT     1
#define JUMPER_BIT  5

static inline void  bootLoaderInit(void)
{
   PORTD |= (1 << JUMPER_BIT);
}

#define bootLoaderCondition()   ((PIND & (1 << JUMPER_BIT)) == 0)


i need to change the bootLoaderCondition, but i am not sure what to use. what i know is that i need to press and hold the jumper (button) to update the firmware. like i said, i would like to simply start the bootloader from the firmware without any intervention.

in the firmware i have this piece of code that seems to work.
Code: Select all
// ------------------------------------------------------------------------------
// - Start Bootloader
// ------------------------------------------------------------------------------
// dummy function doing the jump to bootloader section (Adress 1C00 on Atmega16)
void (*jump_to_bootloader)(void) = 0x1C00; __attribute__ ((unused))

void startBootloader(void) {
      
      MCUCSR &= ~(1 << PORF);         // clear power on reset flag
                              // this will hint the bootloader that it was forced
   
      cli();                     // turn off interrupts
      wdt_disable();               // disable watchdog timer
      usbDeviceDisconnect();          // disconnect gnusb from USB bus
      
      cbi(ADCSRA, ADIE);            // disable ADC interrupts
      cbi(ADCSRA, ADEN);            // disable ADC (turn off ADC power)

      PORTA = 0;                  // pull all pins low
      PORTB = 0;
      PORTC = 0;
      jump_to_bootloader();
}


pat
psc
 
Posts: 26
Joined: Sat Nov 15, 2008 8:51 pm

Postby christian » Tue Feb 03, 2009 2:15 pm

Note that you need some kind of emergency entry if you boot-load a broken firmware which is not able to pass control to the boot loader.

You would want to base the boot loader condition on the value of a byte in EEPROM. Write this byte to (e.g.) 0 and make a reset to run the boot loader, reset it to 0xff in the boot loader when you go back to your application. In addition to that, run the boot loader if a jumper is set.
christian
Objective Development
Objective Development
 
Posts: 1262
Joined: Thu Nov 09, 2006 10:46 am

Postby psc » Tue Feb 03, 2009 11:05 pm

excellent! here's how i did it:

Code: Select all
char do_boot_load;
do_boot_load = ~PIND & (1 << JUMPER_BIT);  // see if jumper is set (= 0)
do_boot_load += ~MCUCSR & (1 << PORF); // if we come here without a power on reset
   
    //if(bootLoaderCondition()){
    if(do_boot_load){

    ...

    //}while(bootLoaderCondition());
    }while(1);
psc
 
Posts: 26
Joined: Sat Nov 15, 2008 8:51 pm

Error in description of USB_CFG_CLOCK_KHZ

Postby Guest » Tue Feb 24, 2009 4:37 am

Error in description for USB_CFG_CLOCK_KHZ in bootloaderconfig.h and usbconfig-prototype.h

This text is in both bootloaderconfig.h and usbconfig-prototype.h
Code: Select all
#define USB_CFG_CLOCK_KHZ       (F_CPU/1000)
/* Clock rate of the AVR in MHz. Legal values are 12000, 12800, 15000, 16000,
* 16500 and 20000.

The description says "Clock rate of the AVR in MHz", but actually it's the clock rate in kHz.
Guest
 

Postby Guest » Tue Feb 24, 2009 4:57 am

The same error with Mhz vs kHz is in usbconfig-prototype.h (usbdrv folder) and usbconfig.h (test folder) in the AVR-USB source code.
And also usbconfig.h in in the all the example folders.
Code: Select all
#define USB_CFG_CLOCK_KHZ       (F_CPU/1000)
/* Clock rate of the AVR in MHz. Legal values are 12000, 12800, 15000, 16000,
* 16500 and 20000.
Guest
 

Postby christian » Tue Feb 24, 2009 11:55 am

Thanks for the info!
christian
Objective Development
Objective Development
 
Posts: 1262
Joined: Thu Nov 09, 2006 10:46 am

Re:

Postby AndersAnd » Wed Apr 15, 2009 8:19 pm

I can see it has now been updated in some header files but the file below is still not updated in Release 2009-03-23:
Tests -> usbconfig.h
AndersAnd
 
Posts: 0
Joined: Wed Apr 15, 2009 7:59 pm

Re: BootloadHID

Postby christian » Wed Apr 15, 2009 8:26 pm

The tests directory is primarily for internal use. It's therefore not maintained in the same degree as the rest of the code. But thanks again for this info!
christian
Objective Development
Objective Development
 
Posts: 1262
Joined: Thu Nov 09, 2006 10:46 am

atmega328p

Postby otitov » Sun Apr 26, 2009 8:12 pm

hi! does anybody succeed to run BootloadHID on atmega328p?
otitov
 
Posts: 0
Joined: Sun Apr 26, 2009 7:01 pm
Location: Mexico

Re: BootloadHID

Postby honda4life » Sat Jun 20, 2009 1:07 pm

[code]rm -rf usbdrvasm.o main.o oddebug.o usbdrv.o BootLoadHID.elf dep/* BootLoadHID.hex BootLoadHID.eep BootLoadHID.lss BootLoadHID.map
Build succeeded with 0 Warnings...
avr-gcc -mmcu=atmega16 -mmcu=atmega16 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=20000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT usbdrvasm.o -MF dep/usbdrvasm.o.d -x assembler-with-cpp -Wa,-gdwarf2 -c ../usbdrvasm.S
avr-gcc -mmcu=atmega16 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=20000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT main.o -MF dep/main.o.d -c ../main.c
In file included from ../usbdrv.h:13,
from ../usbdrv.c:12,
from ../main.c:22:
../usbconfig.h:33:1: warning: "USB_CFG_DMINUS_BIT" redefined
In file included from ../main.c:21:
../bootloaderconfig.h:46:1: warning: this is the location of the previous definition
avr-gcc -mmcu=atmega16 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=20000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT oddebug.o -MF dep/oddebug.o.d -c ../oddebug.c
avr-gcc -mmcu=atmega16 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=20000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT usbdrv.o -MF dep/usbdrv.o.d -c ../usbdrv.c
avr-gcc -mmcu=atmega16 -Wl,-Map=BootLoadHID.map usbdrvasm.o main.o oddebug.o usbdrv.o -o BootLoadHID.elf
usbdrv.o: In function `usbInit':
C:\Documents and Settings\Bart\Mijn documenten\AVR\BootLoadHID\default/../usbdrv.c:610: multiple definition of `usbInit'
main.o:C:\Documents and Settings\Bart\Mijn documenten\AVR\BootLoadHID\default/../usbdrv.c:610: first defined here
usbdrv.o: In function `usbPoll':
C:\Documents and Settings\Bart\Mijn documenten\AVR\BootLoadHID\default/../usbdrv.c:566: multiple definition of `usbPoll'
main.o:C:\Documents and Settings\Bart\Mijn documenten\AVR\BootLoadHID\default/../usbdrv.c:566: first defined here
usbdrv.o:(.data+0x0): multiple definition of `usbTxLen'
main.o:(.data+0x0): first defined here
usbdrv.o:(.progmem.data+0x28): multiple definition of `usbDescriptorDevice'
main.o:(.progmem.data+0x28): first defined here
usbdrv.o:(.progmem.data+0x3a): multiple definition of `usbDescriptorConfiguration'
main.o:(.progmem.data+0x3a): first defined here
usbdrv.o:(.progmem.data+0x0): multiple definition of `usbDescriptorString0'
main.o:(.progmem.data+0x0): first defined here
usbdrv.o:(.progmem.data+0x4): multiple definition of `usbDescriptorStringVendor'
main.o:(.progmem.data+0x4): first defined here
usbdrv.o:(.progmem.data+0x16): multiple definition of `usbDescriptorStringDevice'
main.o:(.progmem.data+0x16): first defined here
make: *** [BootLoadHID.elf] Error 1
Build failed with 1 errors and 2 warnings...[/code]

Can someone help with this error
I'm using AVR Studio 4.16

And is it still possible to send data to computer like ADC readings.
What's a good example for a beginner
honda4life
 
Posts: 4
Joined: Sat Jun 20, 2009 10:05 am

Re: BootloadHID

Postby christian » Sat Jun 20, 2009 1:32 pm

BootloadHID includes the usb driver in main.c instead of linking it in order to save code space. Please don't add usbdrv.c to the list of modules, because it's already included from main.c.
christian
Objective Development
Objective Development
 
Posts: 1262
Joined: Thu Nov 09, 2006 10:46 am

Re: BootloadHID

Postby honda4life » Sat Jun 20, 2009 1:44 pm

thanks, this worked ^^

don't know much about bootstuff of avr i'm totally new in this

So I guess i will need to set the fuse bits correct, download this program, and when i adapted the bootloader I change the fuses back, the program can be erased but still this works?
honda4life
 
Posts: 4
Joined: Sat Jun 20, 2009 10:05 am

Re: BootloadHID

Postby christian » Wed Jul 08, 2009 10:01 am

You flash the program, set the fuse bits and then (if you like) also protect the boot loader from overwriting. That's all.
christian
Objective Development
Objective Development
 
Posts: 1262
Joined: Thu Nov 09, 2006 10:46 am

Re: atmega328p

Postby rodmolina » Wed Jul 22, 2009 2:56 pm

[quote="otitov"]hi! does anybody succeed to run BootloadHID on atmega328p?[/quote]

i have the same problem.. i made it work on atmega168v @ 12MHz crystal but when i switch to atmega328p it just doesnt work..

the only way it works is setting TEST_MODE = 1 and BOOTLOADER_ADDRESS = 0

any help? please
rodmolina
 
Posts: 14
Joined: Fri Mar 27, 2009 6:33 pm

Re: BootloadHID

Postby christian » Wed Jul 22, 2009 3:16 pm

Have you set the boot loader base address correctly?
christian
Objective Development
Objective Development
 
Posts: 1262
Joined: Thu Nov 09, 2006 10:46 am

PreviousNext

Return to V-USB Project Ratings

Who is online

Users browsing this forum: No registered users and 1 guest