Help with V-USB and USBaspLoader

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I'm working with V-USB and Code::Blocks, trying to generate easy to compile projects with that IDE to put them on-line, and trying to add some small features as well (like tx/rx LEDs in CDC devices). I made a small PCB in different versions (crystals and mcus), in order to test the library. I have the following working:

- CDC-232 with mega48 (20 MHz)
- USBasp with mega48 (20 MHz), mega168 (12 MHz) and mega328p (12 MHz)
- USBDoper with mega328p (12 Mhz) in HID and CDC modes.

But, I can't put to work any USB bootloader based on V-USB. I'm using WinAVR-20090313, (but tried 20081205 and 20080610 too). Now, to simpify, I'm centered in USBaspLoader with m168 @ 12 MHz.
I only modified the Makefile and the usbconfig.h to accomodate to my hardware, and get the following strange result: When I build the hex file, If I use

BOOTLOADER_ADDRESS = 0

and program fuses as a if it were a "standard app", Windows and the avrdude recognizes the device (of course it does not work as a bootloader, due to it's location in memory). BUT, if I just modify the Makefile (AND NOTHING ELSE) with:

BOOTLOADER_ADDRESS = 0x3800

and then with the AVRStudio program the fuses, when I plug-in the device, it's not recognized by Windows.
More: If I do program the fuses to start at 0x3800, and then download the wrong file (that starting at 0x0000), it works too! But when the hex is well generated (and I dumped it and it's correct starting at 0x3800) nothing works. I din't see any report on this, everybody seems to have working the USBasploader too soon. I don't see any thing else to experiment (I tried to use BootloadHID, and the problem is similar, tried the mega328p -worst-, different crystals, even making with make and making with Code::Blocks). Please help! I can upload sources, schematics, screenshoots, etc..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, it seems that it lacks these two lines:

MCUCR = (1<<IVCE);
MCUCR = (1<<IVSEL);

at the begining of the main(). I found them at the excellent AVR Bootloader FAQ (thanks to Brad Shick and Cliff Lawson!). So added them, and it seems to be working now (i have to do more tests). But i don't understand how did it work at all, without these changes on those demos in Internet...