How I can understand LUFA DFU Bootloader is working?

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

Hi, I'm using Atmega16u4 MCU and JTAGICE MKII device programmer. I have changed following parameters of makefile of DFU Bootloader -

MCU = atmega16u4
FLASH_SIZE_KB = 16
BOOT_SECTION_SIZE_KB = 4

Using Avr Studio and JTAGICE MKII I have generated hex file and loaded to the flash memory respectively. My question is that how I can understand the bootloader is working.

Before loading hex file I have connected the micro-controller through USB and it has shown ATm32U4DFU in "Device Manager" under "Unknown device" (since it has factory configured bootloader beforehand), but after loading hex file it shows "Unknown Device" under "Universal Serial Bus Controllers". If DFU bootloader hex file is working perfectly (I guess) it should show ATm32U4DFU under Unknown device!

I am using:
Windows 7
LUFA-120219
WinAVR-20100110

Any suggestions will be very much appreciable.

Thanks,
Chotan

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

Another thing, if I connect the MCU with USB; my OS is telling "one of the usb attached to this computer has malfunctioned and windows does not recognize it"

From this link (https://www.avrfreaks.net/index.p...) I have checked my clock in makefile which is 8MHz. I don't get any clue for this problem.

Any suggestions please!!

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

Just to be on the same page I downloaded the version of LUFA that you indicated and took the time to build the DFU bootloader and load into my device. I don't have an ATmega16U4 based device. Mine is an ATmega32U4 based board. That should not matter too much though. It performs as it should.

I'm not sure exactly why you aren't getting a good build, but I think something is incorrect in the makefile. Can you answer these questions?

What is "BOARD = " defined as in the makefile?
Did you save the makefile after making your changes?
Did you rebuild all?

Also you set MCU = atmega16u4 but then in your post you mention the device as being an ATm32U4DFU ( I think you may have an ATmega32u4 based device). Are you sure you have an ATmega16U4?

My device shows up in the device manager under "libusb-win32 devices" as "Atmega32U4".

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

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

Moderator - shouldn't this be in the AVR Forum?

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

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

What are your AVR's bootloader fuses set to, and what is your external crystal frequency? After altering the makefile you should run a "make clean" followed by a "make all" to ensure everything is properly rebuilt.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Another hint is that JTAGICE MkII is a debugger.

No RSTDISBL, no fun!

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

Quote:
What is "BOARD = " defined as in the makefile?
Did you save the makefile after making your changes?
Did you rebuild all?

Also you set MCU = atmega16u4 but then in your post you mention the device as being an ATm32U4DFU ( I think you may have an ATmega32u4 based device). Are you sure you have an ATmega16U4?

I haven't changes BOARD, but it's designed by a PhD. student. S0 what do you suggest? Shall I use USER, NONE or without any parameters?

I have done several time the same procedure, so I saved makefile, then clean the project with Avr Studio 4.19 and build it.

Yes I'm using Atmel Mega16u4, but at initially I have seen in the device manager that it was showing ATm32U4DFU. But when I updated driver software with Flip under Atmel USB devices it was showing ATmega16U4.

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

Quote:
What are your AVR's bootloader fuses set to, and what is your external crystal frequency? After altering the makefile you should run a "make clean" followed by a "make all" to ensure everything is properly rebuilt.

I didn't change anything in fuses in AVR. After connecting and reading the signature at Fuses tab, it shows:

BODLEVEL Brown-out detection at VCC=2.6 V
HWBE [checked]
JTAGEN [checked]
SPIEN [checked]
BOOTSZ Boot Flash size=2048 words start address=$1800
CKDIV8 [checked]
SUT_CKSEL Ext. Crystal Osc. 8.0- MHz; Start-up time: 258 CK + 65 ms

I'm using 8MHz crystal.

make clean in cmd prompt or clean with AVR, I have done both. And then I Build again.

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

Hrm, sounds fine. What is the size output given when you compile? The old WinAVR compiler might be producing a binary larger than 4KB.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

chotan wrote:
I haven't changes BOARD, but it's designed by a PhD. student. S0 what do you suggest? Shall I use USER, NONE or without any parameters?

What is Board set to now?

I think Dean can answer what to set BOARD to better than I can.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

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

Quote:

I haven't changes BOARD, but it's designed by a PhD. student. S0 what do you suggest? Shall I use USER, NONE or without any parameters?

The bootloader only uses the board LED driver, so if you don't care about LED flashing when it's active just set BOARD to NONE.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

If I change the BOARD = NONE, it's showing following error.

E:\LUFA-120219\Bootloaders\DFU/BootloaderDFU.c:129: undefined reference to `LEDs_Disable'
collect2: ld returned 1 exit status
make: *** [BootloaderDFU.elf] Error 1

But if I change the following parameters-

MCU = atmega16u4
BOARD = USBKEY
F_CPU = 8000000
FLASH_SIZE_KB = 16
BOOT_SECTION_SIZE_KB = 4

I'm getting-

Size after:
AVR Memory Usage
----------------
Device: atmega16u4

Program: 3754 bytes (22.9% Full)
(.text + .data + .bootloader)

Data: 127 bytes (9.9% Full)
(.data + .bss + .noinit)

Quote:
My device shows up in the device manager under "libusb-win32 devices" as "Atmega32U4".

I haven't install libusb-win32. Is it necessary?

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

Quote:

E:\LUFA-120219\Bootloaders\DFU/BootloaderDFU.c:129: undefined reference to `LEDs_Disable'
collect2: ld returned 1 exit status
make: *** [BootloaderDFU.elf] Error 1

Ah yes, a bug in the release (I forgot to add in a dummy handler for BOARD_NONE for that function). That won't be a problem in the future - the bug is fixed, and I added this to the codebase:

https://github.com/abcminiuser/l...

To test for this before future releases. For now just comment out the call to LEDs_Disable() in the bootloader if you use BOARD_NONE.

Quote:

Size after:
AVR Memory Usage
----------------
Device: atmega16u4

Program: 3754 bytes (22.9% Full)
(.text + .data + .bootloader)

Data: 127 bytes (9.9% Full)
(.data + .bss + .noinit)

Hrm, so it's not that then. Can you try compiling and loading the Demos/Device/ClassDriver/Mouse/ demo onto the board, just to rule out an issue with the bootloader?

Quote:

I haven't install libusb-win32. Is it necessary?

It will be once it's correctly recognized - although you install the libUSB based driver included with Atmel FLIP, rather than libUSB itself.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

After changing makefile and building successfully I got

AVR Memory Usage
----------------
Device: atmega16u4

Program: 4338 bytes (26.5% Full)
(.text + .data + .bootloader)

Data: 32 bytes (2.5% Full)
(.data + .bss + .noinit)

After loading the hex file it's telling "One of the usb attached to this computer has malfunctioned and windows does not recognize it"

-Chotan

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

Now I have changed my crystal and placed with 16MHz. After loading hex file I got change in Unknown device which is given as attached. Is it okay?

Attachment(s): 

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

The mouse from Demos/Device/ClassDriver/Mouse/ is working now, because after connecting the usb, the mouse cursor is going to bellow-right corner.

But I don't have any control over mouse :oops:

How can I come out from this :?

-Chotan

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

chotan wrote:
Now I have changed my crystal and placed with 16MHz. After loading hex file I got change in Unknown device which is given as attached. Is it okay?

No. The device has not been detected correctly.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

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

chotan wrote:
The mouse from Demos/Device/ClassDriver/Mouse/ is working now, because after connecting the usb, the mouse cursor is going to bellow-right corner.

But I don't have any control over mouse :oops:

How can I come out from this :?

-Chotan

This has nothing to do with your original problem. Start a new thread for this.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

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

chotan wrote:
...
After loading the hex file it's telling "One of the usb attached to this computer has malfunctioned and windows does not recognize it"

-Chotan

This is telling you that your bootloader device is not working. Are you actually programming the device with the new .hex file after building the software.

1. After every change that is made to the makefile you must save the makefile.
2. You must "Make Clean" the project.
3. You must "Build" the project.
4. Finally you must program the device with the new .hex file.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

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

Sorry, I forgot to mention but my comment on 11:37 PM (6th may'12) was based on Demos/Device/ClassDriver/Mouse/ this hex file, not for DFU , because in previous comment Dean told me to chk the demo mouse program.

Thanks for the procedure Larry.

Quote:
After changing makefile and building successfully I got

This mean

Quote:
1. After every change that is made to the makefile you must save the makefile.
2. You must "Make Clean" the project.
3. You must "Build" the project.
4. Finally you must program the device with the new .hex file.

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

chotan wrote:
because in previous comment Dean told me to chk the demo mouse program.

Thanks for the procedure Larry.

My mistake. You are welcome Chotan.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

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

Right, the mouse cursor moving says that the board is fine - I suspect one of the GPIO pins used by the board you have set in the makefile are either non-present on that package or it's currently low, causing the cursor movement.

Your screenshot looks correct for the bootloader before a driver has been installed - it will appear as "AVR DFU Bootloader". You need to point Windows to the FLIP drivers for it to become functional.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Thanks Dean for your reply and support.