Mega48p and JTAGICE2 vs AVRdude & Eclipse

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

Tonight, I decided to try using Eclipse to build a C project. I already had the most recent release of WINAVR installed, so I just downloaded & unzipped the C/C++ edition of Eclipse, installed the AVR-eclipse plugin, and started working through the tutorial.

Problem #1: It claims AVRDude doesn't support the Mega48p.

Problem #2: It seems to be unable to connect to the JTAGICE2 in ISP mode via USB. I *did* explicitly set the "port" to "USB" in the properties settings.

WinAVR itself is 20090313.

Starting with problem #1... is the Mega48p *really* unsupported? Or does this just mean I have to lie and say it's a non-P Mega48, and somehow override the signature bytes so it will treat the Mega48p as if it were a Mega48?

Continuing with problem #2... I remember reading somewhere that AVRdude needs to have USB support compiled in. Can I safely assume that the default package everyone downloads DOES, in fact, have USB compiled in, and this is just a symptom of some other problem I'm having?

There's no place like ~/

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

1. just use '-p m48'

2. avrdude chooses to use a different USB device driver to Atmel. So you have to download and install "libUSB"

When I last downloaded the WinAVR package, (20081205) "libUSB" was not automatically installed.

When you have done this, you can use the JTAGICE-2 via the command line jtagiceii.exe, avrdude.exe or the GUI interface in Studio.

If you ever have any programmer problems "avrdude -v" is a lot more informative than any of the other calling methods.

David.

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

OK, I just got the libUSB-win32 filter driver to work. The instructions don't make it particularly obvious, but after you download the installer, you have to right-click it, open 'properties', go to the 'compatibility' tab, and have it run as "XP SP2".

I'm not sure whether it mattered, but I also right-clicked it and ran it as administrator (even though I have UAC disabled anyway).

(oops... wrote too soon in my jubilation that libUSB-win32 was no longer trashing the rest of Windows)

Now I have a new error. When I try going to Properties -> AVR -> Target Hardware and click "Load from MCU", I get a popup:

AVRDude Error
The port for the Programmer is blocked.

Check that no other instances of AVRDude or any other program is using the port.

Reason:
avrdude:ser_open(): can't open device "USB": The system cannot find the file specified.

Here's the output from TestLibUsb:

DLL version:	0.1.12.2
Driver version:	0.1.12.2

bus/device  idVendor/idProduct
bus-0/\\.\libusb0-0001--0x03eb-0x2103     03EB/2103
- Manufacturer : ATMEL
- Product      : JTAGICE mkII
- Serial Number: 070000000A21
  wTotalLength:         32
  bNumInterfaces:       1
  bConfigurationValue:  1
  iConfiguration:       0
  bmAttributes:         80h
  MaxPower:             250
    bInterfaceNumber:   0
    bAlternateSetting:  0
    bNumEndpoints:      2
    bInterfaceClass:    255
    bInterfaceSubClass: 0
    bInterfaceProtocol: 0
    iInterface:         0
      bEndpointAddress: 82h
      bmAttributes:     02h
      wMaxPacketSize:   64
      bInterval:        10
      bRefresh:         0
      bSynchAddress:    0
      bEndpointAddress: 02h
      bmAttributes:     02h
      wMaxPacketSize:   64
      bInterval:        10
      bRefresh:         0
      bSynchAddress:    0
bus-0/\\.\libusb0-0002--0x045e-0x008c     045E/008C
- Manufacturer : Microsoft
- Product      : Microsoft Wireless Optical Mouse® 1.0A
  wTotalLength:         34
  bNumInterfaces:       1
  bConfigurationValue:  1
  iConfiguration:       0
  bmAttributes:         a0h
  MaxPower:             25
    bInterfaceNumber:   0
    bAlternateSetting:  0
    bNumEndpoints:      1
    bInterfaceClass:    3
    bInterfaceSubClass: 1
    bInterfaceProtocol: 2
    iInterface:         0
      bEndpointAddress: 81h
      bmAttributes:     03h
      wMaxPacketSize:   8
      bInterval:        10
      bRefresh:         0
      bSynchAddress:    0

Here's the AVRDude command line preview:

avrdude -pm48 -cjtag2isp -PUSB -Uflash:w:EclipseBlink.hex:a

There's no place like ~/

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

Update: it appears the example I found for "-PUSB" shoudl have really been "-Pusb". I don't know whether it helped, but I also deleted all the libusb*.dll files from WinAVR's libusb directory based on a post from Joerg I found.

There's no place like ~/

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

OK, another tiny step forward. I loaded avrdude.conf, copied & pasted the definition for Mega48, then replaced the first few lines with:

#------------------------------------------------------------
# ATmega48p
#------------------------------------------------------------

part
    id               = "m48p";
    desc             = "ATMEGA48p";
     has_debugwire = yes;
     flash_instr   = 0xB6, 0x01, 0x11;
     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
	             0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
	             0x99, 0xF9, 0xBB, 0xAF;
    stk500_devcode   = 0x59;
#    avr910_devcode   = 0x;
    signature        = 0x1e 0x92 0x0a;

so AVRdude would quit complaining about the signature. From that point, I could autodetect the chip type, but when I try to flash it, I get:

Launching C:\WinAVR-20090313\bin\avrdude -pm48p -cjtag2isp -Pusb -Uflash:w:EclipseBlink.hex:a 
Output:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.15s

avrdude: Device signature = 0x1e920a
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "EclipseBlink.hex"
avrdude: input file EclipseBlink.hex auto detected as Intel Hex
avrdude: writing flash (78 bytes):

Writing | ################################################## | 100% 0.21s

avrdude: 78 bytes of flash written
avrdude: verifying flash memory against EclipseBlink.hex:
avrdude: load data flash data from input file EclipseBlink.hex:
avrdude: input file EclipseBlink.hex auto detected as Intel Hex
avrdude: input file EclipseBlink.hex contains 78 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.10s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x19 != 0x00
avrdude: verification error; content mismatch

avrdude done.  Thank you.

avrdude finished

There's no place like ~/

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

Update 3: still not working.

What I've tried:

* Connected 12v, 2A power supply to JTAGICE2 to eliminate the possibility of power-related problems.

* Changed connection from usb to serial (-Pcom1) to eliminate USB weirdness from the equation.

* Went back into AVR Studio and flashed a program onto the chip to light up a LED on the board. Success.

* Added -B8 flag. It shouldn't matter, because the speed is 8MHz, but I'm desperate at this point and blindly trying just about anything someone mentions in a post on the random chance it might work :(

I'm pretty much out of ideas, and stuck until someone comes up with another suggestion to try.

(update)
To conclusively rule out one more possibility, I reverted the avrdude.conf file to its original form, reloaded Eclipse, and reconfigured AVRdude to forcibly treat it like a Mega48. With the same results:

Launching C:\WinAVR-20090313\bin\avrdude -pm48 -cjtag2isp -Pcom1 -B8 -F -Uflash:w:EclipseBlink.hex:a 
Output:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.21s

avrdude: Device signature = 0x1e920a
avrdude: Expected signature for ATMEGA48 is 1E 92 05
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "EclipseBlink.hex"
avrdude: input file EclipseBlink.hex auto detected as Intel Hex
avrdude: writing flash (154 bytes):

Writing | ################################################## | 100% 0.47s

avrdude: 154 bytes of flash written
avrdude: verifying flash memory against EclipseBlink.hex:
avrdude: load data flash data from input file EclipseBlink.hex:
avrdude: input file EclipseBlink.hex auto detected as Intel Hex
avrdude: input file EclipseBlink.hex contains 154 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.26s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x19 != 0x00
avrdude: verification error; content mismatch

avrdude done.  Thank you.

avrdude finished

There's no place like ~/